var reEmail=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/

//******************************************************************************************************************************
var ElementObjectsCache=new Object();
function GetE(objID){
  if (!ElementObjectsCache[objID]) ElementObjectsCache[objID]=document.getElementById(objID);    
  return ElementObjectsCache[objID];
}

//******************************************************************************************************************************
function SearchProds(){
  if (GetE('filter_str').value=='' && GetE('filter_ctr').selectedIndex==0 && GetE('filter_man').selectedIndex==0){
    alert('* Cel putin unul dintre campuri trebuie completat pentru a continua cautarea');
    GetE('filter_str').focus();
  }else{
    document.forms.mainform.search.value='1';
    document.forms.mainform.submit();
  }
}

//******************************************************************************************************************************
function TopSearchProds(page,filter_man){
  if (GetE('topsearch').value=='' || GetE('topsearch').value.length<3){
    alert('Vă rugăm introduceți min 3 caractere in câmpul de căutare !');
    GetE('topsearch').focus();
  }else{
    window.location='index.php?page='+page+'&search=1'+(filter_man!=0?"&filter_man="+filter_man:"")+'&filter_str='+GetE('topsearch').value;
  }
}

//**********************************************************************************************************************
 function showpic(url){
   w = window.open('','PopUpImage','top=0,left=0,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=20,height=20');
   w.document.write("<html>                                                                                                               ");
   w.document.write("  <head>                                                                                                             ");
   w.document.write("    <title>..:: Image ::..</title>                                                                               ");
   w.document.write("    <script language='JavaScript'>                                                                                   ");
   w.document.write("    IE5=NN4=NN6=false;                                                                                               ");
   w.document.write("    if(document.getElementById){                                                                              ");
   w.document.write("      NN6=true;                                                                                                      ");
   w.document.write("    } else if(document.layers) {                                                                                     ");
   w.document.write("      NN4=true;                                                                                                      ");
   w.document.write("    }                                                                                                                ");
   w.document.write("  function autoSize() {                                                                                              ");
   w.document.write("   W=document.images[0].width;H=document.images[0].height;                                             ");
   w.document.write("   if (W>screen.width-80){                                                                                           ");
   w.document.write("     H=Math.round(H*(screen.width-80)/W);                                                                            ");
   w.document.write("     W=screen.width-80;                                                                                              ");
   w.document.write("   }                                                                                                                 ");
   w.document.write("   if (H>screen.height-80){                                                                                          ");
   w.document.write("     W=Math.round(W*(screen.height-80)/H);                                                                           ");
   w.document.write("     H=screen.height-80;                                                                                             ");
   w.document.write("   }                                                                                                                 ");
   w.document.write("   document.images[0].width=W;document.images[0].height=H;                                                           ");
   w.document.write("   if(NN6) {self.resizeTo(W+19,H+63);}                                                                          ");
   w.document.write("   else {top.window.resizeTo(W,H);}                                                                                  ");
   w.document.write("   self.moveTo((screen.width-W)/2,(screen.height-H-62)/2);                                                           ");
   w.document.write("   self.focus();                                                                                                     ");
   w.document.write("  }                                                                                                                  ");
   w.document.write("  </scr");
   w.document.write("ipt>                                                                                                                 ");     
   w.document.write("  </head>                                                                                                            ");
   w.document.write("  <body leftmargin='0' topmargin='0' marginwidth='0' bgcolor='#D7D7D7' marginheight='0' onLoad='javascript:autoSize();window.focus();' bgcolor='#FFFFFF'>");
   w.document.write("    <table border='0' cellpadding='0' cellspacing='0' width='100%' height='100%'><tr><td width='100%' height='100%' align='center'><img src='"+url+"' border='0' onClick='javascript:window.close();'></td></tr></table>");
   w.document.write("  </body>                                                                                                            ");
   w.document.write("</html>                                                                                                              ");
   w.document.close();
 }

//*************************************************************************************************
function validateFeedback(){  
  var ErrorMessage='';
  var FirstError='';
  if (document.forms.mainform.f_firstname.value==''){
    ErrorMessage+="\n - Nume";
    if (FirstError=='') FirstError='f_firstname';
  }
  if (document.forms.mainform.f_lastname.value==''){
    ErrorMessage+="\n - Prenume";
    if (FirstError=='') FirstError='f_lastname';
  }
  if (document.forms.mainform.f_comment.value==''){
    ErrorMessage+="\n - Sugestii/comentarii";
    if (FirstError=='') FirstError='f_comment';
  }
  if (ErrorMessage==''){
    document.forms.mainform.action.value='SubmitContactRequest';
    document.forms.mainform.submit();
  }else{
    alert('Va rugam completati urmatoarele campuri : '+ErrorMessage);
    document.forms.mainform[FirstError].focus();
  }
}


//*************************************************************************************************
function validateOferta(){  
  var ErrorMessage='';
  var FirstError='';
  if (document.forms.mainform.f_firstname.value==''){
    ErrorMessage+="\n - Nume";
    if (FirstError=='') FirstError='f_firstname';
  }
  if (document.forms.mainform.f_lastname.value==''){
    ErrorMessage+="\n - Prenume";
    if (FirstError=='') FirstError='f_lastname';
  }
  if (document.forms.mainform.f_organisation.value==''){
    ErrorMessage+="\n - Firma";
    if (FirstError=='') FirstError='f_organisation';
  }
  if (document.forms.mainform.f_jobtitle.value==''){
    ErrorMessage+="\n - Functia";
    if (FirstError=='') FirstError='f_jobtitle';
  }
  if (document.forms.mainform.f_address.value==''){
    ErrorMessage+="\n - Adresa";
    if (FirstError=='') FirstError='f_address';
  }
  if (document.forms.mainform.f_domains.value==''){
    ErrorMessage+="\n - Domenii de activitate";
    if (FirstError=='') FirstError='f_domains';
  }
  if (document.forms.mainform.f_email.value==''){
    ErrorMessage+="\n - Email";
    if (FirstError=='') FirstError='f_email';
  }
  if (document.forms.mainform.f_telephone.value==''){
    ErrorMessage+="\n - Telefon";
    if (FirstError=='') FirstError='f_telephone';
  }
  if (document.forms.mainform.f_comment.value==''){
    ErrorMessage+="\n - Mesaj";
    if (FirstError=='') FirstError='f_comment';
  }
  if (ErrorMessage==''){
    document.forms.mainform.action.value='SubmitContactRequest';
    document.forms.mainform.submit();
  }else{
    alert('Va rugam completati urmatoarele campuri : '+ErrorMessage);
    document.forms.mainform[FirstError].focus();
  }
}