// Special Occassion Movie
var specialFMA = false;
specialPIC = "home2.jpg";
specialSWF = "flashhome2.swf";

// Randomly Select Homepage Movie & Background, variable is 0 based.
totalPicNum = 2;
selectPic = Math.round(Math.random()*totalPicNum)+1;

if (specialFMA == true){
	picFileName = "special/"+specialPIC;
	swfFileName = "special/"+specialSWF;
} else {
	picFileName = "home"+selectPic+".jpg";
	swfFileName = "flashhome"+selectPic+".swf";
}

// Global Rollover Image + Description Script
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 displayText(text){
	document.all.displayField.innerHTML=text;
}

// Quick Jump Menu
function quickjump(){
	if(event.srcElement.value == "na"){
		
	} else {
		window.top.document.location = event.srcElement.value;
	}
}
// Bookmark This Page Script
MacUser = (navigator.appVersion.indexOf ("Mac") > 0);

function bookmarkThisPage() { 
  var bookmarktitle = document.title;
  var bookmarkurl = document.location;
  var netscape;
  var macintosh;
  netscape="For Netscape Users, please browse to the page you would like to bookmark and press CTRL+D, Thanks!";
  macintosh="For Macintosh User, please browse to the page you would like to bookmark and press CTRL+D, thanks!";

  if (window.sidebar&&window.sidebar.addPanel) { 
    alert(netscape);
    window.sidebar.addPanel(bookmarktitle, bookmarkurl,""); 
  } else if (MacUser) {
    alert(macintosh);
  } else if (document.all) {
    window.external.AddFavorite(bookmarkurl, bookmarktitle);
  } else if (window.opera && window.print) {
    return true;
  }
}


// Check on Required Fields in Email This Page
function validEmailPageForm(namefrom, emailfrom, nameto, emailto){
	invalidChars="/:,;";
	statement = "";
	
	if (namefrom == ""){
		statement = "Please Provide Your Name";
		return false;
	}
	if (emailfrom == ""){
		statement = "Please Provide Your eMail";
		return false;
	}
	if (nameto == ""){
		statement = "Please Provide Your Name";
		return false;
	}
	if (emailto == ""){
		statement = "Please Provide Your eMail";
		return false;
	}
	for(i=0; i<invalidChars.length; i++){
		badChar = invalidChars.charAt(i);
		if(emailfrom.indexOf(badChar,0) > -1){
			statement = "There are Some Bad Characters Found in Your eMail";
			return false;
		}
	}
	atPos = emailfrom.indexOf("@",1)
	if(atPos == -1){
		statement = "Your eMail must contains @";
		return false;
	}
	if(emailfrom.indexOf("@",atPos+1) != -1){
		statement = "Your eMail cannot have more than 2 @";
		return false;
	}
	periodPos = emailfrom.indexOf(".",atPos)
	if(periodPos == -1){
		statement = "Your eMail must have a . after @";
		return false;
	}
	if(periodPos+3 > emailfrom.length){
		statement = "Your eMail must have more than 2 letters after the .";
		return false;
	}
	return true;
	atPos = emailto.indexOf("@",1)
	if(atPos == -1){
		statement = "Your eMail must contains @";
		return false;
	}
	if(emailto.indexOf("@",atPos+1) != -1){
		statement = "Your eMail cannot have more than 2 @";
		return false;
	}
	periodPos = emailto.indexOf(".",atPos)
	if(periodPos == -1){
		statement = "Your eMail must have a . after @";
		return false;
	}
	if(periodPos+3 > emailto.length){
		statement = "Your eMail must have more than 2 letters after the .";
		return false;
	}
	return true;
}

function emailPage(form){
	if(!validEmailPageForm(emailthispage.namefrom.value, emailthispage.emailfrom.value, emailthispage.nameto.value, emailthispage.emailto.value)){
		alert("Invalid Entry!\rDue to the following reason:\r\r" + statement);
		return false;
	}
}

// Check on Required Fields in Contact Page
function validContactPageForm(namefrom, emailfrom, comment){
	invalidChars="/:,;";
	statement = "";
	
	if (namefrom == ""){
		statement = "Please Provide Your Name";
		return false;
	}
	if (emailfrom == ""){
		statement = "Please Provide Your eMail";
		return false;
	}
	for(i=0; i<invalidChars.length; i++){
		badChar = invalidChars.charAt(i);
		if(emailfrom.indexOf(badChar,0) > -1){
			statement = "There are Some Bad Characters Found in Your eMail";
			return false;
		}
	}
	atPos = emailfrom.indexOf("@",1)
	if(atPos == -1){
		statement = "Your eMail must contains @";
		return false;
	}
	if(emailfrom.indexOf("@",atPos+1) != -1){
		statement = "Your eMail cannot have more than 2 @";
		return false;
	}
	periodPos = emailfrom.indexOf(".",atPos)
	if(periodPos == -1){
		statement = "Your eMail must have a . after @";
		return false;
	}
	if(periodPos+3 > emailfrom.length){
		statement = "Your eMail must have more than 2 letters after the .";
		return false;
	}
	if (comment == ""){
		statement = "Blank Message";
		return false;
	}
	if (comment.length < 10){
		statement = "Message must have more than 10 characters";
		return false;
	}
	return true;
}

function contactUs(form){
	if(!validContactPageForm(contactus.namefrom.value, contactus.emailfrom.value, contactus.comment.value)){
		alert("Invalid Entry!\rDue to the following reason:\r\r" + statement);
		return false;
	}
}

// Check on RFP Company Contact Info
function validRFPForm(companycontact){
	if (companycontact.length < 20){
		statement = "Please fill out at least the contact information, so we can assist you with the rest of the process, thanks!";
		return false;
	}
	return true;
}

function RFP(form){
	if(!validRFPForm(rfp.companycontact.value)){
		alert("Invalid Entry!\rDue to the following reason:\r\r" + statement);
		return false;
	}
}

// Print Window
function openPrintWin(URL){
	windowSize = "top=0, left=" + screen.width/4 + ", height=" + screen.height *0.94 + ", width=650, toolbar=0, menubar=0, location=0, scrollbars=yes, resizable=yes";
	mainWindow = window.open(URL, 'PrintWindow', windowSize);
	mainWindow.focus();
}

// Open Portfolio Window
function openPortfolio(URL, width, height){
	windowSize = "top=100, left=100, width=" + width + ", height=" + height + ", toolbar=0, menubar=0, location=0, scrollbars=0, resizable=0";
	mainWindow = window.open(URL, 'portfoliWindow', windowSize);
	mainWindow.focus();
}