/* This is the file that was passed to me, just added the click to open in the first place - Delmarc */
/* Browser detection */
var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
var splashValue = readCookie('subscribeSplash');
if (OSName == 'Windows') {
	if (splashValue!='Viewed') {
		document.getElementById('splash').style.visibility='visible';
		document.getElementById('splash').style.display='inline';
		document.getElementById('splashinner').style.visibility='visible';
		document.getElementById('splashinner').style.display='inline';
	}
	if (splashValue=='Viewed') {
		document.getElementById('splash').style.visibility='hidden';
		document.getElementById('splash').style.display='none';
		document.getElementById('splashinner').style.visibility='hidden';
		document.getElementById('splashinner').style.display='none';
	}
}
function hideSplash() {
	document.getElementById('splash').style.visibility='hidden';
	document.getElementById('splash').style.display='none';
	document.getElementById('splashinner').style.visibility='hidden';
	document.getElementById('splashinner').style.display='none';
	document.cookie='subscribeSplash=Viewed;path=/;expires=Thu, 01-Jan-2030 00:00:01 GMT; host=www.specialolympics.org;';
}

function showSplash() {
	document.getElementById('splash').style.visibility='visible';
	document.getElementById('splash').style.display='block';
	document.getElementById('splashinner').style.visibility='visible';
	document.getElementById('splashinner').style.display='block';
	document.cookie='subscribeSplash=Viewed;path=/;expires=Thu, 01-Jan-2030 00:00:01 GMT; host=www.specialolympics.org;';
}


function showThanks() {
	document.getElementById('pledge_box').style.visibility='hidden';
	document.getElementById('pledge_box').style.display='none';
	document.getElementById('pledge_box_thanks').style.visibility='visible';
	document.getElementById('pledge_box_thanks').style.display='block';


}




	function TrimString(sInString) {
		sInString = sInString.replace( /^\s+/g, "" );// strip leading
		return sInString.replace( /\s+$/g, "" );// strip trailing
	}

function isEMailAddr(elem) {

	
 var filter=/^.+@.+\..{2,3}$/ 
 
 if (filter.test(elem)) 
    testresults=true 
 else { 
    
    testresults=false 
} 
 return (testresults) 
}
	

function requiredValues(thisform) {


	var useremail= thisform.email.value;
	var userfirstname= thisform.fname.value;
	var userlastname= thisform.lname.value;



	if ((userfirstname == "")|| (userfirstname==null)) {
		alert ("Please enter a first name and try again. ");
		return false;
	}

	if ((userlastname == "") || (userlastname==null)){
		alert ("Please enter a last name and try again. ");
		return false;
	}

	if (!isEMailAddr(useremail) || (useremail=="")) {
		alert ("Please enter a valid email address and try again. ");
		return false;
	}

	//all conditions have been met, so submit the form
	
	hideSplash();
	return true;
}
