function echomail(acc,dom){document.write(acc+"@"+dom)}
function mail2(acc,dom){location.href="mailto:"+acc+"@"+dom}


function showWin(u,n)
{f=(n=="tdp2"?"top=20,left=20":"top=0,left=0")
  +",width=520,height=450,location=no,menubar=no,titlebar=no,status=no,toolbar=no,"
  +"scrollbars=yes,"
  +"resizable=yes";
// if(n==undefined) n="tdp";
 hwnd=window.open(u,n,f);
 //hwnd.focus();
}
function popup(url){showWin(url,"tdp")}



function vContactForm()
{var msg="";
 var obj;
 var form=document.f_contact;
 form.submit.disabled=true;
 if(trim(form.vName.value)=="")
   {msg="Please tell us your name!";
    obj=form.vName;
   }
 else if(!emailCheck(form.vEmail.value))
   {msg="Please specify a valid e-mail address where you want to receive the reply!";
    obj=form.vEmail;
   }
 else if(trim(form.vMsg.value)=="")
   {msg="Please type in the message you want to send to us!";
    obj=form.vMsg;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    form.submit.disabled=false;
    return false;
   }
 return true;
}

function vTellafriendForm()
{var msg="";
 var obj;
 var form=document.f_tellafriend;
 if(trim(form.vFromName.value)=="")
   {msg="Please specify your name.\nThe invitation will be signed using this name.";
    obj=form.vFromName;
   }
 else if(!emailCheck(form.vFromEmail.value))
   {msg="Please specify your e-mail address and make sure it's correct.\nThe invitation will appear to be sent from this address.\nIt is also useful if your friend wants to reply to you.";
    obj=form.vFromEmail;
   }
 else if(trim(form.vToName.value)=="")
   {msg="Please specify your friend's name.\nThe invitation will be addressed to this name.";
    obj=form.vToName;
   }
 else if(!emailCheck(form.vToEmail.value))
   {msg="Please specify your friend's e-mail address and make sure it's correct.\nThe invitation will be sent to this address.";
    obj=form.vToEmail;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    return false;
   }
 return true;
}

function vSubscribeForm()
{var msg="";
 var obj;
 var form=document.f_subscribe;
 form.submit.disabled=true;
 if(trim(form.vName.value)=="")
   {msg="Please tell us your name, the way you want us to address you!";
    obj=form.vName;
   }
 else if(!emailCheck(form.vEmail.value))
   {msg="Please specify a valid e-mail address where you want to receive our newsletter";
    obj=form.vEmail;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    form.submit.disabled=false;
    return false;
   }
 return true;
}

function vUnsubscribeForm()
{var msg="";
 var obj;
 var form=document.f_unsubscribe;
 form.submit.disabled=true;
 if(!emailCheck(form.vEmail.value))
   {msg="Please specify the e-mail address where you are currently receiving our newsletter!";
    obj=form.vEmail;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    form.submit.disabled=false;
    return false;
   }
 return true;
}


function vSendpageForm()
{var msg="";
 var obj;
 var form=document.f_tellafriend;
 if(trim(form.vFromName.value)=="")
   {msg="Please specify your name.\nThe message will be signed using this name.";
    obj=form.vFromName;
   }
 else if(!emailCheck(form.vFromEmail.value))
   {msg="Please specify your e-mail address and make sure it's correct.\nThe message will appear to be sent from this address.\nIt is also useful if your friend wants to reply to you.";
    obj=form.vFromEmail;
   }
 else if(trim(form.vToName.value)=="")
   {msg="Please specify your friend's name.\nThe message will be addressed to this name.";
    obj=form.vToName;
   }
 else if(!emailCheck(form.vToEmail.value))
   {msg="Please specify your friend's e-mail address and make sure it's correct.\nThe message will be sent to this address.";
    obj=form.vToEmail;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    return false;
   }
 return true;
}



function vQuoteForm()
{var msg="";
 var obj;
 var form=document.f_quote;
 form.submit.disabled=true;
 if(trim(form.vCompany.value)=="")
   {msg="Please specify the company name!";
    obj=form.vCompany;
   }
 else if(trim(form.vName.value)=="")
   {msg="Please specify your name!";
    obj=form.vName;
   }
 else if(trim(form.vAddress.value)=="")
   {msg="Please specify a mailing address!";
    obj=form.vAddress;
   }
 else if(!emailCheck(form.vEmail.value))
   {msg="Please specify a valid e-mail address where we can reach you!";
    obj=form.vEmail;
   }
 else if(trim(form.vPhone.value)=="")
   {msg="Please specify a telephone number where we can reach you!";
    obj=form.vPhone;
   }
 else if(trim(form.vFax.value)=="")
   {msg="Please specify a fax number where we can reach you!";
    obj=form.vFax;
   }
 else if(trim(form.vProject.value)=="")
   {msg="Please specify the project name!";
    obj=form.vProject;
   }
 else if(trim(form.vLocation.value)=="")
   {msg="Please specify the project location!";
    obj=form.vLocation;
   }
 else if(trim(form.vProduct.value)==""
       &&!(form.vSpecs[0].checked))
   {msg="Please specify the product(s) required or attach specifications!";
    obj=form.vProduct;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    form.submit.disabled=false;
    return false;
   }
 return true;
}


function vMapDirForm()
{var msg="";
 var obj;
 var form=document.f_mapdir;
 if(trim(form.vAddress.value)=="")
   {msg="Please specify a street address to get directions from or to.";
    obj=form.vAddress;
   }
 else if(trim(form.vCity.value)=="")
   {msg="Please specify the city/town for the address to get directions from or to.";
    obj=form.vCity;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    return false;
   }
 return true;
}




function trim(str)
{var first,last;
 for (first=0; first<str.length&&str.charCodeAt(first)==32; first++);
 for (last=str.length; last>first&&str.charCodeAt(last-1)==32; last--);
 return (last>first?str.substr(first,last-first):'');
}

function emailCheck(emailStr) {
emailStr=trim(emailStr);
if(emailStr=='')return false;
var emailPat=/^(.+)@(.+)\.(.{2,})$/;
var matchArray=emailStr.match(emailPat);
if (matchArray==null) return false;
return true;
}
