function func_is_null(text)
{if((func_trim(text)=="")||(text==null))
{return true;}
else
{return false;}}
function func_trim(param_text)
{var str_text=new String(param_text);var str_return_text;str_return_text="";b_non_blank_started=false;b_non_blank_ended=false;str_intermediate_blank_chunk="";var i_loop;for(i_loop=0;i_loop<str_text.length;i_loop++)
{if(str_text.charCodeAt(i_loop)!=32)
{if(!b_non_blank_started)
{b_non_blank_started=true;}
if(b_non_blank_started&&!b_non_blank_ended)
{str_return_text+=str_text.charAt(i_loop);}
if(b_non_blank_ended)
{str_return_text+=(str_intermediate_blank_chunk+str_text.charAt(i_loop));b_non_blank_ended=false;str_intermediate_blank_chunk="";}}
else
{if(b_non_blank_started)
{b_non_blank_ended=true;str_intermediate_blank_chunk+=" ";}}}
return str_return_text;}
function func_len(param_text)
{var str_text=new String(func_trim(param_text));return str_text.length;}
function func_is_email(param_email)
{var str_current_character;var b_valid_email,b_period_present;var i_last_position_of_period,b_correct_length_extension;var i_num_at_symbol=0;var i_pos_at_symbol;var i_length_of_server_name=1;var i_pos_consecutive_dots;var str_email=new String(func_trim(param_email));i_length=str_email.length;b_period_present=1;b_correct_length_extension=1;i_last_position_of_period=0;if(i_length==0)
{return true;}
for(i_loop=0;i_loop<i_length;i_loop++)
{if(!((str_email.charCodeAt(i_loop)>=65&&str_email.charCodeAt(i_loop)<=90)||(str_email.charCodeAt(i_loop)>=97&&str_email.charCodeAt(i_loop)<=122)||(str_email.charCodeAt(i_loop)>=48&&str_email.charCodeAt(i_loop)<=57)||(str_email.charAt(i_loop)=="@")||(str_email.charAt(i_loop)=="_")||(str_email.charAt(i_loop)=="-")||(str_email.charAt(i_loop)==".")))
{return false;}}
i_pos_consecutive_dots=str_email.indexOf('..');if(i_pos_consecutive_dots!=-1)
{return false;}
var i_pos_space;i_pos_space=str_email.indexOf(' ');if(i_pos_space!=-1)
{return false;}
i_last_position_of_period=str_email.lastIndexOf('.');if(i_last_position_of_period<=0)
{b_period_present=0;}
if(((i_length-i_last_position_of_period)>4)||((i_length-i_last_position_of_period)<3))
{b_correct_length_extension=0;}
for(i_loop=0;i_loop<=i_length;i_loop++)
{str_current_character=str_email.charAt(i_loop);if(str_current_character=='@')
{i_num_at_symbol=i_num_at_symbol+1;}}
if(i_num_at_symbol!=1)
{return false;}
i_pos_at_symbol=str_email.indexOf('@');if(str_email.charAt(i_pos_at_symbol+1)=='.')
{i_length_of_server_name=0;}
if((i_num_at_symbol==1)&&(b_period_present==1)&&(b_correct_length_extension==1)&&(i_length_of_server_name==1))
{b_valid_email=1;}
else
{b_valid_email=0;}
if(b_valid_email==0)
{return false;}
else
{return true;}}
function func_is_telephone_number(param_text)
{var b_is_telephone_number=true;if(func_trim(param_text)!="")
{var str_text=new String(func_trim(param_text));var i_length=func_len(str_text);var i_loop;for(i_loop=0;i_loop<i_length;i_loop++)
{if(!((str_text.charCodeAt(i_loop)>=48&&str_text.charCodeAt(i_loop)<=57)||(str_text.charAt(i_loop)=="-")||(str_text.charAt(i_loop)=="(")||(str_text.charAt(i_loop)==")")||(str_text.charAt(i_loop)=="+")||(str_text.charCodeAt(i_loop)==32)||(str_text.charAt(i_loop)==".")))
{b_is_telephone_number=false;}}}
return b_is_telephone_number;}
function func_select_focus(element)
{element.select();element.focus();return true;}
function funcSalesValidate(frmSales)
{var objName,objCompany,objURL,objTel,objEmail,objCountry;var bValid=true;objName=frmSales.txt_contact_person;objCompany=frmSales.txt_organisation;objCountry=frmSales.txt_country;objTel=frmSales.txt_phone;objEmail=frmSales.txt_email;if(bValid)
{if(func_is_null(func_trim(objCompany.value)))
{bValid=false;alert("Please enter the Organisation name");func_select_focus(objCompany);}}
if(bValid)
if(func_is_null(func_trim(objName.value)))
{bValid=false;alert("Please enter Contact Name");func_select_focus(objName);}
if(bValid)
{if(func_is_null(func_trim(objCountry.value)))
{bValid=false;alert("Please Enter your country");func_select_focus(objCountry);}}
if(bValid)
{if(func_is_null(func_trim(objTel.value)))
{bValid=false;alert("Please Enter Phone Number");func_select_focus(objTel);}
else
if((func_is_telephone_number(func_trim(objTel.value))!=true))
{bValid=false;alert("Entry for Phone Number is invalid");func_select_focus(objTel);}
else if(func_is_null(func_trim(objEmail.value)))
{bValid=false;alert(" Please Enter Email");func_select_focus(objEmail);}
else
if(!func_is_email(func_trim(objEmail.value)))
{bValid=false;alert("Entry for Email address is invalid");func_select_focus(objEmail);}}
return bValid;};function func_submit()
{var objName,objCompany,objURL,objTel,objEmail,objCountry,objQuery;var bValid=true;objName=document.frmSales.txt_contact_person;objCompany=document.frmSales.txt_organisation;objCountry=document.frmSales.txt_country;objTel=document.frmSales.txt_phone;objEmail=document.frmSales.txt_email;objQuery=document.frmSales.txt_query;if(bValid)
{if(func_is_null(func_trim(objCompany.value)))
{bValid=false;alert("Please enter the organisation name");func_select_focus(objCompany);}}
if(bValid)
if(func_is_null(func_trim(objName.value)))
{bValid=false;alert("Please enter Contact Name");func_select_focus(objName);}
if(bValid)
{if(func_is_null(func_trim(objCountry.value)))
{bValid=false;alert("Please Enter your country");func_select_focus(objCountry);}}
if(bValid)
{if(func_is_null(func_trim(objTel.value)))
{bValid=false;alert("Please enter phone number");func_select_focus(objTel);}
else
if((func_is_telephone_number(func_trim(objTel.value))!=true))
{bValid=false;alert("Please enter a valid phone number");func_select_focus(objTel);}
else if(func_is_null(func_trim(objEmail.value)))
{bValid=false;alert(" Please Enter Email");func_select_focus(objEmail);}
else
if(!func_is_email(func_trim(objEmail.value)))
{bValid=false;alert("Please enter a valid email address");func_select_focus(objEmail);}
else
if(func_is_null(func_trim(objQuery.value)))
{bValid=false;alert("Please Enter your Query");func_select_focus(objQuery);}}
return bValid;}