    //-------------------------------------------------------------
    //----Select highligh rows when the checkboxes are selected
    //
    // Note: The colors are hardcoded, however you can use 
    //       RegisterClientScript blocks methods to use Grid's
    //       ItemTemplates and SelectTemplates colors.
    //         for ex: grdEmployees.ItemStyle.BackColor OR
    //                 grdEmployees.SelectedItemStyle.BackColor
    //-------------------------------------------------------------
    function HighlightRow(chkB)    {
     
 	xState=chkB.checked;  
	         
    if(xState)
        {
          
        chkB.parentElement.parentElement.style.backgroundColor='#ffffcc';
           // grdEmployees.SelectedItemStyle.BackColor
         chkB.parentElement.parentElement.style.color='#cc0033'; 
           // grdEmployees.SelectedItemStyle.ForeColor
        }else 
        {chkB.parentElement.parentElement.style.backgroundColor='#f6f5f4'; 
             //grdEmployees.ItemStyle.BackColor
         chkB.parentElement.parentElement.style.color='black'; 
             //grdEmployees.ItemStyle.ForeColor
        }
    }
    
	
	//-------------------------------------------------------------
    // Select all the checkboxes (Hotmail style)
    //-------------------------------------------------------------
    function SelectAllCheckboxes(spanChk,strcmp){
    
    // Added as ASPX uses SPAN for checkbox 
  //  var oItem = spanChk.children;
  
  //var oItem = spanChk.children;
   // var theBox=oItem.item(0)
   // xState=theBox.checked;
    
    
    var theBox=spanChk
    xState=theBox.checked;    

     var elm=theBox.form.elements;
  
      elm=theBox.form.elements;
        for(i=0;i<elm.length;i++)
        
        if(elm[i].type=="checkbox" && elm[i].id!=theBox.id && elm[i].id.indexOf(strcmp) != -1  )
            {
            //elm[i].click();
           
            if(elm[i].checked!=xState)
            elm[i].click();
            //elm[i].checked=xState;
            }
    }
    
    function void1(){}
    
    function doBlink() {
		// Blink, Blink, Blink...
		var blink = document.all.tags("BLINK")
		for (var i=0; i < blink.length; i++)
			blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
		}

		function startBlink() {
		// Make sure it is IE4
		if (document.all)
			setInterval("doBlink()",1000)
		}
		
		function LoadingStatus(Status)
			{
			var x,y;
			if (self.innerHeight)
			{// all except Explorer
				x = self.innerWidth;
				y = self.innerHeight;
			}
			else 
			if (document.documentElement && document.documentElement.clientHeight)
			{// Explorer 6 Strict Mode
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
			}
			else
			if (document.body)
			{// other Explorers
			x = document.body.clientWidth;
			y = document.body.clientHeight;
			}

			  
				var el=document.getElementById("LoadingMsg");
				if(null!=el)
				{
				
					var top = (y/2) - 280;
					var left = (x/2) - 200;
					if( left<=0 ) left = 10;
				
					el.style.visibility = (Status=="Loading")?'visible':'hidden';
					el.style.display = (Status=="Loading")?'block':'none';
					el.style.left = left + "px"
					el.style.top = top + "px";
					el.style.zIndex = 2;
					
				}
				
				
			}
		
		
		function isDate(dateStr) {

				var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
				var matchArray = dateStr.match(datePat); // is the format ok?

				if (matchArray == null) {
					//alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
					return false;
				}

				day = matchArray[1]; // parse date into variables
				month = matchArray[3];
				year = matchArray[5];
				
				if (month < 1 || month > 12) { // check month range
					//alert("Month must be between 1 and 12.");
					return false;
				}

				if (day < 1 || day > 31) {
					//alert("Day must be between 1 and 31.");
					return false;
				}

				if ((month==4 || month==6 || month==9 || month==11) && day==31) {
					//alert("Month "+month+" doesn't have 31 days!")
					return false;
				}

				if (month == 2) { // check for february 29th
					var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
					if (day > 29 || (day==29 && !isleap)) {
						//alert("February " + year + " doesn't have " + day + " days!");
						return false;
					}
				}
				return true; // date is valid
			}

			function GetDate(CtrlName){
				ChildWindow = window.open('/admin/AdminCalendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' + CtrlName , "PopUpCalendar", "width=270,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no");
			}
	       
			function ValidateDate(source, arguments){
				if (isDate(arguments.Value)){
					arguments.IsValid = true;
				}
				else{
					arguments.IsValid = false;
				}
			}
			
			
			function display(image,name){
				var theImage = new Image();
					theImage.src = image+'?'+new Date().getUTCSeconds();
					theImage.onerror = function(){
						alert("Probleme: Pas d'Image !");
					}

					theImage.onload  = function(){
					var width  = theImage.width;  if(width <100) { width  = 100 };if(width >640) { width  = 640 }
					var height = theImage.height; if(height<100) { height = 100 };if(height>640) { height = 640 }
					theImage.width = width
					var left = Math.round((screen.width - width) / 2);
					var top  = Math.round((screen.height - height) / 2);
					var features = 'top='+top+',left='+left+',width='+width+',height='+height;
					var openWindow = window.open('','display',features);
						with(openWindow.document){
						writeln('<html><head><title>'+name+'</title></head>');
						writeln('<body onload="self.focus()" onblur="self.close()"');
						writeln('style="background-image:url('+image+');');
						writeln('background-repeat:no-repeat;width:'+width+';height:'+height+'">');
					
						writeln('</body></html>');
						close();
						}
					}
						return false;
				}

		//Refresh timer
		timer1=null;
		function RefreshTimer(RefreshTime) {
			timer1=setTimeout("__doPostBack('','');", RefreshTime);
		}	
					 
//-------------------------------- Object handlin ---------------------------

function changeVisibility( oName, oVis, oFrame ) 
{
	var theDiv = getObj( oName, oFrame ); 
	if( !theDiv ) { return; }
	if( theDiv.style ) 
	{ 
		theDiv.style.visibility = "hidden"
		if (oVis == true)
		{
			theDiv.style.visibility = "visible"
		}
		
	} 
	else 
	{ 
		theDiv.visibility = "hide"
		if (oVis == true)
		{
			theDiv.visibility = "show"
		}
		
	}
}


	function getObj( oName, oFrame, oDoc ) 
		{
					
			//return document.getElementById(oName);
			if( !oDoc ) { if( oFrame ) { oDoc = oFrame.document; } else {
				oDoc = window.document; } }

			//check for images, forms, layers
			if( oDoc[oName] ) { return oDoc[oName]; }

			//check for pDOM layers
			if( oDoc.all && oDoc.all[oName] ) { return oDoc.all[oName]; }

			//check for DOM layers
			if( oDoc.getElementById && oDoc.getElementById(oName) ) {
				return oDoc.getElementById(oName); }

			//check for form elements
			for( var x = 0; x < oDoc.forms.length; x++ ) {
				if( oDoc.forms[x][oName] ) { return oDoc.forms[x][oName]; } }

			//check for anchor elements
			//NOTE: only anchor properties will be available,
			//NOT link properties!
			for( var x = 0; x < oDoc.anchors.length; x++ ) {
				if( oDoc.anchors[x].name == oName ) {
					return oDoc.anchors[x]; } }

			//check for any of the above within a layer in layers browsers
			for( var x = 0; document.layers && x < oDoc.layers.length; x++ ) {
				var theOb = MWJ_findObj( oName, null, oDoc.layers[x].document );
					if( theOb ) { return theOb; } }

			//check for frames, variables or functions
			if( !oFrame && window[oName] ) { return window[oName]; }
			if( oFrame && oFrame[oName] ) { return oFrame[oName]; }

			//if checking through frames, check for any of the above within
			//each child frame
			for( var x = 0; oFrame && oFrame.frames &&
			x < oFrame.frames.length; x++ ) {
				var theOb = MWJ_findObj( oName, oFrame.frames[x],
				oFrame.frames[x].document ); if( theOb ) { return theOb; } }
			alert("can't find elem" + oName);
			return null;
		}
		 function GetDateWithPath(Path,CtrlName){
	         ChildWindow = window.open(Path + 'AdminCalendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' + CtrlName , "PopUpCalendar", "width=270,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no");
			}
		
			function ValidateDate2(source, arguments){
			    //alert("Inside validatedate "+ arguments.Value)
			    if(arguments.Value=="[Today]"){
					arguments.IsValid=true;
			    }else if (isDate(arguments.Value)){
					arguments.IsValid = true;
				}
				else{
					arguments.IsValid = false;
				}
			}
			// display dropdownlist 
function DisplayControl(ddListValue,ctrName)
{
    if (ddListValue.value =="exactdate"){
       //alert(" inside display control" + ddListValue.value);
                 
         // document.getElementById("txtCmdeDate_Start").value="";
        //  document.getElementById("txtCmdeDate_End").value="";
          document.getElementById(ctrName+"_ExactDateDiv").style.display="";
          document.getElementById(ctrName+"_PeriodDiv1").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv2").style.display="none";
          // update hidden field 
          document.getElementById(ctrName+"_hdPeriodDateDiv1").value="0";
          document.getElementById(ctrName+"_hdPeriodDateDiv2").value="0";
        document.getElementById(ctrName+"_hdExacteDateDiv").value="1";
          
    }
    if(ddListValue.value=="perioddate"){
         
         // document.getElementById("txtExacteDate").value="";
          document.getElementById(ctrName+"_ExactDateDiv").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv1").style.display="";
          document.getElementById(ctrName+"_PeriodDiv2").style.display="";
          // update hidden field 
          document.getElementById(ctrName+"_hdPeriodDateDiv1").value="1";
          document.getElementById(ctrName+"_hdPeriodDateDiv2").value="1";
         document.getElementById(ctrName+"_hdExacteDateDiv").value="0";
          
    //alert(" inside display control" + ddListValue.value);
          //  Me.td_ClientDate_Start.Visible = True
           // Me.td_ClientDate_End.Visible = True
    }
    if ((ddListValue.value !="perioddate") && (ddListValue.value !="exactdate")){
    
      document.getElementById(ctrName+"_ExactDateDiv").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv1").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv2").style.display="none";
          // update hidden field 
          document.getElementById(ctrName+"_hdPeriodDateDiv1").value="0";
          document.getElementById(ctrName+"_hdPeriodDateDiv2").value="0";
          document.getElementById(ctrName+"_hdExacteDateDiv").value="0";
          
    }
}

function DisplayPeriodControl(ddListValue,ctrName)
{
// alert(" inside display control   " + ddListValue.value);
    if (ddListValue.value =="exactdate"){
         document.getElementById(ctrName+"_ExactDateDiv").style.display="";
         document.getElementById(ctrName+"_PeriodDiv1").style.display="none";
         document.getElementById(ctrName+"_PeriodDiv2").style.display="none";
        // update hidden field 
        document.getElementById(ctrName+"_hdPeriodDateDiv1").value="0";
        document.getElementById(ctrName+"_hdPeriodDateDiv2").value="0";
        document.getElementById(ctrName+"_hdExacteDateDiv").value="1";
          
    }
    if(ddListValue.value=="perioddate"){
         
         // document.getElementById("txtExacteDate").value="";
          document.getElementById(ctrName+"_ExactDateDiv").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv1").style.display="";
          document.getElementById(ctrName+"_PeriodDiv2").style.display="";
          // update hidden field 
          document.getElementById(ctrName+"_hdPeriodDateDiv1").value="1";
          document.getElementById(ctrName+"_hdPeriodDateDiv2").value="1";
         document.getElementById(ctrName+"_hdExacteDateDiv").value="0";
          
    //alert(" inside display control" + ddListValue.value);
          //  Me.td_ClientDate_Start.Visible = True
           // Me.td_ClientDate_End.Visible = True
    }
    if ((ddListValue.value !="perioddate") && (ddListValue.value !="exactdate")){
    
      document.getElementById(ctrName+"_ExactDateDiv").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv1").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv2").style.display="none";
          // update hidden field 
          document.getElementById(ctrName+"_hdPeriodDateDiv1").value="0";
          document.getElementById(ctrName+"_hdPeriodDateDiv2").value="0";
          document.getElementById(ctrName+"_hdExacteDateDiv").value="0";
          
    }
}

function DisplayDateControl(ddListValue,ctrName)
{
    if (ddListValue.value =="ExactDate"){
      
          document.getElementById(ctrName+"_ExactDateDiv").style.display="";
          document.getElementById(ctrName+"_PeriodDiv1").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv2").style.display="none";
          // update hidden field 
          document.getElementById(ctrName+"_hdPeriodDateDiv1").value="0";
          document.getElementById(ctrName+"_hdPeriodDateDiv2").value="0";
        document.getElementById(ctrName+"_hdExacteDateDiv").value="1";
          
    }
    if(ddListValue.value=="Period"){
         
        
          document.getElementById(ctrName+"_ExactDateDiv").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv1").style.display="";
          document.getElementById(ctrName+"_PeriodDiv2").style.display="";
          // update hidden field 
          document.getElementById(ctrName+"_hdPeriodDateDiv1").value="1";
          document.getElementById(ctrName+"_hdPeriodDateDiv2").value="1";
         document.getElementById(ctrName+"_hdExacteDateDiv").value="0";
          
  
    }
    if ((ddListValue.value !="Period") && (ddListValue.value !="ExactDate")){
    
      document.getElementById(ctrName+"_ExactDateDiv").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv1").style.display="none";
          document.getElementById(ctrName+"_PeriodDiv2").style.display="none";
          // update hidden field 
          document.getElementById(ctrName+"_hdPeriodDateDiv1").value="0";
          document.getElementById(ctrName+"_hdPeriodDateDiv2").value="0";
          document.getElementById(ctrName+"_hdExacteDateDiv").value="0";
          
    }
}

function ShowHide(szDivID, iState) 
{
	/*var obj = document.layers ? document.layers[szDivID] : document.getElementById ?  document.getElementById(szDivID).style : document.all[szDivID].style;
	obj.visibility = document.layers ? (iState ? "show" : "hide") : (iState ? "visible" : "hidden");
	*/
	var theDiv = getObj( szDivID); 
	if( !theDiv ) { return; }
	theDiv.style.display=iState;
}

/* Highligthing Data Grids lines for statistics system */
var tempColors = new String(25)
var HighLigthColor = "#f5f5f5"
function HighLigthRow(Elem)
{
	for(var i=0;i<=Elem.cells.length-1;i++)
	{
		if (Elem.cells[i])
		{
			tempColors[i] = Elem.cells[i].style.backgroundColor
			Elem.cells[i].style.backgroundColor = HighLigthColor
		}
	}
}
function cancelHighLigthRow(Elem)
{
	for(var i=0;i<=Elem.cells.length-1;i++)
	{
		if (tempColors[i] && Elem.cells[i])
		{
			Elem.cells[i].style.backgroundColor = tempColors[i]
		}
	}
}
/*************************************************************/
/*************************************************************/
/*************************************************************/
// used by the EventViewer.ascx user control to show and hide the history div
function ChangeDivState(divID, ImgTreeID, hdDivStateID)
{

	var divStateElem = getObj(hdDivStateID)
	var ImgElem = getObj(ImgTreeID)
	if (ImgElem)
	{
		
		if (ImgElem.src.indexOf("/images/navopened.gif",0) >= 0)
		{
			ShowHide(divID, "none")
			ImgElem.src = "/images/navclosed.gif"
			divStateElem.value = "close"
		}
		else
		{
			// show the div and change the image src value
			ShowHide(divID, "")
			ImgElem.src = "/images/navopened.gif"
			divStateElem.value = "open"
		}
		
	}

}

/*************************************************************/
