<!--
var globalValueCounter = 1;
var totalValues = 6;
var valuesMovies = false;

function reloadValues(){
	if (!valuesMovies)  return;
	// apply filter on values, change display, then play
	var values = document.getElementById("values");
	var value = document.getElementById("value");
	//var whiteValue = document.getElementById("whiteValue");
	
	if (values){
			values.filters[0].Apply();
			//value.style.display = 'none';
			//whiteValue.style.display = 'block';
			
			// change content
			valueSpan = document.getElementById("value"+globalValueCounter);
			if (valueSpan) valueSpan.style.display = 'none';
			
			globalValueCounter++;
			if (globalValueCounter > totalValues) globalValueCounter = 1;
			
			valueSpan = document.getElementById("value"+globalValueCounter);
			if (valueSpan) valueSpan.style.display = 'inline'
			
			values.filters[0].play();
			setTimeout(reloadValues,5000);
	}
}
/*
function playSmooth(){
	// apply filter on values, change display, then play
	var values = document.getElementById("values");
	var value = document.getElementById("value");
	var whiteValue = document.getElementById("whiteValue");
	
	if (values){
		values.filters[0].Apply();
		value.style.display = 'block';
		whiteValue.style.display = 'none';
		values.filters[0].play();
		
		// settimeout and redo
		setTimeout(reloadValues,5000);
	}
}
*/
function callRegister(){
		window.location.href = 'code/register.htm';
}
window.setTimeout(reloadValues,5000);

function fixBehaviors(){
	// if this is the main page, change the urls in all behaviors to be relative to root
	var styleSh = document.styleSheets[0];
	styleSh.addRule(".imgHover","behavior: url(code/imgHover.htc);");
	styleSh.addRule(".navTitle","behavior: url(code/navTitle.htc);");
	
	valuesMovies = true;
}

/*******************************************************************
			Returns a String containing a copy of a specified string without leading spaces. 

			Parameters:
			String - The required string argument is any valid 
					string expression. If string contains null, 
					false is returned.
			Returns: String.
			*******************************************************************/
			function LTrim(String)
			{
				var i = 0;
				var j = String.length - 1;

				if (String == null)
					return (false);

				for (i = 0; i < String.length; i++)
				{
					if (String.substr(i, 1) != ' ' && String.substr(i, 1) != '\t')
						break;
				}

				if (i <= j)
					return (String.substr(i, (j+1)-i));
				else
					return ('');
			}

			/*******************************************************************
			Returns a String containing a copy of a specified string without trailing spaces. 

			Parameters:
			String - The required string argument is any valid 
					string expression. If string contains null, 
					false is returned.
			Returns: String.
			*******************************************************************/
			function RTrim(String)
			{
				var i = 0;
				var j = String.length - 1;

				if (String == null)
					return (false);

				for(j = String.length - 1; j >= 0; j--)
				{
					if (String.substr(j, 1) != ' ' && String.substr(j, 1) != '\t')
						break;
				}

				if (i <= j)
					return (String.substr(i, (j+1)-i));
				else
					return ('');
			}

			/*******************************************************************
			Returns a String containing a copy of a specified string without 
			both leading and trailing spaces .

			Parameters:
			String - The required string argument is any valid 
					string expression. If string contains null, 
					false is returned.
			Returns: String.
			*******************************************************************/
			function Trim(String)
			{
				if (String == null)
					return (false);
				return RTrim(LTrim(String));
			}

			function ValidateForm(){
			
				if (Trim(document.signIn.txtUsername.value) == ""){
					alert("Please enter the user name");
					document.signIn.txtUsername.focus();
					return false;
				}
				if (Trim(document.signIn.txtPassword.value) == ""){
					alert("Please enter the password");
					document.signIn.txtPassword.focus();
					return false;
				}
				
				//If pass the validation the submit the form
				document.signIn.submit();
			}
		function openPopup(pagePath,iWidth,iHeight,forPrint){
			var iWinWidth = 455;
			var iWinHeight = 380;
			
			pagePath = String(pagePath).toLowerCase();
			// if other arguments exist, the first after url overwrites width of window
			
			
			//if (iWidth) iWinWidth = iWidth;
			//if (iHeight) iWinHeight = iHeight;
				
			
			var iAvailWidth = screen.availWidth;
			var iAvailHeight = screen.availHeight;
			if (iAvailWidth < iWinWidth) iWinWidth = iAvailWidth;
			if (iAvailHeight < iWinHeight) iWinHeight = iAvailHeight;
			// also center position of window
			var iLeft = (iAvailWidth - iWinWidth)/2;
			var iTop = (iAvailHeight - iWinHeight)/2;
			
			if (forPrint){
				iWinWidth = (800 > screen.availWidth/2) ? 800 : screen.availWidth/2;
				iWinHeight = (500 > screen.availHeight/2) ? 500 : screen.availHeight/2;
			
			}
			if (forPrint)
				newWin = window.open(pagePath,'newWin','width='+ iWinWidth +',left='+ iLeft +',top='+ iTop +',height='+ iWinHeight +',toolbar=0,status=0,menubar=1,resizable=1,scrollbars=1');
			else
				newWin = window.open(pagePath,'newWin','width='+ iWinWidth +',left='+ iLeft +',top='+ iTop +',height='+ iWinHeight +',toolbar=0,status=0,menubar=0,resizable=0,scrollbars=1');
				
			newWin.focus();	
			//return false
			//event.cancelBubble = true;
			//event.returnValue = false;
				
		}
	

		
	var newWin;
	
	function unloadPopup(){
		if (!window.opener){
			if (window.newWin)
				if(!window.newWin.closed)
					window.newWin.close();
		}
	}
	window.onunload = unloadPopup;

var timeoutIndex = null;
function resetNav() {
	clearResetNav();
	timeoutIndex = setTimeout(checkNav, 500);
}
function clearResetNav() {
	if(timeoutIndex != null) {
		clearTimeout(timeoutIndex);
	}
}


function showNav(subnavId){
	// get the subnav value, and show respectivly
	// first hide all children of subNavBar
	
	var subNavContainer = document.getElementById("subNavBar");
	
	subNavBarChildNode = subNavContainer.firstChild;
	
	do {
		if(subNavBarChildNode.nodeName == "SPAN") {
			subNavBarChildNode.style.display = (subNavBarChildNode.id != subnavId)? "none": "inline";
		}
	}
	while(subNavBarChildNode = subNavBarChildNode.nextSibling);
	
	// Old code supports IE only
	/*
	var subNavBar = document.getElementById("subNavBar");
	if (subNavBar){
		for(i=0;i<subNavBar.children.length;i++){
			subNavBar.children[i].style.display = 'none';
		}
	}
	var subnav = event.srcElement.getAttribute("subnav");
	if (subnav){
		
		var navBar = document.getElementById(subnav);
		if (navBar) {
			navBar.style.display = 'inline';
		}
	}
	*/
}
var gNav;
function checkNav(){
	// according to global variable, check the default nav item
	
	if(gNav != null) {
		var navContainer = document.getElementById("subNavBar");
		var currentPageNavItem = document.getElementById(gNav);

		if(currentPageNavItem) {
			currentPageNavItem.className += " sel";
			showNav(currentPageNavItem.getAttribute("subnav"));
		}
	
	}
	
	// Old code supports IE only
	/*
	if (gNav){
		var gNavBar = document.getElementById("gNavBar");
		if (gNavBar){
			for (var j=0; j<gNavBar.children.length; j++){
				if (gNavBar.children[j].gnavid == gNav){
					gNavBar.children[j].className += " sel";
					// make child default show
					var navBar = document.getElementById(gNavBar.children[j].subnav);
					if (navBar) {
						navBar.style.display = 'inline';
					}
					break;
				}
			}
		}
	}
	*/
}

function myButtonFunc(bId,elem){
	document.getElementById(bId).disabled=!elem.checked
}
function handleCurr(pid,bShow,rid,rtext){
	document.getElementById(pid).style.display = (bShow) ? "block" : "none";
	document.getElementById(rid).innerText = rtext;
}

var tsCount = 0;
var tsInt;
function doCalc(){
	var tMinsT= 0, tHrsT = 0, tPCostT = 0, tWCostT = 0, tGrandT = 0;
	// add tMin to tMins, add tHr to tHrs
	// tPCost = tMins/60 * tPCph
	// tWCost = tHrs * tWCph
	// tGrand = tPCost + tWCost;
	var tMins = document.getElementsByName("tMin");
	var tHrs = document.getElementsByName("tHr");
	var tPCph = document.getElementById("tPCph").value;
	var tWCph = document.getElementById("tWCph").value;
	

	
	for (var i=0; i<tMins.length; i++){
		if (!isNaN(parseFloat(tMins[i].value))) {
			if (parseFloat(tMins[i].value) <= 0){
				alert('insert positive numbers only');
				return false;
			}
			tMinsT += parseFloat(tMins[i].value);
		}else {
			if (tMins[i].value == "") {
				alert("Please submit the time values");
				return false;
			}
			alert('insert numbers only');
			return false;
		}
		if (!isNaN(parseFloat(tHrs[i].value))) {
			if (parseFloat(tHrs[i].value) <= 0){
				alert('insert positive numbers only');
				return false;
			}
			tHrsT += parseFloat(tHrs[i].value);
		}else {
			if (tHrs[i].value == "") {
				alert("Please submit the time values");
				return false;
			}
			alert('insert numbers only');
			return false;
		}
	}
	
	tPCostT = Math.round(Math.round(tMinsT*100/60)/100 * parseFloat(tPCph)* 100)/100;
	tWCostT = Math.round(tHrsT * parseFloat(tWCph) * 100)/100;
	tGrandT = tWCostT + tPCostT;
	
	// also change tPCostA, tWCostA, according to tMinsA * tPCph, tHrsA * tWCPg
	
	document.getElementById("tMins").innerText = tMinsT;
	document.getElementById("tHrs").innerText = tHrsT;
	document.getElementById("tWCost").innerText = "$" +tWCostT;
	document.getElementById("tPCost").innerText = "$" +tPCostT
	document.getElementById("tGrand").innerText = "$" +tGrandT;
	
	var tMinsA = parseInt(document.getElementById("tMinsA").innerText);
	var tHrsA = parseInt(document.getElementById("tHrsA").innerText);
	var tPCostA = Math.round(Math.round(tMinsA*100/60)/100 * parseFloat(tPCph)* 100)/100;
	var tWCostA = Math.round(tHrsA * parseFloat(tWCph)* 100)/100;
	document.getElementById("tPCostA").innerText = "$" + tPCostA;
	document.getElementById("tWCostA").innerText = "$" + tWCostA;
	
	var tGrandAT = Math.round((tPCostA + tWCostA)* 100)/100;
	document.getElementById("tGrandA").innerText = tGrandAT;
	document.getElementById("tSaving").innerText = Math.round((tGrandT - tGrandAT)*100)/100;
	
	tsInt = window.setInterval(playTotal,500);
}

function doCalc2(){
	
	var tMins = document.getElementsByName("tMin");
	var tCosts = document.getElementsByName("tCost");
	
	var tMinsT = 0, tCostsT = 0; 
	for (var i=0; i<tMins.length; i++){
		if (!isNaN(parseFloat(tMins[i].value))) {
			if (parseFloat(tMins[i].value) < 0){
				alert('insert positive numbers only');
				return false;
			}
			tMinsT += parseFloat(tMins[i].value);
		}else {
			if (tMins[i].value != "") {
				//alert("Please submit the time and cost values");
				//return false;
				alert('insert numbers only');
				return false;
			}
			
		}
		if (!isNaN(parseFloat(tCosts[i].value))) {
			if (parseFloat(tCosts[i].value) < 0){
				alert('insert positive numbers only');
				return false;
			}
			tCostsT += parseFloat(tCosts[i].value);
		}else {
			if (tCosts[i].value != "") {
				//alert("Please submit the time and cost values");
				//return false;
				alert('insert numbers only');
				return false;
			}
			
		}
	}
	tMinsT = Math.round(tMinsT*100)/100;
	tCostsT = Math.round(tCostsT *100)/100;
	document.getElementById("tMins").innerText = tMinsT;
	document.getElementById("tCosts").innerText = "$" + tCostsT;
	tsInt = window.setInterval(playTotal,10);
}

function playTotal(){
	
	var ts = document.getElementsByName("tAcebroker");
	if (tsCount < ts.length){
	//for (var i=0; i<ts.length;i++){
		ts[tsCount].filters[0].apply();
		ts[tsCount].style.display = 'block';
		ts[tsCount].filters[0].play();
		
		tsCount++;
	}else{
		window.clearInterval(tsInt);
	}
	
	//}
}
//-->