// Site General JS Document

//Browser Detect

// to use, call : browser = "", OS = "", etc
var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring;

	if (checkIt('konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}
 else if (checkIt('netscape')) browser = "Netscape Navigator";
	else if (checkIt('safari')) browser = "Safari";
	else if (checkIt('omniweb')) browser = "OmniWeb";
	else if (checkIt('opera')) browser = "Opera";
	else if (checkIt('webtv')) browser = "WebTV";
	else if (checkIt('icab')) browser = "iCab";
	else if (checkIt('msie')) browser = "Internet Explorer";
	else if (checkIt('firefox')) browser = "Mozilla Firefox";
	else if (!checkIt('compatible'))
	{
		browser = "Mozilla"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS)
	{
		if (checkIt('linux')) OS = "Linux";
		else if (checkIt('x11')) OS = "Unix";
		else if (checkIt('mac')) OS = "Mac"
		else if (checkIt('win')) OS = "Windows"
		else OS = "an unknown operating system";
	}

	function checkIt(string) 
	{
		place = detect.indexOf(string) + 1;
		thestring = string;
		return place;
	}

hasBeenChecked = 0;

function checkBrowserReturn() {
	return confirm('Hello! You may notice my site looks a bit odd.\nThats because you need to update your browser!\nIts free and only takes a moment. Click OK to do it right now.');
}

function checkBrowser() {
	//redirect ie7
	if(browser == "Internet Explorer" && version < 8) {
		
		if(hasBeenChecked == 0) {
			
			var checkMsg = checkBrowserReturn();
						
			if(checkMsg == true) {
				window.location.href('http://www.microsoft.com/windows/internet-explorer/');	
			}
			
		}
		
		hasBeenChecked = 1;	
	}
	
	//redirect safari
	if(browser == "Safari" && version < 2) {
		
		if(hasBeenChecked == 0) {
			
			var checkMsg = checkBrowserReturn();
						
			if(checkMsg == true) {
				window.location.href('http://www.apple.com/safari/');	
			}
			
		}
		
		hasBeenChecked = 1;	
	}
}	

function validateContact() {
	
	if(document.getElementById('contact_name').value == "") {
		alert("Please enter your [Name]");
		document.getElementById('contact_name').select(this);
		return false;
	}
	
	if(document.getElementById('contact_phone').value == "") {
		alert("Please enter your [Phone Number]");
		document.getElementById('contact_phone').select(this);
		return false;
	}
	
	if(document.getElementById('contact_email').value == "") {
		alert("Please enter your [Email Address]");
		document.getElementById('contact_email').select(this);
		return false;
	} else {
		if(document.getElementById('contact_email').value.indexOf("@")== -1 || document.getElementById('contact_email').value.indexOf(".")== -1) {
		alert("Please enter a [Valid Email Address]");
		document.getElementById('contact_email').select(this);
		return false;
		}
	} 
	
	if(document.getElementById('location').value == "") {
		alert("Please enter your [Location - city, state/province]");
		document.getElementById('location').select(this);
		return false;
	}
	
	if(document.getElementById('interested').value == "") {
		alert("Please select what you are [Interested in]");
		document.getElementById('interested').focus();
		return false;
	}
	
	if(document.getElementById('captchaCode').value == "") {
		alert("Please enter the [Code]");
		document.getElementById('captchaCode').select(this);
		return false;
	}

	
    //return false;
	
}

function checkInterests(value) {
	
	if(value == "Other") {
		document.getElementById('otherFields').innerHTML = '<b>Tell Me!:</b> <input type="text" name="interestOther" id="interestOther" size="33" class="input">';
	} else {
		document.getElementById('otherFields').innerHTML = '';
	}
}
