<!-- Hide from JavaScript-impaired browsers
var mywindow 
function checkSelectAll( checkbox ) {
	var items = document.getElementsByName( checkbox );	for( var i = 0; i < items.length; i++ ) {		items[i].checked = true;	}}function checkDeselectAll( checkbox ) {
	var items = document.getElementsByName( checkbox );	for( var i = 0; i < items.length; i++ ) {		items[i].checked = false;	}}
function deselectAll( selectBox ) {
    for( var i = 0; i < selectBox.options.length; i++ ) {
        selectBox.options[i].selected = false;
    }
}

function selectValue( selectBox, selectValue ) {
    deselectAll(selectBox);
    for( var i = 0; i < selectBox.options.length; i++ ) {
        //alert ( selectBox.options[i].value + " vs " + selectValue );
        
        if ( selectBox.options[i].value == selectValue ) {
            selectBox.options[i].selected = true;
        }
    }
}

function jsHide(idList) {
    var ids = split(idList,",");
    for( var i = 0; i < ids.length; i++ ) {
        var e = document.getElementById( trim(ids[i]) );
        if ( e ) {
            e.style.display = "none";
        }
    }
}

function jsShow(idList) {
    var ids = split(idList,",");
    for( var i = 0; i < ids.length; i++ ) {
        var e = document.getElementById( trim(ids[i]) );
        if ( e ) {
            e.style.display = "";
        }
    }
}        

function trim(str) {
    var startIndex,endIndex;
    var newStr = str;
    
    for( startIndex = 0; startIndex < newStr.length; startIndex++ ) {
        if( newStr.substr(startIndex,1) != ' ' ) {
            break;
        }
    }
    
    if ( startIndex < newStr.length ) {
        newStr = newStr.substr(startIndex);
    }
    
    for( endIndex = newStr.length-1; endIndex >= 0; endIndex-- ) {
        if( newStr.substr(endIndex,1) != ' ' ) {
            break;
        }
    }
    
    if( endIndex >= 0 ) {
        newStr = newStr.substr(0,endIndex);      
    }
    
    return newStr;
}
    
function openHelp(linkName)
	{
		var strSend = "help.asp?helpID=" + linkName
		var helpWindow = window.open(strSend,'Help_Window','width=400,height=350,dependent,resizable=yes,scrollbars=yes')
	}
function openeHelp(linkName)
	{
		var strSend = "ehelp.asp?ehelpID=" + linkName
		var helpWindow = window.open(strSend,'Help_Window','width=400,height=350,dependent,resizable=yes,scrollbars=yes')
	}
function openWindow(linkName,width,height)
	{
		var strSend = linkName
		var previewWindow = window.open(strSend,'_blank','width='+width+',height='+height+',dependent,resizable=no,scrollbars=yes,menubar=no,toolbar=no')
	}
function openLink(linkName,width,height)
	{
		var strSend = linkName
		var helpWindow = window.open(strSend,'Edit_Window','width='+width+',height='+height+', dependent,resizable=yes, scrollbars=yes,menubar=yes,toolbar=yes')
	}
function openNewLink(linkName,width,height) {
		var strSend = linkName
		var helpWindow = window.open(strSend,'_blank','width='+width+',height='+height+', dependent,resizable=yes, scrollbars=yes,menubar=yes,toolbar=yes')
}
function displayids(id) {
  var i =0 ;
  var o = document.all.item(id, i);
    while (o != null) {
    if (o.style.display == "none") {
      o.style.display = "";
    } else {
      o.style.display = "none";
    }      
      i++;
      o = document.all.item(id, i);
    }
      
    return;
  }

function gotoIFrame(ifName,frameTarget, frameWidth, frameHeight) {
	if (ifName.style.display=="none") {
	    
		ifName.height=frameHeight;
		ifName.width=frameWidth;
		textlink = frameTarget;
		ifName.src = '';
		ifName.src=textlink;
		// Correct placement of IFrame
		var eP = window.event.srcElement
					
      var eL=0;var eT=0;
		for(var p=eP; p&&p.tagName!='BODY'; p=p.offsetParent){
			eL+=p.offsetLeft;
			eT+=p.offsetTop;
		}
	
		var eH=eP.offsetHeight-28;
		var dH=ifName.style.pixelHeight;
		var sT=document.body.scrollTop;
		//ifName.style.left=eL;
		
		//alert(eT );
		//alert(sT);
		//alert(dH);
		//alert(eH);
		//alert(document.body.clientHeight);
		
		//alert(document.body.clientHeight+sT);
		
		if(eT-dH >= sT && eT+eH+dH > document.body.clientHeight+sT){
		  ifName.style.top=eT+dH;
		  //alert('+');
		  }
		else {
		  ifName.style.top=eT-eH;
		  //alert('-');
		  }
		  
		  //alert(ifName.style.top);
		  
		var eW=eP.offsetWidth;
		var dW=ifName.width;
		var sL=document.body.scrollLeft;
		
		if(eL-dW >= sL && eL+eW+dW > document.body.clientWidth+sL){
		  ifName.style.left=eL-dW;
		  }
		else {
			if (((document.body.clientWidth+sL)-(eL+eW))<dW) {
				ifName.style.left=eL+(eW/2)-(dW-((document.body.clientWidth+sL)-(eL+(eW/2)))+18);
			}
			else {			
				ifName.style.left=eL+(eW / 2);
			}
		 }
		  

		 ifName.style.display="block";
		}
	else {
	      ifName.src="";
		 ifName.style.display="none";
		}
}


function calcExpense(val, rowNum) {
	if (!document.mainform.id59) return;
	
		var rate = 0;
		var unit = 0;
		if (rowNum == 1) {
			unit = parseFloat(document.mainform.id60.value);
			rate = parseFloat(document.mainform.id66.value.replace(",",""));
			document.mainform.subTotal1.value = (rate * unit).toFixed(2);
			document.mainform.id66.value = rate.toFixed(2);
			if (isNaN(document.mainform.subTotal1.value)){
			 document.mainform.subTotal1.value = "0.00";
			}
			if (isNaN(document.mainform.id66.value)){ document.mainform.id66.value = "0.00"; }
		}
		if (rowNum == 2) {
			unit = parseFloat(document.mainform.id61.value.replace(",",""));
			rate = parseFloat(document.mainform.id68.value.replace(",",""));
			document.mainform.subTotal2.value = (rate * unit).toFixed(2);
			document.mainform.id68.value = rate.toFixed(2);
			if (isNaN(document.mainform.subTotal2.value)){
				 document.mainform.subTotal2.value = "0.00";
		 	
			}
			if (isNaN(document.mainform.id68.value)){ document.mainform.id68.value = "0.00"; }
		}
		if (rowNum == 3) {
			unit = parseFloat(document.mainform.id499.value.replace(",",""));
			rate = parseFloat(document.mainform.id501.value.replace(",",""));
			document.mainform.subTotal3.value = (rate * unit).toFixed(2);
			document.mainform.id501.value = rate.toFixed(2);
			if (isNaN(document.mainform.subTotal3.value)){
				document.mainform.subTotal3.value = "0.00";
		 	
			}
			if (isNaN(document.mainform.id501.value)){ document.mainform.id501.value = "0.00"; }
		}
		if (rowNum == 4) {
			unit = parseFloat(document.mainform.id668.value.replace(",",""));
			rate = parseFloat(document.mainform.id691.value.replace(",",""));
			document.mainform.subTotal4.value = (rate * unit).toFixed(2);
			document.mainform.id691.value = rate.toFixed(2);
			if (isNaN(document.mainform.subTotal4.value)){
				document.mainform.subTotal4.value = "0.00";
		 	
			}
			if (isNaN(document.mainform.id691.value)){ document.mainform.id691.value = "0.00"; }
		}
		
		if (rowNum == 5) {
			unit = parseFloat(document.mainform.id675.value.replace(",",""));
			rate = parseFloat(document.mainform.id677.value.replace(",",""));
			document.mainform.subTotal5.value = (rate * unit).toFixed(2);
			document.mainform.id677.value = rate.toFixed(2);
			if (isNaN(document.mainform.subTotal5.value)){
				document.mainform.subTotal5.value = "0.00";
		 	
			}
			if (isNaN(document.mainform.id677.value)){ document.mainform.id677.value = "0.00"; }
		}		

		if (rowNum == 6) {
			unit = parseFloat(document.mainform.id684.value.replace(",",""));
			rate = parseFloat(document.mainform.id686.value.replace(",",""));
			document.mainform.subTotal6.value = (rate * unit).toFixed(2);
			document.mainform.id686.value = rate.toFixed(2);
			if (isNaN(document.mainform.subTotal6.value)){
				document.mainform.subTotal6.value = "0.00";
		 	
			}
			if (isNaN(document.mainform.id686.value)){ document.mainform.id686.value = "0.00"; }
		}
		
		rate = parseFloat(document.mainform.id59.value.replace(",",""));
		document.mainform.id59.value = rate.toFixed(2);
		if(! isNaN(rate)){
			document.mainform.grandtotal.value = (parseFloat(document.mainform.subTotal1.value) + 
													parseFloat(document.mainform.subTotal2.value) + 
													parseFloat(document.mainform.subTotal3.value) +
													parseFloat(document.mainform.subTotal4.value) + 
													parseFloat(document.mainform.subTotal5.value) + 
													parseFloat(document.mainform.subTotal6.value) +  
													parseFloat(rate)).toFixed(2);
			}
		else{
			document.mainform.id59.value = "0.00";
			document.mainform.grandtotal.value = (parseFloat(document.mainform.subTotal1.value) + 
													parseFloat(document.mainform.subTotal2.value) + 
													parseFloat(document.mainform.subTotal4.value) + 
													parseFloat(document.mainform.subTotal5.value) + 
													parseFloat(document.mainform.subTotal6.value) +
													parseFloat(document.mainform.subTotal3.value)).toFixed(2);
			}
			
	



}

function calculateRowTotal(cell1, cell2, totalCell) {
		unit = parseFloat(cell1.value);
		rate = parseFloat(cell2.value.replace(",",""));
		totalCell.value =  (rate * unit).toFixed(2);
		totalCell.value = rate.toFixed(2);
		if (isNaN(totalCell.value)){
			 totalCell.value = 0;
		}
		if (isNaN(cell2.value) || cell2.value == ""){ cell2.value = "0.00"; }
}

function getTotals(){
		var rate = 0;
		var unit = 0
		//alert("foobar");
		unit = parseFloat(document.mainform.id60.value);
		rate = parseFloat(document.mainform.id66.value.replace(",",""));
		document.mainform.subTotal1.value = (rate * unit).toFixed(2);
		//document.mainform.id60.value = rate;
		document.mainform.id66.value = rate.toFixed(2);
		if (isNaN(document.mainform.subTotal1.value)){
			 document.mainform.subTotal1.value = 0;
		}
		if (isNaN(document.mainform.id66.value)){ document.mainform.id66.value = "0.00"; }
		unit = parseFloat(document.mainform.id61.value);
		rate = parseFloat(document.mainform.id68.value.replace(",",""));
		document.mainform.subTotal2.value = (rate * unit).toFixed(2);
		document.mainform.id68.value = rate.toFixed(2);
		if (isNaN(document.mainform.subTotal2.value)){
			 document.mainform.subTotal2.value = 0;
		}
		if (isNaN(document.mainform.id68.value)){ document.mainform.id68.value = "0.00"; }
		unit = parseFloat(document.mainform.id499.value);
		rate = parseFloat(document.mainform.id501.value.replace(",",""));
		document.mainform.subTotal3.value =  (rate * unit).toFixed(2);
		document.mainform.id501.value = rate.toFixed(2);
		if (isNaN(document.mainform.subTotal3.value)){
			 document.mainform.subTotal3.value = 0;
		}
		if (isNaN(document.mainform.id501.value)){ document.mainform.id501.value = "0.00"; }

		calculateRowTotal(document.mainform.id668, document.mainform.id691, document.mainform.subTotal4 );
		calculateRowTotal(document.mainform.id675, document.mainform.id677, document.mainform.subTotal5 );
		calculateRowTotal(document.mainform.id684, document.mainform.id686, document.mainform.subTotal6 );
		
		rate = parseFloat(document.mainform.id59.value.replace(",",""));
		document.mainform.id59.value = rate.toFixed(2);
		if(!isNaN(rate)){
			document.mainform.grandtotal.value = (parseFloat(document.mainform.subTotal1.value) + parseFloat(document.mainform.subTotal2.value) + parseFloat(document.mainform.subTotal3.value) + parseFloat(rate)).toFixed(2);
		}
		else{
			document.mainform.id59.value = "0.00";		
			document.mainform.grandtotal.value = parseFloat(document.mainform.subTotal1.value) + parseFloat(document.mainform.subTotal2.value) + parseFloat(document.mainform.subTotal3.value);
			if ( isNaN(document.mainform.grandtotal.value || isnull(document.mainform.grandtotal.value))){
			document.mainform.grandtotal.value = "0.00"; }
			else{
			document.mainform.grandtotal.value = parseFloat(document.mainform.subTotal1.value) + parseFloat(document.mainform.subTotal2.value) + parseFloat(document.mainform.subTotal3.value); }
		}

}

function correctPNG() 

   {

   for(var i=0; i<document.images.length; i++)

      {

              var img = document.images[i]

              var imgName = img.src.toUpperCase()

              if (imgName.substring(imgName.length-3, imgName.length) == "PNG")

                 {

                         var imgID = (img.id) ? "id='" + img.id + "' " : ""

                         var imgClass = (img.className) ? "class='" + img.className + "' " : ""

                         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "

                         var imgStyle = "display:inline-block;" + img.style.cssText 

                         if (img.align == "left") imgStyle = "float:left;" + imgStyle

                         if (img.align == "right") imgStyle = "float:right;" + imgStyle

                         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle              

                         var strNewHTML = "<span " + imgID + imgClass + imgTitle

                         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"

                 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"

                         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 

                         img.outerHTML = strNewHTML

                         i = i-1
                         }
      }

   }

