// JavaScript Document
function formrule(field)
	{
		if (field.defaultValue == field.value){
		 field.value = "";
		 }
	}

function formrule2(field) {
  if (field.value == "") {
    field.value = field.defaultValue;
  }
}

function articleView(n){
	if(window.document.getElementById("q"+n).style.display == "none"){
		window.document.getElementById("q"+n).style.display="";
	}
	else{
		window.document.getElementById("q"+n).style.display="none";
	}
}
function articleViewHide(){
	for(var n=1;n<17;n++){
		window.document.getElementById("q"+n).style.display="none";
	}
}


//####################################################################//
	function clearpopup(){
			window.document.getElementById("idin").style.display = '';
			window.document.getElementById("idup").style.display = 'none';
			window.document.getElementById("idforgotp").style.display = 'none';
			window.document.getElementById("idinvite").style.display = 'none';
			window.document.getElementById("idnewsletter").style.display = 'none';
	}
	function clearpopup_new(){
			window.document.getElementById("idin").style.display = 'none';
			window.document.getElementById("idup").style.display = 'none';
			window.document.getElementById("idforgotp").style.display = 'none';
			window.document.getElementById("idinvite").style.display = 'none';
			window.document.getElementById("idnewsletter").style.display = 'none';
			window.document.getElementById("idnewsletter").style.display = 'none';
	}
	function clearPopup(){
			window.document.getElementById("idinvite").style.display = '';
			window.document.getElementById("idin").style.display = 'none';
			
			window.document.getElementById("idup").style.display = 'none';
			window.document.getElementById("idforgotp").style.display = 'none';
			window.document.getElementById("idnewsletter").style.display = 'none';
	}
	function clearPopUp(){
			window.document.getElementById("idnewsletter").style.display = '';
			window.document.getElementById("idinvite").style.display = 'none';
			window.document.getElementById("idin").style.display = 'none';
			window.document.getElementById("idup").style.display = 'none';
			window.document.getElementById("idforgotp").style.display = 'none';
	}
	function signupin(){
	
		if(window.document.getElementById("idin").style.display == '')
		{
			window.document.homePage.action="javascript:signUpFunc()";
window.document.getElementById("uptest").style.display = 'none';

			window.document.getElementById("idin").style.display = 'none';
			window.document.getElementById("remember_pwd_no").style.display = 'none';
			window.document.getElementById("sending_forgot").style.display = 'none';
			window.document.getElementById("id_signup").style.display = 'none';
window.document.getElementById("uptest").style.display = 'none';
			
			
			window.document.getElementById("idup").style.display = '';
			window.document.getElementById("idforgotp").style.display = 'none';
		}
		else{
			window.document.getElementById("remember_pwd").style.display = 'none';
			window.document.getElementById("idin").style.display = '';
			window.document.getElementById("idup").style.display = 'none';
			window.document.getElementById("idforgotp").style.display = 'none';
			window.document.getElementById("id_signup").style.display = 'none';
		}
	}
	function signup_new(){
		window.document.getElementById("idup").style.display = '';
		window.document.getElementById("After_Newsletter").style.display = 'none';
		
	}
	function forgotpass(){
		if(window.document.getElementById("idin").style.display == '')
		{
			window.document.homePage.action="javascript:forgotPasswd()";
			window.document.getElementById("idforgotp").style.display = '';
			window.document.getElementById("idin").style.display = 'none';
		}
	}
	function invite(){
			window.document.homePage.action="javascript:sendFriendMail()";
			window.document.getElementById("flash").style.display = 'none';
			window.document.getElementById("box").style.display = '';
			window.document.getElementById("overlay").style.display = '';
			window.document.getElementById("idnewsletter").style.display = 'none';
			window.document.getElementById("loadingImage").style.display = 'none';
			window.document.getElementById("afterMail_friend").style.display = 'none';
			window.document.getElementById("idinvite").style.display = '';
			window.scrollTo(0,0);
	}
	function newsletter(){
			window.document.homePage.action="javascript:newsletter_func()";
			window.document.getElementById("flash").style.display = 'none';
			window.document.getElementById("box").style.display = '';
			window.document.getElementById("overlay").style.display = '';
			window.document.getElementById("idinvite").style.display = 'none';
			window.document.getElementById("After_Newsletter").style.display = 'none';
			window.document.getElementById("loadingImageNews").style.display = 'none';
			window.document.getElementById("idnewsletter").style.display = '';
			window.scrollTo(0,0);
	}
	
  var xmlHttp;
function GetXmlHttpObject()
{
  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;
}

	function loginPage(){
	if(document.homePage.author1.value==""){
	

		alert("Enter Email Address");
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.homePage.author1.value)){
		alert("Invalid E-mail Address! Please re-enter.")
	}else if(document.homePage.email1.value==""){
		alert("Enter Password");
	}else{
		xmlHttp=GetXmlHttpObject();
		var emailid=window.document.homePage.author1.value;
		var passwd=window.document.homePage.email1.value;
		if (xmlHttp==null)
		  {
		  window.alert ("Your browser does not support AJAX!");
		  return;
		  } 
		var url="login.php";
		url+="?emailAddress="+emailid;
		url+="&password="+passwd;
		xmlHttp.onreadystatechange=function(){
										if (xmlHttp.readyState==4)
										{ 
											var a=xmlHttp.responseText.toString();
											if(a == "no"){
											
												window.document.getElementById("id_error").style.display='';
											}
											else{
											document.homePage.email1.value="";
												window.open("Merchant.html",'mywindow','width=1024,height=750');											}
										}
									}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);

	
	}
	
	}

	function sendFriendMail(){
	var friendName=document.homePage.friends_Name.value;
	var friendEmail=document.homePage.friends_email.value;
		if(document.homePage.friends_Name.value==""){
			alert("Enter Name");
		}else if(document.homePage.friends_email.value==""){
			alert("Enter Email");
		}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.homePage.friends_email.value)){
			alert("Invalid Friends E-mail Address! Please re-enter.")
		}
		else if(document.homePage.your_Name.value==""){
			alert("enter your Name");
		}else if(document.homePage.your_email.value==""){
			alert("enter your Email Id");			
		}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.homePage.your_email.value)){
			alert("Invalid Your E-mail Address! Please re-enter.")
		}else{
				
				xmlHttp=GetXmlHttpObject();
				var friendName=document.homePage.friends_Name.value;
				var friendEmail=document.homePage.friends_email.value;
				var yourName=document.homePage.your_Name.value;
				var youremail=document.homePage.your_email.value;
					if (xmlHttp==null){
						  window.alert ("Your browser does not support AJAX!");
						  return;
						  } 
		var url1="emailToFriend.php";
		url1+="?friendname="+friendName;
		url1+="&friendemailid="+friendEmail;
		url1+="&yourname="+yourName;
		url1+="&yourmail="+youremail;
		xmlHttp.onreadystatechange=function(){
										if(xmlHttp.readyState==1){
												window.document.getElementById("idinvite").style.display='none';
												window.document.getElementById("loadingImage").style.display='';
											}
											
										if (xmlHttp.readyState==4)
										{ 											
											var a=xmlHttp.responseText.toString();
											if(a == "yes"){
												window.document.getElementById("loadingImage").style.display='none';
												window.document.getElementById("idinvite").style.display='none';
												window.document.getElementById("afterMail_friend").style.display='';
											}
											
										}
									}
		xmlHttp.open("GET",url1,true);
		xmlHttp.send(null);
		}
	}


	function openYourDetail(){
		if(document.homePage.friends_Name.value==""){
			alert("Enter Name");
		}else if(document.homePage.friends_email.value==""){
			alert("Enter Email");
		}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.homePage.friends_email.value)){
			alert("Invalid E-mail Address! Please re-enter.")
		}else{
			window.document.getElementById("yourname").style.display='';
			window.document.getElementById("friend_but").style.display='none';
		}
	}

	function newsletter_func(){
		if(document.homePage.newsletter_name.value==""){
			alert("Enter Email address");
		}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.homePage.newsletter_name.value)){
			alert("Invalid E-mail Address! Please re-enter.")
		}else{
			xmlHttp=GetXmlHttpObject();
				var cust_mailid=document.homePage.newsletter_name.value;
				
					if (xmlHttp==null){
						  window.alert ("Your browser does not support AJAX!");
						  return;
						  } 
		var url2="newsletter_unreg.php";
		url2+="?mailid="+cust_mailid;
		
		xmlHttp.onreadystatechange=function(){
			
										if(xmlHttp.readyState==1){
												window.document.getElementById("idnewsletter").style.display='none';
												window.document.getElementById("loadingImageNews").style.display='';
											}
										if (xmlHttp.readyState==4)
										{ 
											
											var a=xmlHttp.responseText.toString();
											if(a == "yes"){
												window.document.getElementById("loadingImageNews").style.display='none';
												window.document.getElementById("idnewsletter").style.display='none';
												window.document.getElementById("After_Newsletter").style.display='';
											}
											
										}
									}
		xmlHttp.open("GET",url2,true);
		xmlHttp.send(null);
		}
	}

	function forgotPasswd(){
		if(document.homePage.email_forgot.value==""){
			alert("Enter The Email Id");
		}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.homePage.email_forgot.value)){
			alert("Invalid E-mail Address! Please re-enter.")
		}else{
			xmlHttp=GetXmlHttpObject();
				var forgot_mailid=document.homePage.email_forgot.value;
				
				
					if (xmlHttp==null){
						  window.alert ("Your browser does not support AJAX!");
						  return;
						  } 
		var url3="ForgotPassword.php";
		url3+="?user_address="+forgot_mailid;
		
		xmlHttp.onreadystatechange=function(){
			
										if(xmlHttp.readyState==1){
												window.document.getElementById("idforgotp").style.display='none';
												window.document.getElementById("sending_forgot").style.display='';												
											}
										if (xmlHttp.readyState==4)
										{ 
											
											var a=xmlHttp.responseText.toString();
											if(a == "yes"){
												window.document.getElementById("sending_forgot").style.display='none';
												window.document.getElementById("idforgotp").style.display='none';
												window.document.getElementById("remember_pwd").style.display='';
											}else{
												window.document.getElementById("idforgotp").style.display='';
												window.document.getElementById("sending_forgot").style.display='none';
												window.document.getElementById("before_send").style.display='none';
												window.document.getElementById("remember_pwd_no").style.display='';
											}
											
										}
									}
		xmlHttp.open("GET",url3,true);
		xmlHttp.send(null);
		}
	}

	function signUpFunc(){
		if(document.homePage.author_signup.value==""){
			alert("Please Enter The Name");
		}else if(document.homePage.author_email_signup.value==""){
			alert("Please Enter The Email Address");
		}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.homePage.author_email_signup.value)){
			alert("Invalid E-mail Address! Please re-enter.")
		}else if(document.homePage.password_signup.value==""){ 
			alert("Please Enter The Password");
		}else if(document.homePage.author_confirm.value==""){
			alert("Please Enter The Confirm Password");
		}else if(document.homePage.password_signup.value!=document.homePage.author_confirm.value){
			alert("Check Both Password are same");
		}else{
				xmlHttp=GetXmlHttpObject();
				var emailAddress1=document.homePage.author_email_signup.value;
				var firstName=document.homePage.author_signup.value;
				var password=document.homePage.password_signup.value;
				
				
					if (xmlHttp==null){
						  window.alert ("Your browser does not support AJAX!");
						  return;
						  } 
		var url4="AddUserAccountInformation.php";
		url4+="?emailAddress1="+emailAddress1;
		url4+="&firstName="+firstName;
		url4+="&password="+password;
		
		
		xmlHttp.onreadystatechange=function(){
			
										if(xmlHttp.readyState==1){
												window.document.getElementById("idforgotp").style.display='none';
												
											}
										if (xmlHttp.readyState==4)
										{ 
											
											var a=xmlHttp.responseText.toString();
											if(a == "no"){
												
												window.document.getElementById("id_signup_error").style.display='';
												window.document.getElementById("id_signup").style.display='none';
												
											}else{
												document.homePage.password_signup.value="";
												document.homePage.author_confirm.value="";
												window.document.getElementById("id_signup_error").style.display='none';
												window.document.getElementById("id_signup").style.display='';
												window.document.getElementById("idup").style.display='none';
											}
											
										}
									}
		xmlHttp.open("GET",url4,true);
		xmlHttp.send(null);
		}
	}
	
	function Reg_Login_Func(){
	
		window.open("http://localhost/Merchant/bin/Merchant.html",'mywindow','width=1024,height=750');
	}

	function assistance(){
	if(document.general_info.comments11.value!='Comments' && document.general_info.comments11.value!=''){
		window.document.getElementById('assistance_hide').style.display='';
		
		window.document.getElementById('button2').style.display='none';
		window.document.general_info.action="javascript:assistance_send()";
		
	}else{
		alert("Enter The General information");
		
		}
	}
	function assistance_send(){
		if(document.general_info.comments11.value=='Comments' || document.general_info.comments11.value==''){
		alert("Enter The General information");
		}else if(document.general_info.name_name.value==''||document.general_info.name_name.value=='name'){
			alert("Enter Name");
		}else if(document.general_info.name_mail.value=='' || document.general_info.name_mail.value=='email'){
			alert("Enter Email");		
		}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.general_info.name_mail.value)){
			alert("Invalid E-mail Address! Please re-enter.");
			}
		else{
			xmlHttp=GetXmlHttpObject();
				var general_info=document.general_info.comments11.value;
				var name_info=document.general_info.name_name.value;
				var mail_id_info=document.general_info.name_mail.value;
				var sub_info = document.general_info.name.value;
				
				
					if (xmlHttp==null){
						  window.alert ("Your browser does not support AJAX!");
						  return;
						  } 
		var url5="general_unreg_contact.php";
		var par = "sub_info="+sub_info;
		par += "&general_info="+general_info;
		par += "&name_info="+name_info;
		par += "&mail_id_info="+mail_id_info;
		
		
		xmlHttp.onreadystatechange=function(){
			
										if(xmlHttp.readyState==1){
												window.document.getElementById("full_info_div").style.display='none';
												window.document.getElementById("while_load").style.display='';												
											}
										if (xmlHttp.readyState==4)
										{ 
												window.document.getElementById("before_send_info").style.display='';
												window.document.getElementById("while_load").style.display='none';
												window.document.getElementById("full_info_div").style.display='none';
										}
									}
		xmlHttp.open("POST",url5,true);
		xmlHttp.send(par);
		}
	}
	
function unreg_login(){
	window.open("MerchantBeforeLogin.html",'mywindow','width=1024,height=750');

}




