var xmlHttp

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
  	{
		xmlHttp=new XMLHttpRequest();
  	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function PollopenWin(URL,Name,butt) 
{
	var radioObj = document.Poll.PollOptions;
	var radioLength = radioObj.length;
	var radioValue = "";
	var radioCheckCnt = 0;
	
	if(radioLength == undefined)
		if(radioObj.checked)
			radioValue = radioObj.value;
		else
			radioValue =  "";
			
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			radioValue =  radioObj[i].value;
			radioCheckCnt++;
		}
	}
	
	if(radioCheckCnt != 0) {
		URL = URL + "&PollOptions=" + radioValue
		window.open(URL,Name,butt);
	}
	else {
		alert("Please select one poll option.");
	}
}

function validateNews() 
{
	var errormsg;
	errormsg = "";
		
	if (document.MailingForm.newsName.value == "")
		errormsg += "Please fill in 'Name'.\n";
		
	if (document.MailingForm.newsEmail.value == "")
		errormsg += "Please fill in 'Email'.\n";
	else
	{
		if (!isEmail(document.MailingForm.newsEmail.value))
			errormsg += "Please fill in a valid Email address.\n";
	}
	
	if ((errormsg == null) || (errormsg == ""))
	{
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}
		var url="mailinglist.php?newsName="+document.MailingForm.newsName.value+"&newsEmail="+document.MailingForm.newsEmail.value+"&sid="+Math.random();

		xmlHttp.onreadystatechange=NewsStateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	else
	{
		alert(errormsg);
		return false;
	}
}

function NewsStateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{
		document.getElementById("msg").innerHTML=xmlHttp.responseText;
		document.MailingForm.newsName.value="";
		document.MailingForm.newsEmail.value="";
	}
}

function MyPopUpWin(pic, picWidth, picHeight) 
{
	var iMyWidth;
	var iMyHeight;
	if(parseFloat(window.screen.width) > parseFloat(picWidth))
		iMyWidth = (parseFloat(window.screen.width) - parseFloat(picWidth))/2;
	else
		iMyWidth = 0;
	if(parseFloat(window.screen.height) > parseFloat(picHeight))
		iMyHeight = (parseFloat(window.screen.height) - parseFloat(picHeight))/2;
	else
		iMyHeight = 0;
	var win2 = window.open(pic,"Window2","height=" + (parseFloat(picHeight) + 20) + ",width=" + (parseFloat(picWidth) + 10) + ",left=" + iMyWidth + ",top=" + iMyHeight + ",status=no,resizable=no,toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
	win2.focus();
}
