// JavaScript Document
function validate()
{
	var req = new Array ("txt1", "txt2", "txt3", "txt4", "txt5");
	var email = new Array ("txt2","txt4");	
	var number = new Array ();
	var x;
		for (x in req)   
			if (dlt_checkRequired(document.getElementById(req[x]).value) == false ) 
			{document.getElementById(req[x]).focus();return false;}
		for (x in email) 
			if (dlt_checkEmail(document.getElementById(email[x]).value) == false ) 
			{document.getElementById(email[x]).focus();return false;}
		for (x in number)
			if (dlt_checknumber(document.getElementById(number[x]).value) == false ) 
			{document.getElementById(number[x]).focus(); return false;}
		
	document.getElementById('emailtofriend_response').innerHTML  = "Please Wait.Sending an email...!"	
	SendCoupon();
}
//
function showhide_mailbody()
	{
	if ( document.getElementById('emailtofriend').style.display =='block') 
		{
		document.getElementById('emailtofriend').style.display='none';
		document.getElementById('emailtofriend_response').innerHTML="";
		}
	else
		document.getElementById('emailtofriend').style.display='block';	
	}
//
// Ajax JavaScript Document
var xmlHttp;
	function SendCoupon()
		{ str="";
			xmlHttp=GetXmlHttpObject3();
			if (xmlHttp==null)
			  {  alert ("Your browser does not support AJAX!");
				  return;
			  } 
var url="SendCoupon.asp";
url=url+"?tName="+ document.getElementById('txt1').value;
url=url+"&tEmail="+ document.getElementById('txt2').value;
url=url+"&rName="+ document.getElementById('txt3').value;
url=url+"&rEmail="+ document.getElementById('txt4').value;
url=url+"&mSubject="+ document.getElementById('txt5').value;
url=url+"&mComments="+ document.getElementById('txt6').value.replace(/%/,'%25').replace(/&/,'%26');
url=url+"&rowid="+ document.getElementById('send_discount_coupon').value;
url=url+"&sid="+Math.random();
//alert(url);
//xmlHttp.overrideMimeType('text/html')
xmlHttp.onreadystatechange=dateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
//
function dateChanged() 
{ 
if (xmlHttp.readyState==4)
{	if (xmlHttp.status==200) 
		{ 
			document.getElementById('emailtofriend_response').innerHTML = xmlHttp.responseText; //"Thanks for sending discount coupon to your friend.<br>";
			//document.getElementById('emailtofriend_response').innerHTML  = xmlHttp.responseText;
			document.getElementById('txt3').value= ""
			document.getElementById('txt4').value= ""
			
		 }
	else
		{
			document.getElementById('emailtofriend_response').innerHTML = xmlHttp.responseText; //"Page Not Found";
		}
}
}
//
function PrintCoupon()
{ 	str="";
	xmlHttp=GetXmlHttpObject3();
	if (xmlHttp==null)
	 {  alert ("Your browser does not support AJAX!");
	  	return;
	 } 
	var url="discount-coupon-click-reservation.asp?print=y";
	url=url+"&rowid="+ "" + document.getElementById('send_discount_coupon').value + "";
	url=url+"&sid="+Math.random();

	xmlHttp.onreadystatechange=PrintClick;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
//
function PrintClick()
{
if (xmlHttp.readyState==4)
{	
		
	if ( parseInt(xmlHttp.status) == 200) 
		{ 
			
			eval(xmlHttp.responseText);
			
		 }
	else
		{
			
			document.write(xmlHttp.responseText);
		}
}
}
//
function GetXmlHttpObject3()
{var xmlHttp=null;
try
  { // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
