// VALIDATES THE CONTACT FORM
function validateForm(theForm) {
	
	if (!theForm.ddlSubject.value) {
		alert("Please select a subject.");
		theForm.ddlSubject.focus();
		return false;
	}
	
	if (!theForm.txtFullName.value) {
		alert("Please enter your full name.");
		theForm.txtFullName.focus();
		return false;
	}
	
	if (theForm.txtEmail.value=="")
	{   alert("Please enter your email address.");
		theForm.txtEmail.focus();
		return false;
	} 
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(theForm.txtEmail.value))) { 
	   alert("Please enter a valid email address.");
	   return false;
	}
	
	if (!theForm.txtPhone.value) {
		alert("Please enter your phone number.");
		theForm.txtPhone.focus();
		return false;
	}
	
	   return true;
}

// OPENS THE WINDOW TO THE UPPER LEFT HAND SIDE TO THE SCREEN
function openWindow(width,height,strurl,winName,scrollb) {
    x = (640 - width)/2, y = (480 - height)/10;

    if (screen) {
        y = (screen.availHeight - height)/10;
        x = (screen.availWidth - width)/10;
    }
    
    if (screen.availWidth > 1800) { 
	x = ((screen.availWidth/2) - width)/10; 
    } 
	window.open(strurl,winName,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',scrollbars='+scrollb);
}

// OPENS THE WINDOW IN THE CENTER OF THE SCREEN
function openWindowM(width,height,strurl,winName,scrollb) {
    x = (640 - width)/2, y = (480 - height)/2;

    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
    
    if (screen.availWidth > 1800) { 
	x = ((screen.availWidth/2) - width)/2; 
    } 
	window.open(strurl,winName,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',scrollbars='+scrollb);
}

//GO TO A URL
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


//DROP DOWN MENUS
startList = function()
  {
  var node = document.getElementById("nav");
    
  AssignMenuEvents(node) ;
  }

function AssignMenuEvents(pObject)
  {
  var node ;
  var vPreviousIndex ;
  
  for (i=0; i < pObject.childNodes.length; i++)
    {
    node = pObject.childNodes[i];

    if (node.tagName == "LI")
      {
      if (document.all && document.getElementById)
        {
        node.onmouseover=function()
                           {
                           this.className+=" over";
                           }

        node.onmouseout=function()
                           {
                           this.className=this.className.replace(" over", "");
                           }
        node.onclick   = MenuClickHandlerIE;
        }
      else
        {
      node.addEventListener("click", MenuClickHandlerMoz, false);
        }
      }

    if (node.childNodes.length > 0)
      {
      vPreviousIndex = i ;
      AssignMenuEvents(node);
      i = vPreviousIndex ;
      }
    }
  }

function MenuClickHandlerIE()
  {
  var node ;
  var vFoundAction = false ;
  pNode = event.srcElement ;
  
  for (i=0; i < pNode.childNodes.length; i++)
    {
    node = pNode.childNodes[i];

    if (node.tagName == "A")
      {
      vFoundAction = true ;
      
      if (node.click)
        {
        node.click();
        }
      else
        {
        window.location.replace(node.href);
        }
      }
    if (vFoundAction)
      {
      break ;
      }
    }
  event.cancelBubble  = true ;
  }


function MenuClickHandlerMoz(e)
  {
  var node ;
  var vFoundAction = false ;
  pNode = e.target  ;
  
  for (i=0; i < pNode.childNodes.length; i++)
    {
    node = pNode.childNodes[i];

    if (node.tagName == "A")
      {
      vFoundAction = true ;
      
      if (node.onclick)
        {
        node.onclick();
        }
      else
        {
        window.location.replace(node.href);
        }
      }
    if (vFoundAction)
      {
      break ;
      }
    }
  e.cancelBubble  = true ;
  }
  
  //This is to alert user before deleting
function checkDelete()	{
	return (confirm("Are you sure you want to delete?"));
	}

window.onload=startList;
