var win = null;
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
var timerID = 0;
var tStart  = null;
var tDate = null;
var tLocal = null;
var tOff = null;
var CurMinutes = null;

function isInteger(s){
	var i;
	for (i = 0; i < s.length; i++){   
	    // Check that current character is number.
	    var c = s.charAt(i);
	    if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
}

function stripCharsInBag(s, bag){
	var i;
	var returnString = "";
	// Search through string's characters one by one.
	// If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++){   
	    var c = s.charAt(i);
	    if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
	// EXCEPT for centurial years which are not also divisible by 400.
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
	} 
	return this
}

function isDate(dtStr){
	var daysInMonth = Array(31,31,29,31,30,31,30,31,31,30,31,30,31)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear

	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
	//	alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
//		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
//		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
//		alert("Please enter a valid date")
		return false
	}
return true
}


function newWindow(mypage,myname,w,h,features)
  {
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += features;
	win = window.open(mypage,myname,settings);
	win.window.focus();
  }


function verifyEmail(field)
{

  var checkEmail = field.value;
    if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))
    {
      field.focus();
      return false;
    }

  return true;

}

function ConfirmBox(url,msg){
	var conf = confirm(msg); 
	if(conf){
		window.location.href = url; 
	}
}
function returnBrowser() {
	if (navigator.userAgent.indexOf("Firefox")>0) {
		return 'Firefox'
		}
	else
		{
		return 'IE'
		}
}

function ConfirmWithSisterFrameRefresh(url,msg,sisterframe,otherframerefresh){
	var conf = confirm(msg); 
	if(conf){
		window.location.href = url; 
		if (navigator.userAgent.indexOf("Firefox")>0) {
			if (InStr(parent.document.getElementById(sisterframe).src,'?',true,0)==0)
			{
				parent.document.getElementById(sisterframe).src=parent.document.getElementById(sisterframe).src + '?' + Math.random();		
			}
			else
			{
				parent.document.getElementById(sisterframe).src=parent.document.getElementById(sisterframe).src + '&' + Math.random();		
			}
			if(otherframerefresh){
				if(otherframerefresh != ''){
					parent.document.getElementById(otherframerefresh).src = parent.document.getElementById(otherframerefresh).src; }}
		}
		else
		{
			if (InStr(parent.document[sisterframe].location.href,'?',true,0)==0)
			{
				parent.document[sisterframe].location.href=parent.document[sisterframe].location.href + '?' + Math.random();		
			}
			else
			{
				parent.document[sisterframe].location.href=parent.document[sisterframe].location.href + '&' + Math.random();		
			}
			if(otherframerefresh){
				if(otherframerefresh != ''){
					parent.document[otherframerefresh].location.href = parent.document[otherframerefresh].location.href; }}
		}
		
	}
}
function ConfirmWithSisterFrameRefreshEx(url,msg,sisterframe,otherframerefresh){
	var conf = confirm(msg); 
	if(conf){
		window.location.href = url; 
		if (navigator.userAgent.indexOf("Firefox")>0) {
			if (InStr(parent.document.getElementById(sisterframe).src,'?',true,0)==0)
			{
				parent.document.getElementById(sisterframe).src=parent.document.getElementById(sisterframe).src + '&' + Math.random();		
			}
			else
			{
				parent.document.getElementById(sisterframe).src=parent.document.getElementById(sisterframe).src + '?' + Math.random();		
			}
			if(otherframerefresh){
				if(otherframerefresh != ''){
					parent.document.getElementById(otherframerefresh).src = parent.document.getElementById(otherframerefresh).src; }}
		}
		else
		{
			if (InStr(parent.document[sisterframe].location.href,'?',true,0)==0)
			{
				parent.document[sisterframe].location.href=parent.document[sisterframe].location.href + '&' + Math.random();		
			}
			else
			{
				parent.document[sisterframe].location.href=parent.document[sisterframe].location.href + '?' + Math.random();		
			}
			if(otherframerefresh){
				if(otherframerefresh != ''){
					parent.document[otherframerefresh].location.href = parent.document[otherframerefresh].location.href; }}
		}
		
	}
}
function ConfirmTimeout(url,urlno,frame,msg){
	var conf = confirm(msg); 
	if(conf){
		Reset();
		Start();
		if (navigator.userAgent.indexOf("Firefox")>0) {
			parent.document.getElementById(frame).src=url;		
		}
		else
		{
			parent.document[frame].location.href=url;
		}
	} 
	else
	{
		if (navigator.userAgent.indexOf("Firefox")>0) {
			parent.document.getElementById(frame).src=urlno;		
		}
		else
		{
			parent.document[frame].location.href=urlno;
		}
	}
}


function CheckFrameLocation(Frame,Source){
if(InStr(window.parent.document[Frame].location.href,Source,true,1) <=0){
	window.parent.document[Frame].location.href = Source;
	}
}

function LoadFrame(Frame,URL){
	if (navigator.userAgent.indexOf("Firefox")>0) {
		parent.document.getElementById(Frame).src=URL;
	}
	else{
		parent.document[Frame].location.href=URL;		
	}
}

function LoadFrameParent(Frame,URL){
	LoadFrame(Frame,URL);
}

function LoadFrameSame(Frame,URL){
	if(navigator.userAgent.indexOf("Firefox")>0){
		 document.getElementById(Frame).src = URL;
	}
	else{
		document[Frame].location.href = URL;		
	}
}

/*

// Compare two options within a list by VALUES
function compareOptionValues(a, b) { 
  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values
  var sA = parseInt( a.value, 36 );  
  var sB = parseInt( b.value, 36 );  
  return sA - sB;
}

// Compare two options within a list by TEXT
function compareOptionText(a, b){ 
  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values
  var sA = parseInt( a.text, 36 );  
  var sB = parseInt( b.text, 36 );  
  return sA - sB;
}

// Dual list move function
function moveDualList( srcList, destList, moveAll) {

  // Do nothing if nothing is selected
  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )   )
  { return; }

  newDestList = new Array( destList.options.length );
  var len = 0;
  
  for( len = 0; len < destList.options.length; len++ ) 
  {
  if ( destList.options[ len ] != null ) {

      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
    }
  }

  for( var i = 0; i < srcList.options.length; i++ )   { 
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
    {
       // Statements to perform if option is selected
       // Incorporate into new list
       newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
       len++;
    }
  }

  // Sort out the new destination list
  if(destList.options.length >1){
 // newDestList.sort( compareOptionValues );   // BY VALUES
  //newDestList.sort( compareOptionText );   // BY TEXT
 }
  // Populate the destination with the items from the new array
  for ( var j = 0; j < newDestList.length; j++ )  {
    if ( newDestList[ j ] != null )  {
      destList.options[ j ] = newDestList[ j ];
    }
  }
  
  // Erase source list selected elements
  for( var i = srcList.options.length - 1; i >= 0; i-- )  { 
	  //we get content only for the right column
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )    {
       // Erase Source
       //srcList.options[i].value = "";
       //srcList.options[i].text  = "";
       srcList.options[i] = null;
    }
  }

} // End of moveDualList()

function SelectAll(srcList,destList){
	var i = 0;
 for(i = 0; i < srcList.options.length; i++ )   { 
    srcList.options[i].selected = true;
 }
 for(i = 0; i < destList.options.length; i++ )   { 
    destList.options[i].selected = true; 
 }

}

function RemoveAll(srcList){
	var i = 0;
 	for(i = 0; i < srcList.options.length; i++ )   { 
    	srcList.options[i] = null;
 	}
	srcList.length = 0;
}


function SelectAllFromList(srcList){
	var i = 0;
 for(i = 0; i < srcList.options.length; i++ )   { 
    srcList.options[i].selected = true;
 }
}
*/

//used to show/hide a div.
function showhide(el,divID) {
	var _div = document.getElementById(divID);
	if(_div){
		if(_div.style.display == "none"){
			_div.style.display = "";
			if(el) el.src = 'images/collapse.jpg';
		}
		else{
			_div.style.display = "none";
			if(el) el.src = 'images/expand.jpg';
		}
	}
}

function showhide_2(show,divID) {
	var _div = document.getElementById(divID);
	if(_div){
		if(show){
			_div.style.display = "";
		}
		else{
			_div.style.display = "none";
		}
	}
}

function showhide_3 (objID) {
    var _objID = document.getElementById(objID);
    
    if (_objID) {
        if (_objID.style.display=='none') {
            _objID.style.display = 'inline';
        } else {
            _objID.style.display = 'none';
        }
    }
}

function CInt(NUMBER){
return parseInt(NUMBER);
}


function CStr(VALUE){
return VALUE.toString();
}


function CSng(NUMBER){
return parseFloat(NUMBER);
}

function CDbl(NUMBER){
return parseFloat(NUMBER);
}

function CBool(VALUE){
VALUE = new String(VALUE);
VALUE = VALUE.toLowerCase();
if(VALUE== "1" || VALUE=="-1" || VALUE=="true" || VALUE == "yes"){
return true;
}
else{
return false;
}
}


function InStr(STRING,SUBSTRING,COMPARE,START){
if(START){
STRING = STRING.substring(START,STRING.length);
}
if(CBool(COMPARE) || COMPARE ==undefined){
STRING = STRING.toLowerCase();
SUBSTRING = SUBSTRING.toLowerCase();
}
if(STRING.indexOf(SUBSTRING) > -1){
return STRING.indexOf(SUBSTRING)
}
else{
return 0;
}
}

function LeftPad(num,padstring,count)
{ 
   var numZeropad = num + '';
   while(numZeropad.length < count){
      numZeropad = CStr(padstring) + CStr(numZeropad); 
   }
   return numZeropad;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.-";
   var IsNumber=true;
   var Char;

   if (sText.length==0)
	{
	IsNumber = false;	
	}
   else
	{
	for (i = 0; i < sText.length && IsNumber == true; i++) 
		{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
			{
			IsNumber = false;
			}
		}
	}
   
   return IsNumber;
   
   }
   
function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}
function CommaFormatted(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}

function getInvoiceTotal(theForm) {
	var i = 0;
	var totalamount = 0;
	for(i=0; i<theForm.elements.length; i++){

		if(theForm.elements[i].type == "text" && theForm.elements[i].name.substring(0,9) == "LineTotal"){
			if (IsNumeric(theForm.elements[i].value.replace(',','')) == true) {
				totalamount += parseFloat(theForm.elements[i].value.replace(',',''));
			}
		}
	}
	return '' + CommaFormatted(CurrencyFormatted(totalamount));
}


function ValidateAndMultiply(firstnumber,secondnumber,decimalplaces,resultfield) 
	{
		if (IsNumeric(firstnumber.replace(',','')) && IsNumeric(secondnumber.replace(',',''))) 
			{
				resultfield.value=(parseFloat(firstnumber.replace(',',''))*parseFloat(secondnumber.replace(',',''))).toFixed(decimalplaces);
			}
		else
			{
				resultfield.value='';
			}
	}
	
function ValidateAndMultiplyQuote(firstnumber,secondnumber,thirdnumber,decimalplaces,resultfield) 
	{
		if (IsNumeric(firstnumber.replace(',','')) && IsNumeric(secondnumber.replace(',','')) && IsNumeric(thirdnumber.replace(',',''))) 
			{
				resultfield.value=((parseFloat(firstnumber.replace(',',''))+parseFloat(secondnumber.replace(',','')))*parseFloat(thirdnumber.replace(',',''))).toFixed(decimalplaces);
			}
		else
			{
				resultfield.value='';
			}
	}
		
	 function maskKeyPress(objEvent,IsDecimal) 
     {

       var iKeyCode;       
       //iKeyCode = objEvent.keyCode;  
	   
		var evt=(objEvent)?objEvent:(window.event)?window.event:null;
		if(evt){
		iKeyCode=(evt.charCode)?evt.charCode:
			((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
		}
	   	   
	   //alert(':' + iKeyCode);

       // only allow numbers and the minus keys to be entered
       if (iKeyCode>=48 && iKeyCode<=57) {
          return true;
       }
       else if (iKeyCode == 45 ) {
          return true;
       }
	   else if (IsDecimal && iKeyCode == 46){ //controla decimal
			return true;   
	   }
       else
          return false;
     }

     function finalCheck(el)
     {
      // This final check occurs when then leave the textbox, it ensures that it is an integer
      if (isNaN((el.value))) {
            el.value = "";
			alert('Sorry, not a valid number. Please, try again.');
			el.focus();

        } else {
            el.value = (el.value);
        }
     }
     
    function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	
	function overlayshow() {
		el = document.getElementById("overlay");
		el.style.visibility = "visible";
	}

	function overlayhide() {
		el = document.getElementById("overlay");
		el.style.visibility = "hidden";
	}
	
	function overlaydoneshow() {
		el = document.getElementById("overlaydone");
		el.style.visibility = "visible";
	}

	function overlaydonehide() {
		el = document.getElementById("overlaydone");
		el.style.visibility = "hidden";
	}
	
	function UpdateTimer() {
		//disable this function
		void(0);
		return;
		
	if(timerID) {
		clearTimeout(timerID);
		clockID  = 0;
	}

	if(!tStart)
		tStart   = new Date();

	tDate = new Date();
	var   tDiff = tDate.getTime() - tStart.getTime();
	tDate.setTime(tDiff);
	CurMinutes = tDate.getMinutes(); 
//		if (CurMinutes>40) {
//			document.ABANDON.location.href="/abandon.asp"
			//overlayhide(			);
			//overlaydoneshow();
//			Stop();
//		}
//		else if (CurMinutes>35) {
		if (CurMinutes>55) 
			{
			//overlayshow();
				alert('Are you still there?  Your current session is about to expire. For your security, EnterYourHours.com sessions time out after 40 minutes of inactivity.')
				try	
					{
						RedirectIFRAME('refresh.asp',document['ABANDON'],document.getElementById('ABANDON'))
						Reset;
						Start();
					}
				catch(err)	
					{
						try 
						{
							RedirectIFRAME('refresh.asp',parent.document['ABANDON'],parent.document.getElementById('ABANDON'))
							Reset;
							Start();
						}
						catch(err)
						{
							Start();
							Reset;
							void(0);
						}
					}
				timerID = setTimeout("UpdateTimer()", 1000);
			} 
		else {
			timerID = setTimeout("UpdateTimer()", 1000);
		}
	}

	function Start() {
		tStart = new Date();
		tLocal = new Date();
		tLocal.setTime(0);	
		timerID  = setTimeout("UpdateTimer()", 1000);
	}

	function Reset() {
	tStart = null;

	//   document.theTimer.theTime.value = "00:00:00";
	}

	function Stop() {
	if(timerID) {
		clearTimeout(timerID);
		timerID  = 0;
	}
	tStart = null;
	}
	
	function changeDropDownByIndex(dropdownname,NewSelectedIndex){
			var s=document.getElementById(dropdownname);
			if(NewSelectedIndex == null) NewSelectedIndex = -1;
			if(s != null){
				if(NewSelectedIndex >=0 && s.options.length > NewSelectedIndex) {
					s.selectedIndex=NewSelectedIndex;
				}else{
					s.selectedIndex= -1;
				}
			}
	  }

	  function changeDropDownByValue(dropdownname,NewSelectedValue){
			var s=document.getElementById(dropdownname);
			var myindex = 0;
			if(NewSelectedValue == null) NewSelectedValue = '';
			if(s){
				for(myindex;myindex<s.options.length;myindex++){
					  if(NewSelectedValue==s.options[myindex].value){
							break;
					  }
				}
				changeDropDownByIndex(dropdownname,myindex);
			}
	  }
	
		function pausecomp(millis) 
		{
		var date = new Date();
		var curDate = null;

		do { curDate = new Date(); } 
		while(curDate-date < millis);
		} 
	
	
	function CallPrintingEx(fName){
		
		var f = null; 
		f = document.getElementById(fName);
		if(f == null){
			alert("Print Error. Please try again."); 	
			return; //Exit error
		}
		
		var printframe = null; 
		printframe = document.getElementById('HIDDENPRINTFRAME1');
		if(printframe==null) printframe = parent.document.getElementById('HIDDENPRINTFRAME1');
		
		if(printframe==null){
			alert('print frame not found');
			return; //Exit error
		}
		
		var content = ''; 
		content = f.contentDocument.body.innerHTML;
		if(content == '' || content == null) content = f.innerHTML;
		if(content == ''){
			alert('nothing to print');
			return; //Exit error
		}
		
		printframe.src='PrintMeHelper.html';
		printframe.contentDocument.getElementById('Content').value=content;
		printframe.contentDocument.Form1.submit();	
					
		//parent.document.all.item('HIDDENCHECK').value="2"
		//parent.document['HIDDENPRINTFRAME1'].location.href='PrintMeHelper.html';

	
	}


	function CallPrinting(divName){
		if (navigator.userAgent.indexOf("Firefox")>0) {
			if (parent.document.all.item('HIDDENCHECK').value=="1") {
				parent.document.getElementById('HIDDENPRINTFRAME1').src='PrintMeHelper.html';
				parent.document.getElementById('HIDDENPRINTFRAME1').contentDocument.getElementById('Content').value=document.getElementById(divName).innerHTML; 
				parent.document.getElementById('HIDDENPRINTFRAME1').contentDocument.Form1.submit();	
				parent.document.all.item('HIDDENCHECK').value="2"
				parent.document.getElementById('HIDDENPRINTFRAME2').src='PrintMeHelper.html';
				}
			else
				{
				parent.document.getElementById('HIDDENPRINTFRAME2').src='PrintMeHelper.html';
				parent.document.getElementById('HIDDENPRINTFRAME2').contentDocument.getElementById('Content').value=document.getElementById(divName).innerHTML; 
				parent.document.getElementById('HIDDENPRINTFRAME2').contentDocument.Form1.submit();	
				parent.document.all.item('HIDDENCHECK').value="2"
				parent.document.getElementById('HIDDENPRINTFRAME1').src='PrintMeHelper.html';
				}
			}
		else
			{
			if (parent.document.all.item('HIDDENCHECK').value=="1") {
				parent.document['HIDDENPRINTFRAME1'].location.href='PrintMeHelper.html';
				parent.document['HIDDENPRINTFRAME1'].document.getElementById('Content').value=document.getElementById(divName).innerHTML; 
				parent.document['HIDDENPRINTFRAME1'].document.Form1.submit();	
				parent.document.all.item('HIDDENCHECK').value="2"
				parent.document['HIDDENPRINTFRAME2'].location.href='PrintMeHelper.html';
				}
			else
				{
				parent.document['HIDDENPRINTFRAME2'].location.href='PrintMeHelper.html';
				parent.document['HIDDENPRINTFRAME2'].document.getElementById('Content').value=document.getElementById(divName).innerHTML; 
				parent.document['HIDDENPRINTFRAME2'].document.Form1.submit();	
				parent.document.all.item('HIDDENCHECK').value="2"
				parent.document['HIDDENPRINTFRAME1'].location.href='PrintMeHelper.html';
				}
			
			}		
	}
	function CallPrintingFrame(iFrame){
		if (navigator.userAgent.indexOf("Firefox")>0) {
			if (parent.document.all.item('HIDDENCHECK').value=="1") {
					parent.document.getElementById('HIDDENPRINTFRAME1').src='PrintMeHelper.html';
					parent.document.getElementById('HIDDENPRINTFRAME1').contentDocument.getElementById('Content').value=document.getElementById(iFrame).contentDocument.body.innerHTML; 
					parent.document.getElementById('HIDDENPRINTFRAME1').contentDocument.Form1.submit();	
					parent.document.all.item('HIDDENCHECK').value="2"
					parent.document.getElementById('HIDDENPRINTFRAME2').src='PrintMeHelper.html';
					}
				else
					{
					parent.document.getElementById('HIDDENPRINTFRAME2').src='PrintMeHelper.html';
					parent.document.getElementById('HIDDENPRINTFRAME2').contentDocument.getElementById('Content').value=document.getElementById(iFrame).contentDocument.body.innerHTML; 
					parent.document.getElementById('HIDDENPRINTFRAME2').contentDocument.Form1.submit();	
					parent.document.all.item('HIDDENCHECK').value="2"
					parent.document.getElementById('HIDDENPRINTFRAME1').src='PrintMeHelper.html';
					}
		}
		else
		{
			if (parent.document.all.item('HIDDENCHECK').value=="1") {
				parent.document['HIDDENPRINTFRAME1'].src='PrintMeHelper.html';
				parent.document['HIDDENPRINTFRAME1'].document.getElementById('Content').value=document[iFrame].document.body.innerHTML; 
				parent.document['HIDDENPRINTFRAME1'].document.Form1.submit();	
				parent.document.all.item('HIDDENCHECK').value="2"
				parent.document['HIDDENPRINTFRAME2'].src='PrintMeHelper.html';
				}
			else
				{
				parent.document['HIDDENPRINTFRAME2'].src='PrintMeHelper.html';
				parent.document['HIDDENPRINTFRAME2'].document.getElementById('Content').value=document[iFrame].document.body.innerHTML; 
				parent.document['HIDDENPRINTFRAME2'].document.Form1.submit();	
				parent.document.all.item('HIDDENCHECK').value="2"
				parent.document['HIDDENPRINTFRAME1'].src='PrintMeHelper.html';
				}
		}
	}
	
	//*** These two functions is used when we have checkboxes in the form
	//** and we need to check all /uncheck all 
	//** call CheckAll on click of the checkbox that do the checkall/uncheckall
	//** call verifycheckall on every checkbox in the form. 
	//** (document.form1.checkALL,document.form1.Mychecks)
	function CheckAll(chkAll,chk) {
	  if(chk && chkAll){
		  for (var i=0;i<chk.length;i++) {
			  if(chk[i].type == "checkbox"){
				chk[i].checked = chkAll.checked;
			  }
		  }
	  }
	}
	function VerifyCheckAll(chkAll,chk){
		var FinalChecked = true; 
		if(chk && chkAll){	
			for(var i = 0; i<chk.length;i++){
				if(chk[i].type == "checkbox"){
					if(chk[i].checked == false){
						FinalChecked = false;
						break;
					}
				}
			}
			chkAll.checked = FinalChecked;
		}
	}
	
	function getIFRAMEObject(FrameName,useParent)
	{
		if (useParent==true)
		{
			if (navigator.userAgent.indexOf("Firefox")>0) {
				return parent.document.getElementById(FrameName)	
			}
			else
			{
				return parent.document[FrameName]
			}
		}
		else
		{
			if (navigator.userAgent.indexOf("Firefox")>0) {
				return document.getElementById(FrameName)	
			}
			else
			{
				return document[FrameName]
			}
		
		}
	}

	function RedirectIFRAME(url,iframeIE,iframeMozilla) {
		if (navigator.userAgent.indexOf("Firefox")>0) {
			iframeMozilla.src=url
		}
		else
		{
			iframeIE.location.href=url
		}
	}
	function GetIFRAMEValue(iframename,formelement) {	
		if (navigator.userAgent.indexOf("Firefox")>0) {
			return document.getElementById(iframename).contentDocument.getElementById(formelement).value;
		}
		else
		{
			return document[iframename].document.getElementById(formelement).value;
		}
	}

	function GetIFRAMEDocument(iframename) {	
		if (navigator.userAgent.indexOf("Firefox")>0) {
			return document.getElementById(iframename).contentDocument;
		}
		else
		{
			return document[iframename].document;
		}
	}
	
	function ResetTimerAndRedirect(url,reset) {
		switch(reset)
			{
			case 1:
				//called from IFRAME
				parent.Reset();
				parent.Start();
				break;    
			case 2:
				//called from toolbar-enabled page
				Reset();
				Start();
				break;
			case 3:
				//called from a window opened from toolbar-enabled page
				window.opener.Reset();
				window.opener.Start();
				break;
			case 4:
				//called from a window opened from an IFRAME
				window.opener.parent.Reset();
				window.opener.parent.Start();
				break;
			}
		location.href=url		
	}
	
	function DisplayMessage(ID,text){
		var x = document.getElementById(ID); 
		if(x){
			x.innerHTML=text;	
		}
	}
	
	function GetQueryString(sName) {
		hu = GetALLQueryString();
		gy = hu.split("&");
		for (i=0;i<gy.length;i++) {
			ft = gy[i].split("=");
			if (ft[0] == sName) {
				return ft[1];
			}
		}
	}
	function GetALLQueryString() {
		hu = document.location.search.substring(1);
		return hu;
	}
	
	//COOKIES FUNCTIONS... 

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
/*
// remember, these are the possible parameters for Set_Cookie:
// name, value, expires, path, domain, secure
Set_Cookie( 'test', 'it works', '', '/', '', '' );
if ( Get_Cookie( 'test' ) ) alert( Get_Cookie('test'));
// and these are the parameters for Delete_Cookie:
// name, path, domain
// make sure you use the same parameters in Set and Delete Cookie.
Delete_Cookie('test', '/', '');
( Get_Cookie( 'test' ) ) ? alert( Get_Cookie('test')) : 
alert( 'it is gone');


*/

	//used in the filters that have equal / greater / less than
	function togglecriteria2(el,fieldname){
		if (el.options[el.selectedIndex].value =='9300')
			document.all.item(fieldname).style.display='';
		else
			document.all.item(fieldname).style.display='none';
	}

	//This functions automatically set the height of an iframe the same size of its content so there is no scrollbar
	function ccExpandIframe(fooFrame) { // only good for page in the same domain name.
	   location.hash="#";       
		var fooWin = eval("window." + fooFrame.name);
	  if (document.getElementById) {
		  try {
		  //if (location.hostname == fooWin.location.hostname) {
	
				var fooBody = fooWin.document.body;
				var fooHeight=fooBody.scrollHeight + fooBody.offsetHeight - fooBody.clientHeight;
				var fooWidth=fooBody.scrollWidth + fooBody.offsetWidth - fooBody.clientWidth;
				fooFrame.style.height = fooHeight + 30;
				fooFrame.style.width = fooWidth;
			fooFrame.style.borderStyle="none";
				if (document.all) {
			  fooBody.scroll="no";
			  fooFrame.frameBorder=0;
			}
		  //}
		  } catch (e) {}
	  }
	}


/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)


subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function getposOffsetVAdjust(overlayVAdjust, offsettype){
var totaloffset=(offsettype=="left")? overlayVAdjust.offsetLeft : overlayVAdjust.offsetTop;
var parentEl=overlayVAdjust.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlayVAdjust(curobj, subobjstr, opt_position,VAdjust){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"

if (navigator.userAgent.indexOf("Firefox")>0) {

    var xpos;
    if (subobjstr=="BALLOON_WPGENERAL") {
        xpos=10
    } else if (subobjstr=="BALLOON_WPPERF") {
        xpos=110
    } else if (subobjstr=="BALLOON_WPINVOICING") {
        xpos = 210
    } else if (subobjstr=="BALLOON_WPCUSTOM") {
        xpos = 315
    } else if (subobjstr=="BALLOON_WPOUTBOUND") {
        xpos = 425
    }
    subobj.style.left=xpos+"px"
    
    var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
    subobj.style.top=ypos-10+"px"
    DisplayMessage("CZ_DEBUG",xpos);
    
} 
else 
{
    var xpos=getposOffsetVAdjust(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
    var ypos=getposOffsetVAdjust(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
    subobj.style.left=xpos+"px"
    subobj.style.top=(ypos-VAdjust)+"px"
}
return false
}
else
return true
}


function getposOffsetX(overlayX, offsettype){
var totaloffset=(offsettype=="left")? overlayX.offsetLeft : overlayX.offsetTop;
var parentEl=overlayX.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlayX(curobj, subobjstr, opt_position,xAdjust){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffsetX(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffsetX(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)


subobj.style.left=(xAdjust+xpos)+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}



function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}

//**********************************************************

function SetPerformance(){
	var s; 
	s = window.location.href;
	if(GetALLQueryString() == '') {
		s = s + '?setperformance=1';	
	}
	else{
		s = s + GetALLQueryString().replace('setperformance=','spf=') + '&setperformance=1';	
	}
	window.location.href = s;
}



	
function isIFRAME(){
	try
		{
			var dummy = parent.document.getElementsByTagName('iframe')[0].name;
			return true;
		}
	catch(err)
		{
			return false;
		}
		
}	


	function VerifyDate(sdate){
		var isOk = true;
		//validation for the date fields
		if(sdate){
			if(sdate != ''){
				isOk = isDate(sdate);
				if(!isOk){
					alert('Error, Date format should be mm/dd/yyyy. Please, try again.');
				}
			}
		}
		return isOk;
	}
	
	function populateDropDown(cmb,arrText,arrValue,IncludeBlank){
			var c = document.getElementById(cmb);
			var v = new Array();
			var t = new Array();
			var icount = 0; 
			if(c!=null){
				c.options.length = 0;
				if(IncludeBlank){
					c.options[c.length] =  new Option( ' ----------------------','');
				}
				v = arrValue.split('|');				
				t = arrText.split('|');				
				for ( icount = 0; icount < v.length; icount++ ) {
					if(v[icount] != ""){
						c.options[c.length] =  new Option(t[icount],v[icount]);
					}
				}
				c.selectedIndex = 0;					
			}
		
		}		
	
	





function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null;	
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP";
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP";
	} 
	try
	{ 
		objXmlHttp=new ActiveXObject(strName);
		objXmlHttp.onreadystatechange=handler;
		return objXmlHttp;
	} 
	catch(e)
	{ 
		alert("Error. Scripting for ActiveX might be disabled");
		return;
	} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler;
		return objXmlHttp;
	}
} 

/* JSON FUNCTIONS START*/
/*global json_parse */

json_parse = (function () {

// This is a function that can parse a JSON text, producing a JavaScript
// data structure. It is a simple, recursive descent parser. It does not use
// eval or regular expressions, so it can be used as a model for implementing
// a JSON parser in other languages.

// We are defining the function inside of another function to avoid creating
// global variables.

    var at,     // The index of the current character
        ch,     // The current character
        escapee = {
            '"':  '"',
            '\\': '\\',
            '/':  '/',
            b:    '\b',
            f:    '\f',
            n:    '\n',
            r:    '\r',
            t:    '\t'
        },
        text,

        error = function (m) {

// Call error when something is wrong.

            throw {
                name:    'SyntaxError',
                message: m,
                at:      at,
                text:    text
            };
        },

        next = function (c) {

// If a c parameter is provided, verify that it matches the current character.

            if (c && c !== ch) {
                error("Expected '" + c + "' instead of '" + ch + "'");
            }

// Get the next character. When there are no more characters,
// return the empty string.

            ch = text.charAt(at);
            at += 1;
            return ch;
        },

        number = function () {

// Parse a number value.

            var number,
                string = '';

            if (ch === '-') {
                string = '-';
                next('-');
            }
            while (ch >= '0' && ch <= '9') {
                string += ch;
                next();
            }
            if (ch === '.') {
                string += '.';
                while (next() && ch >= '0' && ch <= '9') {
                    string += ch;
                }
            }
            if (ch === 'e' || ch === 'E') {
                string += ch;
                next();
                if (ch === '-' || ch === '+') {
                    string += ch;
                    next();
                }
                while (ch >= '0' && ch <= '9') {
                    string += ch;
                    next();
                }
            }
            number = +string;
            if (isNaN(number)) {
                error("Bad number");
            } else {
                return number;
            }
        },

        string = function () {

// Parse a string value.

            var hex,
                i,
                string = '',
                uffff;

// When parsing for string values, we must look for " and \ characters.

            if (ch === '"') {
                while (next()) {
                    if (ch === '"') {
                        next();
                        return string;
                    } else if (ch === '\\') {
                        next();
                        if (ch === 'u') {
                            uffff = 0;
                            for (i = 0; i < 4; i += 1) {
                                hex = parseInt(next(), 16);
                                if (!isFinite(hex)) {
                                    break;
                                }
                                uffff = uffff * 16 + hex;
                            }
                            string += String.fromCharCode(uffff);
                        } else if (typeof escapee[ch] === 'string') {
                            string += escapee[ch];
                        } else {
                            break;
                        }
                    } else {
                        string += ch;
                    }
                }
            }
            error("Bad string");
        },

        white = function () {

// Skip whitespace.

            while (ch && ch <= ' ') {
                next();
            }
        },

        word = function () {

// true, false, or null.

            switch (ch) {
            case 't':
                next('t');
                next('r');
                next('u');
                next('e');
                return true;
            case 'f':
                next('f');
                next('a');
                next('l');
                next('s');
                next('e');
                return false;
            case 'n':
                next('n');
                next('u');
                next('l');
                next('l');
                return null;
            }
            error("Unexpected '" + ch + "'");
        },

        value,  // Place holder for the value function.

        array = function () {

// Parse an array value.

            var array = [];

            if (ch === '[') {
                next('[');
                white();
                if (ch === ']') {
                    next(']');
                    return array;   // empty array
                }
                while (ch) {
                    array.push(value());
                    white();
                    if (ch === ']') {
                        next(']');
                        return array;
                    }
                    next(',');
                    white();
                }
            }
            error("Bad array");
        },

        object = function () {

// Parse an object value.

            var key,
                object = {};

            if (ch === '{') {
                next('{');
                white();
                if (ch === '}') {
                    next('}');
                    return object;   // empty object
                }
                while (ch) {
                    key = string();
                    white();
                    next(':');
                    if (Object.hasOwnProperty.call(object, key)) {
                        error('Duplicate key "' + key + '"');
                    }
                    object[key] = value();
                    white();
                    if (ch === '}') {
                        next('}');
                        return object;
                    }
                    next(',');
                    white();
                }
            }
            error("Bad object");
        };

    value = function () {

// Parse a JSON value. It could be an object, an array, a string, a number,
// or a word.

        white();
        switch (ch) {
        case '{':
            return object();
        case '[':
            return array();
        case '"':
            return string();
        case '-':
            return number();
        default:
            return ch >= '0' && ch <= '9' ? number() : word();
        }
    };

// Return the json_parse function. It will have access to all of the above
// functions and variables.

    return function (source, reviver) {
        var result;

        text = source;
        at = 0;
        ch = ' ';
        result = value();
        white();
        if (ch) {
            error("Syntax error");
        }

// If there is a reviver function, we recursively walk the new structure,
// passing each name/value pair to the reviver function for possible
// transformation, starting with a temporary root object that holds the result
// in an empty key. If there is not a reviver function, we simply return the
// result.

        return typeof reviver === 'function' ? (function walk(holder, key) {
            var k, v, value = holder[key];
            if (value && typeof value === 'object') {
                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = walk(value, k);
                        if (v !== undefined) {
                            value[k] = v;
                        } else {
                            delete value[k];
                        }
                    }
                }
            }
            return reviver.call(holder, key, value);
        }({'': result}, '')) : result;
    };
}());

/* JSON FUNCTIONS END */

