
var bIsIE   = (document.all) ? true : false;
var bIsDOM  = (document.getElementById) ? true : false;


function checkDate(formname)
	{
			var x = document.forms[formname].date.value;
			var filter  = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
			if (filter.test(x)) return true;
			else 
			{
				document.forms[formname].date.value=x;
				alert('Incorrect date ');
				document.forms[formname].date.focus();
			}

	}

	function checkMail(formname)
	{
			var x = document.forms[formname].email.value;
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (filter.test(x)) return true;
			else 
			{
				document.forms[formname].email.value=x;
				alert('Invalid email address');
				document.forms[formname].email.focus();
			}

	}
	function checkPhoneNumber(formname)
	{
		 // matches phone ###-###-####
	     // valid.phoneNumber = /^\(?\d{3}\)?\s|-\d{3}-\d{4}$/;
        // International Phone Number
        // valid.phoneNumberInternational = /^\d(\d|-){7,20}/;	
			var x = document.forms[formname].tel.value;
			var filter  = /^\d(\d|-){7,20}/;	
			if (filter.test(x)) return true;
			else 
			{
				document.forms[formname].tel.value=x;
				alert('Invalid telephone number!\n( US: 800-555-1212     Intl: 1-12-3123-4141 )');
				document.forms[formname].tel.focus();
			}

	}
	
	
function notImplemented(){
	alert( "This functionality is not avaible in this version." );
}


function findPosX(obj) 
{     
	var curleft = 0;     
	if (obj.offsetParent) 
	{         
		while (obj.offsetParent) 
		{             
			curleft += obj.offsetLeft             
			obj = obj.offsetParent;         
		}      
	} 
	else 
		if (obj.x)         
			curleft += obj.x;     
	
	return curleft; 
}   

function findPosY(obj) 
{     
	var curtop = 0;     
	if (obj.offsetParent) 
	{         
		while (obj.offsetParent) 
		{             
			curtop += obj.offsetTop             
			obj = obj.offsetParent;         
		}      
	} 
	else 
		if (obj.y)         
			curtop += obj.y;     
	
	return curtop; 
}


function adjustDropDownMenus() {

	var MenuWidth = new Array( 105, 110, 110, 126, 133, 118, 159 );
	
	if(bIsIE)
		var StartingPoint = findPosX( document.all.menuanchor );
	else if(bIsDOM)
		var StartingPoint = findPosX( document.getElementById( "menuanchor" ) );
		
	if(bIsIE){
		for( i=1; i<=6; i++ ){
			Tmp = eval("document.all.dropdown"+i);
			Tmp.style.pixelLeft = (StartingPoint += MenuWidth[i-1]);
		}
	}
	else if(bIsDOM) {
		for( i=1; i<=6; i++ )
			document.getElementById( "dropdown"+i ).style.left = (StartingPoint += MenuWidth[i-1]);
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
		if ((obj=MM_findObj(args[i]))!=null) 
		{   v=args[i+2];
			if (obj.style) 
			{
				obj=obj.style;
				v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
			}
			if (obj.visibility!=v)
				obj.visibility=v;
		}
}

function hideAll(SelectedMenu){
	MM_showHideLayers('dropdown1','','hide','dropdown2','','hide','dropdown3','','hide','dropdown4','','hide','dropdown5','','hide','dropdown6','','hide');
}

var timerID = null;
var timerOn = false;
var timecount = 200;
	
function startTime() {
       if (timerOn == false) {
              timerID = setTimeout( "hideAll()" , timecount);
              timerOn = true;
       }
}

function stopTime() {
       if (timerOn) {
  	        clearTimeout(timerID);
              timerID = null;
              timerOn = false;
       }
}

//window.onresize = adjustDropDownMenus;

function setImgSrc( ImgObj, Filename ){
	if( !ImgObj ) return false;
	ImgObj.src = Filename;
}


function collapseDiv( BoxName, Status ){
	if( !(Box=MM_findObj(BoxName)) )
		return false;
		
	if( Status ){
		if( Status == "show" )
			Box.style.display = "block";
		else
			Box.style.display = "none";
	}
	else{
		if(Box.style.display == "block"){
			Box.style.display = "none";
		}
		else{
			Box.style.display = "block";
		}
	}
}

function popupWindow( Page, Width, Height ){
	/*if(isNaN(window.screenLeft))
	{
		popWindow = window.open( Page,"popWindow","width="+Width+",height="+Height+",scrollbars=0,left="+((document.width-Width)+window.screenX)+",top="+((document.height-Height)+window.screenY)).focus();		
		
	}
	else
	popWindow = window.open( Page,"popWindow","width="+Width+",height="+Height+",scrollbars=0,left="+((document.width-Width)+window.screenLeft)+",top="+((document.height-Height)+window.screenRight)).focus();		*/
	popWindow = window.open( Page,"popWindow","width="+Width+",height="+Height+",scrollbars=1,left="+((screen.width-Width)/2)+",top="+((screen.height-Height)/2)).focus();
}