// JavaScript Document


function validate_editprofile ()
{ 
    $("#inputFNameLabel").removeClass("error");
    $("#inputLNameLabel").removeClass("error");
    $("#inputCountryLabel").removeClass("error");
    $("#inputIndustryLabel").removeClass("error");
    $("#inputDesignationLabel").removeClass("error");
    $("#inputOrgznLabel").removeClass("error");
    $("#inputContactCtryLabel").removeClass("error");
    $("#inputContactNoLabel").removeClass("error");
    $("#emailFormatLabel").removeClass("error");
	$("#inputContactTypeLabel").removeClass("error");

    valid = true;
    strGenericError = "Please complete fields marked in red.";
    strErrorMessage = "";
                
    var firstname = document.getElementById("inputFname");
    var lastname = document.getElementById("inputLname");
    var country = document.getElementById("inputCountry");
    var industry = document.getElementById("inputIndustry");
    var organisation = document.getElementById("inputOrgzn");
         
    var biznumber = document.getElementById("inputContactNo");
    var bizcountrycode = document.getElementById("inputContactCtry");
    var bizareacode = document.getElementById("inputContactArea");
    var inputContactType = document.getElementById("inputContactType");
    var inputDesignation = document.getElementById("inputDesignation");
    var surveyInterest = document.getElementById("surveyInterest");

	var counter = 0;

                
    if (firstname.value == "" || firstname == null) {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputFNameLabel").addClass("error");
                firstname.focus();
                //return valid;
				counter++;
    }

    if (lastname.value == "" || lastname == null) {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputLNameLabel").addClass("error");
                lastname.focus();
                //return valid;
				counter++;
    }
    

    if (country.value == "0" || country == null || country.value == "") {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputCountryLabel").addClass("error");
                country.focus();
                //return valid;
				counter++;
    }

    if (industry.value == "0" ||industry == null || industry.value == "") {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputIndustryLabel").addClass("error");
                industry.focus();
                //return valid;
				counter++;
    }

    if (inputDesignation.value == "0" || inputDesignation == null || inputDesignation.value == "") {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputDesignationLabel").addClass("error");
                inputDesignation.focus();
                //return valid;
				counter++;
    }

    if (organisation == null || organisation.value == "") {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputOrgznLabel").addClass("error");
                organisation.focus();
                return valid;
				counter++;
    }

    if (( bizcountrycode == null || bizcountrycode.value == "")  )  {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputContactCtryLabel").addClass("error");
                bizcountrycode.focus();
                //return valid;
				counter++;
    }
    else {

                if (isNaN(bizcountrycode.value)) {
                strErrorMessage += "Please enter only numbers for country codes"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputContactCtryLabel").addClass("error");
                bizcountrycode.focus();
                //return valid;
				counter++;
                }
    }

    if (( bizareacode != null && bizareacode.value != "")  )  {
                if (isNaN(bizareacode.value)) {
                                strErrorMessage += "Please enter only numbers for area codes"; 
                                valid = false;
                                //alert (strErrorMessage);
								$("#inputContactAreaLabel").addClass("error");
                                bizareacode.focus();
                                //return valid;
								counter++;
                }
    }

    if (( biznumber == null || biznumber.value == "")  )  {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputContactNoLabel").addClass("error");
                biznumber.focus();
                //return valid;
				counter++;
    }

    if (inputContactType.value == "0" || inputContactType == null ||inputContactType.value == "") {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputContactTypeLabel").addClass("error");
                inputContactType.focus();
                //return valid;
				counter++;
    }


	
	if(counter>1){
		alert(strGenericError);
	}
	else if(counter==1){
		alert(strErrorMessage);
	}


    return valid;
}



function validate_siform6 ()
{ 
    $("#inputEmailLabel").removeClass("error");
    $("#passwordLabel").removeClass("error");

    	valid = true;
    	//strErrorMessage = "The following required fields were incomplete or invalid:\n\n";
   	strErrorMessage = "";
	
	var email = document.getElementById("unsub_email");
	var password = document.getElementById("unsub_password");
	var unsubscribe1 = document.getElementById("unsubscribe1").checked;
	var unsubscribe2 = document.getElementById("unsubscribe2").checked;
	var unsubscribe3 = document.getElementById("unsubscribe3").checked;
	var unsubscribe4 = document.getElementById("unsubscribe4").checked;
	var unsubscribe5 = document.getElementById("unsubscribe5").checked;
	var inputUnsub4 = document.getElementById("inputUnsub4");
	var inputUnsub5 = document.getElementById("inputUnsub5");


	if ( (email.value == "") || email == null) {
                strErrorMessage += "Email not provided or is incomplete or invalid"; 
                valid = false;
                alert (strErrorMessage);
				$("#inputEmailLabel").addClass("error");
                email.focus();
                return valid;
    	}

	if(password.value == "" || password.value.length < 4 || password.value.length > 10) {
                strErrorMessage += "Password should be between 4 to 10 characters consist of alphanumerical only";
                valid = false;
                alert (strErrorMessage);
				$("#passwordLabel").addClass("error");
                password.focus();
                return valid;

    	}

	if (unsubscribe1 || unsubscribe2 || unsubscribe3 || unsubscribe4 || unsubscribe5){
		;
	}
	else{
		strErrorMessage += "Please check at least one of the boxes.";
		valid = false;
		alert (strErrorMessage);
                unsubscribe1.focus();
                return valid;
	}

	
	//alert(inputUnsub4.value);
	//alert(inputUnsub5.value);

	return true;
}




function validate_siform5 ()
{ 
    $("#passwordLabel").removeClass("error");
    $("#password_confirmLabel").removeClass("error");

    	valid = true;
    	//strErrorMessage = "The following required fields were incomplete or invalid:\n\n";
	strErrorMessage = "";
	
	var hiddenpassword = document.getElementById("hiddenpassword");
	var oldpassword = document.getElementById("inputOldPassword");
	var password = document.getElementById("inputNewPassword");
	var cpassword = document.getElementById("inputCPassword");
	

	if(oldpassword.value == "" || oldpassword.value.length < 4 || oldpassword.value.length > 10){
		strErrorMessage += "Password should be between 4 to 10 characters consist of alphanumerical only";
		valid = false;
		alert (strErrorMessage);
                oldpassword.focus();
                return valid;
	}
	else if (oldpassword.value!=hiddenpassword.value){
		strErrorMessage += "Invalid old password";
		valid = false;
		alert (strErrorMessage);
                oldpassword.focus();
                return valid;
	}


	if(password.value == "") {
                strErrorMessage += "Password should be between 4 to 10 characters consist of alphanumerical only";
                valid = false;
                alert (strErrorMessage);
				$("#passwordLabel").addClass("error");
                password.focus();
                return valid;

	    } else {
	                if(password.value.length < 4 || password.value.length > 10) {
	                                strErrorMessage += "Password should be between 4 to 10 characters consist of alphanumerical only";
	                                valid = false;
	                                alert (strErrorMessage);
									$("#passwordLabel").addClass("error");
	                                password.focus();
	                                return valid;
	                } 
	                else {
	                                if(cpassword.value == "") {
	                                                strErrorMessage += "Please re-enter password";
	                                                valid = false;
	                                                alert (strErrorMessage);
													$("#password_confirmLabel").addClass("error");
	                                                cpassword.focus();
	                                                return valid;
	                                
	                                }
	                        else {
	                                                if(password.value != cpassword.value) {
	                                                                strErrorMessage += "Password does not match";
	                                                                valid = false;
	                                                                alert (strErrorMessage);
																	$("#password_confirmLabel").addClass("error");
	                                                                cpassword.focus();
	                                                                return valid;
	                                                }
	                                }
	                }
	    }


	
    return true;
}




function validate_feedbackform ()
{

    valid = true;
    strErrorMessage = "The following required fields were incomplete or invalid:\n\n";
	
	var title = document.getElementById("inputTitle");
    var firstname = document.getElementById("inputFname");
    var lastname = document.getElementById("inputLname");
    var email = document.getElementById("inputEmail");
    var country = document.getElementById("inputCountry");
    var industry = document.getElementById("inputIndustry");
    var ecategory = document.getElementById("inputEcategory");
	var customindustry = document.getElementById("inputCustomIndustry");
	var customcategory = document.getElementById("inputCustomCategory");
	var mobilectry = document.getElementById("inputMobileCtry");
	var mobilearea = document.getElementById("inputMobileArea");
	var mobileno = document.getElementById("inputMobileNo");
	var state = document.getElementById("inputState");
	var businessctry = document.getElementById("inputBusinessCtry");
	var businessarea = document.getElementById("inputBusinessArea");
	var businessno = document.getElementById("inputBusinessNo");
    
	     
	if (title.value == "0" || title == null || title.value == "")
	  {
      strErrorMessage += "- Title not selected.\n"; 
      valid = false;
    }
	if (firstname.value == "" || firstname == null || isInteger(firstname.value))
	  {
      strErrorMessage += "- First name not provided or is in the incorrect format.\n"; 
      valid = false;
    }
    if (lastname.value == "" || lastname == null || isInteger(lastname.value))
	  {
      strErrorMessage += "- Last name not provided or is in the incorrect format.\n"; 
      valid = false;
    }
    if ( (checkEmail(email.value)==false) || email == null || !check_email2(email.value))
	  {
      strErrorMessage += "- Email not provided or is in the incorrect format.\n"; 
      valid = false;
    }
	if(state != null && state.value != "" && isInteger(state.value))
	{
      strErrorMessage += "- State is in incorrect format.\n"; 
      valid = false;
	}
    if (country.value == "0" || country == null || country.value == "")
	  {
      strErrorMessage += "- Country not selected.\n"; 
      valid = false;
    }
    if (industry.value == "0" || industry == null || industry.value == "")
	  {
      strErrorMessage += "- Industry not selected.\n"; 
      valid = false;
    }
	if (industry.value == "-1" && (customindustry.value == "" || customindustry == null)){
		strErrorMessage += "- Other Industry not provided.\n"; 
      	valid = false;
	}
    if (ecategory.value == "0" || ecategory == null || ecategory.value == "")
	  {
      strErrorMessage += "- Enquiry category not selected.\n"; 
      valid = false;
    }
    if (ecategory.value == "-1" && (customcategory.value == "" || customcategory == null)){
		strErrorMessage += "- Other Enquiry category not provided.\n"; 
      	valid = false;
	}
	if(mobilectry != null && mobilectry.value != "")
	{
		if(!isInteger(mobilectry.value))
		{
			strErrorMessage += "- Mobile No Country is in incorrect format.\n"; 
      		valid = false;
		}
	}
	if(mobilearea != null && mobilearea.value != "")
	{
		if(!isInteger(mobilearea.value))
		{
			strErrorMessage += "- Mobile No Area is in incorrect format.\n"; 
      		valid = false;
		}
	}
	if(mobileno != null && mobileno.value != "")
	{
		if(!isInteger(mobileno.value))
		{
			strErrorMessage += "- Mobile No is in incorrect format.\n"; 
      		valid = false;
		}
	}
	if(businessctry != null && businessctry.value != "")
	{
		if(!isInteger(businessctry.value))
		{
			strErrorMessage += "- Business No Country is in incorrect format.\n"; 
      		valid = false;
		}
	}
	if(businessarea != null && businessarea.value != "")
	{
		if(!isInteger(businessarea.value))
		{
			strErrorMessage += "- Business No Area is in incorrect format.\n"; 
      		valid = false;
		}
	}
	if(businessno != null && businessno.value != "")
	{
		if(!isInteger(businessno.value))
		{
			strErrorMessage += "- Business No is in incorrect format.\n"; 
      		valid = false;
		}
	}

    if (!valid)
    {
    alert (strErrorMessage);
	return false;
    }else{
		 //submitFeedback();
return true;
		
		}    
}
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}
function checkEmail(nr_emailStr)
{	
   

//	nr_emailStr = eval(nr_emailStr);
	var nr_emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=nr_emailStr.match(nr_emailPat)
	if (matchArray==null) {
		return false;
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
		return false;
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				return false;
			}
		}
		return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		return false;
	}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
		 return false;
	}
	if (len<2) {
		return false;
	}
	return true;
}
function check_email2(email)
{
	var email1 = email.substring(email.indexOf("@")+1);
	email1 = email1.substring(email1.indexOf(".")+1);
	email1 = email1.substring(email1.indexOf(".")+1);
	var email2 = email1.substring(email1.indexOf(".")+1);
	if(email1 != email2)
	{
		return false;
	}
	return true;
}

function validate_loginform ()
{
	var email= document.getElementById("txtEmail");
    var password = document.getElementById("txtPassword");
	strErrorMessage = "";

	var valid = true;

 	if ( (checkEmail(email.value)==false) || email == null)
	  {
      strErrorMessage += "Email not provided or is incomplete or invalid"; 
      valid = false;
	  alert (strErrorMessage);
	  email.focus();
	  return valid;
    }
	if (password.value == "" || password == null )
	{
      strErrorMessage += "Please enter password to login"; 
      valid = false;
	  alert (strErrorMessage);
	  password.focus();
	  return valid;
    }

	return true;
}


function validate_forgetpassword ()
{
	var email= document.getElementById("inputEmail");
    
	strErrorMessage = "";

	var valid = true;

 	if ( (checkEmail(email.value)==false) || email == null)
	  {
     strErrorMessage += "Email not provided or is incomplete or invalid";
                valid = false;
                alert (strErrorMessage);
                email.focus();
                return valid;
    }
	

	return true;
}

function validate_siform3 ()
{
    valid = true;
    strErrorMessage = "The following required fields were incomplete or invalid:\n\n";
	
    var firstname = document.getElementById("inputFname");
    var lastname = document.getElementById("inputLname");
    var email = document.getElementById("inputEmail");
    var country = document.getElementById("inputCountry");
    //var industry = document.getElementById("inputIndustry");
    var organisation = document.getElementById("inputOrgzn");
    var mobilenumber = document.getElementById("inputMobileNo");
    var mobilecountrycode = document.getElementById("inputMobileCtry");             
    var biznumber = document.getElementById("inputBusinessNo");
    var bizcountrycode = document.getElementById("inputBusinessCtry");
    var bizareacode = document.getElementById("inputBusinessArea");

	var password = document.getElementById("password");
	var cpassword = document.getElementById("password_confirm");
	
    

	  if (firstname.value == "" || firstname == null)
	  {
      strErrorMessage += "- First name not provided.\n"; 
      valid = false;
    }
    if (lastname.value == "" || lastname == null)
	  {
      strErrorMessage += "- Last name not provided.\n"; 
      valid = false;
    }
   // if ( (checkEmail(email.value)==false) || email == null)
	 // {
      //strErrorMessage += "- Email not provided or is in the incorrect format.\n"; 
      //valid = false;
   // }

    if (country.value == "0" || country == null || country.value == "")
	  {
      strErrorMessage += "- Country not selected.\n"; 
      valid = false;
    }
   

    if (( biznumber == null || biznumber.value == "")  ) 
	{
      strErrorMessage += "- Business number is required.\n"; 
      valid = false;
    }    

    if ( (mobilenumber != null && mobilenumber.value != "") && (mobilecountrycode == null || mobilecountrycode.value == "") ) 
	  {
      strErrorMessage += "- Mobile country code not provided.\n"; 
      valid = false;
    }
      
	/*
	if ( (biznumber != null && biznumber.value != "") && (bizcountrycode == null || bizcountrycode.value == "") ) 
	   {
       strErrorMessage += "- Business contact country code not provided.\n"; 
       valid = false;
       }
	*/



	if(password.value == "")
		{
		strErrorMessage += "- Please enter password.\n";
		valid = false;
		} else {
			if(password.value.length < 4)
				{
				strErrorMessage += "- Password length must be minimum 4 chars.\n";
				valid = false;
				} else {

				if(password.value != cpassword.value)
				{
				strErrorMessage += "- Please confirm password.\n";
				valid = false;
				}
				}
	}
   

    if (organisation == null || organisation.value == "")
	  {
      strErrorMessage += "- Organisation not provided.\n"; 
      valid = false;
    }

 var counter=0;

var vindustry =  document.formsi.chkIndustry;

    var vindustryAll = document.formsi.chkIndustryAll;

    if (!vindustryAll.checked)
	{
		for(var i=0;i<vindustry.length;i++)
	    {
	      if (vindustry[i].checked==true)
	      {
	        counter++; 
	      }
	    }
    
	    if (counter==0)
	    {
	      strErrorMessage += "- Choose at least one industry.\n"; 
	      valid = false;
	    }
	     if (counter>5)
	    {
	      strErrorMessage += "- You can choose only up to 5 industries.\n"; 
	      valid = false;
	    }
	}
    
    if (!valid)
    {
      alert (strErrorMessage);
    }
  
    return valid;
}


function validate_siform4 ()
{ 
    $("#inputEmailLabel").removeClass("error");
    $("#passwordLabel").removeClass("error");
    $("#password_confirmLabel").removeClass("error");
    $("#inputFNameLabel").removeClass("error");
    $("#inputLNameLabel").removeClass("error");
    $("#inputCountryLabel").removeClass("error");
    $("#inputIndustryLabel").removeClass("error");
    $("#inputDesignationLabel").removeClass("error");
    $("#inputOrgznLabel").removeClass("error");
    $("#inputContactCtryLabel").removeClass("error");
    $("#inputContactNoLabel").removeClass("error");
    $("#emailFormatLabel").removeClass("error");
	$("#inputContactTypeLabel").removeClass("error");

    valid = true;
    strGenericError = "Please complete fields marked in red.";
    strErrorMessage = "";
                
    var firstname = document.getElementById("inputFname");
    var lastname = document.getElementById("inputLname");
    var email = document.getElementById("inputEmail");
    var country = document.getElementById("inputCountry");
    var industry = document.getElementById("inputIndustry");
    var organisation = document.getElementById("inputOrgzn");
    //var mobilenumber = document.getElementById("inputMobileNo");
    //var mobilecountrycode = document.getElementById("inputMobileCtry");             
    var biznumber = document.getElementById("inputContactNo");
    var bizcountrycode = document.getElementById("inputContactCtry");
    var bizareacode = document.getElementById("inputContactArea");
    var inputContactType = document.getElementById("inputContactType");
    var inputDesignation = document.getElementById("inputDesignation");
    var surveyInterest = document.getElementById("surveyInterest");

    var password = document.getElementById("password");
    var cpassword = document.getElementById("password_confirm");


	var counter = 0;
                


    if ( (checkEmail(email.value)==false) || email == null) {
                strErrorMessage += "Email not provided or is incomplete or invalid"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputEmailLabel").addClass("error");
                email.focus();
                //return valid;
				counter++;
    }

    if(password.value == "") {
                strErrorMessage += "Password should be between 4 to 10 characters consist of alphanumerical only";
                valid = false;
                //alert (strErrorMessage);
				$("#passwordLabel").addClass("error");
                password.focus();
                //return valid;
				counter++;

    } else {
                if(password.value.length < 4 || password.value.length > 10) {
                                strErrorMessage += "Password should be between 4 to 10 characters consist of alphanumerical only";
                                valid = false;
                                //alert (strErrorMessage);
								$("#passwordLabel").addClass("error");
                                password.focus();
                                //return valid;
								counter++;
                } 
                else {
                                if(cpassword.value == "") {
                                                strErrorMessage += "Please re-enter password";
                                                valid = false;
                                                //alert (strErrorMessage);
												$("#password_confirmLabel").addClass("error");
                                                cpassword.focus();
                                                //return valid;
												counter++;
                                
                                }
                        else {
                                                if(password.value != cpassword.value) {
                                                                strErrorMessage += "Password does not match";
                                                                valid = false;
                                                                //alert (strErrorMessage);
																$("#password_confirmLabel").addClass("error");
                                                                cpassword.focus();
                                                                //return valid;
																counter++;
                                                }
                                }
                }
    }


    if (firstname.value == "" || firstname == null) {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputFNameLabel").addClass("error");
                firstname.focus();
                //return valid;
				counter++;
    }

    if (lastname.value == "" || lastname == null) {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputLNameLabel").addClass("error");
                lastname.focus();
                //return valid;
				counter++;
    }
    

    if (country.value == "0" || country == null || country.value == "") {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputCountryLabel").addClass("error");
                country.focus();
                //return valid;
				counter++;
    }

    if (industry.value == "0" ||industry == null || industry.value == "") {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputIndustryLabel").addClass("error");
                industry.focus();
                //return valid;
				counter++;
    }

    if (inputDesignation.value == "0" || inputDesignation == null || inputDesignation.value == "") {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputDesignationLabel").addClass("error");
                inputDesignation.focus();
                //return valid;
				counter++;
    }

    if (organisation == null || organisation.value == "") {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputOrgznLabel").addClass("error");
                organisation.focus();
                //return valid;
				counter++;
    }

    if (( bizcountrycode == null || bizcountrycode.value == "")  )  {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputContactCtryLabel").addClass("error");
                bizcountrycode.focus();
                //return valid;
				counter++;
    }
    else {

                if (isNaN(bizcountrycode.value)) {
                strErrorMessage += "Please enter only numbers for country codes"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputContactCtryLabel").addClass("error");
                bizcountrycode.focus();
                //return valid;
				counter++;
                }
    }

    if (( bizareacode != null && bizareacode.value != "")  )  {
                if (isNaN(bizareacode.value)) {
                                strErrorMessage += "Please enter only numbers for area codes"; 
                                valid = false;
                                //alert (strErrorMessage);
								$("#inputContactAreaLabel").addClass("error");
                                bizareacode.focus();
                                //return valid;
								counter++;
                }
    }

    if (( biznumber == null || biznumber.value == "")  )  {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputContactNoLabel").addClass("error");
                biznumber.focus();
                //return valid;
				counter++;
    }

    if (inputContactType.value == "0" || inputContactType == null ||inputContactType.value == "") {
                strErrorMessage += "Please complete fields marked in red"; 
                valid = false;
                //alert (strErrorMessage);
				$("#inputContactTypeLabel").addClass("error");
                inputContactType.focus();
                //return valid;
				counter++;
    }



	if(counter>1){
		alert(strGenericError);
	}
	else if(counter==1){
		alert(strErrorMessage);
	}


    return valid;
}



/* ---- form submissin --- */


function submitFeedback()
{

var strURL = "/content/edb/sg/en_uk/index/feedback.FeedbackSubmit.jsp";
$("#errMsg").html("<div class=loading>Loading..</div>");
 var strData = "hello world";
     $.ajax({
		type: "POST",
		processData: true,
		url: strURL,
		data: strData,
		contentType: "application/x-www-form-urlencoded",
		success: function(msg){
			BuildTable(msg);
		},
		error: function(msg){
			BuildErrTable(msg);
		}
	});


}


function submitSINews()
	{

/*
var strURL = "/author/edb/sg/en_uk/index/registration.sinewssubmit.html";
$("#errMsg").html("<div class=loading>Loading..</div>");
 var strData = "";



var title = $("#inputTitle").val();
var fname = $("#inputFname").val();
var lname =  $("#inputLname").val(); 
var ctry1 =  $("#inputCountry").val(); 
var email =  $("#inputEmail").val(); 

var ind =  $("#inputIndustry").val();
var indothers =  $("#inputCustomIndustry").val();

var organisation = $("#inputOrgzn").val();

var mobilenumber = $("#inputMobileNo").val();
var mobilecountrycode = $("#inputMobileCtry").val();             

var biznumber = $("#inputBusinessNo").val();
var bizcountrycode =$("#inputBusinessCtry").val();
var bizareacode = $("#inputBusinessArea").val();

var state = $("#inputState").val();



strData = "inputTitle="+ title +"inputFname="+ fname + "&inputLname="+ lname + "&inputCountry="+ ctry1 + "&inputEmail="+ email + "&inputIndustry="+ ind + "&inputCustomIndustry="+ indothers + "&inputOrgzn="+ organisation + "&inputMobileNo="+ mobilenumber + "&inputMobileCtry="+ mobilecountrycode + "&inputBusinessNo="+ biznumber + "&inputBusinessCtry="+ bizcountrycode + "&inputBusinessArea="+ bizareacode + "&state="+ inputState;





     $.ajax({
		type: "POST",
		processData: true,
		url: strURL,
		data: strData,
		contentType: "application/x-www-form-urlencoded",
		success: function(msg){
			BuildTable(msg);
		},
		error: function(msg){
		//	BuildErrTable(msg);
		}
	});

*/
	}


function setIp2Location(str)
{

	var strURL = "/author/edb/sg/en_uk/index.Ip2Loc.html";


 	var strData = "?strCtry=" + str;
    /* $.ajax({
		type: "POST",
		processData: true,
		url: strURL,
		data: strData,
		contentType: "application/x-www-form-urlencoded",
		success: function(msg){
		//	BuildTable(msg);
		alert(str);
		}
	
	}); */
	
	//var request:URLRequest = new URLRequest(strURL + ";jsessionid=" _yoursessionid);
	
	var xmlHttp;
	
	try
	{ // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{ // Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!"); return false;
			}
		}
	}
	
	strURL=strURL+strData;
	
	xmlHttp.open("GET",strURL,true);
	xmlHttp.send(null);
}



function BuildErrTable(msg)
{

 $("#errMsg").html("<div class=error>"+ msg + "</div>");
}

function BuildTable(msg)
 {
 $("#errMsg").html(msg);
 }

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
	{
		return;
	}	
	
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	
	if(!objCheckBoxes)
	{
		return;
	}
	
	var countCheckBoxes = objCheckBoxes.length;
	
	if(!countCheckBoxes)
	{
		objCheckBoxes.checked = CheckValue;
	}
	else
	{
		for(var i = 0; i < countCheckBoxes; i++)
		{
			objCheckBoxes[i].checked = CheckValue;
			if (CheckValue)
			{
				objCheckBoxes[i].disabled = true;
			}
			else
			{
				objCheckBoxes[i].disabled = false;
			}
			
		}	
	}
}

function IndustryCheckboxToggle(FormName, FieldName)
{
	if(!document.forms[FormName])
	{
		return;
	}
	
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	
	if(!objCheckBoxes)
	{
		return;
	}
	
	var countCheckBoxes = objCheckBoxes.length;
	
    var counter = 0;
	var j = 0;
	var uncheckedArray = new Array();

	for(var i = 0; i < countCheckBoxes; i++)
	{
		if (objCheckBoxes[i].checked)
		{	
			counter = counter+1;
		}
		else
		{
			uncheckedArray[j] = objCheckBoxes[i];
			j = j+1;
		}	
	}	

	var countCheckBoxes = uncheckedArray.length;
	
	for( j = 0; j < countCheckBoxes; j++)
	{
		if (counter < 5)
		{
			uncheckedArray[j].disabled = false;
		}
		else
		{
			uncheckedArray[j].disabled = true;
		}
	}
}
