function close_window()
{	window.close();}
function popPage(strURL, intWidth, intHeight, strParams)
{
	if(intWidth && intHeight)
	{		
		var window_left = 50;
		var window_top = 50;
		if(strParams)
		{
			var winParams = strParams;
		}
		else
		{
			var winParams = "'resizable=no,toolbar=no,location=no,menubar=no,scrollbars=yes'";
		}
		
		win = window.open(strURL,'popUp','width=' + intWidth + ',height=' + intHeight + ',top=' + window_top + ',left=' + window_left + ',' + strParams);	
	}
	else
	{
		win = window.open(strURL,'popUp','width=735,height=500,top=50,left=50,resizable=no,toolbar=no,location=no,menubar=no,scrollbars=yes');
	}
	
	win.opener.name = "opener";
	win.focus();
}


var digits = "0123456789";
var phoneNumberDelimiters = "()- ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function checkInternationalPhone(strPhone){
    s=stripCharsInBag(strPhone,validWorldPhoneChars);
    return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
function checkit_mediasub()
{
	var s = "";
	var e = 0;
	if (!document.form1.elements[0].value)
	{
		s += '- First Name is a required field \n';
		e = 1;
	}
	if (!document.form1.elements[1].value)
	{
		s += '- Last Name is a required field \n';
		e = 1;
	}
	if (!document.form1.elements[2].value)
	{
		s += '- Job Title is a required field \n';
		e = 1;
	}
	if (!document.form1.elements[3].value)
	{
		s += '- Company is a required field \n';
		e = 1;
	}
	if (!document.form1.elements[4].value)
	{
		s += '- Address 1 is a required field \n';
		e = 1;
	}
	if (!document.form1.elements[6].value)
	{
		s += '- City is a required field \n';
		e = 1;
	}
	if (!document.form1.elements[7].value)
	{
		s += '- State is a required field \n';
		e = 1;
	}
	if (!document.form1.elements[8].value)
	{
		s += '- Zip Code is a required field \n';
		e = 1;
	}
	if (!document.form1.elements[9].value)
	{
		s += '- Phone is a required field \n';
		e = 1;
	}
	else if (checkInternationalPhone(document.form1.elements[9].value)==false)
	{
	    s += '- Phone is invalid \n';
	    e = 1;
	}
	if (!document.form1.elements[11].value)
	{
		s += '- Email Address is a required field \n';
		e = 1;
	}
	else if (!(document.form1.elements[11].value.indexOf(".") > 2) || !(document.form1.elements[11].value.indexOf("@") > 0))
	{
	    s += '- Email Address is invalid \n';
	    e = 1;
	}
	if (e == 1)
	{
		alert(s);
		return false;
	}
	return true;
}
