// THIS CODE was modified by Tim Fadden, from the mutated, modified, and re-done code of the K10kª semi-bald posse (which was done in 1997-2002).  You guys are AWESOME!
//
// ----------------------------------------------------------------------

// CHECK CLIENT BROWSER & PLATFORM
// original code from http://developer.apple.com/internet/_javascript/
//
// USAGE:	browserNaming();
// NOTES:	call it from within an external JS document
// RESULT:	browserNew = true/false
//			browserName = IE/NS/Opera
//			browserNameLong = IE5/etc
//			Macintosh = true/false
// WORKS:	everything

	var its;
	var browserName;
	var browserNameLong;
	var browserNew;
	var preloadFlag = false;
	var Macintosh = navigator.userAgent.indexOf('Mac')>0;

	function its() {
		var n = navigator;
		var ua = ' ' + n.userAgent.toLowerCase();
		var pl = n.platform.toLowerCase();
		var an = n.appName.toLowerCase();

		// browser version
		this.version = n.appVersion;
		this.nn = ua.indexOf('mozilla') > 0;

		// 'compatible' versions of mozilla aren't navigator
		if(ua.indexOf('compatible') > 0) {
			this.nn = false;
		}
		
		this.opera = ua.indexOf('opera') > 0;
		this.ie = ua.indexOf('msie') > 0;
		this.major = parseInt( this.version );
		this.minor = parseFloat( this.version );

		// platform
		this.mac = ua.indexOf('mac') > 0;
		this.win = ua.indexOf('win') > 0;

		// workaround for IE5 which reports itself as version 4.0
		if(this.ie) {
			if(ua.indexOf("msie 5") > 1) {
			var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;
			this.major = parseFloat(navigator.appVersion.substr(msieIndex,3));
			}
		}

		return this;
	}

	function browserNaming() {
		its = new its();
		
		// is it a DOM-enabled browser?
		if (!document.getElementById) {
			browserNew = false;
		}
		else {
			browserNew = true;
		}

		// need the name, too
		if (its.opera) {
			browserName = "Opera";
		}
		else if (its.ie) {
			browserName = "IE";
		}
		else {
			browserName = "NS";
		}

		// and the number
		browserNameLong = browserName + its.major;
	
	}


// DOM / SET PROPERTY
// original code from http://www.alistapart.com/
//
// NOTES:	given an id and a property (as strings), set the given property of that id to the value provided.
// WORKS:	ie5+, ns6+, opera5+

	function setIdProperty(id,property,value) {
		var styleObject = document.getElementById( id );
		if (styleObject != null) {
			styleObject = styleObject.style;
			styleObject[ property ] = value;
		}
	}

	
// MOVE LAYERS TO POSITION BASED ON INNER WIDTH OF BROWSER WINDOW, MINUS CONSTANT (valpx)
// original code by Tim Fadden
// USAGE:	move('layer number'); valpx=new Array('value','value');
// WORKS:	ie4+, ns4+, opera

	function move(id) {
		var	valpx=0;
		if(browserName == "IE") {
			var moveval=document.body.clientWidth/2;}
		else {
			var moveval=window.innerWidth/2;}
		if(browserNew && browserName == "NS" && window.innerWidth<1000) moveval=(window.innerWidth/2)-7;
		if(id==5||id==6||id==8||id==9||id==10||id==11||id==15)valpx=-20;
		else valpx=186;
		var movepx=(moveval-valpx)+"px";
		if (browserNew) {
			setIdProperty(id,"left",movepx);}
		else {
			if (browserName == "NS") { document.layers[id].left = ((window.innerWidth/2)-valpx)*.986;}
			else { document.all[id].style.pixelLeft = (document.body.clientWidth/2)-valpx;}
		}
	}

	
// HIDE OPEN LAYERS
// USAGE:	show('layer number');
// WORKS:	ie4+, ns4+, opera	

	function hideOpenLayers(lid,totL,momL) {
	for (var i=1; i<=totL; i++ ){
			if (lid!=i||lid!=momL){
				hide(i);
			}
		}
	}


// HIDE LAYERS
// USAGE:	hide('layer number');
// WORKS:	ie4+, ns4+, opera

	function hide(id) {
		if (browserNew) {
			setIdProperty(id,"visibility","hidden");
		}
		else {
			if (browserName == "NS") { document.layers[id].visibility = "hide";}
			else { document.all[id].style.visibility = "hidden";}
		}
	}
	
	
// SHOW LAYERS
// USAGE:	show('layer number');
// WORKS:	ie4+, ns4+, opera

	function show(id) {
		move(id);
		if (browserNew) {
			setIdProperty(id,"visibility","visible");
		}
		else {
			if (browserName == "NS") { document.layers[id].visibility = "show"; }
			else { document.all[id].style.visibility = "visible"; }
		}
	}
	
	
// HIDE LAYERS TIMER, ENABLES clearTimeout()
// USAGE:	hideTimer('layer number');
// WORKS:	ie4+, ns4+, opera

var myTimeout=0;
var myTimeout2=0;

	function hideTimer(id){
	if (id<=4||id==7||id==12||id==13||id==14) myTimeout=setTimeout('hide("'+id+'")',500);
	if (id==5||id==6||id==8||id==9||id==10||id==11||id==15) myTimeout2=setTimeout('hide("'+id+'")',1500);
	}
		

browserNaming();


var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1);
function printit() {
 if (pr) 
    window.print()
  else if (da && !mac) 
    vbPrintPage()
  else 
    alert('Sorry, your browser does not support this feature. Please print using the menu on your browser.');
}
if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln(' OLECMDID_PRINT = 6');
  writeln(' OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln(' OLECMDEXECOPT_PROMPTUSER = 1');
  writeln(' On Error Resume Next');
  writeln(' WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}

function checkAll() {
    txt=self.document.forms[0].email.value;
	if (txt == "") {
			alert("Please enter your e-mail address");
		self.document.forms[0].email.focus();
        return (false);
	} else if (txt.indexOf("@")<2){
			alert("This e-mail address is not valid."
  +"\nPlease make sure your e-mail address contains an '@' sign.");
        self.document.forms[0].email.focus();
        return (false);
    }
    if (self.document.forms[0].First_Name.value == "") {
           alert("\nPlease enter your First name.");
        self.document.forms[0].First_Name.focus();
        return (false);
    }
    if (self.document.forms[0].Last_Name.value == "") {
           alert("\nPlease enter your Last name.");
        self.document.forms[0].Last_Name.focus();
        return (false);
    }
	if (self.document.forms[0].City.value == "") {
           alert("\nPlease enter your City name.");
        self.document.forms[0].City.focus();
        return (false);
    }
    if (self.document.forms[0].State.value == "") {
           alert("\nPlease enter your State name.");
        self.document.forms[0].State.focus();
        return (false);
    }
    return (true);
}

function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
}}}}

var url=document.location.href;
var title=document.title;
function fav() {
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
