/****************************************************************
*                                                               *
*	For use with ProChoiceAmerica.org and affiliated websites	*
*                                                               *
*	written by Michael Rathmann                                 *
*	(c)RathmannDesign.com. All rights reserved.                 *
*                                                               *
****************************************************************/

// Print Function
if (window.focus) { self.focus(); }
function printWindow() {
	bV = parseInt(navigator.appVersion);
	if (bV >= 4) { window.print(); }
}


//	Browser Check Variables
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
	&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
	&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav4up = (is_nav && (is_major >= 4));
var is_nav6up = (is_nav && (is_major >= 5));

var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);


// Form Field Effects
function handleFocus(form) { form.id = "fieldon"; }

function handleBlur(form) { form.id = "fieldoff"; }


// Popup Windows
var chasm = screen.availWidth;
var mount = screen.availHeight;
var width = 0;
var height = 0;

var paux = null;
function formWindow(width,height) {
	if (paux != null && paux.open) paux.close();
	paux = window.open('','form','resizable=yes,toolbar=no,scrollbars=yes,status=yes,width=' + width + ',height=' + height + ',left=' + ((chasm - width - 10) * .5) + ',top=' + ((mount - height - 30) * .5));
}
function pdfWindow(width,height) {
	if (paux != null && paux.open) paux.close();
	paux = window.open('','pdf','resizable=yes,toolbar=no,scrollbars=yes,status=yes,width=' + width + ',height=' + height + ',left=' + ((chasm - width - 10) * .5) + ',top=' + ((mount - height - 30) * .5));
}
function popWindow(width,height) {
	if (paux != null && paux.open) paux.close();
	paux = window.open('','popup','resizable=no,toolbar=no,scrollbars=yes,status=yes,width=' + width + ',height=' + height + ',left=' + ((chasm - width - 10) * .5) + ',top=' + ((mount - height - 30) * .5));
}
function auxWindow(width,height) {
	if (paux != null && paux.open) paux.close();
	paux = window.open('','aux','resizable=no,toolbar=no,scrollbars=no,status=yes,width=' + width + ',height=' + height + ',left=' + ((chasm - width - 10) * .5) + ',top=' + ((mount - height - 30) * .5));
}

function fmcWindow(url,width,height) {
	var left = screen.availWidth/2 - width/2;
	var top = screen.availHeight/2 - height/2;
	if (paux != null && paux.open) paux.close();
	paux = window.open(url, "", "dependent=yes,width="+width+"px,height="+height+",left="+left+",top="+top);
}

function eradic() {
	if (paux != null && paux.open) paux.close();
}

function openTable(tableid) {
	which = document.getElementById(tableid);
	if (which.style.display == "block") { which.style.display = "none"; }
	else { which.style.display = "block"; }
}


// CAN sign-up leadin validation
function validateEmail(form) {
	alertStart = "In order to continue, please ";
	if (!form.contactEmail.value) {
		alert(alertStart + "enter your E-MAIL ADDRESS.");
		form.contactEmail.focus(); return false;
	} if (!isEmail(form.contactEmail.value)) {
		alert("'" + form.contactEmail.value + "' is an invalid E-MAIL ADDRESS! Please reenter.");
		form.contactEmail.focus(); form.contactEmail.select(); return false;
	} openTable('canDisplay'); return true; //change this to return false to disable
}

function isEmail(str) {
	if (str.length <= 6) { return false; }
	else { return ((str != "") && (str.indexOf("@") != -1) && (str.indexOf(".") != -1)); }
}
