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


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


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, 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 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.\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.\nThe invitation will be sent to this address.";
    obj=form.vToEmail;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    return false;
   }
 return true;
}


function vSendartForm()
{var msg="";
 var obj;
 var form=document.f_sendart;
 form.submit.disabled=true;
 if(trim(form.vBody.value)=="")
   {msg="Please insert your article";
    obj=form.vBody;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    form.submit.disabled=false;
    return false;
   }
 return true;
}

function vSendevtForm()
{var msg="";
 var obj;
 var form=document.f_sendevt;
 form.submit.disabled=true;
 if(trim(form.vName.value)=="")
   {msg="Please insert your event name";
    obj=form.vName;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    form.submit.disabled=false;
    return false;
   }
 return true;
}

function vPaymentForm()
{var msg="";
 var obj;
 var form=document.f_pay;
 form.submit.disabled=true;
 now = new Date();
 cy=now.getYear();
 if(cy<1000) cy+=1900;
 cm=now.getMonth()+1;
 vy=parseInt(form.expYear.value,10);
 vm=parseInt(form.expMonth.value,10);
 if(isNaN(vy)||isNaN(vm)) vy=0;
  else vy+=2000;
 form.cc_num.value=trim(form.cc_num.value);
 if(form.cc_num.value.length!=16)
   {msg="Please specify a valid credit card number - 16 digits, without spaces or other separators.";
    obj=form.cc_num;
   }
 else if(vy<cy||(vy==cy&&vm<cm))
   {msg="The credit card expiration date ("+vm+"/"+vy+") is in the past!";
    obj=form.expMonth;
   }
 else if(trim(form.cardholder.value)=="")
   {msg="Please specify the cardholder's name exactly as it apears on the credit card.";
    obj=form.cardholder;
   }
 else if(!emailCheck(form.email.value))
   {msg="Please specify a valid e-mail address where you want to receive the receipt!";
    obj=form.email;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    form.submit.disabled=false;
    return false;
   }
 return true;
}

function vOrderBookForm()
{var msg="";
 var obj;
 var form=document.f_order_book;
 form.submit.disabled=true;
 if(isNaN(form.vQuantity.value)
  ||isNaN(parseInt(form.vQuantity.value))
  ||parseInt(form.vQuantity.value)<=0
   )
   {msg="Please specify a valid quantity!";
    obj=form.vQuantity;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    form.submit.disabled=false;
    return false;
   }
 return true;
}

function vDinnerRegisterForm()
{var msg="";
 var obj;
 var form=document.f_dinner_register;
 form.submit.disabled=true;
 if(form.vJoin[2].checked
  &&form.vJoinType.selectedIndex==0
   )
   {msg="Please choose a type of membership!";
    obj=form.vJoinType;
   }
 var l=(document.all?document.all["selCatList"]:document.getElementById("selCatList"));
 if(msg==""&&form.vJoin[2].checked&&l.length==0)
   {msg="Please choose a category for your profile in the directory!";
    obj=l;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    form.submit.disabled=false;
    return false;
   }
 if(l.length>0) for(var i=0;i<l.length;i++) l[i].selected=true;
 return true;
}

function vEventRegisterForm()
{var msg="";
 var obj;
 var form=document.f_event_register;
 form.submit.disabled=true;
 var pack=-1;
 for(var i in form.vPack)
   if(form.vPack[i].checked) pack=i;
 if(pack==-1)
   {msg="Please select at least one registration item.";
    obj=form.vPack[0];
   }
 if(form.vJoin[2].checked
  &&form.vJoinType.selectedIndex==0
   )
   {msg="Please choose a type of membership!";
    obj=form.vJoinType;
   }
 var l=(document.all?document.all["selCatList"]:document.getElementById("selCatList"));
 if(msg==""&&form.vJoin[2].checked&&l.length==0)
   {msg="Please choose a category for your profile in the directory!";
    obj=l;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    form.submit.disabled=false;
    return false;
   }
 if(l.length>0) for(var i=0;i<l.length;i++) l[i].selected=true;
 return true;
}


function vJoinForm()
{var msg="";
 var obj;
 var form=document.f_join;
 if(typeof(form.vSubmit)!="undefined") form.vSubmit.disabled=true;
 if(form.vJoinType.selectedIndex==0)
   {msg="Please choose a type of membership!";
    obj=form.vJoinType;
   }
 var l=(document.all?document.all["selCatList"]:document.getElementById("selCatList"));
 if(l.length==0)
   {msg="Please choose a category for your profile in the directory!";
    obj=l;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    if(typeof(form.vSubmit)!="undefined") form.vSubmit.disabled=false;
    return false;
   }
 for(var i=0;i<l.length;i++) l[i].selected=true;
 return true;
}


function vMemSurveyForm()
{var msg="";
 var obj;
 var form=document.f_memsurvey;
 if(processingForm)
   {alert('The form is being processed.');
    return false;
   }
 processingForm=true;
     if(trim(form.vFirstName.value)=="")
       {msg="Please tell us your first name.";
        obj=form.vFirstName;
       }
     else if(trim(form.vLastName.value)=="")
       {msg="Please tell us your last name.";
        obj=form.vLastName;
       }
     else if(trim(form.vCompany.value)=="")
       {msg="Please tell us the name of your company";
        obj=form.vCompany;
       }
      else if(trim(form.vAddress.value)=="")
       {msg="Please tell us your address.";
        obj=form.vAddress;
       }
      else if(trim(form.vCity.value)=="")
       {msg="Please tell us your city.";
        obj=form.vCity;
       }
      else if(trim(form.vPostCode.value)=="")
       {msg="Please tell us your postal code.";
        obj=form.vPostCode;
       }
     else if(trim(form.vPhone.value)=="")
       {msg="Please provide a phone number where we can contact you.";
        obj=form.vPhone;
       }
     else if(!emailCheck(form.vEmail.value))
       {msg="Please provide an e-mail address where we can contact you.";
        obj=form.vEmail;
       }
     else if(trim(form.vSelfEmployed.value)=="")
       {msg="How long have you been self-employed?";
        obj=form.vSelfEmployed;
       }
     else if(trim(form.vBizType.value)=="")
       {msg="What type of business are you in?";
        obj=form.vBizType;
       }
     else if(trim(form.vBizCust.value)=="")
       {msg="Who is your ideal customer?";
        obj=form.vBizCust;
       }
     else if(trim(form.vBizHelp.value)=="")
       {msg="How can we help you?  Is there an area of your business where you need help?";
        obj=form.vBizHelp;
       }
 if(msg!="")
   {alert(msg);
    obj.focus();
    processingForm=false;
    return false;
   }
 return true;
}






function clearField(o,t)
{if(typeof(o)=='undefined'||o==null) return;
 if(typeof(o.value)=='undefined') return;
 if(typeof(t)=='undefined'||o.value==t) o.value='';
}

function fillField(o,t)
{if(typeof(o)=='undefined'||o==null) return;
 if(typeof(o.value)=='undefined') return;
 if(typeof(t)!='undefined'&&o.value=='') o.value=t;
}


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=/^(.+)@(.+)$/;
var matchArray=emailStr.match(emailPat);
if (matchArray==null) return false;
return true;
}
