function request(){
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	}
function sendmail()
    {
	document.getElementById("fail").style.display='block';
	var email = escape(document.getElementById("email").value);
    var femail = escape(document.getElementById("femail").value);
	var tourid = escape(document.getElementById("tourid").value);
    var returnurl = escape(document.getElementById("returnurl").value);
	if(femail=='')
	{
		
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Friend Email Required!</p></div></div>';
        document.getElementById("femail").focus();
		return false;
	}
    if(!echeck(femail))
	{
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Valid Email Required!</p></div></div>';
        document.getElementById("femail").focus();
		return false;
	}
    if(email=='')
	{
		
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Your Email Required!</p></div></div>';
        document.getElementById("email").focus();
		return false;
	}
    if(!echeck(email))
	{
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Valid Email Required!</p></div></div>';
        document.getElementById("email").focus();
		return false;
	}
	html = "<img src='images/ajax-loader.gif' style='padding-top:10px;padding-left:80px;'>";
	document.getElementById("fail").innerHTML=html;
	request();
	xmlhttp.onreadystatechange=function()
	{
	  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		      //alert(xmlhttp.responseText);
			if(xmlhttp.responseText==1)
			{
			     document.getElementById("fail").innerHTML='<div class="succes"><div class="succes_icon"></div><div class="desc"><span>Success!</span><p>Mail Send Successfully To Your Friend!!</p></div></div>';
			}			
			if(xmlhttp.responseText==2)
			{
				document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Sorry! There is some problem of Server.<br/>Please try again Later!!</p></div></div>';
			}
		}
	}
	
	xmlhttp.open("GET","sendmail.php?action=Tour&email="+email+"&femail="+femail+"&tourid="+tourid+"&returnurl="+returnurl,true);
	xmlhttp.send();
}
function sendnews()
    {
	document.getElementById("fail").style.display='block';
	var email = escape(document.getElementById("email").value);
    var femail = escape(document.getElementById("femail").value);
	var newsid = escape(document.getElementById("newsid").value);
    var returnurl = escape(document.getElementById("returnurl").value);
	if(femail=='')
	{
		
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Friend Email Required!</p></div></div>';
        document.getElementById("femail").focus();
		return false;
	}
    if(!echeck(femail))
	{
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Valid Email Required!</p></div></div>';
        document.getElementById("femail").focus();
		return false;
	}
    if(email=='')
	{
		
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Your Email Required!</p></div></div>';
        document.getElementById("email").focus();
		return false;
	}
    if(!echeck(email))
	{
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Valid Email Required!</p></div></div>';
        document.getElementById("email").focus();
		return false;
	}
	html = "<img src='images/ajax-loader.gif' style='padding-top:10px;padding-left:80px;'>";
	document.getElementById("fail").innerHTML=html;
	request();
	xmlhttp.onreadystatechange=function()
	{
	  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		      //alert(xmlhttp.responseText);
			if(xmlhttp.responseText==1)
			{
			     document.getElementById("fail").innerHTML='<div class="succes"><div class="succes_icon"></div><div class="desc"><span>Success!</span><p>Mail Send Successfully To Your Friend!!</p></div></div>';
			}			
			if(xmlhttp.responseText==2)
			{
				document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Sorry! There is some problem of Server.<br/>Please try again Later!!</p></div></div>';
			}
		}
	}
	
	xmlhttp.open("GET","sendmail.php?action=News&email="+email+"&femail="+femail+"&newsid="+newsid+"&returnurl="+returnurl,true);
	xmlhttp.send();
}
function sendpackage()
    {
	document.getElementById("fail").style.display='block';
	var email = escape(document.getElementById("email").value);
    var femail = escape(document.getElementById("femail").value);
	var packageid = escape(document.getElementById("packageid").value);
    var returnurl = escape(document.getElementById("returnurl").value);
	if(femail=='')
	{
		
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Friend Email Required!</p></div></div>';
        document.getElementById("femail").focus();
		return false;
	}
    if(!echeck(femail))
	{
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Valid Email Required!</p></div></div>';
        document.getElementById("femail").focus();
		return false;
	}
    if(email=='')
	{
		
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Your Email Required!</p></div></div>';
        document.getElementById("email").focus();
		return false;
	}
    if(!echeck(email))
	{
		document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Valid Email Required!</p></div></div>';
        document.getElementById("email").focus();
		return false;
	}
	html = "<img src='images/ajax-loader.gif' style='padding-top:10px;padding-left:80px;'>";
	document.getElementById("fail").innerHTML=html;
	request();
	xmlhttp.onreadystatechange=function()
	{
	  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		      //alert(xmlhttp.responseText);
			if(xmlhttp.responseText==1)
			{
			     document.getElementById("fail").innerHTML='<div class="succes"><div class="succes_icon"></div><div class="desc"><span>Success!</span><p>Mail Send Successfully To Your Friend!!</p></div></div>';
			}			
			if(xmlhttp.responseText==2)
			{
				document.getElementById("fail").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Sorry! There is some problem of Server.<br/>Please try again Later!!</p></div></div>';
			}
		}
	}
	
	xmlhttp.open("GET","sendmail.php?action=Package&email="+email+"&femail="+femail+"&packageid="+packageid+"&returnurl="+returnurl,true);
	xmlhttp.send();
}
function getPage(str)
    {
	html = "<img src='images/ajax-loader.gif' style='padding-top:10px;padding-left:80px;'>";
	document.getElementById("sett").innerHTML=html;
	request();
	xmlhttp.onreadystatechange=function()
	{
	  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		     if (xmlhttp.readyState==4 && xmlhttp.status==200)
    		{
    			document.getElementById('sett').innerHTML=xmlhttp.responseText;
    		}
		}
	}
	
	xmlhttp.open("GET","action.php?action="+str,true);
	xmlhttp.send();
}
function changepassword()
    {
	document.getElementById("proc").style.display='block';
	var oldpassword = escape(document.getElementById("old_password").value);
	var newpassword = escape(document.getElementById("new_password").value);
    var cpassword = escape(document.getElementById("c_password").value);
    var id = escape(document.getElementById("id").value);
	if(oldpassword=='')
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Old Password Required!</p></div></div>';
		return false;
	}
	if(newpassword=='')
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>New Password Required!</p></div></div>';
		return false;
	}
    if(cpassword=='')
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Confirm Password Required!</p></div></div>';
		return false;
	}
    if(cpassword!=newpassword)
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Both Password Same Required!</p></div></div>';
		return false;
	}
	html = "<img src='images/ajax-loader.gif' style='padding-top:10px;padding-left:80px;'>";
	document.getElementById("proc").innerHTML=html;
	request();
	xmlhttp.onreadystatechange=function()
	{
	  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		    //alert(xmlhttp.responseText);
			if(xmlhttp.responseText==1)
			{
				document.getElementById("proc").innerHTML='<div class="succes"><div class="succes_icon"></div><div class="desc"><span>Success!</span><p>Password Changed successfully!</p></div></div>';
                document.getElementById('old_password').value = '';
                document.getElementById('new_password').value = '';
                document.getElementById('c_password').value = '';
			}
			if(xmlhttp.responseText==2)
			{
				document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Incorrect Username or Password!</p></div></div>';
			}
		}
	}
	
	xmlhttp.open("GET","action.php?action=changepassword&oldpassword="+oldpassword+"&newpassword="+newpassword+"&id="+id,true);
	xmlhttp.send();
}
function changeaccount()
    {
	document.getElementById("proc").style.display='block';
	var name = document.getElementById("name").value;
	var email = document.getElementById("email").value;
    var username = document.getElementById("username").value;
	var gender = document.getElementById("gender").value;
	var address = document.getElementById("address").value;
    var city = document.getElementById("city").value;
    var newsletter = document.getElementById("newsletter").value;
    var id = escape(document.getElementById("id").value);
	if(name=='')
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Name Required!</p></div></div>';
		return false;
	}
	if(email=='')
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Email Required!</p></div></div>';
		return false;
	}
    if(username=='')
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>User Name Required!</p></div></div>';
		return false;
	}
    if(gender=='')
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Gender Select Required!</p></div></div>';
		return false;
	}
    if(address=='')
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Address Required!</p></div></div>';
		return false;
	}
    if(city=='')
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>City Required!</p></div></div>';
		return false;
	}
    if(newsletter=='')
	{
		
		document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Newsletter select Required!</p></div></div>';
		return false;
	}
	html = "<img src='images/ajax-loader.gif' style='padding-top:10px;padding-left:80px;'>";
	document.getElementById("proc").innerHTML=html;
	request();
	xmlhttp.onreadystatechange=function()
	{
	  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		      //alert(xmlhttp.responseText);
			if(xmlhttp.responseText==1)
			{
				document.getElementById("proc").innerHTML='<div class="succes"><div class="succes_icon"></div><div class="desc"><span>Success!</span><p>Account Settings Changed successfully!</p></div></div>';
			}
			if(xmlhttp.responseText==2)
			{
				document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Problem Occur!Try Latter!</p></div></div>';
			}
		}
	}
	
	xmlhttp.open("GET","action.php?action=changeaccount&name="+name+"&email="+email+"&username="+username+"&gender="+gender+"&city="+city+"&address="+address+"&newsletter="+newsletter+"&id="+id,true);
	xmlhttp.send();
    
}
function deactivate()
{
	document.getElementById("proc").style.display='block';
    var id = escape(document.getElementById("id").value);
	html = "<img src='images/ajax-loader.gif' style='padding-top:10px;padding-left:80px;'>";
	document.getElementById("proc").innerHTML=html;
	request();
	xmlhttp.onreadystatechange=function()
	{
	  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		    //alert(xmlhttp.responseText);
			if(xmlhttp.responseText==1)
			{
				document.getElementById("proc").innerHTML='<div class="succes"><div class="succes_icon"></div><div class="desc"><span>Success!</span><p>Your Account Deactivated successfully!</p></div></div>';
                document.getElementById("deact").style.display='none';
                document.getElementById("act").style.display='block';
			}
			if(xmlhttp.responseText==2)
			{
				document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Server Problem!Please Try Later</p></div></div>';
			}
		}
	}
	
	xmlhttp.open("GET","action.php?action=deactivation&id="+id,true);
	xmlhttp.send();
}
function activate()
{
	document.getElementById("proc").style.display='block';
    var id = escape(document.getElementById("id").value);
	html = "<img src='images/ajax-loader.gif' style='padding-top:10px;padding-left:80px;'>";
	document.getElementById("proc").innerHTML=html;
	request();
	xmlhttp.onreadystatechange=function()
	{
	  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		    //alert(xmlhttp.responseText);
			if(xmlhttp.responseText==1)
			{
				document.getElementById("proc").innerHTML='<div class="succes"><div class="succes_icon"></div><div class="desc"><span>Success!</span><p>Your Account Activated successfully!</p></div></div>';
                document.getElementById("deact").style.display='block';
                document.getElementById("act").style.display='none';
			}
			if(xmlhttp.responseText==2)
			{
				document.getElementById("proc").innerHTML='<div class="warning"><div class="warn_icon"></div><div class="desc"><span>Warning!</span><p>Server Problem!Please Try Later</p></div></div>';
			}
		}
	}
	
	xmlhttp.open("GET","action.php?action=activation&id="+id,true);
	xmlhttp.send();
}
function echeck(str)
{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		 //  alert("Invalid E-mail ID")
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  // alert("Invalid E-mail ID")
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   // alert("Invalid E-mail ID")
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   // alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }
 		 return true					
}
