function contact() {
    var message1='';
    if(document.getElementById('name').value=='') {
        message1+='Va rugam completati numele dvs.\n';
        valid=0;
        }
    
    if(document.getElementById('phone').value=='') {
        message1+='Va rugam completati telefonul dvs.\n';
        valid=0;
        }

    if(document.getElementById('email').value=='') {
        message1+='Va rugam completati adresa dvs. de e-mail\n';
        valid=0;
        }
    
    
    if(document.getElementById('subject').value=='') {
        message1+='Va rugam introduceti subiectul mesajului\n';
        valid=0;
        }
    
    //index1=document.getElementById('subject').selectedIndex;
    /*if(index1=='') {
        message1+='Va rugam completati subiectul\n';
        valid=0;
        }*/


    if(document.getElementById('message_content').value=='') {
        message1+='Va rugam introduceti mesajul\n';
        valid=0;
        }
    
    if(message1!='') { alert(message1);}
	else document.getElementById('contact_form').submit();
    
    
}



function editare_date(){
	var mesaj='';
    var mesaj_cont='';
    var mesaj_bill='';
    var mesaj_shipp='';
     
    if(document.getElementById('nume').value=='') mesaj_cont+='Campul Nume este obligatoriu\n';
    if(document.getElementById('prenume').value=='') mesaj_cont+='Campul Prenume este obligatoriu\n';
    if(document.getElementById('email').value=='') mesaj_cont+='Campul Email este obligatoriu\n';
	if(document.getElementById('telefon').value=='') mesaj_cont+='Campul Telefon este obligatoriu\n';
        
    if(mesaj_cont!="")
        mesaj+='Informatii necesare contului dvs.: \n\n'+mesaj_cont;
        
    if(document.getElementById('bill_nume').value==''){ mesaj_bill='Campul Nume este obligatoriu\n';}
    if(document.getElementById('bill_prenume').value==''){ mesaj_bill+='Campul Prenume este obligatoriu\n';}   
    if(document.getElementById('bill_telefon').value=='') mesaj_bill+='Campul Telefon este obligatoriu\n'; 
	if(document.getElementById('bill_cnp').value==''){ mesaj_bill+='Campul CNP este obligatoriu\n';}
	if(document.getElementById('bill_serie_ci').value=='')  mesaj_bill+='Campul Serie CI este obligatoriu\n';
	if(document.getElementById('bill_nr_ci').value=='')  mesaj_bill+='Campul Numar CI este obligatoriu\n';    
	if(document.getElementById('bill_city').value=='')  mesaj_bill+='Campul Localitate este obligatoriu\n';
    if(document.getElementById('bill_strada').value=='')  mesaj_bill+='Campul Strada este obligatoriu\n';
	if(document.getElementById('bill_strada_nr').value=='')  mesaj_bill+='Campul Numar (numarul strazii) este obligatoriu\n';
	
    index1=document.getElementById('bill_county').selectedIndex;
	valoare_judet=document.getElementById('bill_county').options[index1].value;
	if( valoare_judet=='')
		mesaj_bill+='Campul Judet este obligatoriu\n';
	if (document.getElementById('bill_postal_code').value.length!=6) mesaj_bill+='Campul Cod Postal trebuie sa contina exact 6 caractere\n';
	
    if(document.getElementById('juridica').checked==true) {
   	    if(document.getElementById('bill_company').value=='')  mesaj_bill+='Campul Nume firma este obligatoriu\n';
        if(document.getElementById('bill_company_cui').value=='')  mesaj_bill+='Campul Cod Fiscal este obligatoriu\n';
        if(document.getElementById('bill_company_reg_com').value=='')  mesaj_bill+='Campul Nr. inreg. fiscala este obligatoriu\n';
        }   
    if(mesaj_bill!="")
        mesaj+='\nInformatii necesare facturarii: \n\n'+mesaj_bill;
    
    if(document.getElementById('shipp_nume').value==''){ mesaj_shipp='Campul Nume este obligatoriu\n';}
    if(document.getElementById('shipp_prenume').value==''){ mesaj_shipp+='Campul Prenume este obligatoriu\n';}   
    if(document.getElementById('shipp_telefon').value=='') mesaj_shipp+='Campul Telefon este obligatoriu\n'; 
	if(document.getElementById('shipp_city').value=='')  mesaj_shipp+='Campul Localitate este obligatoriu\n';
    if(document.getElementById('shipp_strada').value=='')  mesaj_shipp+='Campul Strada este obligatoriu\n';
	if(document.getElementById('shipp_strada_nr').value=='')  mesaj_shipp+='Campul Numar (numarul strazii) este obligatoriu\n';
	index1=document.getElementById('shipp_county').selectedIndex;
	valoare_judet=document.getElementById('shipp_county').options[index1].value;
	if( valoare_judet=='')
		mesaj_shipp+='Campul Judet este obligatoriu\n';
	if (document.getElementById('shipp_postal_code').value.length!=6) mesaj_shipp+='Campul Cod Postal trebuie sa contina exact 6 caractere\n';
	
    if(document.getElementById('juridica').checked==true) 
   	    if(document.getElementById('shipp_company').value=='')  mesaj_shipp+='Campul Nume firma este obligatoriu\n';
        
    if(mesaj_shipp!="")
        mesaj+='\nInformatii necesare livrarii: \n\n'+mesaj_shipp;
    
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();  
}



function inregistrare(){
	var mesaj='';
    var mesaj_cont='';
    var mesaj_bill='';
    var mesaj_shipp='';
     
    if(document.getElementById('nume').value=='') mesaj_cont+='Campul Nume este obligatoriu\n';
    if(document.getElementById('prenume').value=='') mesaj_cont+='Campul Prenume este obligatoriu\n';
    if(document.getElementById('email').value=='') mesaj_cont+='Campul Email este obligatoriu\n';
	if(document.getElementById('telefon').value=='') mesaj_cont+='Campul Telefon este obligatoriu\n';
    if(document.getElementById('pass1').value=='') mesaj_cont+='Campul Parola este obligatoriu\n';
    
    if(mesaj_cont!="")
        mesaj='Informatii necesare contului dvs.: \n\n'+mesaj_cont;
        
    if(document.getElementById('bill_nume').value==''){ mesaj_bill='Campul Nume este obligatoriu\n';}
    if(document.getElementById('bill_prenume').value==''){ mesaj_bill+='Campul Prenume este obligatoriu\n';}   
    if(document.getElementById('bill_telefon').value=='') mesaj_bill+='Campul Telefon este obligatoriu\n'; 
	if(document.getElementById('bill_cnp').value==''){ mesaj_bill+='Campul CNP este obligatoriu\n';}
	if(document.getElementById('bill_serie_ci').value=='')  mesaj_bill+='Campul Serie CI este obligatoriu\n';
	if(document.getElementById('bill_nr_ci').value=='')  mesaj_bill+='Campul Numar CI este obligatoriu\n';    
	if(document.getElementById('bill_city').value=='')  mesaj_bill+='Campul Localitate este obligatoriu\n';
    if(document.getElementById('bill_strada').value=='')  mesaj_bill+='Campul Strada este obligatoriu\n';
	if(document.getElementById('bill_strada_nr').value=='')  mesaj_bill+='Campul Numar (numarul strazii) este obligatoriu\n';
	
    index1=document.getElementById('bill_county').selectedIndex;
	valoare_judet=document.getElementById('bill_county').options[index1].value;
	if( valoare_judet=='')
		mesaj_bill+='Campul Judet este obligatoriu\n';
	if (document.getElementById('bill_postal_code').value.length!=6) mesaj_bill+='Campul Cod Postal trebuie sa contina exact 6 caractere\n';
	
    if(document.getElementById('juridica').checked==true) {
   	    if(document.getElementById('bill_company').value=='')  mesaj_bill+='Campul Nume firma este obligatoriu\n';
        if(document.getElementById('bill_company_cui').value=='')  mesaj_bill+='Campul Cod Fiscal este obligatoriu\n';
        if(document.getElementById('bill_company_reg_com').value=='')  mesaj_bill+='Campul Nr. inreg. fiscala este obligatoriu\n';
        }   
    if(mesaj_bill!="")
        mesaj+='\nInformatii necesare facturarii: \n\n'+mesaj_bill;
    
    if(document.getElementById('shipp_nume').value==''){ mesaj_shipp='Campul Nume este obligatoriu\n';}
    if(document.getElementById('shipp_prenume').value==''){ mesaj_shipp+='Campul Prenume este obligatoriu\n';}   
    if(document.getElementById('shipp_telefon').value=='') mesaj_shipp+='Campul Telefon este obligatoriu\n'; 
	if(document.getElementById('shipp_city').value=='')  mesaj_shipp+='Campul Localitate este obligatoriu\n';
    if(document.getElementById('shipp_strada').value=='')  mesaj_shipp+='Campul Strada este obligatoriu\n';
	if(document.getElementById('shipp_strada_nr').value=='')  mesaj_shipp+='Campul Numar (numarul strazii) este obligatoriu\n';
	index1=document.getElementById('shipp_county').selectedIndex;
	valoare_judet=document.getElementById('shipp_county').options[index1].value;
	if( valoare_judet=='')
		mesaj_shipp+='Campul Judet este obligatoriu\n';
	if (document.getElementById('shipp_postal_code').value.length!=6) mesaj_shipp+='Campul Cod Postal trebuie sa contina exact 6 caractere\n';
	
    if(document.getElementById('juridica').checked==true) 
   	    if(document.getElementById('shipp_company').value=='')  mesaj_shipp+='Campul Nume firma este obligatoriu\n';
        
    if(mesaj_shipp!="")
        mesaj+='\nInformatii necesare livrarii: \n\n'+mesaj_shipp;
    
    if (document.getElementById('termeni_cond').checked==false)  mesaj+='\nTrebuie sa fii de acord cu termenii si conditiile de utilizare\n';
	
     
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();  
}

function inregistrare_hu(){
	var mesaj='';
    var mesaj_cont='';
    var mesaj_bill='';
    var mesaj_shipp='';
     
    if(document.getElementById('nume').value=='') mesaj_cont+='A vezetéknév mező kitöltése kötelező!\n';
    if(document.getElementById('prenume').value=='') mesaj_cont+='A keresztnév mező kitöltése kötelező!\n';
    if(document.getElementById('email').value=='') mesaj_cont+='E-mail mező kitöltése kötelező\n';
	if(document.getElementById('telefon').value=='') mesaj_cont+='Telefonszám mező kitöltése kötelező\n';
    if(document.getElementById('pass1').value=='') mesaj_cont+='Jelszó mező kitöltése kötelező\n';
    
    if(mesaj_cont!="")
        mesaj='Fiók információk: \n\n'+mesaj_cont;
        
    if(document.getElementById('bill_nume').value==''){ mesaj_bill='A vezetéknév mező kitöltése kötelező!\n';}
    if(document.getElementById('bill_prenume').value==''){ mesaj_bill+='A keresztnév mező kitöltése kötelező!\n';}   
    if(document.getElementById('bill_telefon').value=='') mesaj_bill+='Telefonszám mező kitöltése kötelező\n'; 
	if(document.getElementById('bill_city').value=='')  mesaj_bill+='A helységnév mező kitöltése kötelező!\n';
    if(document.getElementById('bill_strada').value=='')  mesaj_bill+='Az utcanév mező kitöltése kötelező!\n';
	if(document.getElementById('bill_strada_nr').value=='')  mesaj_bill+='A házszám mező kitöltése kötelező!\n';
	
    index1=document.getElementById('bill_county').selectedIndex;
	valoare_judet=document.getElementById('bill_county').options[index1].value;
	if( valoare_judet=='')
		mesaj_bill+='A megye mező kitöltése kötelező!\n';
	if (document.getElementById('bill_postal_code').value=='') mesaj_bill+='Irányítószám mező kitöltése kötelező!\n';
	
    if(document.getElementById('juridica').checked==true) {
   	    if(document.getElementById('bill_company').value=='')  mesaj_bill+='Campul Nume firma este obligatoriu\n';
        if(document.getElementById('bill_company_cui').value=='')  mesaj_bill+='Campul Cod Fiscal este obligatoriu\n';
        }   
    if(mesaj_bill!="")
        mesaj+='\nSzámlázási adatok: \n\n'+mesaj_bill;
    
    if(document.getElementById('shipp_nume').value==''){ mesaj_shipp='A vezetéknév mező kitöltése kötelező!\n';}
    if(document.getElementById('shipp_prenume').value==''){ mesaj_shipp+='A keresztnév mező kitöltése kötelező!\n';}   
    if(document.getElementById('shipp_telefon').value=='') mesaj_shipp+='Telefonszám mező kitöltése kötelező\n'; 
	if(document.getElementById('shipp_city').value=='')  mesaj_shipp+='A helységnév mező kitöltése kötelező!\n';
    if(document.getElementById('shipp_strada').value=='')  mesaj_shipp+='Az utcanév mező kitöltése kötelező!\n';
	if(document.getElementById('shipp_strada_nr').value=='')  mesaj_shipp+='A házszám mező kitöltése kötelező!\n';
	index1=document.getElementById('shipp_county').selectedIndex;
	valoare_judet=document.getElementById('shipp_county').options[index1].value;
	if( valoare_judet=='')
		mesaj_shipp+='Campul Judet este obligatoriu\n';
	if (document.getElementById('shipp_postal_code').value=='') mesaj_shipp+='Irányítószám mező kitöltése kötelező!\n';
	
    if(document.getElementById('juridica').checked==true) 
       	    if(document.getElementById('shipp_company').value=='')  mesaj_shipp+='Campul Nume firma este obligatoriu\n';
        
    if(mesaj_shipp!="")
        mesaj+='\nSzállítási információ: \n\n'+mesaj_shipp;
    
    if (document.getElementById('termeni_cond').checked==false)  mesaj+='\nEl kell fogadnia a felhasználás feltételeit!\n';
	
     
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();  
}


function trimite_comanda(){
	var mesaj='';
    var mesaj_cont='';
    var mesaj_bill='';
    var mesaj_shipp='';
    var mesaj_plata='';
        
    if(document.getElementById('bill_nume').value==''){ mesaj_bill='Campul Nume este obligatoriu\n';}
    if(document.getElementById('bill_prenume').value==''){ mesaj_bill+='Campul Prenume este obligatoriu\n';}   
    if(document.getElementById('bill_telefon').value=='') mesaj_bill+='Campul Telefon este obligatoriu\n'; 
	if(document.getElementById('bill_cnp').value==''){ mesaj_bill+='Campul CNP este obligatoriu\n';}
	if(document.getElementById('bill_serie_ci').value=='')  mesaj_bill+='Campul Serie CI este obligatoriu\n';
	if(document.getElementById('bill_nr_ci').value=='')  mesaj_bill+='Campul Numar CI este obligatoriu\n';    
	if(document.getElementById('bill_city').value=='')  mesaj_bill+='Campul Localitate este obligatoriu\n';
    if(document.getElementById('bill_strada').value=='')  mesaj_bill+='Campul Strada este obligatoriu\n';
	if(document.getElementById('bill_strada_nr').value=='')  mesaj_bill+='Campul Numar (numarul strazii) este obligatoriu\n';
	
    index1=document.getElementById('bill_county').selectedIndex;
	valoare_judet=document.getElementById('bill_county').options[index1].value;
	if( valoare_judet=='')
		mesaj_bill+='Campul Judet este obligatoriu\n';
	if (document.getElementById('bill_postal_code').value.length!=6) mesaj_bill+='Campul Cod Postal trebuie sa contina exact 6 caractere\n';
	
    if(document.getElementById('juridica').checked==true) {
   	    if(document.getElementById('bill_company').value=='')  mesaj_bill+='Campul Nume firma este obligatoriu\n';
        if(document.getElementById('bill_company_cui').value=='')  mesaj_bill+='Campul Cod Fiscal este obligatoriu\n';
        if(document.getElementById('bill_company_reg_com').value=='')  mesaj_bill+='Campul Nr. inreg. fiscala este obligatoriu\n';
        }   
    if(mesaj_bill!="")
        mesaj+='\nInformatii necesare facturarii: \n\n'+mesaj_bill;
    
    if(document.getElementById('shipp_nume').value==''){ mesaj_shipp='Campul Nume este obligatoriu\n';}
    if(document.getElementById('shipp_prenume').value==''){ mesaj_shipp+='Campul Prenume este obligatoriu\n';}   
    if(document.getElementById('shipp_telefon').value=='') mesaj_shipp+='Campul Telefon este obligatoriu\n'; 
	if(document.getElementById('shipp_city').value=='')  mesaj_shipp+='Campul Localitate este obligatoriu\n';
    if(document.getElementById('shipp_strada').value=='')  mesaj_shipp+='Campul Strada este obligatoriu\n';
	if(document.getElementById('shipp_strada_nr').value=='')  mesaj_shipp+='Campul Numar (numarul strazii) este obligatoriu\n';
	index1=document.getElementById('shipp_county').selectedIndex;
	valoare_judet=document.getElementById('shipp_county').options[index1].value;
	if( valoare_judet=='')
		mesaj_shipp+='Campul Judet este obligatoriu\n';
	if (document.getElementById('shipp_postal_code').value.length!=6) mesaj_shipp+='Campul Cod Postal trebuie sa contina exact 6 caractere\n';
	
    if(document.getElementById('juridica').checked==true) 
   	    if(document.getElementById('shipp_company').value=='')  mesaj_shipp+='Campul Nume firma este obligatoriu\n';
        
    if(mesaj_shipp!="")
        mesaj+='\nInformatii necesare livrarii: \n\n'+mesaj_shipp;
    
    if (document.getElementById('termeni_cond').checked==false)  mesaj+='\nTrebuie sa fii de acord cu termenii si conditiile de utilizare\n';
	
    
   
	index1=document.getElementById('tip_plata').selectedIndex;
	valoare_plata=document.getElementById('tip_plata').options[index1].value;
	if( valoare_plata=='0')
		mesaj_plata+='\n\nNu ai selectat modalitatea de plata\n';
	    
    mesaj+=mesaj_plata;
    
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();  
}




function trimite_comanda_hu() {
	var mesaj='';
    
    if(document.getElementById('bill_nume').value==''){ mesaj='A vezetéknév mező kitöltése kötelező!\n';}
    if(document.getElementById('bill_prenume').value==''){ mesaj+='A keresztnév mező kitöltése kötelező!\n';}
   
    if(document.getElementById('bill_city').value=='')  mesaj+='A helységnév mező kitöltése kötelező!\n';
	if(document.getElementById('bill_strada_nr').value=='')  mesaj+='A házszám mező kitöltése kötelező!\n';
	index1=document.getElementById('bill_county').selectedIndex;
	valoare_judet=document.getElementById('bill_county').options[index1].value;
	if( valoare_judet=='')
		mesaj+='A megye kiválasztása kötelező!\n';
	
	index1=document.getElementById('tip_plata').selectedIndex;
	valoare_plata=document.getElementById('tip_plata').options[index1].value;
	if( valoare_plata=='0')
		mesaj+='A fizetési mód kiválasztása kötelező!\n';
	
	
	if(document.getElementById('bill_strada').value=='')  mesaj+='Az utcanév mező kitöltése kötelező!\n';
	
    if(document.getElementById('email').value=='') mesaj+='E-mail mező kitöltése kötelező\n';
	if (document.getElementById('bill_telefon').value=='') mesaj+='Telefonszám mező kitöltése kötelező\n';  
        
	if(document.getElementById('termeni_cond').checked==false)  mesaj+='El kell fogadnia a felhasználás feltételeit!\n';
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}




function hide_company() {
    document.getElementById('show_bill_company').style.display='none';
    document.getElementById('show_bill_company_cui').style.display='none';
    document.getElementById('show_bill_company_reg_com').style.display='none';
    document.getElementById('show_bill_company_banca').style.display='none';
    document.getElementById('show_bill_iban').style.display='none';
    document.getElementById('show_shipp_company').style.display='none';
       
}

function show_company() {
    document.getElementById('show_bill_company').style.display='block';
    document.getElementById('show_bill_company_cui').style.display='block';
    document.getElementById('show_bill_company_reg_com').style.display='block';
    document.getElementById('show_bill_company_banca').style.display='block';
    document.getElementById('show_bill_iban').style.display='block';
    document.getElementById('show_shipp_company').style.display='block';
       
}

function contact_en() {
    var message1='';
    if(document.getElementById('name').value=='') {
        message1+='Please fill in your name\n';
        valid=0;
        }
    
    if(document.getElementById('phone').value=='') {
        message1+='Please fill in your phone number\n';
        valid=0;
        }

    if(document.getElementById('email').value=='') {
        message1+='Please fill in your e-mail address\n';
        valid=0;
        }

    if(document.getElementById('subject').value=='') {
        message1+='Please fill in the subject\n';
        valid=0;
        }

    if(document.getElementById('message_content').value=='') {
        message1+='Please fill in your message\n';
        valid=0;
        }
    
    if(message1!='') { alert(message1);}
	else document.getElementById('contact_form').submit();
    
    
}   

function go_to_cat_prod(categorie,poz) {
   
   document.location=categorie+document.getElementById('producator'+poz).value+'/';
}

function click_same_bill() {
    if(document.getElementById('same_bill').checked==true) {
        document.getElementById('bill_nume').value=document.getElementById('nume').value;
        document.getElementById('bill_prenume').value=document.getElementById('prenume').value;
        document.getElementById('bill_telefon').value=document.getElementById('telefon').value;
    }
    else {
        document.getElementById('bill_nume').value='';
        document.getElementById('bill_prenume').value='';
        document.getElementById('bill_telefon').value='';
    }
     
}
function click_same_shipp() {
   
    if(document.getElementById('same_shipp').checked==true) {
        document.getElementById('shipp_nume').value=document.getElementById('bill_nume').value;
        document.getElementById('shipp_prenume').value=document.getElementById('bill_prenume').value;
        document.getElementById('shipp_telefon').value=document.getElementById('bill_telefon').value;        
        index1=document.getElementById('bill_county').selectedIndex;
        document.getElementById('shipp_county').selectedIndex=index1;        
        document.getElementById('shipp_strada').value=document.getElementById('bill_strada').value;
        document.getElementById('shipp_company').value=document.getElementById('bill_company').value;        
        document.getElementById('shipp_strada_nr').value=document.getElementById('bill_strada_nr').value;
        document.getElementById('shipp_bloc').value=document.getElementById('bill_bloc').value;
        document.getElementById('shipp_scara').value=document.getElementById('bill_scara').value;
        document.getElementById('shipp_apartament').value=document.getElementById('bill_apartament').value;
        document.getElementById('shipp_sector').value=document.getElementById('bill_sector').value;        
        document.getElementById('shipp_city').value=document.getElementById('bill_city').value;
        document.getElementById('shipp_postal_code').value=document.getElementById('bill_postal_code').value;
        } 
    else {
        
        document.getElementById('shipp_nume').value='';
        document.getElementById('shipp_prenume').value='';
        document.getElementById('shipp_telefon').value='';
        document.getElementById('shipp_county').selectedIndex='';        
        document.getElementById('shipp_strada').value='';
        document.getElementById('shipp_company').value='';     
        document.getElementById('shipp_strada_nr').value='';
        document.getElementById('shipp_bloc').value='';
        document.getElementById('shipp_scara').value='';
        document.getElementById('shipp_apartament').value='';
        document.getElementById('shipp_sector').value='';        
        document.getElementById('shipp_city').value='';
        document.getElementById('shipp_postal_code').value='';
    }
}

function cauta_cod(){
	var bulk='';
	
	index1=document.getElementById('cod_jud').selectedIndex;
	valoare_judet=document.getElementById('cod_jud').options[index1].value;
	bulk+='jud='+valoare_judet;
	
	loc=document.getElementById('cod_loc').value;
	bulk+='&loc='+loc;
	
	strada=document.getElementById('cod_str').value;
	bulk+='&str='+strada;
	
	window.open('http://www.coduripostale.ro/new/index.php?'+bulk+'&list=Cauta');
}



function kiki(img,ind){	
	var img2=img.split(',');
	
	if(ind<img2.length){
		document.getElementById('top_news').innerHTML=img2[ind];
		ind++;
		setTimeout('kiki2(\''+img+'\',\''+(ind)+'\')',5000);
		}
	else{	
		document.getElementById('top_news').innerHTML=img2[0];
		setTimeout('kiki2(\''+img+'\',\'1\')',5000);
		}
	
	}

function kiki2(img,ind){
	var img2=img.split(',');
	if(ind<img2.length){
		document.getElementById('top_news').innerHTML=img2[ind];
		ind++;
		setTimeout('kiki(\''+img+'\',\''+(ind)+'\')',5000);
		}
	else{
		document.getElementById('top_news').innerHTML=img2[0];
		setTimeout('kiki(\''+img+'\',\'1\')',5000);
		}
	}



function NewWindow(mypage,myname,w,h,scroll,pos) 
{ 
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor		
	(Math.random()*((screen.height-h)-75)):100;} 
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;} 
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20} settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no'; win=window.open(mypage,myname,settings); 
}  




function getHTTPObject(url,c) { 
	  var http_request;
	 
	  if (window.XMLHttpRequest) { // Mozilla, Safari,... alte browsere normale
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                
            }
        } else if (window.ActiveXObject) { // IE
            try {
		    //ie 6 sp
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
			// ie 5,6
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e2) {
			// daca e un browser de consola n-ar trebui sa fie deranjat de alert
		alert('Your browser doesnt understand Ajax. Use Firefox');
		}
            }
        }

        if (!http_request) {
		// daca e un browser de consola n-ar trebui sa fie deranjat de alert
            alert('Your browser doesnt understand Ajax. Use Firefox');
            return false;
        }
	
	http_request.onreadystatechange = function() { handleHttpResponse(http_request,c); };
        http_request.open('GET', url, true);
	// nefolosit
        http_request.send(null);
  }
  

  
function handleHttpResponse(http_request,c) {

	if (http_request.readyState == 4) {
		// ca sa ii afisam un div cu Loading... sa stie omul ca dureaza - acum nefolosit
		//document.getElementById('loading').style.display = 'none';
        
		 
		if (http_request.status == 200) {
			
			switch (c)	{
				// start introducere 
				case 'select_produse':
				document.getElementById('select_produse').innerHTML =  http_request.responseText;
				break;
				
				case 'disc_plata':
				document.getElementById('discount_plata').innerHTML =  http_request.responseText;
				break;
				
				case 'news':
				
				document.getElementById('search2').innerHTML =  http_request.responseText;
				break;
				
			//end introducere start search
			/*
			case 'oferte_search':
			var xmlDocument = http_request.responseXML;
			var title = xmlDocument.getElementsByTagName('content').item(0).firstChild.data;
			
			document.getElementById('tari').innerHTML = title;
			break;*/
			
				}
            } 
		else 
                alert('There was a problem with the request.');
            
			
		
        }
	else
	{
		// ca sa ii afisam un div cu Loading... sa stie omul ca dureaza -nefolosit acum
		//document.getElementById('loading').style.display = 'inline';
	}
		
}




//functie ajax cu 2 parametrii

function getHTTPObject2(url,c,d) { 
	  var http_request;
	  
	 
	  if (window.XMLHttpRequest) { // Mozilla, Safari,... alte browsere normale
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                
            }
        } else if (window.ActiveXObject) { // IE
            try {
		    //ie 6 sp
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
			// ie 5,6
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e2) {
			// daca e un browser de consola n-ar trebui sa fie deranjat de alert
		alert('Your browser doesnt understand Ajax. Use Firefox');
		}
            }
        }

        if (!http_request) {
		// daca e un browser de consola n-ar trebui sa fie deranjat de alert
            alert('Your browser doesnt understand Ajax. Use Firefox');
            return false;
        }
	
	http_request.onreadystatechange = function() { handleHttpResponse2(http_request,c,d); };
        http_request.open('GET', url, true);
	// nefolosit
        http_request.send(null);
  }
  

  
function handleHttpResponse2(http_request,c,where) {

	if (http_request.readyState == 4) {
		// ca sa ii afisam un div cu Loading... sa stie omul ca dureaza - acum nefolosit
		//document.getElementById('loading').style.display = 'none';
        
		
		if (http_request.status == 200) {
			
			switch (c)	{
				// start introducere
				
				case 'nume_produse_admin':
				document.getElementById('rez_nume_'+where).innerHTML =  http_request.responseText;
				break;
				case 'schimba_produse_admin':
				document.getElementById('nume_afisat_'+where).innerHTML =  http_request.responseText;
				break;
				
				case 'schimba_pret_produse_admin':
				document.getElementById('pret_'+where).innerHTML =  http_request.responseText;
				break;
				
				case 'schimb_pret_produs':
			
				document.getElementById('pret_'+where).innerHTML =  http_request.responseText;
				break;
				
				
				case 'schimba_pret_subtotal_produse_admin':
				
				document.getElementById('subtotal_pret_'+where).innerHTML =  http_request.responseText;
				break;
				
				
				case 'schimba_subtotal_produse_admin':
				
				document.getElementById('subtotal_pret_'+where).innerHTML =  http_request.responseText;
				break;
				
				
				
				case 'schimba_total_pret_produse_admin':
				
				document.getElementById('total_produse').innerHTML =  http_request.responseText;
				break;
				
				case 'schimba_total_produse_admin':
				document.getElementById('total_produse').innerHTML =  http_request.responseText;
				break;
						
				case 'schimb_cantitate_produs':
				document.getElementById('cant_'+where).innerHTML =  http_request.responseText;
				break;
				
				case 'schimba_disc_subtotal_produse_admin':
				document.getElementById('subtotal_pret_'+where).innerHTML =  http_request.responseText;
				break;
				
				
				case 'add_produs':
				document.getElementById('rezultate_nume').innerHTML =  http_request.responseText;
				break;
				
				case 'discount_total':
				document.getElementById('total_produse').innerHTML =  http_request.responseText;
				break;
				
				case 'continut':

				document.getElementById('continut_'+where).innerHTML =  http_request.responseText;

				break;
			
			//end introducere start search
			/*
			case 'oferte_search':
			var xmlDocument = http_request.responseXML;
			var title = xmlDocument.getElementsByTagName('content').item(0).firstChild.data;
			
			document.getElementById('tari').innerHTML = title;
			break;*/
			
				}
            } 
		else 
                alert('There was a problem with the request.');
            
			
		
        }
	else
	{
		// ca sa ii afisam un div cu Loading... sa stie omul ca dureaza -nefolosit acum
		//document.getElementById('loading').style.display = 'inline';
	}
		
}





function change_nume(id) {
	document.getElementById('nume_'+id).style.display='block';	
	}

function add_altul() {
	document.getElementById('adauga_nou').style.display='block';	
	}


function change_pret(id) {
	document.getElementById('schimba_pret_'+id).style.display='block';	
	}

function change_cant(id) {
	document.getElementById('schimba_cant_'+id).style.display='block';	
	}

function stergere(id,id_comanda) {
	if(confirm("Sunteti sigur ca doriti sa stergeti ?"))
		document.location='comenzi.php?act=sterge&id_comanda='+id_comanda+'&id='+id;
	}
	

function salveaza_produs_pret(id,id_old) {
	document.getElementById('schimba_pret_'+id).style.display='none';	
	pret=document.getElementById('pret_nou_'+id).value;
	document.getElementById('disc_nou_'+id).value='';
	getHTTPObject2('ajax/comenzi.php?act=schimb_pret2&id_old='+id_old+'&nr='+id+'&pret='+pret,'schimb_pret_produs',id);
	setTimeout('1',1000);

	getHTTPObject2('ajax/comenzi.php?act=subtotal_produs&id_nume='+id_old+'&nr='+id,'schimba_pret_subtotal_produse_admin',id);
	setTimeout('1',1000);
	
	getHTTPObject2('ajax/comenzi.php?act=subtotal','schimba_total_pret_produse_admin',id);
	}
	

function salveaza_cant_pret(id,id_old) {
	document.getElementById('schimba_cant_'+id).style.display='none';	
	cant=document.getElementById('cant_nou_'+id).value;
	document.getElementById('disc_nou_'+id).value='';
	getHTTPObject2('ajax/comenzi.php?act=cantitate&id_old='+id_old+'&nr='+id+'&cant='+cant,'schimb_cantitate_produs',id);
	
	document.getElementById('cant_'+id).innerHTML='<img src="../img/loading.gif" />';	
	
	setTimeout('1',1000);
	getHTTPObject2('ajax/comenzi.php?act=subtotal_produs&id_nume='+id_old+'&nr='+id,'schimba_pret_subtotal_produse_admin',id);
	document.getElementById('subtotal_pret_'+id).innerHTML='<img src="../img/loading.gif" />';	
	setTimeout('1',1000);
	getHTTPObject2('ajax/comenzi.php?act=subtotal','schimba_total_pret_produse_admin',id);
	}

function discount_produs(id,id_old) {
	document.getElementById('schimba_cant_'+id).style.display='none';	
	disc=document.getElementById('disc_nou_'+id).value;
	getHTTPObject2('ajax/comenzi.php?act=discount&id_old='+id_old+'&nr='+id+'&disc='+disc,'schimba_disc_subtotal_produse_admin',id);
	setTimeout('1',1000);
	
	getHTTPObject2('ajax/comenzi.php?act=subtotal','schimba_total_pret_produse_admin',id);
	}
	
function cauta_produs_nume(id,id_old) {
	nume=document.getElementById('nume_cauta_'+id).value;
	
	getHTTPObject2('ajax/comenzi.php?act=caut_nume&id_old='+id_old+'&nr='+id+'&nume='+nume,'nume_produse_admin',id);
	
	
	}
	
function discount_total() {
	disc=document.getElementById('discount_total').value;
	getHTTPObject2('ajax/comenzi.php?act=discount_total&disc='+disc,'discount_total');
	}	
	

function cauta_produs_nume2(id_com) {
	nume=document.getElementById('nume_produs').value;
	id=1;
	getHTTPObject2('ajax/comenzi.php?act=caut_nume_add&id_com='+id_com+'&nume='+nume,'add_produs',id);
	
	
	}


function go_up(id,id_nume,id_old) {

getHTTPObject2('ajax/comenzi.php?act=schimb_nume&id_old='+id_old+'&nr='+id+'&id_nume='+id_nume,'schimba_produse_admin',id);
document.getElementById('rez_nume_'+id).innerHTML='';	

setTimeout('1',1000);
getHTTPObject2('ajax/comenzi.php?act=schimb_pret1&id_old='+id_old+'&nr='+id+'&id_nume='+id_nume,'schimba_pret_produse_admin',id);
document.getElementById('pret_'+id).innerHTML='<img src="../img/loading.gif" />';	
setTimeout('1',1000);
getHTTPObject2('ajax/comenzi.php?act=subtotal_produs&id_old='+id_old+'&nr='+id+'&id_nume='+id_nume,'schimba_subtotal_produse_admin',id);
document.getElementById('subtotal_pret_'+id).innerHTML='<img src="../img/loading.gif" />';	

setTimeout('1',1000);
getHTTPObject2('ajax/comenzi.php?act=subtotal&id_old='+id_old+'&nr='+id+'&id_nume='+id_nume,'schimba_total_produse_admin',id);
document.getElementById('total_produse').innerHTML='<img src="../img/loading.gif" />';	

}


function scoate(id) {
	
	getHTTPObject('ajaxing/comparator.php?id_prod='+id,'select_produse');
	
}



	function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

  function snowIE_NS6() {  // IE and NS6 main animation function
    doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
		doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")?  iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;
    for (i = 0; i < no; ++ i) {  // iterate for every dot
      yp[i] += sty[i];
      if (yp[i] > doc_height-50) {
        xp[i] = Math.random()*(doc_width-am[i]-30);
        yp[i] = 0;
        stx[i] = 0.02 + Math.random()/10;
        sty[i] = 0.7 + Math.random();
      }
      dx[i] += stx[i];
      document.getElementById("dot"+i).style.top=yp[i]+"px";
      document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";  
    }
    snowtimer=setTimeout("snowIE_NS6()", 10);
  }

	function hidesnow(){
		if (window.snowtimer) clearTimeout(snowtimer)
		for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"
	}
		
		
function check_tip_plata(url) {
	getHTTPObject(url+'?tip='+document.getElementById('tip_plata').value,'disc_plata');
	
	}
		
		
function add_news(tip) {
	document.getElementById('search2').innerHTML = '<br />..se incarca';
	getHTTPObject('ajax/newsletter.php?email='+document.getElementById('email2').value,'news');
	
	}
	

function submit_fiz2() {
	var mesaj='';
    
    if(document.getElementById('nume').value==''){ mesaj='Campul Nume este obligatoriu\n';}
    if(document.getElementById('prenume').value==''){ mesaj+='Campul Prenume este obligatoriu\n';}
   
   
	if(document.getElementById('cnp_fiz').value==''){ mesaj+='Campul CNP este obligatoriu\n';}
	if(document.getElementById('serie_ci_fiz').value=='')  mesaj+='Campul Serie CI este obligatoriu\n';
	if(document.getElementById('nr_ci_fiz').value=='')  mesaj+='Campul Numar CI este obligatoriu\n';
	
	if(document.getElementById('PFLocalitateHtml').value=='')  mesaj+='Campul Localitate este obligatoriu\n';
	if(document.getElementById('PFStrNrHtml').value=='')  mesaj+='Campul Numar (numarul strazii) este obligatoriu\n';
	index1=document.getElementById('PFJudetHtml').selectedIndex;
	valoare_judet=document.getElementById('PFJudetHtml').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Campul Judet este obligatoriu\n';
	
	index1=document.getElementById('tip_plata').selectedIndex;
	valoare_plata=document.getElementById('tip_plata').options[index1].value;
	if( valoare_plata=='0')
		mesaj+='Campul Tip Plata este obligatoriu. Nu a fost selectat tipul platii.\n';
	
	
	if(document.getElementById('strada').value=='')  mesaj+='Campul Strada este obligatoriu\n';
	
	
	if(document.getElementById('email_fiz').value=='') mesaj+='Campul Email este obligatoriu\n';
	if (document.getElementById('telefon_fiz').value=='') mesaj+='Campul Telefon este obligatoriu\n';
    if (document.getElementById('PFCodPostalHtml').value=='') mesaj+='Campul Cod Postal este obligatoriu\n';
    
	
    if(document.getElementById('formular_pers_jur').style.display=='block') {
   	    if(document.getElementById('PJNumeFirmaHtml').value=='')  mesaj+='Campul Nume firma este obligatoriu\n';
        if(document.getElementById('cui').value=='')  mesaj+='Campul Cod Fiscal este obligatoriu\n';
        if(document.getElementById('PJInregFiscHtml').value=='')  mesaj+='Campul Nr. inreg. fiscala este obligatoriu\n';
    
        }    
    
	if(document.getElementById('termeni_cond').checked==false)  mesaj+='Trebuie sa fii de acord cu termenii si conditiile de utilizare\n';
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}

function submit_fiz2_en() {
	var mesaj='';
     
    if(document.getElementById('bill_nume').value==''){ mesaj+='Billing Last Name\n';}
    if(document.getElementById('bill_prenume').value==''){ mesaj+='Billing Name\n';}
  //  if(document.getElementById('bill_telefon').value=='') mesaj+='Billing Phone number\n';
    if(document.getElementById('bill_country').value=='') mesaj+='Billing Country\n';
    if(document.getElementById('bill_adresa').value=='') mesaj+='Billing Address\n';
    if(document.getElementById('bill_city').value=='') mesaj+='Billing City\n';
   
    index1=document.getElementById('bill_county').selectedIndex;
	valoare_judet=document.getElementById('bill_county').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Billing County/Region\n';
    if(document.getElementById('bill_postal_code').value=='') mesaj+='Billing Postal Code\n';
    
    if(document.getElementById('shipp_nume').value==''){ mesaj+='Shipping Last Name\n';}
    if(document.getElementById('shipp_prenume').value==''){ mesaj+='Shipping Name\n';}
 //   if(document.getElementById('shipp_telefon').value=='') mesaj+='Shipping Phone number\n';
    if(document.getElementById('shipp_country').value=='') mesaj+='Shipping Country\n';
    if(document.getElementById('shipp_adresa').value=='') mesaj+='Shipping Address\n';
    if(document.getElementById('shipp_city').value=='') mesaj+='Shipping City\n';
    index1=document.getElementById('shipp_county').selectedIndex;
	valoare_judet=document.getElementById('shipp_county').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Shipping County/Region\n';
    if(document.getElementById('shipp_postal_code').value=='') mesaj+='Shipping Postal Code\n';
    
   	if(mesaj!='') 
        mesaj='Please fill in the following fields:\n'+mesaj;
        
 	if(document.getElementById('termeni_cond').checked==false)  mesaj+='You have to agree the terms and conditions\n';
    
    
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}

function submit_fiz2_hu() {
	var mesaj='';
    
    if(document.getElementById('nume').value==''){ mesaj='A vezetéknév mező kitöltése kötelező!\n';}
    if(document.getElementById('prenume').value==''){ mesaj+='A keresztnév mező kitöltése kötelező!\n';}
   
    if(document.getElementById('PFLocalitateHtml').value=='')  mesaj+='A helységnév mező kitöltése kötelező!\n';
	if(document.getElementById('PFStrNrHtml').value=='')  mesaj+='A házszám mező kitöltése kötelező!\n';
	index1=document.getElementById('PFJudetHtml').selectedIndex;
	valoare_judet=document.getElementById('PFJudetHtml').options[index1].value;
	if( valoare_judet=='')
		mesaj+='A megye kiválasztása kötelező!\n';
	
	index1=document.getElementById('tip_plata').selectedIndex;
	valoare_plata=document.getElementById('tip_plata').options[index1].value;
	if( valoare_plata=='0')
		mesaj+='A fizetési mód kiválasztása kötelező!\n';
	
	
	if(document.getElementById('strada').value=='')  mesaj+='Az utcanév mező kitöltése kötelező!\n';
	
    if(document.getElementById('email_fiz').value=='') mesaj+='E-mail mező kitöltése kötelező\n';
	if (document.getElementById('telefon_fiz').value=='') mesaj+='Telefonszám mező kitöltése kötelező\n';  
        
        
        
        
        
        
	
	if(document.getElementById('termeni_cond').checked==false)  mesaj+='El kell fogadnia a felhasználás feltételeit!\n';
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}

function submit_fiz5() {
	var mesaj='';
	index1=document.getElementById('tip_plata').selectedIndex;
	valoare_plata=document.getElementById('tip_plata').options[index1].value;
	if( valoare_plata=='0')
		mesaj+='Campul Tip Plata este obligatoriu. Nu a fost selectat tipul platii.\n';
	
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}

function submit_fiz5_en() {
	var mesaj='';
	index1=document.getElementById('tip_plata').selectedIndex;
	valoare_plata=document.getElementById('tip_plata').options[index1].value;
	if( valoare_plata=='0')
		mesaj+='Please select a payment method.\n';
	
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}
    
function submit_fiz5_hu() {
	var mesaj='';
	index1=document.getElementById('tip_plata').selectedIndex;
	valoare_plata=document.getElementById('tip_plata').options[index1].value;
	if( valoare_plata=='0')
		mesaj+='A fizetési mód kiválasztása kötelező!\n';
	
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}
	
    	
function submit_fiz() {
	var mesaj='';
    
	if(document.getElementById('cnp_fiz').value==''){ mesaj='Campul CNP este obligatoriu\n';}
	if(document.getElementById('serie_ci_fiz').value=='')  mesaj+='Campul Serie CI este obligatoriu\n';
	if(document.getElementById('nr_ci_fiz').value=='')  mesaj+='Campul Numar CI este obligatoriu\n';
	
	if(document.getElementById('PFLocalitateHtml').value=='')  mesaj+='Campul Localitate este obligatoriu\n';
	if(document.getElementById('PFStrNrHtml').value=='')  mesaj+='Campul Numar este obligatoriu\n';
	index1=document.getElementById('PFJudetHtml').selectedIndex;
	valoare_judet=document.getElementById('PFJudetHtml').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Campul Judet este obligatoriu\n';
	
	
	
	if(document.getElementById('strada').value=='')  mesaj+='Campul Strada este obligatoriu\n';
	
	
	if( (document.getElementById('telefon_fiz').value=='') && (document.getElementById('email_fiz').value=='') )  
		mesaj+='Campul Telefon sau Email este obligatoriu\n';
	
	if(document.getElementById('termeni_cond').checked==false)  mesaj+='Trebuie sa fii de acord cu termenii si conditiile de utilizare\n';
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('form_fiz').submit();
	}
	
function submit_fiz4() {
	var mesaj='';
    if(document.getElementById('PFNumeHtml').value==''){ mesaj='Campul Nume este obligatoriu \n';}
    if(document.getElementById('PFPrenumeHtml').value==''){ mesaj+='Campul Prenume este obligatoriu \n';}
    
	if(document.getElementById('cnp').value==''){ mesaj='Campul CNP este obligatoriu\n';}
	if(document.getElementById('serie_ci').value=='')  mesaj+='Campul Serie CI este obligatoriu\n';
	if(document.getElementById('nr_ci').value=='')  mesaj+='Campul Numar CI este obligatoriu\n';
	
	if(document.getElementById('PFLocalitateHtml').value=='')  mesaj+='Campul Localitate este obligatoriu\n';
	if(document.getElementById('PFStrNrHtml').value=='')  mesaj+='Campul Numar (numarul strazii) este obligatoriu\n';
	index1=document.getElementById('PFJudetHtml').selectedIndex;
	valoare_judet=document.getElementById('PFJudetHtml').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Campul Judet este obligatoriu\n';
	
	if(document.getElementById('strada').value=='')  mesaj+='Campul Strada este obligatoriu\n';
	
	
	if(document.getElementById('email_fiz').value=='') mesaj+='Campul Email este obligatoriu\n';
	if (document.getElementById('telefon_fiz').value=='') mesaj+='Campul Telefon este obligatoriu\n';
    if (document.getElementById('PFCodPostalHtml').value=='') mesaj+='Campul Cod Postal este obligatoriu\n';
    
    	
    if(document.getElementById('formular_pers_jur').style.display=='block') {
   	    if(document.getElementById('PJNumeFirmaHtml').value=='')  mesaj+='Campul Nume firma este obligatoriu\n';
        if(document.getElementById('cui').value=='')  mesaj+='Campul Cod Fiscal este obligatoriu\n';
        if(document.getElementById('PJInregFiscHtml').value=='')  mesaj+='Campul Nr. inreg. fiscala este obligatoriu\n';
    
        }    
    
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}
	
function submit_fiz4_hu() {
	var mesaj='';

    if(document.getElementById('PFNumeHtml').value==''){ mesaj='A vezetéknév mező kitöltése kötelező!\n';}
    if(document.getElementById('PFPrenumeHtml').value==''){ mesaj+='A keresztnév mező kitöltése kötelező!\n';}

	if(document.getElementById('PFLocalitateHtml').value=='')  mesaj+='A helységnév mező kitöltése kötelező!\n';
	if(document.getElementById('PFStrNrHtml').value=='')  mesaj+='A házszám mező kitöltése kötelező!\n';
	index1=document.getElementById('PFJudetHtml').selectedIndex;
	valoare_judet=document.getElementById('PFJudetHtml').options[index1].value;
	if( valoare_judet=='')
		mesaj+='A megye kiválasztása kötelező!\n';
	
	if(document.getElementById('strada').value=='')  mesaj+='Az utcanév mező kitöltése kötelező!\n';
	
    if(document.getElementById('email_fiz').value=='') mesaj+='E-mail mező kitöltése kötelező\n';
	if(document.getElementById('telefon_fiz').value=='') mesaj+='Telefonszám mező kitöltése kötelező\n';  

    if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}

function submit_fiz3() {
	var mesaj='';
     
    if(document.getElementById('nume').value==''){ mesaj='Campul Nume este obligatoriu\n';}
    if(document.getElementById('prenume').value==''){ mesaj+='Campul Prenume este obligatoriu\n';}
    
	if(document.getElementById('cnp').value==''){ mesaj+='Campul CNP este obligatoriu\n';}
	if(document.getElementById('serie_ci').value=='')  mesaj+='Campul Serie CI este obligatoriu\n';
	if(document.getElementById('nr_ci').value=='')  mesaj+='Campul Numar CI este obligatoriu\n';
	
	if(document.getElementById('PFLocalitateHtml').value=='')  mesaj+='Campul Localitate este obligatoriu\n';
	if(document.getElementById('PFStrNrHtml').value=='')  mesaj+='Campul Numar (numarul strazii) este obligatoriu\n';
	index1=document.getElementById('PFJudetHtml').selectedIndex;
	valoare_judet=document.getElementById('PFJudetHtml').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Campul Judet este obligatoriu\n';
	
	if(document.getElementById('strada').value=='')  mesaj+='Campul Strada este obligatoriu\n';
	
	
	if(document.getElementById('email_fiz').value=='') mesaj+='Campul Email este obligatoriu\n';
	if (document.getElementById('telefon_fiz').value=='') mesaj+='Campul Telefon este obligatoriu\n';
    if (document.getElementById('PFCodPostalHtml').value=='') mesaj+='Campul Cod Postal este obligatoriu\n';
    
	if(document.getElementById('formular_pers_jur').style.display=='block') {
   	    if(document.getElementById('PJNumeFirmaHtml').value=='')  mesaj+='Campul Nume firma este obligatoriu\n';
        if(document.getElementById('cui').value=='')  mesaj+='Campul Cod Fiscal este obligatoriu\n';
        if(document.getElementById('PJInregFiscHtml').value=='')  mesaj+='Campul Nr. inreg. fiscala este obligatoriu\n';
    
        }   
	if(document.getElementById('termeni_cond').checked==false)  mesaj+='Trebuie sa fii de acord cu termenii si conditiile de utilizare\n';
	
     
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}
	
function inregistrare_en() {
	var mesaj='';
     
    if(document.getElementById('nume').value==''){ mesaj='Last Name\n';}
    if(document.getElementById('prenume').value==''){ mesaj+='Name\n';}
    if(document.getElementById('email').value=='') mesaj+='E-mail\n';
	if(document.getElementById('telefon').value=='') mesaj+='Phone\n';
    if(document.getElementById('pass1').value=='') mesaj+='Password\n';
    if(document.getElementById('pass2').value=='') mesaj+='Password Confirmation\n';        
	
    if(document.getElementById('bill_nume').value==''){ mesaj+='Billing Last Name';}
    if(document.getElementById('bill_prenume').value==''){ mesaj+='Billing Name\n';}
  //  if(document.getElementById('bill_telefon').value=='') mesaj+='Billing Phone number\n';
    if(document.getElementById('bill_country').value=='') mesaj+='Billing Country\n';
    if(document.getElementById('bill_adresa').value=='') mesaj+='Billing Address\n';
    if(document.getElementById('bill_city').value=='') mesaj+='Billing City\n';
    index1=document.getElementById('bill_county').selectedIndex;
	valoare_judet=document.getElementById('bill_county').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Billing County/Region\n';
    if(document.getElementById('bill_postal_code').value=='') mesaj+='Billing Postal Code\n';
    
    if(document.getElementById('shipp_nume').value==''){ mesaj+='Shipping Last Name';}
    if(document.getElementById('shipp_prenume').value==''){ mesaj+='Shipping Name\n';}
  //  if(document.getElementById('shipp_telefon').value=='') mesaj+='Shipping Phone number\n';
    if(document.getElementById('shipp_country').value=='') mesaj+='Shipping Country\n';
    if(document.getElementById('shipp_adresa').value=='') mesaj+='Shipping Address\n';
    if(document.getElementById('shipp_city').value=='') mesaj+='Shipping City\n';
    index1=document.getElementById('shipp_county').selectedIndex;
	valoare_judet=document.getElementById('shipp_county').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Shipping County/Region\n';
    if(document.getElementById('shipp_postal_code').value=='') mesaj+='Shipping Postal Code\n';
    
   	if(mesaj!='') 
        mesaj='Please fill in the following fields:\n'+mesaj;
        
 	if(document.getElementById('termeni_cond').checked==false)  mesaj+='You have to agree the terms and conditions\n';
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}

function editare_en() {
	var mesaj='';
     
    if(document.getElementById('nume').value==''){ mesaj='Last Name\n';}
    if(document.getElementById('prenume').value==''){ mesaj+='Name\n';}
    if(document.getElementById('email').value=='') mesaj+='E-mail\n';
	if(document.getElementById('telefon').value=='') mesaj+='Phone\n';

    if(document.getElementById('bill_nume').value==''){ mesaj+='Billing Last Name';}
    if(document.getElementById('bill_prenume').value==''){ mesaj+='Billing Name\n';}
    if(document.getElementById('bill_telefon').value=='') mesaj+='Billing Phone number\n';
    if(document.getElementById('bill_country').value=='') mesaj+='Billing Country\n';
    if(document.getElementById('bill_adresa').value=='') mesaj+='Billing Address\n';
    if(document.getElementById('bill_city').value=='') mesaj+='Billing City\n';
    index1=document.getElementById('bill_county').selectedIndex;
	valoare_judet=document.getElementById('bill_county').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Billing County/Region\n';
    if(document.getElementById('bill_postal_code').value=='') mesaj+='Billing Postal Code\n';
    
    if(document.getElementById('shipp_nume').value==''){ mesaj+='Shipping Last Name';}
    if(document.getElementById('shipp_prenume').value==''){ mesaj+='Shipping Name\n';}
    if(document.getElementById('shipp_telefon').value=='') mesaj+='Shipping Phone number\n';
    if(document.getElementById('shipp_country').value=='') mesaj+='Shipping Country\n';
    if(document.getElementById('shipp_adresa').value=='') mesaj+='Shipping Address\n';
    if(document.getElementById('shipp_city').value=='') mesaj+='Shipping City\n';
    index1=document.getElementById('shipp_county').selectedIndex;
	valoare_judet=document.getElementById('shipp_county').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Shipping County/Region\n';
    if(document.getElementById('shipp_postal_code').value=='') mesaj+='Shipping Postal Code\n';
    
   	if(mesaj!='') 
        mesaj='Please fill in the following fields:\n'+mesaj;
        
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}	
    
function submit_fiz3_hu() {
	var mesaj='';
     
    if(document.getElementById('nume').value==''){ mesaj='A vezetéknév mező kitöltése kötelező!\n';}
    if(document.getElementById('prenume').value==''){ mesaj+='A keresztnév mező kitöltése kötelező!\n';}
    
	if(document.getElementById('PFLocalitateHtml').value=='')  mesaj+='A helységnév mező kitöltése kötelező!\n';
	if(document.getElementById('PFStrNrHtml').value=='')  mesaj+='A házszám mező kitöltése kötelező!\n';
	index1=document.getElementById('PFJudetHtml').selectedIndex;
	valoare_judet=document.getElementById('PFJudetHtml').options[index1].value;
	if( valoare_judet=='')
		mesaj+='A megye kiválasztása kötelező!\n';
	
	if(document.getElementById('strada').value=='')  mesaj+='Az utcanév mező kitöltése kötelező!\n';
	
	
	if(document.getElementById('email_fiz').value=='') mesaj+='E-mail mező kitöltése kötelező\n';
	if(document.getElementById('telefon_fiz').value=='') mesaj+='Telefonszám mező kitöltése kötelező\n';  
	
	if(document.getElementById('termeni_cond').checked==false)  mesaj+='El kell fogadnia a felhasználás feltételeit!\n';
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}

	

function submit_jur2() {
	var mesaj='';
	if(document.getElementById('cui').value==''){ mesaj='Campul Cod Fiscal este obligatoriu\n';}
	if(document.getElementById('strada_jur').value=='')  mesaj+='Campul Strada este obligatoriu\n';
	
	
	if(document.getElementById('PFLocalitateHtml_jur').value=='')  mesaj+='Campul Localitate este obligatoriu\n';
	if(document.getElementById('PFStrNrHtml_jur').value=='')  mesaj+='Campul Numar este obligatoriu\n';
	index1=document.getElementById('PFJudetHtml_jur').selectedIndex;
	valoare_judet=document.getElementById('PFJudetHtml_jur').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Campul Judet este obligatoriu\n';
		
	index1=document.getElementById('tip_plata').selectedIndex;
	valoare_plata=document.getElementById('tip_plata').options[index1].value;
	if( valoare_plata=='0')
		mesaj+='Campul Tip Plata este obligatoriu. Nu a fost selectat tipul platii.\n';
	
	
	if( (document.getElementById('telefon_jur').value=='') && (document.getElementById('email_fiz').value=='') )  
		mesaj+='Campul Telefon sau Email este obligatoriu\n';
	
	if(document.getElementById('termeni_cond_jur').checked==false)  mesaj+='Trebuie sa fii de acord cu termenii si conditiile de utilizare\n';
	
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('formular').submit();
	}	
	
function submit_jur() {
	var mesaj='';
	if(document.getElementById('cui').value==''){ mesaj='Campul Cod Fiscal este obligatoriu\n';}
	if(document.getElementById('strada').value=='')  mesaj+='Campul Strada este obligatoriu\n';
	
	
	if(document.getElementById('PFLocalitateHtml').value=='')  mesaj+='Campul Localitate este obligatoriu\n';
	if(document.getElementById('PFStrNrHtml').value=='')  mesaj+='Campul Numar este obligatoriu\n';
	index1=document.getElementById('PFJudetHtml').selectedIndex;
	valoare_judet=document.getElementById('PFJudetHtml').options[index1].value;
	if( valoare_judet=='')
		mesaj+='Campul Judet este obligatoriu\n';
	
	
		
	if( (document.getElementById('telefon_fiz').value=='') && (document.getElementById('email_fiz').value=='') )  
		mesaj+='Campul Telefon sau Email este obligatoriu\n';
	
	if(document.getElementById('termeni_cond').checked==false)  mesaj+='Trebuie sa fii de acord cu termenii si conditiile de utilizare\n';
	
	
	if(mesaj!='') { alert(mesaj);}
	else
		document.getElementById('form_jur').submit();
	}	

function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} 

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} 
return strTemp;

} 

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} 
return strTemp;
} 



var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var whitespace = " \t\n\r";

var decimalPointDelimiter = "."

var phoneNumberDelimiters = "()- ";

var validUSPhoneChars = digits + phoneNumberDelimiters;

var validWorldPhoneChars = digits + phoneNumberDelimiters + "+";

var SSNDelimiters = "- ";

var validSSNChars = digits + SSNDelimiters;

var digitsInSocialSecurityNumber = 9;

var digitsInUSPhoneNumber = 10;

var ZIPCodeDelimiters = "-";

var ZIPCodeDelimeter = "-"

var validZIPCodeChars = digits + ZIPCodeDelimiters

var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9

var creditCardDelimiters = " "

function isOkBag (s, bag)

{   var i;
    var returnString = "";

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) return false;
    }
    return true;
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhiteSpace (s)
{   var i;

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

function stripCharsNotInBag (s, bag)

{   var i;
    var returnString = "";

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }

    return returnString;
}

function stripWhitespace (s)

{   return stripCharsInBag (s, whitespace)
}

function charInString (c, s)
{   for (i = 0; i < s.length; i++)
    {   if (s.charAt(i) == c) return true;
    }
    return false
}

function stripInitialWhitespace (s)

{   var i = 0;

    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    
    return s.substring (i, s.length);
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}



function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);


    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    return true;
}

function isSignedInteger (s)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}

function isPositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}

function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}


function isNegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNegativeInteger.arguments.length > 1)
        secondArg = isNegativeInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) < 0) ) );
}


function isNonpositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonpositiveInteger.arguments.length > 1)
        secondArg = isNonpositiveInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) <= 0) ) );
}


function isFloat (s)

{   var i;
    var seenDecimalPoint = false;

    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);

    if (s == decimalPointDelimiter) return false;


    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }

    return true;
}


function isSignedFloat (s)

{   if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedFloat.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedFloat.arguments.length > 1)
            secondArg = isSignedFloat.arguments[1];

        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isFloat(s.substring(startPos, s.length), secondArg))
    }
}


function isAlphabetic (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (!isLetter(c))
        return false;
    }

    return true;
}

function isAlphanumeric (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }

    return true;
}

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "(", 3, ") ", 3, "-", 4))
}

function reformatSSN (SSN)
{   return (reformat (SSN, "", 3, "-", 2, "-", 4))
}

function isLeapYear(argYear) {
	return ((argYear % 4 == 0) && (argYear % 100 != 0)) || (argYear % 400 == 0) 
}

function daysInMonth(argMonth, argYear) {
	switch (Number(argMonth)) {
		case 1:		// Jan
		case 3:		// Mar
		case 5:		// May
		case 7:		// Jul
		case 8:		// Aug
		case 10:		// Oct
		case 12:		// Dec
			return 31;
			break;
		
		case 4:		// Apr
		case 6:		// Jun
		case 9:		// Sep
		case 11:		// Nov
			return 30;
			break;
		
		case 2:		// Feb
			if (isLeapYear(argYear))
				return 29
			else
				return 28
			break;
		
		default:
			return 0;
	}
}

function getDateSeparator(argDate) {
	if ((argDate.indexOf('-') > 0) && (argDate.indexOf('/') > 0))
		return ' '

	if (argDate.indexOf('-') > 0)
		return '-'
	else
		if (argDate.indexOf('/') > 0)
			return '/'
		else
			return ' '
}

function getYear(argDate) {
	var dateSep = getDateSeparator(argDate)
	
	if (dateSep == ' ')
		return 0

	if(argDate.split(dateSep).length == 3)
		return argDate.split(dateSep)[2]
	else
		return 0
}

function getMonth(argDate) {
	var dateSep = getDateSeparator(argDate)
	
	if (dateSep == ' ')
		return 0

	if(argDate.split(dateSep).length == 3)
		return argDate.split(dateSep)[0]
	else
		return 0
}

function getDay(argDate) {
	var dateSep = getDateSeparator(argDate)
	
	if (dateSep == ' ')
		return 0

	if(argDate.split(dateSep).length == 3)
		return argDate.split(dateSep)[1]
	else
		return 0
}

function isProperDay(argDay, argMonth, argYear) {
	if ((isWhiteSpace(argDay)) || (argDay == 0))
		return false

	if ((argDay > 0) && (argDay < daysInMonth(argMonth, argYear) + 1))
		return true
	else 
		return false
}

function isProperMonth(argMonth) {
	if ((isWhiteSpace(argMonth)) || (argMonth == 0))
		return false
	
	if ((argMonth > 0) && (argMonth < 13))
		return true
	else
		return false
}

function isProperYear(argYear) {
	if ((isWhiteSpace(argYear)) || (argYear.toString().length > 4) || (argYear.toString().length == 3))
		return false
	
	switch (argYear.toString().length) {
		case 1:
			if (argYear >=0 && argYear < 10)
				return true
			else
				return false
			
		case 2:
			if (argYear >=0 && argYear < 100)
				return true
			else
				return false
			
		case 4:
			if (((argYear >=1900) || (argYear >=2000)) && ((argYear < 3000) || (argYear < 2000)))
				return true
			else
				return false
		
		default:
			return false
	}
}

function isProperDate(argDate) {
	var tmpDay = getDay(argDate)
	var tmpMon = getMonth(argDate)
	var tmpYear = getYear(argDate)

	return isProperDay(tmpDay, tmpMon, tmpYear) && isProperMonth(tmpMon) && isProperYear(tmpYear)
}

function charOccurences(argString, argChar) {
	var intCt = 0

	for(var intI=0; intI < argString.length; intI++)
		if (argString.charAt(intI) == argChar)
			intCt++
	
	return intCt
}

function isProperEmail(argEmail) {
	if (charOccurences(argEmail, '@') + charOccurences(argEmail, '.') < 2)
		return false

	var atPos = argEmail.indexOf('@')
	var dotPos = argEmail.indexOf('.')

	if((atPos == 0) || (atPos == (argEmail.length - 1)))
		return false

	if((dotPos == 0) || (dotPos == (argEmail.length - 1)))
		return false
	
	var checkTLD=1;
 
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
 
	var emailPat=/^(.+)@(.+)$/;
 
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
 
 
	var validChars="\[^\\s" + specialChars + "\]";
 
 
	var quotedUser="(\"[^\"]*\")";
 
 
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
 
 
	var atom=validChars + '+';
 
	var word="(" + atom + "|" + quotedUser + ")";
 
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
 
 
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
 
 
 
	var matchArray=argEmail.match(emailPat);
 
	if (matchArray==null)
		{
		return false;
		}
	var user=matchArray[1];
	var domain=matchArray[2];
 
	for (i=0; i<user.length; i++)
		{
		if (user.charCodeAt(i)>127)
			{
			return false;
			}
		}
	for (i=0; i<domain.length; i++)
		{
		if (domain.charCodeAt(i)>127)
			{
			return false;
			}
		}
 
	if (user.match(userPat)==null)
		{
		return false;
	}
 
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
		{
		for (var i=1;i<=4;i++)
			{
			if (IPArray[i]>255)
				{
				return false;
				}
			}
		return true;
		}
 
 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++)
		{
		if (domArr[i].search(atomPat)==-1)
			{
			return false;
			}
		}
 
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
		{
		return false;
		}
 
	if (len<2)
		{
		return false;
		}
 
	return true;
}

function isProperNumber(argNumber) {
	var numberValue = Number(argNumber)
	
	if (isNaN(numberValue)) 
		return false
	else
		return !isWhiteSpace(argNumber)
}

function isProperAlphabetic(argString) {
	var alphabets = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"

	for(var intI=0; intI<argString.length; intI++)
		if (alphabets.indexOf(argString.charAt(intI)) == -1)
			return false
	
	return true
}

function objectValue(argFrm, argElem) {
	var intI
	var objElem = null

	for (intI=0; intI<argFrm.length; intI++)
		if (argFrm[intI].name == argElem) 
			objElem = argFrm[intI]

	switch (objElem.type) {
		case 'text':
		case 'hidden':
		case 'password':
			return objElem.value
			break;
		
		case 'select-one':
			if (objElem.length == 0)
				return ''
			else 
				return objElem.options[objElem.selectedIndex].value
			break;
		
		case 'radio':
			for (intI=0; intI<argFrm.length; intI++)
				if (argFrm[intI].name == argElem) 
					if (argFrm[intI].checked)
						return argFrm[intI].value

			return ''
			break;
	}
}

function objectFocus(argFrm, argElem) {
	var intI
	var objElem = null
	for (intI=0; intI<argFrm.length; intI++)
		if (argFrm[intI].name == argElem) 
			objElem = argFrm[intI]
	objElem.focus();
}

function isProperZip(argZip) {
	if ((argZip.length == 5) || (argZip.length == 9))
		return isProperNumber(argZip)
	
	if (argZip.length == 10)
		return (isProperNumber(argZip.substr(0, 5)) && isProperNumber(argZip.substr(6, 4)) & (argZip.charAt(5) == '-'))
}

function isProperUSPhone (argPhone)
{
	var argPhone2 = stripCharsNotInBag(argPhone,"0123456789")
    return (isOkBag(argPhone,"01234567890 -().") && isInteger(argPhone2) && argPhone2.length==digitsInUSPhoneNumber)
}

function isProperUSSSN(argSSN) {
	var argSSN2 = stripCharsNotInBag(argSSN,"0123456789")
    return (isOkBag(argSSN,"01234567890-") && isInteger(argSSN2) && argSSN2.length==11)
}

function actionFields(argActions) {
	this.email			= (argActions.indexOf('[email]') > -1)
	this.required		= (argActions.indexOf('[req]') > -1)
	this.checkDate		= (argActions.indexOf('[date]') > -1)
	this.checkZip		= (argActions.indexOf('[zip]') > -1)
	this.checkNumber	= (argActions.indexOf('[number]') > -1)
	this.checkAlphabetic= (argActions.indexOf('[alpha]') > -1)
	this.checkUSPhone	= (argActions.indexOf('[usphone]') > -1)
	this.checkUSSSN		= (argActions.indexOf('[usssn]') > -1)

	if (argActions.indexOf('[len=') > -1) {
		this.checkLength = true

		var lenToCheck = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[len=') +  5);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				lenToCheck += argActions.charAt(intI)
			else
				bolCont = false
		this.lengthToCheck = lenToCheck
	}
	else
		this.checkLength = false

	if (argActions.indexOf('[blankalert=') > -1) {
		this.blankAlert = true

		var alertString = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[blankalert=') +  12);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				alertString += argActions.charAt(intI)
			else
				bolCont = false
		this.blankAlertMessage = alertString
	}
	else
		this.blankAlert = false
	
	if (argActions.indexOf('[invalidalert=') > -1) {
		this.invalidAlert = true

		var alertString = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[invalidalert=') +  14);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				alertString += argActions.charAt(intI)
			else
				bolCont = false
		this.invalidAlertMessage = alertString
	}
	else
		this.invalidAlert = false

	if (argActions.indexOf('[equals=') > -1) {
		this.shouldEqual = true

		var equalsString = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[equals=') +  8);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				equalsString += argActions.charAt(intI)
			else
				bolCont = false
		this.shouldEqualString = equalsString
	}
	else
		this.shouldEqual = false

}


function validateForm(argForm)
	{
	var frmElements = argForm.elements
	var elemName
	var elemObj

	submitonce(argForm);

	for (var intI=0; intI < frmElements.length; intI++) {// *
		elemObj = frmElements[intI]
		elemName = elemObj.name

		if ((elemObj.type == 'hidden') && (elemName.length > 5))
			if (elemName.substr(elemName.length - 5).toLowerCase() == '_vldt') {// **
				var objAction = new actionFields(objectValue(frmElements, elemName))
				var actElem = elemName.substr(0, elemName.length - 5)
				
				if (objAction.required) {
					if (isWhiteSpace(objectValue(frmElements, actElem))) {// ***
						alert (objAction.blankAlert?objAction.blankAlertMessage:actElem + ' cannot be left blank')
						objectFocus(frmElements, actElem);
						submitenabled(argForm);
						return false
					} // ***
				}
				
				if ((objectValue(frmElements, actElem) > '') && (!isWhiteSpace(objectValue(frmElements, actElem)))){// ***
					if (objAction.checkDate)
						if (!isProperDate(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have an invalid date')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkNumber)
						if (!isProperNumber(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have an invalid number')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkZip)
						if (!isProperZip(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have an invalid zipcode')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkAlphabetic)
						if (!isProperAlphabetic(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkUSPhone)
						if (!isProperUSPhone(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkUSSSN)
						if (!isProperUSSSN(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.email)
						if (!isProperEmail(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkLength)
						if (objectValue(frmElements, actElem).length < objAction.lengthToCheck) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' must be at least ' + objAction.lengthToCheck + ' characters long')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****
				} // ***
			} // **
	} // *
		
	return true
}


function submitenabled(theform)
	{
	if (document.all||document.getElementById)
		{
		for (i=0;i<theform.length;i++)
			{
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit" || tempobj.type.toLowerCase()=="reset")
				tempobj.disabled=false;
			}
		}
	}


function submitonce(theform)
	{
	if (document.all||document.getElementById)
		{
		for (i=0;i<theform.length;i++)
			{
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit" || tempobj.type.toLowerCase()=="reset")
				tempobj.disabled=true;
			}
		}
	}



function observeWindowLoad(handler) {
    if (window.addEventListener) { 
        window.addEventListener('load',handler,false);
    }
    else if (document.addEventListener) {
        document.addEventListener('load',handler,false);
    }
    else if (window.attachEvent) { 
        window.attachEvent('onload',handler);
    }
    else {
        if (typeof window.onload=='function') {
            var oldload=window.onload;
            window.onload = function(){
                oldload();
                handler();
            }
        } 
        else { window.onload=init; }
    }
}

