function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function validatefp() {
	var forgottenpassworda=document.info.txtForgottenpassword.value;

	if(forgottenpassworda=="") {
		alert("Please enter your Email ID");
		return;
	}
	if (echeck(forgottenpassworda)==false){
		forgottenpassworda="";
		document.info.txtForgottenpassword.focus();
		return false;
	} 
	document.info.action="sendpassword.php";
	document.info.method="POST";
    document.info.submit();
}


function validateContact() {
	var Contactnamea=document.info.txtContactname.value;
	var Emailida=document.info.txtEmailid.value;
	var Phonea=document.info.txtPhone.value;
	var Messagecommentsa=document.info.tarMessagecomments.value;

	if(Contactnamea=="") {
		alert("Please enter Contact Name");
		return;
	}
	if(Emailida=="") {
		alert("Please enter your EmailID");
		return;
	}
	if (echeck(Emailida)==false){
		Emailida="";
		document.info.txtEmailid.focus();
		return false;
	} 
	if(Phonea=="") {
		alert("Please enter Phone Number");
		return;
	}	
	if(Messagecommentsa=="") {
		alert("Please enter Message/Commentsa");
		return;
	}
	document.info.action="sendcontact.php";
	document.info.method="POST";
        document.info.submit();
}



function validatelogin() {
	 var usernamea=document.login.txtUsername.value;
	 var passworda=document.login.txtPassword.value;

     if(usernamea == "") {
	 	alert("Please Enter User Name");
		return;
	 }	 
     if(passworda == "") {
	 	alert("Please Enter Password");
		return;
	 }	 
	 document.login.action="login.php";
	 document.login.method="POST";
     document.login.submit();
}



function validateadminlogin() {
	 var adminida=document.adminlogin.txtAdminid.value;
	 var passworda=document.adminlogin.txtPassword.value;

     if(adminida == "") {
	 	alert("Please Enter Admin ID");
		return;
	 }	 
     if(passworda == "") {
	 	alert("Please Enter Password");
		return;
	 }	 
	 document.adminlogin.action="loginadmin.php";
	 document.adminlogin.method="POST";
     document.adminlogin.submit();
}


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					
	}
 
function validate() {
	var firstnamea=document.info.txtFirstname.value;
	var lastnamea=document.info.txtLastname.value;
	var usernamea=document.info.txtUsername.value;
	var emailida=document.info.txtEmailid.value;
	var conemailida=document.info.txtConemailid.value;
	var passworda=document.info.txtPassword.value;
	var conpassworda=document.info.txtConpassword.value;
	var veriimagea=document.info.hdnVeriimage.value;
	var verificationcodea=document.info.txtVerificationcode.value;

	if(firstnamea=="") {
		alert("Please enter your First Name");
		return;
	}	
	if(lastnamea=="") {
		alert("Please enter your Last Name");
		return;
	}		
	if(usernamea=="") {
		alert("Please enter your User Name");
		return;
	}
	if(passworda=="") {
		alert("Please enter your Password");
		return;
	}	
	if(conpassworda=="") {
		alert("Please enter your Confirm Password");
		return;
	}
	if(passworda != conpassworda) {
		alert("Password and Confirm Password are not matched.");
		return;
	}
	if(emailida=="") {
		alert("Please enter your Email ID");
		return;
	}
	if (echeck(emailida)==false){
		emailida="";
		document.info.txtemailid.focus();
		return false;
	}
	if(conemailida=="") {
		alert("Please enter your Confirm Email ID");
		return;
	}	
	if (echeck(conemailida)==false){
		conemailida="";
		document.info.txtconemailid.focus();
		return false;
	}
	if(emailida != conemailida) {
		alert("Email ID and Confirm Email ID are not matched.");
		return;
	}
	if(verificationcodea=="") {
		alert("Please enter Verification Code");
		return;
	}
	if(verificationcodea!=veriimagea) {
		alert("Invalid Verification Code. please re-enter");
		return;
	}
	if(document.info.chkIagree.checked != true) {
		alert("You must check for Monica's Fine Foods agreement");
		return;
	}
	
	document.info.action="registersubmit.php";
	document.info.method="POST";
	document.info.submit();	
}

function validateagree(a) {	
	if(a == "chkiagree") {
		if(document.info.chkiagree.checked != true) {
			alert("You must check for Monicas Fine Foods agreement");
			return false;
		} 
                document.info.target="paypal";
                document.info.action="https://www.paypal.com/cgi-bin/webscr";
                document.info.method="post";
                document.info.submit();
	} else if(a == "chkiagree1") {
		if(document.info1.chkiagree1.checked != true) {
			alert("You must check for Monicas Fine Foods agreement");
			return false;
		}
                document.info1.target="paypal";
                document.info1.action="https://www.paypal.com/cgi-bin/webscr";
                document.info1.method="post";
                document.info1.submit();
	} else if(a == "chkiagree2") {
		if(document.info2.chkiagree2.checked != true) {
			alert("You must check for Monicas Fine Foods agreement");
			return false;
		}
                document.info2.target="paypal";
                document.info2.action="https://www.paypal.com/cgi-bin/webscr";
                document.info2.method="post";
                document.info2.submit();
	}
}



var i=0;
var f=1;
function starttimer()
{
	document.getElementById('myimage').style.position="relative";
	document.getElementById('myimage').src="images/"+i+".jpg";
	i=i+1;
	if(i==2) {
		i=0;	
	}
	c=100;
	if(f==1) {
		f++;
		timer=setTimeout("Nexttimer()",5000);
	} else {
		timer=setTimeout("Nexttimer()",0);
	}
}
function stoptimer()
{
clearTimeout(timer);
}
function mouseintimer()
{
	clearTimeout(timer);
}
function mouseouttimer()
{
	if(c==0) {
		document.getElementById('bg').background="images/"+i+".jpg";
		timer=setTimeout("starttimer()",1000);
	} else {
	c=c-1;
	document.getElementById('myimage').style.filter="alpha(opacity="+c+")";
	document.getElementById('bg').background="images/"+i+".jpg";
		timer=setTimeout("Nexttimer()",0);
	}
}
var c=100;
function Nexttimer()
{
	c=c-1;
	document.getElementById('myimage').style.filter="alpha(opacity="+c+")";
	if(c==0) {
		document.getElementById('bg').background="images/"+i+".jpg";
		timer=setTimeout("starttimer()",5000);
	} else {
	document.getElementById('bg').background="images/"+i+".jpg";
		timer=setTimeout("Nexttimer()",0);
	}
}