// JavaScript Document
var xmlHttp,showdiv;
var RE_EMAIL = /^(\w+[\-\.])*\w+@(\w+\.)+[A-Za-z]+$/;
var aflag="";
function country_sel(cat,id,cond,divs)
{ 
showdiv=divs;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} if(cond=='coupon'){
	if(document.getElementById('discountcode').value=="") { alert("Please Enter Discount Code");document.getElementById('discountcode').focus(); return false; }
	if(document.getElementById('expiration').value=="") { alert("Please Select Expiration");document.getElementById('expiration').focus(); return false; }
	if(document.getElementById('description').value=="") { alert("Please Enter Description");document.getElementById('description').focus(); return false; }
	}
if(cond=='newsletter'){
	if(document.getElementById('newslettermail').value=="Enter Email Address") { alert("Please Enter The Enter Email Address");document.getElementById('newslettermail').focus(); return false; }
	if(!RE_EMAIL.test(document.getElementById('newslettermail').value)) {alert("Please Enter Correct Enter Email Address"); document.getElementById('newslettermail').value="";document.flights_email_id.focus();return false;}
	id=document.getElementById('newslettermail').value;
	}
if(cat=='rate'){
	document.getElementById('rate'+id).style.display='none';
	}	
var url="http://www.couponsdiary.com/ajaxdata.php"
url=url+"?cat="+cat+"&sta="+cond
url=url+"&id="+id
if(showdiv=="countrytopdiv"){
url=url+"&super="+showdiv
}
if(cond=='coupon'){
url=url+"&discountcode="+document.getElementById('discountcode').value
url=url+"&expiration="+document.getElementById('expiration').value
url=url+"&description="+document.getElementById('description').value
url=url+"&storeid="+document.getElementById('storeid').value

}
//show times show_times_disp
url=url+"&cond="+cond
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged() 
{
	// alert(xmlHttp.responseText);
	
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById(showdiv).innerHTML=xmlHttp.responseText
 if(showdiv=='newsletterdiv'){
	document.getElementById('newslettermail').value="";
	}
if(showdiv=='coupondiv'){
document.getElementById('discountcode').value="";
document.getElementById('expiration').value="";
document.getElementById('description').value="";
 

	}	  
} else 
{
document.getElementById(showdiv).innerHTML='Loading Please Wait...'
}
}
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;
}
 
