var clientIds = "";

//this function clears inputboxes on first "click"
function clearText(clientId) 
{
    if(clientIds.indexOf(clientId) == -1)
    {
        domid = document.getElementById(clientId);
        domid.setAttribute("value", "");
    
        saveClear(clientId);
    }
}

//this functions keeps track on already "clicked" inputboxes
function saveClear(clientId)
{
    clientIds += clientId;
}
function emptyText(elm,sText)
{
    if(elm != null){
        if(elm.value == sText){
            elm.value = "";
        }
    }
}
function restoreText(elm,sText){
    if(elm != null){
        if(elm.value == "")
        {
            elm.value = sText;
        }
    }
}

function print()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,resizable=yes,"; 
      disp_setting+="scrollbars=yes,width=750, height=600, left=0, top=25"; 
  var content_vlue = document.getElementById("mainContent").innerHTML; 
  
var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head>');

   docprint.document.write('<link rel="stylesheet" type="text/css" href="/css/print.css" />');
   
   docprint.document.write('<title>Diligentia</title>'); 
   docprint.document.write('</head><body onLoad="self.print()"><div class="page"><div class="fullRegion"><div class="mainAndRightRegion"><div class="mainAndMainBottomRegion">');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</div></div></div></div></div></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}






function textboxMultilineMaxNumber(txt,maxLen)
{   
    try{   
        if(txt.value.length > (maxLen-1))return false;   
    }
    catch(e)
    {   
    }   
}

function keyPressEnterPost(evt,elm){
    if(evt.keyCode == 13){
        evt.returnValue = false;
        /*
            event.returnValue=false;
            event.cancelBubble = true;
        */
	    document.getElementById(elm).click();
	}
	//return false;
}

function scrollToAnchorView(anchorName)
{
    document.location.href = document.location.href + "#" + anchorName;
}

	//drop down global menu functionality
$(document).ready(function() {
    $("ul.topMenuLeft li").hover(function() {
        var y = $("div.topMenuContainer").offset().left;
        var m = (y - 9);
             if($('div.secondLevel ul.menuPushList li', this).length == '0') {
                $('div.secondLevel', this).addClass('noPush');
            }
            else if($('div.secondLevel ul.menuPushList li', this).length == '1') {
                $('div.secondLevel', this).addClass('has1Push'); 
                //$('div.secondLevel', this).css('margin-left', '-200px'); 
            }
            else if($('div.secondLevel ul.menuPushList li', this).length == '2') {
                $('div.secondLevel', this).addClass('has2Push'); 
            }
            else if($('div.secondLevel ul.menuPushList li', this).length == '3') {
                $('div.secondLevel', this).addClass('has3Push'); 
                $('div.secondLevel', this).css('left', m + 'px');
            }
        var w = $('div.secondLevel', this).outerWidth(); //width of the drop down
        var p = $(this).show().position();
        var l = (p.left);
        var rp = (l - m); //drop down relative position from left edge of the site
        var re = (rp + w); //drop down right edge position
        var of = (re - 828); //right off-site offset
        var trt = $('div.secondLevel', this);
            if(of > '0' && $('div.secondLevel ul.menuPushList li', this).length < '3') {
                 $('div.secondLevel', this).css('margin-left', -of + 'px');
           }

});
});
$(document).ready(function(){
		$('ul.topMenuLeft li').hover(
			function() { $('div', this).css('display', 'block'); },
			function() { $('div', this).css('display', 'none'); });
		$('ul.topMenuLeft li div.secondLevel').hover(
			function() { $(this).parent().addClass('open'); },
			function() { $(this).parent().removeClass('open'); });
	});

/*slider single value*/
$(document).ready(function() {
if ($("div.slideSelector2").length > 0){
	$(function() {
		$("#slider1").slider({
			value:0,
			min: 0,
			max: 450,
			step: 10,
			slide: function(event, ui) {
				$("#slider1 a input").val(ui.value);
				$("#amount1").val(ui.value);
			}
		});
		$("#slider1 a input").val($("#slider1").slider("value"));
	});
	$(function() {
		$("#slider2").slider({
			value:0,
			min: 0,
			max: 1000,
			step: 40,
			slide: function(event, ui) {
				$("#slider2 a input").val(ui.value);
				$("#amount2").val(ui.value);
			}
		});
		$("#slider2 a input").val($("#slider2").slider("value"));
	});
   
    setInterval(function(){
        var le1 = $("#slider1 a").css("left");
	    if(le1 == '100%') {
            $("#slider1 a input").addClass('plus');
        }
	    else if(le1 != '100%'){
            $("#slider1 a input").removeClass('plus').addClass('normal');
        }
    }, 500);         
    setInterval(function(){
        var le2 = $("#slider2 a").css("left");
	    if(le2 > '0%') {
            $("#slider2 a input").addClass('plus');
        }
	    else if(le2 == '0%'){
            $("#slider2 a input").removeClass('plus').addClass('normal');
        }
    }, 500);    

}	
    //select & hide/show liders
  
    /*$("input[name='searchOpt']:radio").change(function() {
		$("div.slideSelector2 div.slideOverlayer").toggle();
		$("#slider2 a input").val(0);
		$("#slider2 a").css("left", "0%");
		$("div.slideSelector1 div.slideOverlayer").toggle();
		$("#slider1 a input").val(0);
		$("#slider1 a").css("left", "0%");
    });*/
	$("input#antal_medarbetare").attr("checked", "checked");
	// set hidden field value for searching purposes
	
	// this shouldn't be done here
	//$("#active_slider").val(0);

	$("input#storlek").click(function(){
		$("div.slideSelector2 div.slideOverlayer").hide();
		$("div.slideSelector1 div.slideOverlayer").show();
		$("#slider1 a input").val(0);
		$("#slider1 a").css("left", "0%");
		// set hidden field value for searching purposes
		$("#active_slider").val(2);
		
	});
	$("input#antal_medarbetare").click(function(){
		$("div.slideSelector2 div.slideOverlayer").show();
		$("#slider2 a input").val(0);
		$("#slider2 a").css("left", "0%");
		$("div.slideSelector1 div.slideOverlayer").hide();
		// set hidden field value for searching purposes
		$("#active_slider").val(1);
	});
	
	
	$("div.crCboxes input#icMan").click(function(){
		$("fieldset.icMan").toggleClass("visible");
	});

});

//21-01-2010 Bata - DILSUPP-40
function SetAmountSliderValues(idIndex, value)
{
    $(document).ready(function(){
		    $("#amount"+idIndex).val(value);
		    $("#slider"+idIndex).slider("value", value);			   		   
		    $("#slider"+idIndex+" a input").val(value);
		    //$("#slider"+idIndex+" a input").val(value);
	    });
}


