var x,y;
var myCookies = new Array();

function getVariable(myKey) {
	var fullURL = window.location.toString();
	var startPoint = fullURL.indexOf("?");
	var queryString = fullURL.substr(startPoint+1,fullURL.length);
	var keyValuePairs = queryString.split("&");
	var myValue;
				
	for(var x = 0; x < keyValuePairs.length; x++) {
		if(keyValuePairs[x].indexOf(myKey) != -1) {
			myValue = keyValuePairs[x].substr(keyValuePairs[x].indexOf("=")+1,keyValuePairs[x].length);
		}
	}
	return myValue;
}

function verifyFormData() {
	if(isNameValid()) {
		if(isPhoneValid()) {
			if(isEmailValid()) {
				if(isCommentsValid()) {
					if((getCookie('contactForm').length == 0)||(getCookie('contactForm') == undefined)) {
						setCookie('contactForm','filled',2);
						document.getElementById('contactForm').submit();
					}
					else {alert("I'm sorry but you've already filled this form our recently.  Please call us for further assistance.");window.location = 'index.php';}
				}
				else{alert("Please supply your comments.");document.getElementById('contactForm').formObjComments.focus();}
			}
			else{alert("Please supply a valid email address.");document.getElementById('contactForm').formObjEmail.focus();}
		}
		else{alert("Please supply a valid phone number.");document.getElementById('contactForm').formObjPhone.focus();}
	}
	else{alert("Please supply your name.");document.getElementById('contactForm').formObjName.focus();}
}
			
function isNameValid() {
	var myNameValue = document.getElementById('contactForm').formObjName.value;
	if(myNameValue != "") {return true;}
	else{return false;}
}

function isPhoneValid() {
	var myPhoneValue = document.getElementById('contactForm').formObjPhone.value;
	var myPattern = new RegExp(/[a-z]/i);
	if(myPhoneValue != "") {
		if(myPattern.test(myPhoneValue) != true) {return true;}
		else{return false}
	}
	else{return false}
}

function isEmailValid() {
	var myEmailValue = document.getElementById('contactForm').formObjEmail.value;
	var myPattern = new RegExp(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/);
	if(myEmailValue != "") {
		if(myPattern.test(myEmailValue) == true) {return true;}
		else{return false}
	}
	else{return false;}
}

function isCommentsValid() {
	var myCommentsValue = document.getElementById('contactForm').formObjComments.value;
	if(myCommentsValue != "") {return true;}
	else{return false;}
}

function setCookie(myCookieName,myCookieValue,myCookieLife) {
	myCookieLife = 60 * 60 * 24 * parseInt(myCookieLife);
	document.cookie = myCookieName + "=" + myCookieValue + ";max-age=" + myCookieLife;
}

function getCookie(myCookieName) {
	if (document.cookie.length > 0) {
		cookieTray = document.cookie.split(";");
		for(x = 0; x < cookieTray.length; x++) {myCookies[x] = new Array(cookieTray[x].split("="));}
		for(y = 0; y < myCookies.length; y++) {if(myCookies[y][0][0] == myCookieName) {return myCookies[y][0][1];}}
	}
	else {return "";}
}

function showBiggie(myImageName) {
	var popUpWin = window.open("","menu","width=500,height=500,scrollbars=no,resizable=no,menubar=no,status=no,toolbar=no,location=no");
	var myHtml = "<html><head><title>menu item<\/title><style type=\"text/css\">body{margin:0px;padding:0px;}<\/style><\/head><body onBlur=\"window.close();\"><img src=\"images/large/" + myImageName + "\" /><\/body><\/html>";
	popUpWin.document.open();
	popUpWin.document.write(myHtml);
	popUpWin.document.close();
}


var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-11981144-1");
pageTracker._trackPageview();
} catch(err) {}