﻿
//window.onload = page_onload;
var execScripts = new Array();

function AddEventHandler(obj,evnt,func)
{
	if(obj.attachEvent){obj.attachEvent('on'+evnt,func);
}
else if (obj.addEventListener)
{
	obj.addEventListener(evnt, func, true);}
}
AddEventHandler(window,'load',function(){page_onload()});



var page_loaded = false;
//window.onload = function()
function page_onload()
{
	if (page_loaded){return false;}else{page_loaded = true;}
	for (var e=0; e<execScripts.length; e++)
	{
		//eval(execScripts[e])
		try{eval(execScripts[e])}catch(e){e=null;}
	}
}

execScripts.push('anchorsBlurOnFocus()');
function anchorsBlurOnFocus()
{
	//set anchors to blur on focus
	var a = document.getElementsByTagName('a');
	for (var i=0;i<a.length;i++){a[i].onfocus=new Function("try{this.blur();}catch(e){}")}
}


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{	if(popUpWin){if(!popUpWin.closed) popUpWin.close();}
	
	if (left.indexOf('%')!=-1)
	{
		left = ((Number(left.replace('%', '')) / 100) % 100);
		left = Math.round((screen.width * left) - (width * 0.5));
	}
	if (top.indexOf('%')!=-1)
	{
		top = ((Number(top.replace('%', '')) / 100) % 100);
		top = Math.round((screen.height * top) - (height * 0.5));
	}

	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function openWindow(URLStr, windowName, width, height){popUpWindow(URLStr, '50%', '50%', width, height);}


function MailingListForm__submit()
{
	if (document.getElementById('MailingListSubmitText').value.search(/^.+@[^\.].*\.[a-z]{2,}$/) > -1)
		{AjaxLoadHtml('/HomePageEmailSubmission.ashx?email=' + document.getElementById('MailingListSubmitText').value, 'MailingListForm');}
	else
		{alert('Please check that you spelled you email address correctly.')}
}

function AjaxLoadHtml(ScriptPath, ResponseTarget)
{ 
	var xmlHttp;
	try{xmlHttp=new XMLHttpRequest();/*Firefox, Opera 8.0+, Safari*/}
	catch (e)
	{/*Internet Explorer*/
		try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e)
		{
			try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
			catch (e)
			{
				//alert("Your browser does not support AJAX!");
				return false;    
			}
		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(ResponseTarget).innerHTML = xmlHttp.responseText;
		}
	}
	
	xmlHttp.open("GET",ScriptPath,true);
	xmlHttp.send(null);
}
	
