
function chk_domain(dom,allow_1_label)
{var valid="abcdefghijklmnopqrstuvwxyz0123456789-.",invalid_edge="-.";if(dom.length<3&&!allow_1_label)
return false;dom=dom.toLowerCase();for(var i=dom.length-1;i>=0;i-=1)
{if(valid.indexOf(dom.charAt(i))<0)
return false;}
if(invalid_edge.indexOf(dom.charAt(0))>=0||invalid_edge.indexOf(dom.charAt(dom.length-1))>=0||dom.indexOf(".-")>=0||dom.indexOf("-.")>=0||dom.indexOf("..")>=0||((!allow_1_label)&&dom.indexOf(".")<0))
return false;return true;}
function validate_notempty(id,msg)
{var i,ws=" \t\r\n",obj=e(id);if(!obj)
return true;for(i=obj.value.length-1;i>=0;i-=1)
{if(ws.indexOf(obj.value.charAt(i))<0)
return true;}
alert(msg);if(obj.focus)
obj.focus();return false;}
function validate_checked(id,msg)
{var obj=e(id);if(!obj)
return true;if(obj.checked)
return true;alert(msg);if(obj.focus)
obj.focus();return false;}
function validate_not1st(id,msg)
{var obj=e(id);if(!obj)
return true;if(obj.selectedIndex>0)
return true;alert(msg);if(obj.focus)
obj.focus();return false;}
function validate_email(id,msg)
{var valid="abcdefghijklmnopqrstuvwxyz0123456789-._";var i,local,dom,obj=e(id);if(!obj)
return true;i=obj.value.indexOf("@");if(i>0&&i<obj.value.length-1)
{local=obj.value.substring(0,i).toLowerCase();dom=obj.value.substring(i+1,obj.value.length);if(chk_domain(dom,false))
{dom=true;for(i=local.length-1;i>=0;i-=1)
{if(valid.indexOf(local.charAt(i))<0)
{dom=false;break;}}
if(dom)
return true;}}
alert(msg);if(obj.focus)
obj.focus();return false;}
function validate_domain(id,msg)
{var obj=e(id);if(!obj)
return true;if(chk_domain(obj.value,true))
return true;alert(msg);if(obj.focus)
obj.focus();return false;}
function validate_custom_order(f,msg_domain,msg_contract,msg_vat_pt)
{var ix;if(f.form)
f=f.form;if(f.copied_fields.value.indexOf("contract_commerce_hosting_managed = no")>=0)
{alert(msg_contract);if(document.focus)
{for(ix=0;ix<document.forms.length;ix++)
if(document.forms[ix].contract_commerce_hosting_managed)
if(!document.forms[ix].contract_commerce_hosting_managed.checked)
break;if(ix<document.forms.length)
document.forms[ix].contract_commerce_hosting_managed.focus();}
return false;}
if(f.special_requests_notempty.value.toLowerCase()!="no")
{for(ix=0;ix<document.forms.length;ix++)
if(document.forms[ix].special_requests)
break;if(ix<document.forms.length&&!validate_notempty(document.forms[ix].special_requests.id,msg_domain))
return false;}
if(f.sponsor_country.options[f.sponsor_country.selectedIndex].value.toLowerCase()=="pt"&&!validate_notempty(f.sponsor_vat.id,msg_vat_pt))
return false;return true;}
function validate_custom_domain_search(f,msg_none)
{var ix,i,ix1,i1;if(f.form)
f=f.form;ix1=-1;for(ix=0;ix<document.forms.length;ix++)
{for(i=0;i<document.forms[ix].elements.length;i++)
{if(document.forms[ix].elements[i].name!="add[]")
continue;if(document.forms[ix].elements[i].checked)
return true;if(ix1<0)
{ix1=ix;i1=i;}}}
alert(msg_none);if(ix1>=0&&document.focus)
document.forms[ix1].elements[i1].focus();return false;}
function validate_custom_template_search(f,msg_none)
{if(f.form)
f=f.form;if((f.category.selectedIndex>0&&f.category.options[f.category.selectedIndex].value>0)||f.keywords.value!="")
return true;alert(msg_none);if(f.category.focus)
f.category.focus();return false;}