// JavaScript Document
//////////////// GLOBAL VALIDATION STATRS HERE /////////////////////////////////////////////////
//////////////// PLEASE BACK A COPY BEFORE EDITING /////////////////////////////////////////////
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	
	function ClearValue(field, strCheck,strCheck2)
	{
		if(field.value == strCheck || field.value == strCheck2)
		field.value = "";
	}
	function Repopulate(field, strCheck,strCheck2)
	{
		if(field.value == "")
		field.value = strCheck;
	}
	
	function name_validation(f,name,type,mandatory)
	{
		if(mandatory=="yes")
		{	
			if(name.trim()=="" || name=="Enter name")
			{
				if(type=="alert"){
					alert("Please enter name.");
				}else{
					document.getElementById('alert').innerHTML = "Please enter name.";
				}
				f.name.focus();
				return false;
			}
			return true;
		}
	}
	
	function email_validation(f,email,type,mandatory)
	{
		if (!reg1.test(email) && reg2.test(email))
		{}
		else
		{
			if(type=="alert"){
				alert("\"" + email + "\" is an invalid e-mail!"); // this is also optional
			}else{
				document.getElementById('alert').innerHTML = "Please enter valid email.";
			}
			
			f.email.focus();
			f.email.select();
			return false;
		}
		return true;
	}
	function telephone_validation(f,phoneno,type,mandatory)
	{
		var checkOK = "0123456789--,+() \t\r\n\f";
		var checkStr = phoneno;
		var allValid = true;
		if(mandatory=="yes")
		{
			if(phoneno.trim()==""){
				if(type=="alert"){
					alert("Please enter Telephone No.");
				}else{
					document.getElementById('alert').innerHTML = "Please enter Telephone No.";
				}
				f.phoneno.focus();
				return false;
			}
		}

		for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
			break;
			if (j == checkOK.length)
			{
				allValid = false;
				break;
			}
		}
		
		if (!allValid)
		{
			if(type=="alert"){
				alert("Please enter valid Telephone No.");
			}else{
				document.getElementById('alert').innerHTML = "Please enter valid Telephone No.";
			}
			f.phoneno.focus();
			f.phoneno.select();
			return false;
		}
		return true;
	}
	function mobile_validation(f,mobile,type,mandatory)
	{
		var checkOK = "0123456789--,+() \t\r\n\f";
		var checkStr = mobile;
		var allValid = true;
		if(mandatory=="yes")
		{
			if(mobile.trim()==""){
				if(type=="alert"){
					alert("Please enter Mobile No.");
				}else{
					document.getElementById('alert').innerHTML = "Please enter valid mobile no.";
				}
				f.mobile.focus();
				return false;
			}
		}

		for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
			break;
			if (j == checkOK.length)
			{
				allValid = false;
				break;
			}
		}
		
		if (!allValid)
		{
			if(type=="alert"){
				alert("Please enter valid Mobile No.");
			}else{
				document.getElementById('alert').innerHTML = "Please enter valid mobile no.";
			}
			f.mobile.focus();
			f.mobile.select();
			return false;
		}
		return true;
	}
	function country_validation(f,country,type,mandatory)
	{
		if(mandatory=="yes")
		{
			if(country=="0"){
				if(type=="alert"){
					alert("Please select Country.");
				}else{
					document.getElementById('alert').innerHTML = "Please select Country.";
				}
				f.country.focus();
				return false;	
			}
		}
		return true;
	}
	function captcha_validation(f,captcha,type,mandatory)
	{
		if(mandatory=="yes")
		{
			if(captcha==""){
				if(type=="alert"){
					alert("Please enter Verification Code.");
				}else{
					document.getElementById('alert').innerHTML = "Please enter Verification Code.";
				}
				f.captchafield.focus();
				return false;
			}
		}
		return true;
	}
	function query_validation(f,query,type,mandatory)
	{
		if(mandatory=="yes")
		{
			if(query.trim()==""){
				if(type=="alert"){
					alert("Please enter your Queries.");
				}else{
					document.getElementById('alert').innerHTML = "Please enter your Queries.";
				}
				f.query.focus();
				return false;
			}
		}
		return true;
	}
	function remarks_validation(f,remarks,type,mandatory)
	{
		if(mandatory=="yes")
		{
			if(remarks.trim()==""){
				if(type=="alert"){
					alert("Please enter your Remarks.");
				}else{
					document.getElementById('alert').innerHTML = "Please enter your Remarks.";
				}
				f.remarks.focus();
				return false;
			}
		}
		return true;
	}
	function state_validation(f,state,type,mandatory)
	{
		if(mandatory=="yes")
		{
			if(state.trim()==""){
				if(type=="alert"){
					alert("Please enter your State.");
				}else{
					document.getElementById('alert').innerHTML = "Please enter your State.";
				}
				f.state.focus();
				return false;
			}
		}
		return true;
	}
//////////////// GLOBAL VALIDATION STATRS HERE /////////////////////////////////////////////////
//////////////// HOME PAGE DISTRUBUTORS FORM STARTS HERE ///////////////////////////////////////
function chk_dealers()
{
        var f = document.dealers;
        var name =f.name.value;
        var email=f.email.value;
        var mobile=f.mobile.value;
        if(name_validation(f,name,"noalert","yes") && email_validation(f,email,"noalert","yes") && mobile_validation(f,mobile,"noalert","yes"))
                return true;
                else
                return false;
}
//////////////// HOME PAGE DISTRUBUTORS FORM ENDS HERE //////////////////////////////////////////
//////////////// DISTRIBUTORS PAGE FORM STARTS HERE //////////////////////////////////////////
function discheck()
{
	var f=document.distributors;
	var name=f.name.value;
	var email = f.email.value;
	var phoneno = f.phoneno.value;
	var mobile = f.mobile.value;
	var country = f.country.value;
	var captcha=f.captchafield.value;
	if(name_validation(f,name,"alert","yes") && email_validation(f,email,"alert","yes") && telephone_validation(f,phoneno,"alert","yes") && mobile_validation(f,mobile,"alert","yes") && country_validation(f,country,"alert","yes") && captcha_validation(f,captcha,"alert","yes"))
	return true;
	else
	return false;
}
//////////////// DISTRIBUTORS PAGE FORM ENDS HERE //////////////////////////////////////////
//////////////// ASK EXPERT PAGE FORM STARTS HERE //////////////////////////////////////////
function check()
{
	var f=document.askexpert;
	var name=f.name.value;
	var email = f.email.value;
	var mobile = f.mobile.value;
	var country = f.country.value;
	var query = f.query.value;
	var captcha=f.captchafield.value;
	if(name_validation(f,name,"alert","yes") && email_validation(f,email,"alert","yes") && mobile_validation(f,mobile,"alert","yes") && country_validation(f,country,"alert","yes") && query_validation(f,query,"alert","yes") && captcha_validation(f,captcha,"alert","yes"))
	return true;
	else
	return false;

}
//////////////// ASK EXPERT PAGE FORM ENDS HERE //////////////////////////////////////////
//////////////// CONTACT US PAGE FORM STARTS HERE //////////////////////////////////////////
function contactcheck()
{
	var f=document.contactus;
	var name=f.name.value;
        var state=f.state.value;
	var email = f.email.value;
        var phoneno = f.phoneno.value;
	var mobile = f.mobile.value;
	var country = f.country.value;
	var remarks = f.remarks.value;
	var captcha=f.captchafield.value;
	if(name_validation(f,name,"alert","yes") && state_validation(f,state,"alert","yes") && country_validation(f,country,"alert","yes") && email_validation(f,email,"alert","yes") && telephone_validation(f,phoneno,"alert","no") && mobile_validation(f,mobile,"alert","no") && remarks_validation(f,remarks,"alert","yes") && captcha_validation(f,captcha,"alert","yes"))
	return true;
	else
	return false;

}
//////////////// CONTACT US PAGE FORM ENDS HERE //////////////////////////////////////////
// JavaScript Document
function checkName(f)
{
	var name=f.name.value;
	if(name=="") {
		alert("Name should not be Blank.");
		f.name.focus();
		f.name.select();
		return false;
	}
	if(name.substring(0,1)==" "|| !isNaN(name.substring(0,1)))
	{
		alert("Name cannot start with Blank Space or Digits.");
		f.name.select();
		return false;
	}
	return true;
 }
 
 // email
function checkEmail(f)
{
	var email=f.email.value;
    var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
    var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
    if (!reg1.test(email) && reg2.test(email))
    {}
    else
    {
        alert("\"" + email + "\" is an invalid e-mail!"); // this is also optional
        f.email.focus();
        f.email.select();
        return false;
    }
	return true;
}

function checkCountry(f){
	
	var country=f.country.value;
	if(f.country.value=="0")
	{
		alert("Please select Country.");
		f.country.focus();
		return false;
	}	
	return true;
}
function checkPhoneNo(f)
{
    var checkOK = "0123456789--,+() \t\r\n\f";
    var checkStr = f.phone.value;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
                break;
             if (j == checkOK.length)
            {
              allValid = false;
              break;
            }
    }
    if (!allValid)
    {
        alert("Please enter valid phone number.");
        f.phone.focus();
        f.phone.select();
        return (false);
    }
	return true;
}
function checkMobileNo(f)
{
    var checkOK = "0123456789--,+() \t\r\n\f";
    var checkStr = f.mobile.value;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
                break;
             if (j == checkOK.length)
            {
              allValid = false;
              break;
            }
    }
    if (!allValid)
    {
        alert("Please enter valid mobile number.");
        f.mobile.focus();
        f.mobile.select();
        return (false);
    }
	return true;
}

function checkMaritalStatus(f)
{
       
	var maritalstatus=f.maritalstatus.value;
	if(maritalstatus=="")
	{
		alert("Select Marital Status.");
		f.maritalstatus.focus();
		return false;
	}
	
	return true;
}
function checkAgeGroup(f)
{
       
	var agegroup=f.agegroup.value;
	if(agegroup=="")
	{
		alert("Please Select Age Group.");
		f.agegroup.focus();
		return false;
	}
	
	return true;
}

function checkGender(f)
{
       
	var gender=f.gender.value;
	if(gender=="")
	{
		alert("Please Select Gender.");
		f.gender.focus();
		return false;
	}
	
	return true;
}
function answer1(f)
{
 
	var l=f.q1.length;
	var s=0;
	for(i=0;i<l;i++)
	{
		if(f.q1[i].checked==true)
		   {
				s=1;
				break;
		   }
	}
	if(s==0)
	{
		alert("please choose your answer for question 1.");
		return false;
	}
   return true;
   
}

function answeru2(f)
{
 
     var l=f.q2.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q2[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for question 2.");
                            return false;
                          }
       return true;
   
}

function answeru3(f)
{
 
     var l=f.q3.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q3[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for question 3.");
                            return false;
                          }
       return true;
   
}

function answeru4(f)
{
 
     var l=f.q4.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q4[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for question 4.");
                            return false;
                          }
       return true;
   
}

function answeru5(f)
{
 
     var l=f.q5.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q5[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for question 5.");
                            return false;
                          }
       return true;
   
}

function answeru6(f)
{
 
     var l=f.q6.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q6[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for question 6.");
                            return false;
                          }
       return true;
   
}

function answeru7a(f)
{
 
     var l=f.q7a.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q7a[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for question 7.");
                            return false;
                          }
       return true;
   
}

function answeru7b(f)
{
 
     var l=f.q7b.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q7b[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for question 7.");
                            return false;
                          }
       return true;
   
}

function answeru8(f)
{
 
     var l=f.q8.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q8[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for question 8.");
                            return false;
                          }
       return true;
   
}
function checkTextu(f)
{
   var text=f.q9_text.value;
   
   if(text==0)
   {
       alert("Please give your answer for Question 9.");
       f.q9_text.select();
       return false;  
   }
  return true;
}

function answeru10(f)
{
 
     var l=f.q10.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q10[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for question 10.");
                            return false;
                          }
       return true;
   
}
function answerq11a(f)
{
 
     var l=f.q11a.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q11a[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for every question of 11.");
                            return false;
                          }
       return true;
   
}
function answerq11b(f)
{
 
     var l=f.q11b.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q11b[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for every question of 11.");
                            return false;
                          }
       return true;
   
}
function answerq11c(f)
{
 
     var l=f.q11c.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q11c[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for every question of 11.");
                            return false;
                          }
       return true;
   
}
function answerq11d(f)
{
 
     var l=f.q11d.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q11d[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for every question of 11.");
                            return false;
                          }
       return true;
   
}
function answerq11e(f)
{
 
     var l=f.q11e.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q11e[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for every question of 11.");
                            return false;
                          }
       return true;
   
}
function answerq11f(f)
{
 
     var l=f.q11f.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q11f[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for every question of 11.");
                            return false;
                          }
       return true;
   
}
function answerq11g(f)
{
 
     var l=f.q11g.length;
                        var s=0;
                         for(i=0;i<l;i++)
                         {
                            if(f.q11g[i].checked==true)
                               {
                                    s=1;
                                    break;
                               }
                         }
                         if(s==0)
                          {
                            alert("please choose your answer for every question of 11.");
                            return false;
                          }
       return true;
   
}
function checkCapcha(f)
{
	var captchafield=f.captchafield.value;
	if(captchafield=="")
	{
		alert("Please enter Verification Code");
		f.captchafield.focus();
		f.captchafield.select();
		return false;
	}
	return true;
}




//contact

//feedback
	function disable1()
	{
		var f =document.feedbackform;
		f.q2_text.disabled=true;
		f.q2_text.style.background = '#eeeeee';
		f.q2_text.style.color = '#cccccc';
	}
	function disable2()
	{
		var f =document.feedbackform;
		f.q3_text.disabled=true;
		f.q3_text.style.background = '#eeeeee';
		f.q3_text.style.color = '#cccccc';
	}
	function disable3()
	{
		var f =document.feedbackform;
		f.q10_text.disabled=true;
		f.q10_text.style.background = '#eeeeee';
		f.q10_text.style.color = '#cccccc';
	}
	function abled1()
	{
		var f =document.feedbackform;
		f.q2_text.disabled=false;
		f.q2_text.style.background = '';
		f.q2_text.style.color = '';
	}
	function abled2()
	{
		var f =document.feedbackform;
		f.q3_text.disabled=false;
		f.q3_text.style.background = '';
		f.q3_text.style.color = '';
	}
	function abled3()
	{
		var f =document.feedbackform;
		f.q10_text.disabled=false;
		f.q10_text.style.background = '';
		f.q10_text.style.color = '';
	}
	function validate()
	{
		var f=document.feedbackform;
		if(checkName(f) && checkEmail(f) && checkCountry(f) && checkPhoneNo(f) && checkMobileNo(f) && checkAgeGroup(f) && checkGender(f) && checkMaritalStatus(f))
		{
			if(checkCapcha(f))
			return true;
			else
			return false;
		}
		else
		{
			return false;
		} 
	}
	
		
	function chainForm(f)
	{
		var email1=f.email1.value;
		var email2=f.email2.value;
		var email3=f.email3.value;
		var email4=f.email4.value;
		var email5=f.email5.value;
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
		
		if(email1=="" && email2=="" && email3=="" && email4=="" && email5==""){
			alert("Please suggest atlest one friend.");
			f.email1.focus();
			f.email1.select();
			return false;
		}
		if(email1!="" && email2!=""){
		if(email1==email2){
			alert("1st and 2 nd friend address should not be same");
			f.email2.focus();
			return false;
		}
		}
		
		if(email2!="" && email3!=""){
		if(email2==email3){
			alert("2nd and 3rd friend email address should not be same");
			f.email3.focus();
			return false;   			
		}
		}
		if(email3!="" && email4!=""){
		if(email3==email4){
			alert("3rd and 4th friend email address should not be same");
			f.email4.focus();
			return false; 
	    }
		}
		if(email4!="" && email5!=""){
		if(email4==email5){
			alert("4th and 5th friend email address should not be same");
			f.email4.focus();
			return false; 
	    }
		}
		if(email2!="" && email4!=""){
		if(email2==email4){
			alert("2nd and 4th friend email address should not be same");
			f.email2.focus();
			return false; 
	    }
		}
		if(email2!="" && email5!=""){
		if(email2==email5){
			alert("2nd and 5th friend email address should not be same");
			f.email5.focus();
			return false; 
	    }
		}
		if(email1!="" && email4!=""){
		if(email1==email4){
			alert("1st and 4th friend email address should not be same");
			f.email1.focus();
			return false; 
	    }
		}
		if(email3!="" && email5!=""){
		if(email3==email5){
			alert("3rd and 5th friend email address should not be same");
			f.email3.focus();
			return false; 
	    }
		}
		if(email3!="" && email4!=""){
		if(email3==email4){
			alert("3rd and 4th friend email address should not be same");
			f.email3.focus();
			return false; 
	    }
		}
		if(email1!="" && email5!=""){
		if(email1==email5){
			alert("1st and 5th friend email address should not be same");
			f.email1.focus();
			return false; 
	    }
		}
		if(email1!="" && email3!=""){
		if(email1==email3){
			alert("1st and 3rd friend email address should not be same");
			f.email1.focus();
			return false; 
	    }
		}
		if(email1!=""){
			if (!reg1.test(email1) && reg2.test(email1))
			{}
			else
			{
				alert("\"" + email1 + "\" is an invalid e-mail!"); // this is also optional
				f.email1.focus();
				f.email1.select();
				return false;
			}
		}
		
		if(email2!=""){
			if (!reg1.test(email2) && reg2.test(email2))
			{}
			else
			{
				alert("\"" + email2 + "\" is an invalid e-mail!"); // this is also optional
				f.email2.focus();
				f.email2.select();
				return false;
			}
		}
		if(email3!=""){
			if (!reg1.test(email3) && reg2.test(email3))
			{}
			else
			{
				alert("\"" + email3 + "\" is an invalid e-mail!"); // this is also optional
				f.email3.focus();
				f.email3.select();
				return false;
			}
		}
		if(email4!=""){
			if (!reg1.test(email4) && reg2.test(email4))
			{}
			else
			{
				alert("\"" + email4 + "\" is an invalid e-mail!"); // this is also optional
				f.email4.focus();
				f.email4.select();
				return false;
			}
		}
		if(email5!=""){
			if (!reg1.test(email5) && reg2.test(email5))
			{}
			else
			{
				alert("\"" + email5 + "\" is an invalid e-mail!"); // this is also optional
				f.email5.focus();
				f.email5.select();
				return false;
			}
		}
		if(email1!=""){
			if (!reg1.test(email1) && reg2.test(email1))
			{}
			else
			{
				alert("\"" + email1 + "\" is an invalid e-mail!"); // this is also optional
				f.email1.focus();
				f.email1.select();
				return false;
			}
		}
			return true;
	}
	
		