function valimgfile(t)
{
	if(t.imgfile.value=="")
	{
		alert("Please specify Image file to Upload...");
		t.imgfile.focus();
		return 0;
	}
	strr=t.imgfile.value;
	ln=strr.length;
	s1=strr.substring(ln-4,ln);
	
	if(s1!=".jpg" && s1!=".JPG" && s1!=".gif" && s1!=".GIF" )
	{
		alert("Please specify image files Only - .GIF/.JPG");
		t.imgfile.focus();
		return false;	
	}
	//t.target="_blank";
	//t.action="valxls.asp";
	t.submit();
	return 1;
}

function validatefrm(t,secverify)
{
	var emailpat =/^(\".*\"|[A-Za-z0-9]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9]\w*(\.[A-Za-z0-9]\w*)+)$/;
	var matcharray = t.email.value.match(emailpat);

	if(t.name.value=="")
	{
		alert("Please specify your Name....");
		t.name.focus();
		return 0;
	}
    if (matcharray == null)
      { 
        alert("Invalid E-mail Id specified...");
		t.email.focus();
        return false;
      }
	  if(secverify==1)
	  	{
	Item = t.sectorname.selectedIndex; 
	Result1 = t.sectorname.options[Item].text; 

    if (Result1 == "---- Select ----") 
	{
		alert("Please specify your Sector Name....");
		t.sectorname.focus();
		return false;
	}
	}
	if(secverify==2)
  	{
		if(t.dkeyword.value=="")
		{
			alert("Please specify your desired Keyword....");
			t.dkeyword.focus();
			return 0;
		}
	Item = t.shortcode.selectedIndex; 
	Result1 = t.shortcode.options[Item].text; 

    if (Result1 == "--- Select ---") 
	{
		alert("Please specify Short Code you wish to opt....");
		t.shortcode.focus();
		return false;
	}
	}
	if(secverify==3)
  	{
		if(t.dqty.value=="" || (t.dqty.value>='a' && t.dqty.value<='z') || (t.dqty.value>='A' && t.dqty.value<='Z'))
		{
			alert("Please specify your Numeric desired Bulk SMS Quantity....");
			t.dqty.focus();
			return 0;
		}
		if(t.dcountry.value=="")
		{
			alert("Please specify your desired Bulk sms Target Country....");
			t.dcountry.focus();
			return 0;
		}
	}

	if(t.comments.value=="")
	{
		alert("Please specify your Comments/ Suggestions....");
		t.comments.focus();
		return 0;
	}
	if(t.strCAPTCHA.value=="")
	{
		alert("Please specify Capture Code above - Used to Control Automated E-mail Postings....");
		t.strCAPTCHA.focus();
		return 0;
	}
	  
	t.submit();
	return 1;
}
function validatefrm2(t,secverify)
{
	var emailpat =/^(\".*\"|[A-Za-z0-9]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9]\w*(\.[A-Za-z0-9]\w*)+)$/;
	var matcharray = t.email2.value.match(emailpat);

	if(t.name2.value=="")
	{
		alert("Please specify your Name....");
		t.name2.focus();
		return 0;
	}
    if (matcharray == null)
      { 
        alert("Invalid E-mail Id specified...");
		t.email2.focus();
        return false;
      }
	if(t.comments2.value=="")
	{
		alert("Please specify your Comments/ Suggestions....");
		t.comments2.focus();
		return 0;
	}
	if(t.strCAPTCHA2.value=="")
	{
		alert("Please specify Capture Code above - Used to Control Automated E-mail Postings....");
		t.strCAPTCHA2.focus();
		return 0;
	}
	  
	t.submit();
	return 1;
}

function resetvalue(ffield)
{	
	ffield.value="";
	return 1;
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//email validation
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 to check numeric field
function checknumber(input)
{
	var str = input.value;
	for (var i = 0; i < str.length; i++) 
	{
        	var ch = str.substring(i, i + 1)
	        if ((ch < "0" || "9" < ch) && ch != '.'  && ch!=",") 
			{
			input.value=""
        	alert("Please Enter Numeric Value...");
			input.focus();
		    return false;
	    	}
	}
	return true;
}

function checknumber1(input)
{
	var str = input.value;
	for (var i = 0; i < str.length; i++) 
	{
        	var ch = str.substring(i, i + 1)
	        if ((ch < "0" || "9" < ch) ) 
			{
			input.value=""
        	alert("Please Enter Numeric Value...");
			input.focus();
		    return false;
	    	}
	}
	return true;
}


//validation for phone/mobile
function phnocheck(input)
{
	var str = input.value;
	for (var i = 0; i < str.length; i++) 
	{
        	var ch = str.substring(i, i + 1)
	        if (ch < "0" || "9" < ch) 
			{
			input.value=""
        	alert("Invalid Phone number...");
			input.focus();
		    return false;
	    	}
	}
	return true;
}

function monthdays(mon1,yr)
{
	switch (mon1){	
	case "2":
		if (yr==0)
			mdays=29;
		else
		{
			lp1=yr % 400;
			if (lp1==0)
				mdays=29;
			else
			{
				lp2=yr % 4;
				lp3=yr % 100;
				if ((lp2==0) && (lp3>0))
					mdays=29;
				else
					mdays=28;
			}
		}
		break;
	case "4":	
	case "6":
	case "9":	
	case "11":
		mdays=30;
		break;
	default:
		mdays=31;
		break;
	}
	return mdays;
}	


function chkseldate(days,mon,yr)
{
	md=monthdays(mon,yr);
	if (days>md)
	//	alert(" Invalid");	
		return 0;
	else
	//	alert(" Valid");
		return 1;
}

function ldate(d,m,y)
{
	dd=d.selectedIndex;
	dd=d.options[dd].text;
	mm=m.selectedIndex;
	mm=m.options[mm].text;
	yy=y.selectedIndex;
	yy=y.options[yy].text;
	rt=chkseldate(dd,mm,yy);
	if (rt==0)
	{
		alert("Invalid Date");
		d.focus();
		return 0;
	}
		
}
function rptvalid(frm)
{
	
	
	if (ldate(frm.fromdd,frm.frommm,frm.fromyy)==0)
		return 0;
	if (ldate(frm.todd,frm.tomm,frm.toyy)==0)
		return 0;
	
	dd=frm.fromdd.selectedIndex;
	dd=frm.fromdd.options[dd].text;
	mm=frm.frommm.selectedIndex;
	mm=frm.frommm.options[mm].text;
	yy=frm.fromyy.selectedIndex;
	yy=frm.fromyy.options[yy].text;
	
	dd1=frm.todd.selectedIndex;
	dd1=frm.todd.options[dd1].text;
	mm1=frm.tomm.selectedIndex;
	mm1=frm.tomm.options[mm1].text;
	yy1=frm.toyy.selectedIndex;
	yy1=frm.toyy.options[yy1].text;

	dd=eval(dd);
	mm=eval(mm);
	yy=eval(yy);
	dd1=eval(dd1);
	mm1=eval(mm1);
	yy1=eval(yy1);
	if (yy>yy1)
	{
		alert("From Date is larger than to date");
		frm.fromdd.focus();
		return 0;
	}
	else
	{
		if ((yy==yy1) && (mm>mm1))	
		{
			alert("From Date is larger than to date");
			frm.fromdd.focus();
			return 0;
		}
		else
		{
			if (((yy==yy1) && (mm==mm1)) && (dd>dd1))	
			{
				alert("From Date is larger than to date");
				frm.fromdd.focus();
				return 0;
			}
		}
	}
	frm.submit();
	return 1;
}
//Blank textfield validation
function chkblank(txtval,msg)
{
	if (txtval.value=="")
	{
		alert(msg);
		txtval.focus();
		return 0;
	}
	return true;
}

//validation for selection list
function chkselect(t,msg)
{
	selno = t.selectedIndex; 
	
	selvalue = t.options[selno].value; 
	if (selvalue==0)
	{
		alert(msg);
		t.focus();
		return 0;
	}
	return true;
}

//Validation for shipping details
function validship(f,cflag)
{
	if (chkblank(f.name,"Please specify your name!")==0)
		return 0;
	if (chkblank(f.email,"Please specify your email Id!")==0)
		return 0;
	if (echeck(f.email.value)==false)
		{
			f.email.value="";
			f.email.focus();
			return 0;
		}
	if (cflag==1)
	{
		if (chkblank(f.pass,"Please specify password!")==0)
			return 0;
	}
	if (f.office.value!="")
		if (phnocheck(f.office)==0)
			return 0;
	if (f.mobile.value!="")
		if (phnocheck(f.mobile)==0)
			return 0;
	if (f.zip.value!=0)
	{
		if (checknumber1(f.zip)==0)
			return 0;
		else
		{
			l=f.zip.value;
			llen=l.length;
			if (llen!=6)
			{
				alert("Invalid Zip/Postal Code!");
				f.zip.focus();
				return 0;
			}
		}
	}
	if (cflag==1)
	{
		if (chkblank(f.strCaptcha,"Please specify the code!")==0)
			return 0;
	}
	f.submit();
	return 1;
}

function ship(f)
{
	if (chkblank(f.name,"Please specify your name!")==0)
		return 0;
	if (chkblank(f.address,"Please key in the address of the recipient!")==0)
		return 0;
	if (chkblank(f.city,"City not specified!")==0)
		return 0;
	if (chkblank(f.state,"Please specify the state!")==0)
		return 0;
	if (f.email.value!="")
	{
	if (echeck(f.email.value)==false)
		{
			f.email.value="";
			f.email.focus();
			return 0;
		}
	}
	if (f.mobile.value!="")
		if (phnocheck(f.mobile)==0)
			return 0;
	if (f.zip.value!="")
	{
		if (checknumber1(f.zip)==0)
			return 0;
		else
		{
			l=f.zip.value;
			llen=l.length;
			if (llen!=6)
			{
				alert("Invalid Zip/Postal Code!");
				f.zip.focus();
				return 0;
			}
		}
	}
	if (f.rem.value==1)
	{
		if (chkblank(f.remarks,"Please specify special remarks!")==0)
			return 0;
	}
	f.submit();
	return 1;
}


//validations for user registration
function validreg(f)
{
	if (chkblank(f.name,"Please specify name")==0)
		return 0;
	if (f.phone!="")
		if (phnocheck(f.phone)==0)
			return 0;
	if (chkblank(f.email,"Please specify your emailId")==0)
		return 0;
	if (f.email.value!="")
	{
		if (echeck(f.email.value)==false)
		{
			f.email.value="";
			f.email.focus();
			return 0;
		}
	
	}
	
	f.submit();
	return 1;
}
			
			
// Validation for Successfull Signin form
function validsignin(frm4)
{

   if (frm4.email.value=="") 
   {
      alert("Please specify EmailId ");
	  frm4.email.focus();
	  return 0;
	  
   }
   if (echeck(frm4.email.value)==false){
		frm4.email.value="";
		frm4.email.focus();
		return false;
	
 	}
	if (frm4.pwd.value=="") 
   {
      alert("Please specify Password ");
	  frm4.pwd.focus();
	  return 0;
   }
  
  frm4.submit();
  return 1;
}			

function calamount(cnt)
{
	t1="frmshop.qty" + cnt + ".value";
	t1val=eval(t1);
	t2="frmshop.rt" + cnt + ".value";
	t2val=eval(t2);
	amt=t1val*t2val;
	t3="frmshop.amt" + cnt +".value=amt";
	eval(t3);
	
	//Code to calculate final total
	tot=0;
	titems=frmshop.titems.value;
	for(i=1;i<=titems;i++)
	{
		t="frmshop.amt" + i +".value";
		tgross=eval(t);
		if (tgross!="")
		{
			tgross=parseInt(tgross);
			tot=tot + tgross;
		}	
		
	}
	frmshop.total.value=tot;
}


function convertcurr()
{
	amt=frmshop.htotal.value;
   	var fnam="https://www.ccavenue.com/curConvert_ccav.jsp?mpassAmt=" + amt; 
	window.open(fnam,"CurrencyConverter","resizable=no,toolbar=0,location=0,menubar=0,status=0,height=400,width=500,top=0,left=480,scrollbars=1,titlebar=0");
	
	return 1;
}

function regdetails()
{
	if (form1.chk1.checked)
	{
		form1.name.value=form1.hname.value;
		form1.address.value=form1.hadd.value;
		form1.city.value=form1.hcity.value;
			
		form1.state.value=form1.hstate.value;
		form1.zip.value=form1.hzip.value;
		form1.mobile.value=form1.hmobile.value;
		form1.email.value=form1.hemail.value;
	}
	else
	{
		form1.name.value="";
		form1.address.value="";
		form1.city.value="";
			
		form1.state.value="";
		form1.zip.value="";
		form1.mobile.value="";
		form1.email.value="";
	}
	
}

function validcat(f)
{
	if (chkblank(f.name,"Please specify name for the category")==0)
		return 0;
	if (chkblank(f.description,"Provide detailed description of category")==0)
		return 0;
	if (chkblank(f.imgpath,"Please select image to be displayed for the category! If you do not find a proper image you can upload it first and then select")==0)
		return 0;
		f.target="_parent";
		f.action="categorysave.asp"
	f.submit();
	return 1;
		
}
function birthday()
{
	var fnam="http://ejalgaon.com/events/ejalgaon%20birthday.htm"

	window.open(fnam,"_newwindow","resizable=no,toolbar=0,location=0,menubar=0,status=1,height=600,width=800,,scrollbars=1");

}

function offers()
{
	var fnam="offers/new year special.htm"

	window.open(fnam,"offer","resizable=no,toolbar=0,location=0,menubar=0,status=0,height=300,width=600,,scrollbars=1");

}
function strToZero(anyval) { 
     anyval = ""+anyval 
     if (anyval.substring(0,1) < "0" || anyval.substring(0,1) > "9") { 
          anyval = "0" 
     } 
     return eval(anyval) 
} 

function verifypp()
{
sv=searchopt.sv.value;
ev=searchopt.ev.value;
sv=strToZero(sv);
ev=strToZero(ev);

if(sv==0)
{
alert("Incorrect Value Specified");
searchopt.sv.focus();
return 0;
}
if(ev==0)
{
alert("Incorrect Value Specified");
searchopt.ev.focus();
return 0;
}

searchopt.submit();
}


function openLogo(ClientID)
{
var attributes = 'toolbar=0,location=0,directories=0,status=0, menubar=0,scrollbars=1,resizable=1,width=550,height=600,left=0,top=0';
sealWin=window.open('http://www.ccavenue.com/verifySeal.jsp?ClientID='+ClientID ,'win',attributes);
self.name = 'mainWin';
}

function showimgcat(f)
{
	if (chkblank(f.name,"Please specify name for the category")==0)
		return 0;
	if (chkblank(f.description,"Provide detailed description of category")==0)
		return 0;
		ftype=f.formtype.value;
	window.open('/mgmt/uploadimage.asp?nm='+ f.name.value+ '&p=' + f.catid.value + '&sflag=1&ft=' + ftype,"TransactionHistory","resizable=no,toolbar=0,location=0,menubar=0,status=0,height=150,width=900,top=50,left=400,scrollbars=1,titlebar=0");
	return 1;
}

function showimgitem(f)
{
	if (chkblank(f.name,"Please specify name for the item")==0)
		return 0;
	ftype=f.formtype.value;
	s1=f.ccode.selectedIndex;
	sval=f.ccode.options[s1].value;
	window.open('/mgmt/uploadimage.asp?nm='+ f.name.value+ '&p=' + sval + '&sflag=1&ft=' + ftype,"TransactionHistory","resizable=no,toolbar=0,location=0,menubar=0,status=0,height=150,width=900,top=50,left=400,scrollbars=1,titlebar=0");
	return 1;
}

//validation for e-mail us 
function validatefrm(t)
{

	if(t.name.value=="")
	{
		alert("Please specify your Name....");
		t.name.focus();
		return 0;
	}
	var emailID=t.email;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		t.emailID.focus()
		return false
	}
	
	if (echeck(t.email.value)==false){
		t.email.value=""
		t.email.focus()
		return false
	}

	if(t.comments.value=="")
	{
		alert("Please specify your Comments/ Suggestions....");
		t.comments.focus();
		return 0;
	}
	if(t.strCAPTCHA.value=="")
	{
		alert("Please specify capture code shown in image above - Used for controlling automated harvesting....");
		t.strCAPTCHA.focus();
		return 0;
	}
	  
	t.submit();
	return 1;
}

function changep(f)
{
	if (chkblank(f.opwd,"Please specify your old password!")==0)
		return 0;
	if (chkblank(f.npwd,"Please specify new password!")==0)
		return 0;
	if (chkblank(f.cpwd,"Please confirm your password by retyping it!")==0)
		return 0;
	if (f.npwd.value!=f.cpwd.value)
		{
			alert("Your new password does not match with the confirm password. Make sure they are same!!!")
			f.npwd.focus();
			return 0;
		}
		f.submit();
		return 1;
	
}


//recommend to a friend
function valfrm(t)
{
	if (t.sname.value == "")
	{
		alert("Name is not a blank field");
		t.sname.focus();
		return false;
	}
	if (echeck(t.semail.value)==false)
		{
			t.semail.value="";
			t.semail.focus();
			return 0;
		}
	if (echeck(t.femail.value)==false)
		{
			t.femail.value="";
			t.femail.focus();
			return 0;
		}
	if (t.semail.value == t.femail.value)
	{
		alert("Thank you for taking time to promote EJalgaon.com - Please specify other than your own E-mail ID to send this message...");
		t.femail.focus();
		return false;
	}
	if (t.msg.value == "")
	{
		alert("Please specify your Message for Friend");
		t.msg.focus();
		return false;
	}
	if (t.strCAPTCHA.value == "")
	{
		alert("Please type capture code specified above... This is used to control automated postings...");
		t.strCAPTCHA.focus();
		return false;
	}
		t.submit();
		return 1;

}

function sitems(f)
{
	f.action="itemedit.asp";
	f.submit();
	return 1;
}

function nextdir(f)
{
	sflag=f.slogin.value;
	if (sflag==1)
	{
		f.action="/account/shippinginfo.asp";
		f.submit();
	}
	else
	{
		f.action="/asp/checkout.asp";
		f.submit();
	}

}

function cancelorder(orderid,frm)
{
	pppp = confirm("Are you sure to delete this order# " + orderid + " from your orders history?");
	if(pppp==1) 
	{
		frm.action="/account/deleteorder.asp";
		frm.submit();
	}
	return 1;
}