function daysInFebruary (year)
{   
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

function validateUSDate( strValue ) 
{

/* Ex. mm/dd/yyyy or mm-dd-yyyy or mm.dd.yyyy */    

  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
  
  if(!objRegExp.test(strValue))
	return false; 
  else
  {
	var arrayDate = strValue.split(RegExp.$1); 
	var intDay = parseInt(arrayDate[1],10); 
	var intYear = parseInt(arrayDate[2],10);
	var intMonth = parseInt(arrayDate[0],10);    
	
	var daysInMonth = new Array(12);
	daysInMonth[1] = 31;
	daysInMonth[2] = 29;   
	daysInMonth[3] = 31;
	daysInMonth[4] = 30;
	daysInMonth[5] = 31;
	daysInMonth[6] = 30;
	daysInMonth[7] = 31;
	daysInMonth[8] = 31;
	daysInMonth[9] = 30;
	daysInMonth[10] = 31;
	daysInMonth[11] = 30;
	daysInMonth[12] = 31;    
	
	if (intDay > daysInMonth[intMonth]) return false; 
	if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;
	return true;
	}
}

function DateDiff(endingdate,startingdate) 
{
//var endingdate = new Date(2002,0,1);     // 1 January 2002
//var startingdate = new Date(2001,2,15);  // 15 March 2001

//var endingdate = new Date("2/28/2002");     // mm/dd/yyyy
//var startingdate = new Date("2/1/2002");  // mm/dd/yyyy

    var difference = endingdate.getTime() - startingdate.getTime();
    var daysDifference = Math.floor(difference/1000/60/60/24);
    return daysDifference;
}

function isInteger(strValue)
{
	var objRegExp  = /(^\d\d*$)/;
	return objRegExp.test(strValue);
}
	
function isZipCode(strValue)
{
	// 5 digits
	var objRegExp  = /(^\d{5}$)/;
	return objRegExp.test(strValue);
}
	
function isPhone(strValue)
{
	// 10 digits = 3 area + 10 number
	var objRegExp  = /^\d{10}$/;
	return objRegExp.test(strValue); 
}	

function isExt(strValue)
{
	// at max 4 digits
	var objRegExp  = /^\d{1}|\d{2}|\d{3}|\d{4}|\d{5}$/;
	return objRegExp.test(strValue); 
}	
	
function isCell(strValue)
{
	var objRegExp  = /^\d{10}$/;
	return objRegExp.test(strValue); 
}	
	
function isPager(strValue)
{
	var objRegExp  = /^\d{10}$/;
	return objRegExp.test(strValue); 
}		
	

/*

function validateDateRange(datefrom, dateto)
{
	var datefromOK, datetoOK;
	var defaultdateto="1-1-9999"


	if (datefrom=="" && dateto=="")
		return true;
			
	if (validateUSDate(datefrom)==true) 
		datefromOK=true;
	else
		datefromOK=false;
			
	if (dateto=="")
		dateto=defaultdateto;
								
	if (validateUSDate(dateto)==true) 
		datetoOK=true;
	else
		datetoOK=false;	
			
						
	if (datefromOK==true && datetoOK==true)
		return true;
	else
	{
		alert ("dd/mm/yyyy format expected.");
		return false;
	}
}

*/

function validateDateRange(datefrom, dateto)
{
	var datefromOK, datetoOK;

	if (datefrom=="" && dateto=="")
		return true;
			
	if (validateUSDate(datefrom)==true) 
		datefromOK=true;
	else
		datefromOK=false;
											
	if (validateUSDate(dateto)==true) 
		datetoOK=true;
	else
		datetoOK=false;	
			
	if (datefromOK==true && datetoOK==true)
		return true;
	else
	{
		alert ("dd/mm/yy format expected.");
		return false;
	}
}

function newwin(link)
{		
	window.open(link,"_blank");
}

function newwin(link, h, w)
{		
	window.open(link,"_blank","height=" + h + ",width=" + w);
}

function swapImage(imgName,select) 
{ 
	if (browser == "ok") 
	{
		imgOn = eval(select+ ".src"); 
		document.images[imgName].src = imgOn; 
	}
} 

function loadImages() {
	if (document.getElementById) {  // DOM3 = IE5, NS6
		document.getElementById('hidepage').style.visibility = 'hidden';
	}
	else {
		if (document.layers) {  // Netscape 4
		document.hidepage.visibility = 'hidden';
	}
	else {  // IE 4
		document.all.hidepage.style.visibility = 'hidden';
      	}
   }
}