/* Jalgaon IcaI.org
    Author - Umesh B. Sethia, Team SANTRONIX */

function valsearch(t)
{
	if(t.search.value=="")
	{
		alert("Please specify Search Text...");
		t.search.focus();
		return false;
	}
	
	t.action="/asp/membersearch.asp";
	t.submit();
	return true;
}

function valuprofile(t)
{
	if(t.memno.value=="")
	{
		alert("Please specify your Membership Number...");
		t.memno.focus();
		return false;
	}
	
	if(t.birthdate.value=="")
	{
		alert("Please specify your Birth Date...");
		t.birthdate.focus();
		return false;
	}

	t.action="/register/default.asp";
	t.submit();
	return true;
}

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;
	}
	  
	t.submit();
	return 1;
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function valit(t)
{
	if(t.memno.value=="")
	{	
		alert("Please specify your Membership Number...");
		t.memno.focus();
		return 0;
	}

	Item = t.initials.selectedIndex; 
	Result1 = t.initials.options[Item].text; 
    if (Result1 == "--- Specify ---") 
	{
		alert("Please specify your Initials....");
		t.initials.focus();
		return false;
	}

	if(t.name.value=="")
	{	
		alert("Please specify your Name...");
		t.name.focus();
		return 0;
	}
	 Item = t.dd.selectedIndex; 
	Result = t.dd.options[Item].text; 

    if (Result == "DD") 
	{
		alert("Please specify your Birth Date");
		t.dd.focus();
		return false;
	}
	 Item = t.mm.selectedIndex; 
	Result = t.mm.options[Item].text; 

    if (Result == "MM") 
	{
		alert("Please specify your Birth Month...");
		t.mm.focus();
		return false;
	}
	 Item = t.yy.selectedIndex; 
	Result = t.yy.options[Item].text; 

    if (Result == "YYYY") 
	{
		alert("Please specify your Birth Year");
		t.yy.focus();
		return false;
	}

	Item = t.bloodgroup.selectedIndex; 
	Result = t.bloodgroup.options[Item].text; 

    if (Result == "-Specify-") 
	{
		alert("Please specify your Blood Group...");
		t.bloodgroup.focus();
		return false;
	}

	if(t.officeaddress.value=="")
	{	
		alert("Please specify your detailed Office/ Work Address...");
		t.officeaddress.focus();
		return 0;
	}
	if(t.residenceaddress.value=="")
	{	
		alert("Please specify your detailed Residence Address...");
		t.residenceaddress.focus();
		return 0;
	}

	if(t.mobile.value=="" && t.resi.value=="" && t.office.value=="")
	{	
		alert("Please specify at least one contact Number - Mobile/ Residence/ Office");
		t.mobile.focus();
		return 0;
	}

	emailID=t.email;
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.focus()
		return false
	}

	/*
	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 (matcharray == null)
    { 
		k=1;
        alert("Invalid E-mail Id");
		t.email.focus();
        return false;
    }

	*/
		strr=t.photo.value;
		ln=strr.length;
		s1=strr.substring(ln-4,ln);

		if(ln>0)
		{
			if(s1!=".jpg" && s1!=".jpeg" && s1!=".JPG" && s1!=".JPEG" && s1!=".jpg")
			{
				alert("File Name Extension must be .jpg, .jpeg...");
				t.photo.focus();
				return false;	
			}
		}

t.submit();
return 1;
}

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 photoview(pname)
{
	vinfo="viewer.asp?f="+pname;
	window.open(vinfo,"Photo","resizable=yes,toolbar=0,location=0,menubar=0,status=0,height=500 ,top=220,left=250,width=830,,scrollbars=0");	
}
