
function QuickViewUpdate(){
	var SentTo = document.getElementById("QuickView").value;
	location.href=SentTo;
}

function changeFC(obj){ //Change Focus Color of Object
  obj.style.backgroundColor=(obj.style.backgroundColor==""?"#918FC4":"")
} 

function ShowHideID(objID){
	 if( document.getElementById(objID).style.display=='none' ){
	   document.getElementById(objID).style.display = '';
	 }else{
	   document.getElementById(objID).style.display = 'none';
	 }
}

function ShowHideID_Downloads(ShowID,HideIDArray){
	var mySplitResult = HideIDArray.split(",");
	var SplitResult;
	
	for(i = 0; i < mySplitResult.length; i++){
		SplitResult = mySplitResult[i];
		if(SplitResult!==ShowID){
			document.getElementById(SplitResult).style.display = 'none';
			document.getElementById("TR_"+SplitResult).style.backgroundColor   = '#E6EEEE';
		}
	}
	document.getElementById(ShowID).style.display = '';
	document.getElementById("TR_"+ShowID).style.backgroundColor  = '#8DBDD8';
}

function PrintContent(bUseCSS,bShowPrint,bCloseWindow){
	var DocumentContainer = document.getElementById('ResultsWindow');
	var WindowObject = window.open('', "TrackHistoryData", 
						  "width=740,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
	if(bUseCSS==true){
		WindowObject.document.writeln('<link rel="StyleSheet" href="/css/common-style.css" type="text/css">');
		WindowObject.document.writeln('<link rel="StyleSheet" href="/css/menu-style.css" type="text/css">');
		WindowObject.document.writeln('<link rel="StyleSheet" href="/css/tables.css" type="text/css">');
	}
	WindowObject.document.writeln(DocumentContainer.innerHTML);
	WindowObject.document.close();
	WindowObject.focus();
	if(bShowPrint==true){WindowObject.print();}
	if(bCloseWindow==true){WindowObject.close();}
}


function showMessageDiv(ElementID,HideDely,HTML_Message){
	document.getElementById(ElementID+"_Child").innerHTML=HTML_Message;
	document.getElementById(ElementID+"_Child").style.display="";
	document.getElementById(ElementID+"_Parent").style.display="";
	if (HideDely!=='0'){ //If = zero then it will not disapear
		window.setTimeout("hideMessageDiv('"+ElementID+"');", HideDely);
	}
}

function hideMessageDiv(ElementID){
	document.getElementById(ElementID+"_Child").style.display="none";
	document.getElementById(ElementID+"_Parent").style.display="none";
}

function validate_required(field,alerttxt){
	with (field){
	  if (value==null||value==""){
		if(alerttxt!==""){alert(alerttxt);}
		return false;
	  }else{
		return true;
	  }
	}
}

function validate_email(field,alerttxt){
	with (field){
	  apos=value.indexOf("@");
	  dotpos=value.lastIndexOf(".");
	  if (apos<1||dotpos-apos<2){
		  if(alerttxt!==""){alert(alerttxt);}
		  return false;
	  }else{
		  return true;
	  }
	}
}

function ExpandedInput(id,px){
   var element = document.getElementById(id);
   var height = element.clientHeight;

   element.style.height = (parseFloat(height) + parseFloat(px)) + "px";
}

function FormatCurrency(theField){
	var num = theField.value;
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	
	theField.value = (((sign)?'':'-') + num + '.' + cents);
	//theField.value = (((sign)?'':'-') + '$' + num + '.' + cents); //With dollar sign
} 

function days_between(startDate, endDate) {
    if(startDate.length!=10){return null;}
	if(endDate.length!=10){return null;}
	
	var vStartDate = startDate.split("/");
	var vEndDate = endDate.split("/");
	var StartISO = vStartDate[2]+vStartDate[0]+vStartDate[1];
	var EndISO = vEndDate[2]+vEndDate[0]+vEndDate[1];
	
	return (EndISO - StartISO);

}
