function Handle(e)
{
	if ( e.keyCode == 27 )
	{
		closeMe();
	}
}

function closeMe()
{
	self.close();
}
//Check whether specified value is numeric or not?
function ValidateNo(NumStr, String)
{
	for(var Idx=0; Idx<NumStr.length; Idx++)
	{
		var Char = NumStr.charAt(Idx);
		var Match = false;

		for(var Idx1=0; Idx1<String.length; Idx1++)
		{
			if(Char == String.charAt (Idx1))
				Match = true;
		}

		if (!Match) 
			return false;
	}
	return true;
}

function validate1()

{  
	 
	//validate name
  
	if (document.frm.name.value == "")
	{
		alert("Please Enter Your Name");
		document.frm.name.focus();
		return false;
	}
	
	//validate company name
	if (document.frm.company.value == "")
	{
		alert("Please Enter Your Company Name");
		document.frm.company.focus();
		return false;
	}
		if (document.frm.country.selectedIndex == 0)
	{
		alert("Please Enter Your Country");
		document.frm.country.focus();
		return false;
	}
	if (document.frm.city.value == "")
	{
		alert("Please Enter Your City Name");
		document.frm.city.focus();
		return false;
	}
	//validate email
	var mail = document.frm.email.value;

	if(document.frm.email.value=="")
	{
		alert("Please enter a value for the Email Id.");
		document.frm.email.focus();
		return false;
	}

	if ((mail.length == mail.lastIndexOf('.')+1) || (mail.indexOf('@') != mail.lastIndexOf('@')))
	{
		alert("Please enter a proper Email Id");
		document.frm.email.focus();
		return false;
	}

	if(mail.indexOf('@')==-1 || mail.indexOf('.')==-1 ||  mail.indexOf('@',0)==0 || mail.indexOf('.',0)<1 || mail.indexOf('@.')!= -1 || mail.indexOf('.@')!=-1 || mail.indexOf('..')!=-1)
	{
		alert("Please enter a proper Email Id");
		document.frm.email.focus();
		return false;
	}

	if(!ValidateNo(document.frm.email.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@._-"))
	{
		alert("Please enter a proper Email Id");
		document.frm.email.focus();
		return false;
	}
	
	//validating phone number
	//country code
	if (document.frm.cphone.value == "")
	{
		alert("Please enter country number");
		document.frm.cphone.focus();
		return false;
	}
	
	if(!ValidateNo(document.frm.cphone.value,"1234567890+- "))
	{
		alert("Please Enter Only Number");
		document.frm.cphone.focus();
		return false;
	}
	//area code
	if (document.frm.aphone.value == "")
	{
		alert("Please enter area number");
		document.frm.aphone.focus();
		return false;
	}
	
	if(!ValidateNo(document.frm.aphone.value,"1234567890+- "))
	{
		alert("Please Enter Only Number");
		document.frm.aphone.focus();
		return false;
	}
	//phone code
	if (document.frm.pphone.value == "")
	{
		alert("Please enter phone number");
		document.frm.pphone.focus();
		return false;
	}
	
	if(!ValidateNo(document.frm.pphone.value,"1234567890+- "))
	{
		alert("Please Enter Only Number");
		document.frm.pphone.focus();
		return false;
	}


 
	if (document.frm.country.selectedIndex == 0)
	{
		alert("Please Enter Your Country");
		document.frm.country.focus();
		return false;
	}

	//validate comments
	if (document.frm.comments.value == "")
	{
		alert("Please Enter Your Comments");
		document.frm.comments.focus();
		return false;
	}

	var name , company , address , country , phone , fax , email , comments,compurl;

	name = escape(document.frm.name.value);
	company = escape(document.frm.company.value);
	email = escape(document.frm.email.value);
	phone = escape(document.frm.cphone.value)+'-'+escape(document.frm.aphone.value)+'-'+escape(document.frm.pphone.value);
	country = escape(document.frm.country.value);
	comments = escape(document.frm.comments.value);
	city = escape(document.frm.city.value);
	var str;
	str = "name="+name+"&company="+company+"&country="+country+"&phone="+phone+"&email="+email+"&comments="+comments+"&city="+city;
 
	var xmlHttp = null 	
	if (typeof window.ActiveXObject != 'undefined' ) 
	{ 
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	else 
	{ 
		xmlHttp = new XMLHttpRequest(); 
	}

 var url="sendmail.asp?"+str+"&sid="+Math.random()
 	xmlHttp.open("GET", url, false);
    xmlHttp.send(null);
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") 
	{	
		document.getElementById("business").innerHTML=xmlHttp.responseText
	}
}
function jsdownloadmediakit()
{
	if (document.frm.name.value == "")
	{
		alert("Please enter Name");
		document.frm.name.focus();
		return false;
	}
	//email
	if ( document.frm.email.value.search(/([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})/) < 0 )
		{
			alert("Please provide valid Email");
			document.frm.email.focus();
			return false;
		}	
	//phone code
	if (document.frm.cphone.value == "")
	{
		alert("Please enter country number");
		document.frm.cphone.focus();
		return false;
	}
	
	if(!ValidateNo(document.frm.cphone.value,"1234567890+- "))
	{
		alert("Please Enter Only Number");
		document.frm.cphone.focus();
		return false;
	}
	//area code
	if (document.frm.aphone.value == "")
	{
		alert("Please enter area number");
		document.frm.aphone.focus();
		return false;
	}
	
	if(!ValidateNo(document.frm.aphone.value,"1234567890+- "))
	{
		alert("Please Enter Only Number");
		document.frm.aphone.focus();
		return false;
	}
	//phone code
	if (document.frm.pphone.value == "")
	{
		alert("Please enter phone number");
		document.frm.pphone.focus();
		return false;
	}
	
	if(!ValidateNo(document.frm.pphone.value,"1234567890+- "))
	{
		alert("Please Enter Only Number");
		document.frm.pphone.focus();
		return false;
	}
	var name , email , phone

	name = document.frm.name.value ;
	phone = escape(document.frm.cphone.value)+'-'+escape(document.frm.aphone.value)+'-'+escape(document.frm.pphone.value);
	email = document.frm.email.value ;
	

	var str;
	str = "name="+name+"&phone="+phone+"&email="+email;
 
	var xmlHttp = null 	
	if (typeof window.ActiveXObject != 'undefined' ) 
	{ 
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	else 
	{ 
		xmlHttp = new XMLHttpRequest(); 
	}

    var url="sendmail1.asp?"+str
 	xmlHttp.open("GET", url, false);
    xmlHttp.send(null);
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") 
	{	
		document.getElementById("business").innerHTML=xmlHttp.responseText
	}	

}
