/* Javascript documnet  */
var global_pageId;
var global_publishedFileName;
var global_pageTitle;

function checkMessageText(){
var patternText01 = /^([\?\&\s\t\!\"\:\;\(\)\*\+\,\.\@\[\]\|a-zA-Z0-9_-]){0,}$/
var patternText02=/\&/
var patternText03=/([(s|S)(m|M)(i|I)(t|T)(h|H)][\s][\&][\s][(n|N)(e|E)(p|P)(h|h)(e|E)(w|W)]){1}/
if (document.frm_email_page.message.value.search(patternText01)!=-1)  
{
    if(document.frm_email_page.message.value.search(patternText02)!=-1)
    {
        var index=(document.frm_email_page.message.value.indexOf('&'));
        var str=document.frm_email_page.message.value.substring(index-6,index-1);
        var str2=document.frm_email_page.message.value.substring(index+2,index+8);
        str=str.toUpperCase();
        str2=str2.toUpperCase();
        if((document.frm_email_page.message.value.search(patternText03)!=-1) && (str=="SMITH") && (str2=="NEPHEW")) 
        {        

            return true;
        }
        else
        {
            return false;        
        }
    }
    else
    return true;
}
else
return false;
}


function setParametersEmail(pageId, publishedFileName, pageTitle)
{
global_pageId = pageId;
global_publishedFileName = publishedFileName;
global_pageTitle = pageTitle;

}
function dec()
{
alert(test);
}
/*
=========================
Function name : userValidation
Parameters : 
Purpose : function for visitor verification remedy INC000000017736 
Details : This function compares the captcha number and number entered by visitor.
=========================
*/
function userValidation()
{
   var numString, userString;
   numString = a+""+b+""+c+""+d;
   userString=document.getElementById("userString").value;
      if(userString == numString)
          {
              return true;
          }
      else
          {
           //  $("label#label_userString").addClass("error");
             return false;
          }
}

/*
=========================
Function name : count_occurence
Parameters : str, chr
Purpose : function to count the number of occurences of a character in a string.
Details : This function counts the number of occurences of chr in the str.
=========================
*/
function count_occurence(str, chr)
{
var count=0;
for(var i=0; i<str.length; i++)
{
var ch = str.substring(i, i+1);
if(ch==chr)
{
count++;
}
}
return count;
}

/*
=========================
Function name : validate_regionEmail
Parameters : thisform
Purpose : function to validate the email corresponding to every region
Details : This function validates the email and displays the error messages on the form. 
=========================
*/
function validate_regionEmail(thisform)
{
len = document.frm_contact_us.select_region.length;
count_region=0;
count_email=0;
str_error=null;

while(document.frm_contact_us.select_region[count_region].value!=null)
{
	str_emailIds=document.frm_contact_us.select_region[count_region].value;
	if(str_emailIds.indexOf(',')!=-1)
	{
		str_emailId=str_emailIds.split(',');
		while(str_emailId[count_email]!=null)
		{
			str_error=validate_emailId(str_emailId[count_email],thisform,document.frm_contact_us.select_region[count_region].innerText);
			if(str_error!=null)
			{
				document.write(str_error+"<br />");
			}
			count_email++;
		}
	}
	else
	{
		str_emailId=str_emailIds;
		str_error=validate_emailId(str_emailId,thisform,document.frm_contact_us.select_region[count_region].innerText);
			if(str_error!=null)
			{
				document.write(str_error+"<br />");
			}
	}
	count_region++;
	count_email=0;
}
}
function validate_emailId(emailId,thisform,region)
{	
      i = 0
      aposi = 0
      dotposi = 0  
      email = "none"
	  str_error_email=null;
        email_len=emailId.length;
        aposi=emailId.indexOf("@");
        dotposi=emailId.lastIndexOf(".");
        count=count_occurence(emailId,"@");
        if(aposi<1 || dotposi-aposi<2||dotposi==email_len-1 || count>1)
        {
			str_error_email="*Please enter a valid email for region '"+region+"' and emailId '"+emailId+"'.";
			return str_error_email;
        }
		else
		{
			return null;
		}
}
/*
=========================
Function name : clear_emailForm
Parameters : thisform
Purpose : function to clear the email form
Details : This function clears the email form and removes all the error messages.
=========================
*/
function clear_emailForm(thisform)
{
document.getElementById("error_divMandatory").style.display='none';
document.getElementById("error_div1").style.display='none';
document.getElementById("error_div2").style.display='none';
document.getElementById("error_div3").style.display='none';
document.getElementById("error_div4").style.display='none';
document.getElementById("error_div6").style.display='none';
document.getElementById("error_div7").style.display='none';
document.getElementById("senderName").style.color='#747170';
document.getElementById("senderEmail").style.color='#747170';
document.getElementById("recipientName").style.color='#747170';
document.getElementById("recipientEmail").style.color='#747170';
document.getElementById("label_textCaptcha").style.color='#747170';
document.getElementById("sender_name").value="";
document.getElementById("sender_email").value="";  
document.getElementById("recipient_name").value="";
document.getElementById("recipient_email").value="";
document.getElementById("message").value=""; 
document.getElementById("userString").value=""; 
document.getElementById('from_name').innerHTML = "&lt;sender name&gt;";
document.getElementById('from_email').innerHTML = "address";
document.getElementById('to_name').innerHTML = "&lt;recipient name&gt;";
document.getElementById('to_email').innerHTML = "address";
document.getElementById('sender_nme').innerHTML = "&lt;sender name&gt;";
document.getElementById('sub_sender').innerHTML = "&lt;sender name&gt;";
document.getElementById("message").style.border='1px solid #c0c0c0';

return false;
}
/*
=========================
Function name : clear_msgs
Parameters : thisform
Purpose : function to clear the contact us form
Details : This function clears the contact us form and removes all the error messages.
=========================
*/
function clear_msgs(thisform)
{
document.getElementById("error_div").style.display='none';
document.getElementById("error_div1").style.display='none';
document.getElementById("error_div2").style.display='none';
document.getElementById("error_div3").style.display='none';
document.getElementById("namelable").style.color='#747170';
document.getElementById("email").style.color='#747170';
document.getElementById("phone").style.color='#747170';
document.getElementById("contact_name").value=""; 
document.getElementById("email_adr").value=""; 
document.getElementById("phone_number").value=""; 
document.getElementById("txtarea_comments").value=""; 
document.getElementById('select_subject').selectedIndex=0;
document.getElementById('select_region').selectedIndex=0;
return false;
}
/*
=========================
Function name : GetSelectedItem
Parameters : None
Purpose : function to return the ID of selected region from options
Details : This function returns the ID of selected region from the region drop down.
=========================
*/
function GetSelectedItem() 
{
len = document.frm_contact_us.select_region.length
i = 0
chosen = "none"
for (i = 0; i < len; i++) {
if (document.frm_contact_us.select_region[i].selected) {
chosen = document.frm_contact_us.select_region[i].id
} 
}
return chosen
} 

/*
=========================
Function name : validate_bccEmail
Parameters : thisform
Purpose : function to validate BCC email address
Details : This function validates the bcc email for "@" and ".",  and their positions
=========================
*/
function validate_bccEmail(thisform)
{
document.getElementById("error_div5").style.display='none'
value=document.getElementById("bcc_email").value
len=value.length;
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
count=count_occurence(value,"@");
if (apos<1||dotpos-apos<2||dotpos==len-1 || count>1) 
  {
  document.getElementById("error_div5").style.display='block';
  }

}
/*
=========================
Function name : validate_email
Parameters : field
Purpose : function to validate email
Details : This function validates the email for "@" and ".",  and their positions
=========================
*/
function validate_email(field)
{
with (field)
{
if(value=="")
{
return true;
}
len=value.length;
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
count=count_occurence(value,"@");
if (apos<1||dotpos-apos<2||dotpos==len-1 || count>1) 
  {return false;}
else {return true;}
}
}
/*
=========================
Function name : validate_name
Parameters : field
Purpose : function to validate name
Details : This function validates the name and returns false if any special character is found in it.
=========================
*/
function validate_name(field)
{
with (field)
{
if(value.length > 50)
{
return false;
}
for( var i=0; i < value.length; i++)
                {
                        var ch = value.substring(i, i + 1);
                        if(ch=="!" || ch=="@" || ch=="#" || ch=="$" || ch=="%" || ch=="^" || ch=="&" || ch=="*" || ch=="(" || ch==")" || ch=="-" || ch=="_" || ch=="=" || ch=="+" || ch=="/" || ch==":" || ch==";" || ch=="<" || ch==">" || ch=="?" || ch=="," || ch=="[" || ch=="]" || ch=="{" || ch=="}" || ch=="|" || ch=="~" || ch=="`")
                        {
                            return false;
                        }
                }
                return true;
}
}
/*
=========================
Function name : validate_phone
Parameters : field
Purpose : function to validate phone number
Details : This function validates the phone number and returns false if any non-numeric character is found in it.
=========================
*/
function validate_phone(field)
{
with (field)
{
for (var i = 0; i < value.length; i++)
                {
                        var ch = value.substring(i, i + 1);
                        if((ch < '0' || '9' < ch)) 
                        {
                            if(ch == "+" || ch == "-" || ch == "." || ch == ")" || ch == "("  || ch == " ") continue;
                            return false;
                        }
                }
                return true;
          
}
}
/*
=========================
Function name : validate_zipCode
Parameters : field
Purpose : function to validate zip Code
Details : This function validates the zip Code and returns false if any non-numeric character is found in it.
=========================
*/
function validate_zip(field)
{
with (field)
    {
    if(value.length==5)
       {
        for (var i = 0; i < value.length; i++)
                        {
                                var ch = value.substring(i, i + 1);
                                if((ch < '0' || '9' < ch)) 
                                {
                                    if(ch == "+" || ch == "-" || ch == "." || ch == ")" || ch == "("  || ch == " ") continue;
                                    return false;
                                }
                        }
                        return true;
        }
    else
        {
            return false;          
        }
    }
}
/*
=========================
Function name : validate_required
Parameters : field
Purpose : function to check for required validation
Details : This function validates the mandatory fields and returns false if the field is blank
=========================
*/
function validate_required(field)
{
with (field)
{
  if (value==null||value=="")
  {
  return false;
  }
  else
  {
  return true;
  }
}
}

/*
=========================
Function name : validate_form
Parameters : thsiform
Purpose : function to validate the contact us form
Details : This function validates the contact us form and returns false if any validation fails.
=========================
*/
function validate_form(thisform)
{
$("#contact_send").attr("disabled","disabled");
$("#contact_send").attr("value","Sending");
document.getElementById("error_div").style.display='none';
document.getElementById("error_div1").style.display='none';
document.getElementById("error_div2").style.display='none';
document.getElementById("error_div3").style.display='none';
//document.getElementById("error_div7").style.display='block';
document.getElementById("namelable").style.color='#747170';
document.getElementById("email").style.color='#747170';
document.getElementById("phone").style.color='#747170';
//id=GetSelectedItem();
//alert(id);
str=$("select#select_region option:selected").text(); 
document.getElementById("region_name").value=str; 
with (thisform)
{
req=validate_required(email_adr);
req1=validate_required(contact_name);
req2=validate_required(phone_number); 
name_flag=validate_name(contact_name);
email_flag=validate_email(email_adr);
phone_flag=validate_phone(phone_number);
if(req==false || req1==false || req2==false)
{  
document.getElementById("error_div").style.display='block';
} 
else
{
document.getElementById("error_div").style.display='none';
} 
if (name_flag==false)
  {
  
   document.getElementById("error_div3").style.display='block';
   document.getElementById("namelable").style.color='#ff0000';
    
  }
else
{
    document.getElementById("error_div3").style.display='none';
    document.getElementById("namelable").style.color='#747170';
}
  
if (email_flag==false)
  {
   
    
     document.getElementById("error_div1").style.display='block';
     document.getElementById("email").style.color='#ff0000';
        
  }
else
{
    document.getElementById("error_div1").style.display='none';
    document.getElementById("email").style.color='#747170';
}
if (phone_flag==false)
  {
   
    document.getElementById("error_div2").style.display='block';
    document.getElementById("phone").style.color='#ff0000';
  }
else
{
    document.getElementById("error_div2").style.display='none';
    document.getElementById("phone").style.color='#747170';
}
if(name_flag==false || email_flag==false || phone_flag==false || req==false || req1==false || req2==false)
{
$("#contact_send").removeAttr("disabled");
$("#contact_send").attr("value","Send");
return false;
}
}
}

/*
=========================
Function name : validate_emailForm
Parameters : thsiform
Purpose : function to validate the email this page form
Details : This function validates the email this page form and returns false if any validation fails.
=========================
*/
function validate_emailForm(thisform)
{
with(thisform)
{
req=validate_required(sender_name);
req1=validate_required(sender_email);
req2=validate_required(recipient_name);
req3=validate_required(recipient_email);
req4=validate_required(userString);
userValid=userValidation();
senderName_flag=validate_name(sender_name);
recipientName_flag=validate_name(recipient_name);
senderEmail_flag=validate_email(sender_email);
recipientEmail_flag=validate_email(recipient_email);
msg_flag=checkMessageText();
if(req==false || req1==false || req2==false || req3==false || req4==false)
{  
document.getElementById("error_divMandatory").style.display='block';
document.getElementById("senderName").style.color='#ff0000';
} 
else
{
document.getElementById("error_divMandatory").style.display='none';
}

if(req==false)
{
   document.getElementById("senderName").style.color='#ff0000';
}
else
{
 document.getElementById("senderName").style.color='#747170';
}
if(req1==false)
{
   document.getElementById("senderEmail").style.color='#ff0000';
}
else
{
 document.getElementById("senderEmail").style.color='#747170';
}
if(req2==false)
{
   document.getElementById("recipientName").style.color='#ff0000';
}
else
{
 document.getElementById("recipientName").style.color='#747170';
}
if(req3==false)
{
   document.getElementById("recipientEmail").style.color='#ff0000';
}
else
{
 document.getElementById("recipientEmail").style.color='#747170';
}
if(req4==false)
{
  document.getElementById("label_textCaptcha").style.color='#ff0000';
}
else
{
 document.getElementById("label_textCaptcha").style.color='#747170';
}

if (userValid==false && req4==true)
{
 document.getElementById("error_div7").style.display='block';
 document.getElementById("label_textCaptcha").style.color='#ff0000';
}
else 
{
     document.getElementById("error_div7").style.display='none';
 if(req4 != false)
    {
     document.getElementById("label_textCaptcha").style.color='#747170';
    }
}

if (msg_flag==false)
  {
  
   document.getElementById("error_div6").style.display='block';
   document.getElementById("message").style.border='1px solid #ff0000'; 
  }
else 
{
    document.getElementById("error_div6").style.display='none';
    document.getElementById("message").style.border='1px solid #c0c0c0';
}




if (senderName_flag==false)
  {
  
   document.getElementById("error_div1").style.display='block';
   document.getElementById("senderName").style.color='#ff0000';
    
  }
else 
{
    document.getElementById("error_div1").style.display='none';
    if(req != false)
    {
     document.getElementById("senderName").style.color='#747170';
    }
}
if (senderEmail_flag==false)
  {
  
   document.getElementById("error_div2").style.display='block';
   document.getElementById("senderEmail").style.color='#ff0000';
    
  }
else
{
    document.getElementById("error_div2").style.display='none';
    if(req1 != false)
    {
    document.getElementById("senderEmail").style.color='#747170';
    }
}
if (recipientName_flag==false)
  {
  
   document.getElementById("error_div3").style.display='block';
   document.getElementById("recipientName").style.color='#ff0000';
    
  }
else
{
    document.getElementById("error_div3").style.display='none';
    if(req2 != false)
    {
    document.getElementById("recipientName").style.color='#747170';
    }
}
if (recipientEmail_flag==false)
  {
  
   document.getElementById("error_div4").style.display='block';
   document.getElementById("recipientEmail").style.color='#ff0000';
    
  }
else
{
    document.getElementById("error_div4").style.display='none';
    if(req3 != false)
    {
    document.getElementById("recipientEmail").style.color='#747170';
    }
}
if(senderName_flag==true && senderEmail_flag==true && recipientName_flag==true && recipientEmail_flag==true && req==true && req1==true && req2==true && req3==true && req3==true && req4==true && msg_flag==true && userValid==true)
{
document.getElementById("sender_link").value=global_publishedFileName;
document.getElementById("page_title").value=global_pageTitle;
document.getElementById("page_Id").value=global_pageId;
}
if(senderName_flag==false || senderEmail_flag==false || recipientName_flag==false || recipientEmail_flag==false || req==false || req1==false || req2==false || req3==false || req4==false || msg_flag==false || userValid==false)
{
return false;
}
}
}

/*
=========================
Function name : validate_orderingForm
Parameters : thisform
Purpose : function to validate the email corresponding to every region
Details : This function validates the email and displays the error messages on the form. 
=========================
*/
function validate_orderingForm(thisform)
{
	//Code Related To Validation is following
	    countToPassValidation=0;
	    isReturnFalse=0;
	    mailLine2=true;
	/* Hide error divs by default*/
            document.getElementById("error_divMandatoryOrder").style.display='none';
            document.getElementById("error_divFirstNameOrder").style.display='none';
            document.getElementById("error_divLastNameOrder").style.display='none';
            document.getElementById("error_divEmailIdOrder").style.display='none';
            document.getElementById("error_divMailAddressOrder").style.display='none';
            document.getElementById("error_divMailAddress2Order").style.display='none';
            document.getElementById("error_divZipPostalOrder").style.display='none';
            document.getElementById("error_divStateOrder").style.display='none';
            document.getElementById("error_divCityOrder").style.display='none';
    with(thisform)
    {
        isValidField_firstName=validate_required(firstName);
        isValidField_lastName=validate_required(lastName);
        isValidField_emailID=validate_required(emailID);
        isValidField_mailAddress=validate_required(mailAddress);
        isValidField_mailAddress2=validate_required(mailAddress2);
        isValidField_city=validate_required(city);
        isValidField_state=validate_required(state);
        isValidField_zip=validate_required(zipPostal);
        /*Check if no field is empty*/
        if(isValidField_firstName==false || isValidField_lastName==false || isValidField_emailID==false || isValidField_mailAddress==false || isValidField_city==false || isValidField_state==false || isValidField_zip==false)
        {
               document.getElementById("firstNameLabel").style.color='#ff0000';
               document.getElementById("lastNameLabel").style.color='#ff0000';
               document.getElementById("emailIDLabel").style.color='#ff0000';
               document.getElementById("mailAddressLabel").style.color='#ff0000';
               document.getElementById("cityLabel").style.color='#ff0000';
               document.getElementById("stateLabel").style.color='#ff0000';
               document.getElementById("zipPostalLabel").style.color='#ff0000';
               document.getElementById("error_divMandatoryOrder").style.display='block';
               isReturnFalse++;
        }  
        /*Check if first name is valid*/  
        isValidName=validate_name(firstName); 
        if(isValidField_firstName==true && isValidName==true)
        {
            document.getElementById("firstNameLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_firstName==true && isValidName==false)
        {
            document.getElementById("firstNameLabel").style.color='#ff0000';
            document.getElementById("error_divFirstNameOrder").style.display='block';
            isReturnFalse++;
        }          
        /*Check if Last name is valid*/  
        isValidLastName=validate_name(lastName); 
        if(isValidField_lastName==true && isValidLastName==true)
        {
            document.getElementById("lastNameLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_lastName==true && isValidLastName==false)
        {
            document.getElementById("lastNameLabel").style.color='#ff0000';
            document.getElementById("error_divLastNameOrder").style.display='block';
            isReturnFalse++;
        }
        /*Check if email-ID is valid*/  
        isValidemailID=validate_email(emailID); 
        if(isValidField_emailID==true && isValidemailID==true)
        {
            document.getElementById("emailIDLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_emailID==true && isValidemailID==false)
        {
            document.getElementById("emailIDLabel").style.color='#ff0000';
            document.getElementById("error_divEmailIdOrder").style.display='block';
            isReturnFalse++;
        }
        /*Check if mail address is valid*/  
        isValidmailAddress=validate_name(mailAddress); 
        if(isValidField_mailAddress==true && isValidmailAddress==true)
        {
            document.getElementById("mailAddressLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_mailAddress==true && isValidmailAddress==false)
        {
            document.getElementById("mailAddressLabel").style.color='#ff0000';
            document.getElementById("error_divMailAddressOrder").style.display='block';
            isReturnFalse++;
        }
        /*Check if zip is valid*/  
        isValidzip=validate_zip(zipPostal); 
        if(isValidField_zip==true && isValidzip==true)
        {
            document.getElementById("zipPostalLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_zip==true && isValidzip==false)
        {
            document.getElementById("zipPostalLabel").style.color='#ff0000';
            document.getElementById("error_divZipPostalOrder").style.display='block';
            isReturnFalse++;
        }
        /*Check if state is valid*/  
        isValidstate=validate_name(state); 
        if(isValidField_state==true && isValidstate==true)
        {
            document.getElementById("stateLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_state==true && isValidstate==false)
        {
            document.getElementById("stateLabel").style.color='#ff0000';
            document.getElementById("error_divStateOrder").style.display='block';
            isReturnFalse++;
        }
        /*Check if state is valid*/  
        isValidcity=validate_name(city); 
        if(isValidField_city==true && isValidcity==true)
        {
            document.getElementById("cityLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_city==true && isValidcity==false)
        {
            document.getElementById("cityLabel").style.color='#ff0000';
            document.getElementById("error_divCityOrder").style.display='block';
            isReturnFalse++;
        }
        /*Check Mail Address2*/
        if(isValidField_mailAddress2==true)
        {
            isValidmailAddress2=validate_name(mailAddress2);
            if(isValidmailAddress2==true)
            {
                mailLine2=true;
                document.getElementById("mailAddressLabel2").style.color='#666667';
                document.getElementById("error_divMailAddress2Order").style.display='none';
            }
            else if(isValidmailAddress2==false)
            {
                mailLine2=false;
                document.getElementById("mailAddressLabel2").style.color='#ff0000';
                document.getElementById("error_divMailAddress2Order").style.display='block';
            }
        }
        else if(isValidField_mailAddress2==false)
        {
            document.getElementById("mailAddressLabel2").style.color='#666667';
            mailLine2=true;
        }
        /*Check Radio Button is Selected*/
        if(document.getElementById("mandatoryRadio")!=null)
        {
        valRadioButton=true;
        }
        else if(document.getElementById("mandatoryRadio")==null)
        {
        valRadioButton=false;
        }
        if(document.getElementById("mandatoryRadio")!=null)
        {
            if(hipRadio.checked==false && kneeRadio.checked==false)
            {
                valRadioButton=false;
            }
            else
            {
                //do nothing
            }
            if( valRadioButton==false)
            {
            //document.getElementById("hipRadio").style.border='1px solid #ff0000';
            //document.getElementById("kneeRadio").style.border='1px solid #ff0000';
            document.getElementById("error_divRadioOrder").style.display='block';
            }
            else if( valRadioButton==true)
            {
            //document.getElementById("hipRadio").style.border='none';
            //document.getElementById("kneeRadio").style.border='none';
            document.getElementById("error_divRadioOrder").style.display='none';
            }
        }
        else
        {
            //do nothing
        }
    }
	//Code Related To Setting the value of CommCode is as following
		if((document.getElementById("OrderingFormType").value=='MLIA') && document.getElementById("hipRadio").checked==true)
                {
			document.getElementById("CommCodeField").value="46880501";
		}	    	
		else if((document.getElementById("OrderingFormType").value=='MLIA') && (document.getElementById("kneeRadio").checked==true))
                {
			document.getElementById("CommCodeField").value="46890501";
		}
		else if((document.getElementById("OrderingFormType").value=='BHR'))
                {
			document.getElementById("CommCodeField").value="45672901";
		}

    if(document.getElementById("mandatoryRadio")!=null)
    {
        if(countToPassValidation==7 && mailLine2==true && valRadioButton==true)
        {
            return true;
        }
        else if(countToPassValidation!=7 || isReturnFalse!=0 || mailLine2==false || valRadioButton==false)
        {
            return false;
        }
    }
    else if(document.getElementById("mandatoryRadio")==null)
    {
        if(countToPassValidation==7 && mailLine2==true)
        {
            return true;
        }
        else if(countToPassValidation!=7 || isReturnFalse!=0 || mailLine2==false)
        {
            return false;
        }
    }
}
 
function validate_PhysicianLocatorTemplate(thisform)
{
    countToPassValidation=0;
    isReturnFalse=0;
/* Hide error divs by default*/
            document.getElementById("error_divName").style.display='none';
            document.getElementById("error_divEmail").style.display='none';
            document.getElementById("error_divZipCode").style.display='none';
    with(thisform)
    {
        isValidField_NameLabel=validate_required(NameLabel);
        isValidField_EmailLabel=validate_required(EmailLabel);
        isValidField_ZipLabel=validate_required(ZipLabel);
        /*Check if no field is empty*/
        if(isValidField_NameLabel==false && isValidField_EmailLabel==false && isValidField_ZipLabel==false)
        {
               document.getElementById("error_divMandatory").style.display='block';
               return false;
        }
        /*Check if first name is valid*/  
        isValidName=validate_name(NameLabel); 
        if(isValidField_NameLabel==true && isValidName==true)
        {
            document.getElementById("error_divName").style.display='none';
            countToPassValidation++;
        }
        else if(isValidField_NameLabel==true && isValidName==false)
        {
            document.getElementById("error_divName").style.display='block';
            isReturnFalse++;
        }
        /*Check if email-ID is valid*/  
        isValidemailID=validate_email(EmailLabel); 
        if(isValidField_EmailLabel==true && isValidemailID==true)
        {
            document.getElementById("error_divEmail").style.display='none';
            countToPassValidation++;
        }
        else if(isValidField_EmailLabel==true && isValidemailID==false)
        {
            document.getElementById("error_divEmail").style.display='block';
            isReturnFalse++;
        }
        /*Check if zip is valid*/  
        isValidzip=validate_zip(ZipLabel); 
        if(isValidField_ZipLabel==true && isValidzip==true)
        {
            document.getElementById("error_divZipCode").style.display='none';
            countToPassValidation++;
        }
        else if(isValidField_ZipLabel==true && isValidzip==false)
        {
            document.getElementById("error_divZipCode").style.display='block';
            isReturnFalse++;
        }
    }          
        if(countToPassValidation==3)
        {
            return true;
        }
        else if(countToPassValidation!=3 || isReturnFalse!=0)
        {
            return false;
        }
}
 
 



/*
=========================
Function name : validate_mediaContactForm
Parameters : thisform
Purpose : function to validate the fields corresponding to every input
Details : This function validates the fields and displays the error messages on the form | INC Id-22775 & RS2 ID-784485. 
=========================
*/
function validate_mediaContactForm(thisform)
{
    //Code Related To Validation is following
        countToPassValidation=0;
        isReturnFalse=0;
        mailLine2=true;
        isCountry=true;
        isTitle=true;
        isCity=true;
        isState=true;
        isZipPostal=true;
    /* Hide error divs by default*/
            document.getElementById("error_divMandatoryMedia").style.display='none';
            document.getElementById("error_divFirstNameMedia").style.display='none';
            document.getElementById("error_divLastNameMedia").style.display='none';
            document.getElementById("error_divTitleMedia").style.display='none';
            document.getElementById("error_divOrganisationMedia").style.display='none';
            document.getElementById("error_divEmailIdMedia").style.display='none';
            document.getElementById("error_divMailAddressMedia").style.display='none';
            document.getElementById("error_divMailAddress2Media").style.display='none';
            document.getElementById("error_divZipPostalMedia").style.display='none';
            document.getElementById("error_divStateMedia").style.display='none';
            document.getElementById("error_divCityMedia").style.display='none';
            document.getElementById("error_divCountryMedia").style.display='none';
               document.getElementById("firstNameLabel").style.color='#666667';
               document.getElementById("lastNameLabel").style.color='#666667';
               document.getElementById("organisationLabel").style.color='#666667';
               document.getElementById("emailIDLabel").style.color='#666667';
               document.getElementById("questionLabel").style.color='#666667';
     with(thisform)
    {
        isValidField_firstName=validate_required(firstName);
        isValidField_lastName=validate_required(lastName);
        isValidField_title=validate_required(title);
        isValidField_organisation=validate_required(organisation);
        isValidField_emailID=validate_required(emailID);
        isValidField_mailAddress=validate_required(mailAddress);
        isValidField_mailAddress2=validate_required(mailAddress2);
        isValidField_city=validate_required(city);
        isValidField_state=validate_required(state);
        isValidField_zipPostal=validate_required(zipPostal);
        isValidField_country=validate_required(country);
        isValidField_quetion=validate_required(question_area);
      
        if(isValidField_firstName==false || isValidField_lastName==false || isValidField_emailID==false || isValidField_organisation==false || isValidField_quetion==false)
        {
               document.getElementById("firstNameLabel").style.color='#ff0000';
               document.getElementById("lastNameLabel").style.color='#ff0000';
               document.getElementById("organisationLabel").style.color='#ff0000';
               document.getElementById("emailIDLabel").style.color='#ff0000';
               document.getElementById("questionLabel").style.color='#ff0000';
               document.getElementById("error_divMandatoryMedia").style.display='block';
               isReturnFalse++;
        }   
        /*Check if first name is valid*/  
        isValidName=validate_name(firstName); 
        if(isValidField_firstName==true && isValidName==true)
        {
            document.getElementById("firstNameLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_firstName==true && isValidName==false)
        {
            document.getElementById("firstNameLabel").style.color='#ff0000';
            document.getElementById("error_divFirstNameMedia").style.display='block';
            isReturnFalse++;
        }          
        /*Check if Last name is valid*/  
        isValidLastName=validate_name(lastName); 
        if(isValidField_lastName==true && isValidLastName==true)
        {
            document.getElementById("lastNameLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_lastName==true && isValidLastName==false)
        {
            document.getElementById("lastNameLabel").style.color='#ff0000';
            document.getElementById("error_divLastNameMedia").style.display='block';
            isReturnFalse++;
        }

        /*Check if Organisation is valid*/  
        isValidOrganisation=validate_name(organisation); 
        if(isValidField_organisation==true && isValidOrganisation==true)
        {
            document.getElementById("organisationLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_organisation==true && isValidOrganisation==false)
        {
            document.getElementById("organisationLabel").style.color='#ff0000';
            document.getElementById("error_divOrganisationMedia").style.display='block';
            isReturnFalse++;
        }

        /*Check if email-ID is valid*/  
        isValidemailID=validate_email(emailID); 
        if(isValidField_emailID==true && isValidemailID==true)
        {
            document.getElementById("emailIDLabel").style.color='#666667';
            countToPassValidation++;
        }
        else if(isValidField_emailID==true && isValidemailID==false)
        {
            document.getElementById("emailIDLabel").style.color='#ff0000';
            document.getElementById("error_divEmailIdMedia").style.display='block';
            isReturnFalse++;
        }
        
        /*Check if MailAddress is valid*/  
        if(isValidField_mailAddress==true)
        {
            isValidMailAddress=validate_name(mailAddress);
            if(isValidMailAddress==true)
            {
                isMailAddress=true;
                document.getElementById("mailAddressLabel").style.color='#666667';
                document.getElementById("error_divMailAddressMedia").style.display='none';
            }
            else if(isValidMailAddress==false)
            {
                isMailAddress=false;
                document.getElementById("mailAddressLabel").style.color='#ff0000';
                document.getElementById("error_divMailAddressMedia").style.display='block';
            }
        }

        /*Check if Zip is valid*/  
        if(isValidField_zipPostal==true)
        {
            isValidZipPostal=validate_name(zipPostal);
            if(isValidZipPostal==true)
            {
                isZipPostal=true;
                document.getElementById("zipPostalLabel").style.color='#666667';
                document.getElementById("error_divZipPostalMedia").style.display='none';
            }
            else if(isValidZipPostal==false)
            {
                isZipPostal=false;
                document.getElementById("zipPostalLabel").style.color='#ff0000';
                document.getElementById("error_divZipPostalMedia").style.display='block';
            }
        }
        else if(isValidField_zipPostal==false)
        {
            document.getElementById("zipPostalLabel").style.color='#666667';
            isZip=true;
        }

        /*Check if State is valid*/  
        if(isValidField_state==true)
        {
            isValidState=validate_name(state);
            if(isValidState==true)
            {
                isState=true;
                document.getElementById("stateLabel").style.color='#666667';
                document.getElementById("error_divStateMedia").style.display='none';
            }
            else if(isValidState==false)
            {
                isState=false;
                document.getElementById("stateLabel").style.color='#ff0000';
                document.getElementById("error_divStateMedia").style.display='block';
            }
        }
        else if(isValidField_state==false)
        {
            document.getElementById("stateLabel").style.color='#666667';
            isState=true;
        }

        /*Check if City is valid*/  
        if(isValidField_city==true)
        {
            isValidCity=validate_name(city);
            if(isValidCity==true)
            {
                isCity=true;
                document.getElementById("cityLabel").style.color='#666667';
                document.getElementById("error_divCityMedia").style.display='none';
            }
            else if(isValidCity==false)
            {
                isCity=false;
                document.getElementById("cityLabel").style.color='#ff0000';
                document.getElementById("error_divCityMedia").style.display='block';
            }
        }
        else if(isValidField_title==false)
        {
            document.getElementById("titleLabel").style.color='#666667';
            isTitle=true;
        }

        /*Check Mail Address2*/
        if(isValidField_mailAddress2==true)
        {
            isValidmailAddress2=validate_name(mailAddress2);
            if(isValidmailAddress2==true)
            {
                mailLine2=true;
                document.getElementById("mailAddressLabel2").style.color='#666667';
                document.getElementById("error_divMailAddress2Media").style.display='none';
            }
            else if(isValidmailAddress2==false)
            {
                mailLine2=false;
                document.getElementById("mailAddressLabel2").style.color='#ff0000';
                document.getElementById("error_divMailAddress2Media").style.display='block';
            }
        }
        else if(isValidField_mailAddress2==false)
        {
            document.getElementById("mailAddressLabel2").style.color='#666667';
            mailLine2=true;
        }

        /*Check if Title is valid*/  
        if(isValidField_title==true)
        {
            isValidTitle=validate_name(title);
            if(isValidTitle==true)
            {
                isTitle=true;
                document.getElementById("titleLabel").style.color='#666667';
                document.getElementById("error_divTitleMedia").style.display='none';
            }
            else if(isValidTitle==false)
            {
                isTitle=false;
                document.getElementById("titleLabel").style.color='#ff0000';
                document.getElementById("error_divTitleMedia").style.display='block';
            }
        }
        else if(isValidField_title==false)
        {
            document.getElementById("titleLabel").style.color='#666667';
            isTitle=true;
        }

        /*Check if Country is valid*/  
        if(isValidField_country==true)
        {
            isValidCountry=validate_name(country);
            if(isValidCountry==true)
            {
                isCountry=true;
                document.getElementById("countryLabel").style.color='#666667';
                document.getElementById("error_divCountryMedia").style.display='none';
            }
            else if(isValidCountry==false)
            {
                isCountry=false;
                document.getElementById("countryLabel").style.color='#ff0000';
                document.getElementById("error_divCountryMedia").style.display='block';
            }
        }
        else if(isValidField_country==false)
        {
            document.getElementById("countryLabel").style.color='#666667';
            isCountry=true;
        }

    }
       if(isValidField_quetion==true)
        {     
             document.getElementById("questionLabel").style.color='#666667';
        }
       else if(isValidField_quetion==false)
        {
             document.getElementById("questionLabel").style.color='#ff0000';
        }
        if(countToPassValidation==5 && mailLine2==true && isCountry==true)
        {
            return true;
        }
        else if(countToPassValidation!=4 || isReturnFalse!=0 || mailLine2==false  || isCountry==false)
        {
            return false;
        }
}
 
 function validate_toEmail(field)
{
with (field)
{
if(value=="")
{
return true;
}
len=value.length;
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
count=count_occurence(value,"@");
if (apos<1||dotpos-apos<2||dotpos==len-1) 
  {return false;}
else {return true;}
}
}

/*
=========================
Function name : validate_regionmediaEmail
Parameters : thisform
Purpose : function to validate the email corresponding to To field in media contact form
Details : This function validates the email and displays the error messages on the form. 
=========================
*/
function validate_regionmediaEmail(thisform)
{
len = document.mediaContact_form.to_emailID.value.length;
count_email=0;
str_error=null;
if(document.mediaContact_form.to_emailID.value!=null)
{
    str_emailIds=document.mediaContact_form.to_emailID.value;
    if(str_emailIds.indexOf(',')!=-1)
    {
        str_emailId=str_emailIds.split(',');
        while(str_emailId[count_email]!=null)
        {
            str_error=validate_emailId(str_emailId[count_email]);
            if(str_error!=null)
            {
				//document.getElementById("error_validToEmailID").innerText+=str_error;
				//document.getElementById("error_validToEmailID").innerText+=" | ";
				document.write(str_error+"<br />");
            }
            count_email++;
        }
    }
    else
    {
        str_emailId=str_emailIds;
        str_error=validate_emailId(str_emailId);
            if(str_error!=null)
            {
				//document.getElementById("error_validToEmailID").innerText+=str_error;
				//document.getElementById("error_validToEmailID").innerText+=" | ";
				document.write(str_error+"<br />");
            }
    }
}
}
function validate_emailId(emailId)
{    
      i = 0
      aposi = 0
      dotposi = 0  
      email = "none"
      str_error_email=null;
        email_len=emailId.length;
        aposi=emailId.indexOf("@");
        dotposi=emailId.lastIndexOf(".");
        count=count_occurence(emailId,"@");
        if(aposi<1 || dotposi-aposi<2||dotposi==email_len-1 || count>1)
        {
            str_error_email="*Please enter a valid email in To field for emailId '"+emailId+"'.";
            return str_error_email;
        }
        else
        {
            return null;
        }
}
 