// JavaScript Document
var allPageTags = new Array();

function swaptabs(theTab)
{
	for (var x = 1; x++; x <= 7)
	{
		if (theTab == x)
		{
			doSEWC("div" + x,"display","inline","none");
		}
		else
		{
			doSEWC("div" + x,"display","none","inline");
		}
	}
}

function doSEWC(theTab,theGroup,thestyle,theaction,theopposite)
{
	var allPageTags=document.getElementsByTagName("*");
	
	for (i=0; i<allPageTags.length; i++)
	{
		if (allPageTags[i].className.indexOf(theGroup) == 0)
		{
			if (allPageTags[i].className == theGroup + theTab)
			{
				eval("allPageTags[i].style." + thestyle + "='" + theaction + "'");
			}
			else
			{
		    	eval("allPageTags[i].style." + thestyle + "='" + theopposite + "'");
			}
		}
	}
		
	for (x = 1; x <= 3; x++)
	{
		if (x == parseInt(theTab))
		{
			//document.getElementById('tab_' + x.toString()).bgColor='#CCCCCC'; 
			document.getElementById('tab_' + x.toString()).className = "tabs_on";
		}
		else
		{
			//document.getElementById('tab_' + x.toString()).bgColor='#FFFFFF'; 
			document.getElementById('tab_' + x.toString()).className = "tabs_off";
		}
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function openPictureWindow_Fever(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt='+alt+'>'); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}


/** FORM VALIDATION **/

// Checks if an email address is valid.
function IsEmailValid(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	var valid = true;
	
	if (str.indexOf(at)==-1){
		valid = false;
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		valid = false;
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		valid = false;
	}
	
	if (str.indexOf(at,(lat+1))!=-1){
		valid = false;
	}
	
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		valid = false;
	}
	
	if (str.indexOf(dot,(lat+2))==-1){
		valid = false;
	}
	
	if (str.indexOf(" ")!=-1){
		valid = false;
	}
	
	return valid;					
}


// Checks if an email is generic
function IsGenericEmail(str) {

    str = str.toLowerCase();
	var generic = false;
	
	if (str.indexOf("hotmail.com") >= 0) {
		generic = true;
	}
	
	if (str.indexOf("yahoo.com") >= 0) {
		generic = true;
	}	

	if (str.indexOf("aol.com") >= 0) {
		generic = true;
	}
	
	return generic;					
}


// Validates falcon-consultation-form.htm
function ValidateConsultationForm() {

    var errorMsg = "";

    var company = document.consultationForm.company;
    var name = document.consultationForm.name;
	var email = document.consultationForm.email;
	var phone = document.consultationForm.phone;
	
	if ((company.value == null) || (company.value == "")) {
		errorMsg += "Please enter your company.\n";	
	}

	if ((name.value == null) || (name.value == "")) {
		errorMsg += "Please enter your name.\n";	
	}
	
	if ((email.value == null) || (email.value == "")) {
		errorMsg += "Please enter your email address.\n";
	} else if (IsEmailValid(email.value) == false) {
		errorMsg += "The email address you entered is invalid.\n";
	} else if (IsGenericEmail(email.value) == true) {
		errorMsg += "Generic email addresses are not allowed.\n";	
	}
	
	if ((phone.value == null) || (phone.value == "")) {
		errorMsg += "Please enter your phone number.\n";	
	}
	
	if (errorMsg.length > 0) {
	    alert(errorMsg);
	    return false;
	} else {
	    return true;
    }
 }
 
 // Validates falcon-consultation-form.htm
function ValidateJobForm() {

    var errorMsg = "";

    var name = document.jobForm.name;
	var email = document.jobForm.email;
	var phone = document.jobForm.phone;

	if ((name.value == null) || (name.value == "")) {
		errorMsg += "Please enter your name.\n";	
	}
	
	if ((email.value == null) || (email.value == "")) {
		errorMsg += "Please enter your email address.\n";
	} else if (IsEmailValid(email.value) == false) {
		errorMsg += "The email address you entered is invalid.\n";
	}
	
	if ((phone.value == null) || (phone.value == "")) {
		errorMsg += "Please enter your phone number.\n";	
	}
	
	if (errorMsg.length > 0) {
	    alert(errorMsg);
	    return false;
	} else {
	    return true;
    }
 }
