// JavaScript Document
function ChangeFilter_onclick()
{
	if(document.getElementById('filter').style.visibility == "hidden")
	{
		document.getElementById('filter').style.visibility = "visible";
		document.getElementById('filter').style.position = "relative";
	}
	else
	{
		document.getElementById('filter').style.visibility = "hidden";
		document.getElementById('filter').style.position = "absolute";
	}
}



function check_form2() {
	var error = 0;
	var error_message = "S-a produs o EROARE in timpul inregistrarii dvs!\nVa rugam sa efectuati urmatoarele corectii:\n\n";

	var old_password = document.account_edit.old_password.value;
	var password     = document.account_edit.password.value;
	var confirmation = document.account_edit.confirmation.value;

	if (password != confirmation) {
		error_message = error_message + "* 'Parola' si 'Confirmare' trebuie sa fie aceleasi si sa aibe cel putin 5 caractere.\n";
		error = 1;
	}

	if (error == 1) {
		alert(error_message);
		return false;
	} else {
		return true;
	}
}

/* Pop up */
function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function toggle( targetId ){
	if (document.getElementById){
		target = document.getElementById( targetId );
		if (target.style.display == "block"){
			target.style.display = "none";
		}
		else {
			target.style.display = "block";
		}
	}
}

function toggleStyle( targetId, parinte ){
	if (document.getElementById){
		target = document.getElementById( targetId );
		if (target.style.display == "block"){
			target.style.display = "none";
			document.getElementById(parinte).style.borderWidth="0";
			document.getElementById(parinte).style.backgroundColor="white";
		}
		else {
			target.style.display = "block";
			document.getElementById(parinte).style.borderColor="#999999";
			document.getElementById(parinte).style.borderWidth="1px";
			document.getElementById(parinte).style.borderStyle="solid";
			document.getElementById(parinte).style.backgroundColor="#fffee5";
		}
	}
}

function toggleM( targetId, secondTargetId ){
	if (document.getElementById){
		target = document.getElementById( targetId );
		target2 = document.getElementById( secondTargetId );
		if (target.style.display == "block"){
			target2.style.display = "block";
			target.style.display = "none";
		}
		else {
			target.style.display = "block";
			target2.style.display = "none";
		}
	}
}

var timerafiseaza=null, timersorteaza=null;

function setState(which, state) {
	document.getElementById(which).style.display = state;
	if (self["timer"+which]!=null) clearTimeout(self["timer"+which]);
}

function toggleTimed( targetId, state ) {
	var states = new Array("none", "block");
	if (document.getElementById(targetId).style.display==states[state] && self["timer"+targetId]!=null)
		clearTimeout(self["timer"+targetId]);
	else {
		if (state==0)
			self["timer"+targetId]=setTimeout("setState('"+targetId+"', '"+states[state]+"')", 350);
		else
			setState(targetId, states[state]);
	}
}

function refresh_costs() {
	cost_transport = document.getElementById('costtransport').innerHTML.substring(19);
	cost_ramburs = document.getElementById('costramburs').innerHTML.substring(16);
	document.getElementById('costtotal').innerHTML = 'Total costuri expeditie: ' + (parseFloat(cost_transport) + parseFloat(cost_ramburs)) + ' RON';
}

function set_text(element, value)
{
	target = document.getElementById(element);
	target.innerHTML = value;
	
	refresh_costs();
}

function verificaModPlata(what) {
	var lft = new Array("transport1", "transport2", "transport3");
	var rgt = new Array("numerar", "op", "card", "inrate");
	var found = false;
	var msg = "";
	for (i=0; i<lft.length; i++) {
		if (document.getElementById(lft[i]) && document.getElementById(lft[i]).checked) {
			found = true;
			break;
		}
	}
	if (!found) {
		msg += "- Nu ati ales modalitatea de transport!";
	}
	found = false;
	for (i=0; i<rgt.length; i++) {
		if (document.getElementById(rgt[i]) && document.getElementById(rgt[i]).checked) {
			found = true;
			break;
		}
	}
	if (!found) {
		msg += "\n- Nu ati ales modalitatea de plata!";
	}
	if (what==1) {
		if (msg!="") {
			window.alert(msg);
			return false;
		}
		else {
			return true;
		}
	}
	else if (what==2 && msg!="") {
		document.checkoutform.action="/checkout#fact";
	}
	else if (what==2 && msg=="") {
		document.checkoutform.action="/confirmare";
	}
	return true;
}

function goSub() {
	document.checkoutform.submit();
}

function calculateCosts(c_curier,c_roexpres,c_ramburs) {
	
	 cost_livrare		= 0;
	 cost_ramburs	= 0;

	document.getElementById('ramburs_text').className 			= '';	
    	document.getElementById('ramburs_value').className 			= '';
	
	document.getElementById('ramburs_text').innerHTML			='';		
	document.getElementById('ramburs_value').innerHTML			= '';	

	val_cost_cos				= document.getElementById('cost_cos').value;
	val_cost_cos_tva			= document.getElementById('cost_cos_tva').value;
	
	val_cost_cos				= val_cost_cos.replace('.', '');
	val_cost_cos				= val_cost_cos.replace(',', '.');	
	val_cost_cos_tva			= val_cost_cos_tva.replace('.', '');
	val_cost_cos_tva			= val_cost_cos_tva.replace(',', '.');
	
	t1		= document.getElementById('transport1');
	t2		= document.getElementById('transport2');
	t3		= document.getElementById('transport3');

	c1		= document.getElementById('numerar');
	c2		= document.getElementById('op');
	c3		= document.getElementById('card');
	c4		= document.getElementById('inrate');
	

    if (t1 && t1.checked == true) {
        	cost_livrare	= 0;
		cost_ramburs	= 0;
    }

	if (t2 && t2.checked == true) {
	   if (parseFloat(val_cost_cos)<500) {
		 cost_livrare	= c_curier;
	   }        
		cost_ramburs	= 0;
    }
	
	if (t3 && t3.checked == true) {
        if (parseFloat(val_cost_cos)<1000) {
		 cost_livrare	= c_roexpres;	
	   } 
	   if (c1 && c1.checked == true) {
	     cost_ramburs	= c_ramburs;
	   }
    }
    
    var cost_total = parseFloat(val_cost_cos_tva)  + parseFloat(cost_ramburs) + parseFloat(cost_livrare);
    
	var nf = new NumberFormat();
	nf.setInputDecimal('.');
	nf.setPlaces(2);
	nf.setSeparators(true,'.',',');
	
	
	if (cost_ramburs>0) {
		nf.setNumber(cost_ramburs);
		cost_ramburs = nf.toFormatted();
		
	    document.getElementById('ramburs_value').className 			= 'sep';
		document.getElementById('ramburs_text').className 			= 'sep';				
		document.getElementById('ramburs_text').innerHTML			='Costuri ramburs:<span>Taxa de ramburs este perceputa de firma de curierat pentru returul banilor.</span>';		
		document.getElementById('ramburs_value').innerHTML			= cost_ramburs + ' Ron';
	}
	
	nf.setNumber(cost_livrare);
	cost_livrare = nf.toFormatted();
	
	
	
	nf.setNumber(cost_total);
	cost_total = nf.toFormatted();
	
	document.getElementById('c_transport').innerHTML				= cost_livrare + ' Ron';	
	document.getElementById('cost_total').innerHTML				= cost_total + ' Ron';
}

function calculateRamburs(c_ramburs,transport,cost_livrare) {
	
	 cost_ramburs	= 0;

	document.getElementById('ramburs_text').className 			= '';	
    	document.getElementById('ramburs_value').className 			= '';
	
	document.getElementById('ramburs_text').innerHTML			='';		
	document.getElementById('ramburs_value').innerHTML			= '';	

	val_cost_cos				= document.getElementById('cost_cos').value;
	val_cost_cos_tva			= document.getElementById('cost_cos_tva').value;
	
	val_cost_cos				= val_cost_cos.replace('.', '');
	val_cost_cos				= val_cost_cos.replace(',', '.');	
	val_cost_cos_tva			= val_cost_cos_tva.replace('.', '');
	val_cost_cos_tva			= val_cost_cos_tva.replace(',', '.');
	

	c1		= document.getElementById('numerar');
	c2		= document.getElementById('op');
	c3		= document.getElementById('card');
	c4		= document.getElementById('inrate');
	

	
	if (transport == 'roexpres') {
	   if (c1 && c1.checked == true) {
	     cost_ramburs	= c_ramburs;
	   }
    }
    
    var cost_total = parseFloat(val_cost_cos_tva)  + parseFloat(cost_ramburs) + parseFloat(cost_livrare);
    
	var nf = new NumberFormat();
	nf.setInputDecimal('.');
	nf.setPlaces(2);
	nf.setSeparators(true,'.',',');
	
	
	if (cost_ramburs>0) {
		nf.setNumber(cost_ramburs);
		cost_ramburs = nf.toFormatted();
		
	    document.getElementById('ramburs_value').className 			= 'sep';
		document.getElementById('ramburs_text').className 			= 'sep';				
		document.getElementById('ramburs_text').innerHTML			='Costuri ramburs:<span>Taxa de ramburs este perceputa de firma de curierat pentru returul banilor.</span>';		
		document.getElementById('ramburs_value').innerHTML			= cost_ramburs + ' Ron';
	}
	
	
	nf.setNumber(cost_total);
	cost_total = nf.toFormatted();
		
	document.getElementById('cost_total').innerHTML				= cost_total + ' Ron';
}

var cntcup=1;

function adaugaCupon() {
	var wrappingBut = document.createElement('input');
	wrappingBut.type = "text";
	wrappingBut.name = "cod_cupon["+cntcup+"]";
	cntcup++;
	wrappingBut.value = "";
	wrappingBut.className = "casuta";
	wrappingBut.style.display = "block";
	wrappingBut.style.margin = "4px 0";
	document.getElementById("cupoane").appendChild(wrappingBut);
}

/* Verificare input
*****************************************************************/

function checkValid(id, msg, regula) {
	var prefix = "* ";
	var suffix = "\n";
	
	
	switch(regula) {
		case 'required':
						if (document.getElementById(id).value=="")
							return prefix+msg+suffix;
						break;
		case 'select':
						if (document.getElementById(id).options[document.getElementById(id).selectedIndex].value=="")
							return prefix+msg+suffix;
						break;
		case 'numeric':
						var validch = "0123456789.";
						var isNumber=true;
						var ch;
						var val = document.getElementById(id).value;
						
						for (i=0; i<val.length && isNumber == true; i++) { 
							ch = val.charAt(i); 
							if (validch.indexOf(ch) == -1) 								
								return prefix+msg+suffix;
						}
						break;
		case 'email':
						var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
						if (!filter.test(document.getElementById(id).value))
							return prefix+msg+suffix;
						break;
		case 'integer':
						var filter=/^\d{0,9}$/;
						if (!filter.test(document.getElementById(id).value))
							return prefix+msg+suffix;
						break;
		case 'limitpercent':
						if (document.getElementById(id).value<0 || document.getElementById(id).value>100)
							return prefix+msg+suffix;
						break;
	}
	return "";
}

function checkIdentical(id1, id2, msg) {

	var prefix = "* ";
	var suffix = "\n";

	if (document.getElementById(id1).value != document.getElementById(id2).value)
	return prefix+msg+suffix
	else
	return ''

}

function checkLength(id, min, max, msg) {

	var prefix = "* ";
	var suffix = "\n";

	if (document.getElementById(id).value.length < min || document.getElementById(id).value.length > max )
	return prefix+msg+suffix
	else
	return ''

}

function checkRadio(form_name,radio_name,msg)
{
	
	var radio_choice = false;	
	var prefix = "* ";
	var suffix = "\n";
	radio_obj = eval('document.'+form_name+'.'+radio_name);
	
	if (radio_obj.checked) {
		radio_choice = true; 	
	} else {	
		for (counter = 0; counter < radio_obj.length; counter++)
		{
			
			if (radio_obj[counter].checked) {
				radio_choice = true; 
				break;
			}
		}
	}
	
	if (!radio_choice) {
		return prefix+msg+suffix;
	}
	    return '';
}

function verificaFormular(which) {
	var msg_alert = "______________________________________________________\n\n"
	msg_alert += "Cererea dvs. nu a fost indeplinita din motivele de mai jos.\n";
	msg_alert += "Va rugam corectati erorile si incercati din nou:\n";
	msg_alert += "______________________________________________________\n";
	msg_alert += "\n";
	switch(which) {
		case "alerta":
					var msg = "";
					msg += checkValid("nume", "Trebuie sa specificati numele dvs.", "required");
					msg += checkValid("telefon", "Trebuie sa specificati telefonul dvs.", "required");
					msg += checkValid("email", "Trebuie sa specificati o adresa de mail valida", "email");
					msg += checkValid("pret", "Trebuie sa specificati pretul dorit de  dvs.", "required");
					break;
		case "prieten":
					var msg = "";
					msg += checkValid("nume", "Trebuie sa specificati numele dvs.", "required");
					//msg += checkValid("email", "Trebuie sa specificati adresa de mail", "required");
					msg += checkValid("email", "Trebuie sa specificati o adresa de mail valida", "email");
					msg += checkValid("email_tau", "Trebuie sa specificati o adresa de mail valida", "email");
					break;
		case "cerere_oferta":
					msg = "";
					msg += checkValid("name", "Trebuie sa specificati numele dvs.", "required");
					msg += checkValid("email", "Trebuie sa specificati adresa de mail", "required");
					msg += checkValid("email", "Trebuie sa specificati o adresa de mail valida", "email");
					msg += checkValid("phone", "Trebuie sa specificati telefonul dvs.", "required");
					break;					
		case "ajutor_comanda":
					msg = "";
					msg += checkValid("nume", "Trebuie sa specificati numele dvs.", "required");
					msg += checkValid("email", "Trebuie sa specificati adresa de mail", "email");
					msg += checkValid("telefon", "Trebuie sa specificati telefonul dvs", "required");
					break;	

		case "dell":
					msg = "";					
					msg += checkValid("nume", "Trebuie sa specificati numele dvs.", "required");
					msg += checkValid("email", "Trebuie sa specificati adresa de mail", "required");
					msg += checkValid("email", "Trebuie sa specificati o adresa de mail corecta", "email");
					msg += checkValid("telefon", "Trebuie sa specificati telefonul dvs", "required");
					break;
		case "register":				
					msg = "";					
					msg += checkValid("email_address_new", "Trebuie sa specificati o adresa de e-mail corecta.", "email");					
					msg += checkLength("password_new", 5, 15, "Trebuie sa specificati o parola cu o lungime intre 5 si 15 caractere!");
					msg += checkValid("password_confirmation", "Trebuie sa confirmati parola.", "required");
					msg += checkIdentical("password_new","password_confirmation", "Parolele nu sunt identice.");
					break;
		case "auth":				
					msg = "";					
					msg += checkValid("email_address", "Trebuie sa specificati adresa de e-mail.", "required");
					//msg += checkValid("email_address", "Trebuie sa specificati o adresa de e-mail corecta.", "email");			
					msg += checkLength("password", 5, 15, "Trebuie sa specificati o parola cu o lungime intre 5 si 15 caractere!");
					break;
		case "login":				
					msg = "";					
					msg += checkValid("user", "Trebuie sa specificati adresa de e-mail.", "required");
					//msg += checkValid("user", "Trebuie sa specificati o adresa de e-mail corecta.", "email");	
					msg += checkLength("parola", 5, 15, "Trebuie sa specificati o parola cu o lungime intre 5 si 15 caractere!");
					break;
		case "auth_top":				
					msg = "";					
					msg += checkValid("email_address_top", "Trebuie sa specificati adresa de e-mail.", "required");
					msg += checkValid("email_address_top", "Trebuie sa specificati o adresa de e-mail corecta.", "email");										
					break;
		case "my_details":				
					msg = "";					
					msg += checkValid("firstname", "Trebuie sa specificati numele dvs.", "required");
					msg += checkValid("telephone1", "Trebuie sa specificati telefonul dvs", "required");
					msg += checkValid("cnp", "Trebuie sa specificati codul dvs. personal", "required");
					break;
		case "company":
					msg = "";					
					msg += checkValid("denumire", "Trebuie sa specificati numele firmei ", "required");
					msg += checkValid("comert", "Trebuie sa specificati Reg. Comertului", "required");
					msg += checkValid("cif", "Trebuie sa specificati codul fiscal", "required");
					msg += checkValid("cont1", "Trebuie sa specificati contul bancii", "required");
					msg += checkValid("banca1", "Trebuie sa specificati banca", "required");
					msg += checkValid("sucursala1", "Trebuie sa specificati sucursala", "required");
					msg += checkValid("telephone1", "Trebuie sa specificati telefonul dvs", "required");
					msg += checkValid("persoana", "Trebuie sa specificati persoana de contact", "required");
					break;
		case "add_address":				
					msg = "";					
					msg += checkValid("street_address", "Trebuie sa specificati adresa dvs.", "required");
					msg += checkValid("city", "Trebuie sa specificati orasul dvs", "required");
					msg += checkValid("judet", "Trebuie sa specificati judetul dvs.", "select");
					break;
		case "parola":				
					msg = "";				
					msg += checkValid("password_old", "Trebuie sa specificati parola actuala.", "required");
					msg += checkLength("password_new", 5, 15, "Trebuie sa specificati o parola cu o lungime intre 5 si 15 caractere!");
					msg += checkValid("password_confirm", "Trebuie sa confirmati parola.", "required");
					msg += checkIdentical("password_new","password_confirm", "Parolele nu sunt identice.");
					break;
		case "email":				
					msg = "";				
					msg += checkValid("email_new", "Trebuie sa specificati o adresa de e-mail corecta.", "email");
					msg += checkValid("email_confirm", "Trebuie sa confirmati noua adresa de e-mail.", "email");
					msg += checkIdentical("email_new","email_confirm", "Adresele de e-mail furnizate nu sunt identice.");
					break;
		case "new_email":				
					msg = "";				
					msg += checkValid("email_address_new", "Trebuie sa specificati noua adresa de e-mail.", "required");
					msg += checkValid("email_address_new", "Trebuie sa specificati o adresa de e-mail corecta.", "email");					
					break;		
		case "plata_livrare":				
					msg = "";				
					msg += checkRadio("checkoutform","plata", "Trebuie sa specificati o metoda de plata");					
					break;
		case "alege_adrese":				
					msg = "";				
					msg += checkRadio("date_livrare","address", "Trebuie sa specificati o adresa de livrare");					
					break;
		case "alege_cumparator":				
					msg = "";				
					msg += checkRadio("cumparator","cumparator", "Trebuie sa specificati un cumparator");					
					break;		
		case "validare_date":				
					msg = "";				
					msg += checkValid("serie_buletin", "Trebuie sa specificati seria de cartii de identitate","required");					
					msg += checkValid("numar_buletin", "Trebuie sa specificati numarul cartii de identitate","numeric");	
					msg += checkLength("numar_buletin", 6, 6, "Numarul cartii de identitate trebuie sa aiba 6 cifre");				
					break;
		case "marks":				
					msg = "";					
					msg += checkValid("suggestion", "Trebuie sa completati si sugestia.", "required");
					break;
		case "rec":				
					msg = "";					
					msg += checkValid("email", "Trebuie sa completati emailul dumneavoastra.", "required");
					msg += checkValid("friend", "Trebuie sa completati emailul prietenului.", "required");
					break;
		case "search":				
					msg = "";					
					msg += checkValid("text_search", "Trebuie sa completati textul cautat.", "required");
					break;
		case "article":				
					msg = "";					
					msg += checkValid("title", "Trebuie sa completati titlul articolului.", "required");
					msg += checkValid("article", "Trebuie sa completati textul articolului.", "required");
					break;
		case "firm":				
					msg = "";					
					msg += checkValid("furnizor", "Trebuie sa completati furnizorul.", "required");
					msg += checkValid("cui", "Trebuie sa completati C.U.I.", "required");
					msg += checkValid("comert", "Trebuie sa completati Reg. Comertului", "required");
					msg += checkValid("banca", "Trebuie sa completati banca", "required");
					msg += checkValid("cont", "Trebuie sa completati contul", "required");
					break;
		case "parola":				
					msg = "";					
					msg += checkValid("email_address", "Trebuie sa completati email-ul.", "required");
					break;
	}
	if (msg!="") {
		alert(msg_alert+msg);
		return false;
	}else{
		return true;
	}
}

function valideazaCos() {
	result = true;
	for (i=1; i<=100; i++) {
		if (checkValid("cproduct"+i, "0", "required") != "") {
			alert("Trebuie sa specificati cantitatile produselor");
			result = false;
			break;
		}
		else if (checkValid("cproduct"+i, "0", "integer") != "") {
			alert("Cantitatile produselor trebuie sa fie numerice");
			result = false;
			break;
		}
	}
	return result;
}

function verificaConsumabile() {
	total = document.getElementById('totalcons').value;
	msg = "";
	found = false;
	for (i=1; i<=total; i++) {
		msg += checkValid("cons"+i, "Cantitatea dorita trebuie sa fie numerica", "numeric");
		break;
	}
	if (msg=="") {
		for (i=1; i<=total; i++) {
			if (document.getElementById('cons'+i).value != "") {
				found = true;
				break;
			}
		}
		if (found) {
			return true;
		}
		else {
			window.alert("Trebuie sa introduceti cel putin o cantitate dorita.");
			return false;
		}
	}
	else {
		
		window.alert(msg);
		return false;
	}
}

/* base64 encode/decode */

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/=";

function encode64(inp) {
	var out = "";
	var chr1, chr2, chr3 = "";
	var enc1, enc2, enc3, enc4 = "";
	var i = 0;
	do {
		chr1 = inp.charCodeAt(i++);
		chr2 = inp.charCodeAt(i++);
		chr3 = inp.charCodeAt(i++);
		
		enc1 = chr1 >> 2;
		enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
		enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
		enc4 = chr3 & 63;
		
		if (isNaN(chr2)) {
			enc3 = enc4 = 64;
		}
		else if (isNaN(chr3)) {
			enc4 = 64;
		}

		out = out + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);

		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";

	}
	while (i < inp.length);
	return out;
}

function decode64(inp) {
	var out = "";
	var chr1, chr2, chr3 = "";
	var enc1, enc2, enc3, enc4 = "";
	var i = 0;

	var base64test = /[^A-Za-z0-9\+\/\=]/g;

	if (base64test.exec(inp)) {
		alert("There were invalid base64 characters in the input text.\n" + "Valid base64 characters are A-Z, a-z, 0-9, ?+?, ?/?, and ?=?\n" + "Expect errors in decoding.");
	}
	inp = inp.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do {

		enc1 = keyStr.indexOf(inp.charAt(i++));
		enc2 = keyStr.indexOf(inp.charAt(i++));
		enc3 = keyStr.indexOf(inp.charAt(i++));
		enc4 = keyStr.indexOf(inp.charAt(i++));
	
		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;
	
		out = out + String.fromCharCode(chr1);
	
		if (enc3 != 64) {
			out = out + String.fromCharCode(chr2);
		}
		if (enc4 != 64) {
			out = out + String.fromCharCode(chr3);
		}
	
		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";
	
	}
	while (i < inp.length);

	return out;
}

/* galerie poze */
function gal_open_centered(url) {
	w = 700;
	h = 650;
	sw = screen.width;
	sh = screen.height;
	l = (sw - w) / 2;
	t = (sh - h) / 2;
	window.open(url, 'Galerie', 'width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=no,resizable=no');	
}

function showPic (whichpic) { 
	if (document.getElementById) { 
		document.getElementById('placeholder').src = whichpic.href.replace('thumbs', 'big'); 
		if (whichpic.title) { 
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.title; 
		} else { 
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue; 
		} 
		return false; 
	} else { 
		return true; 
	} 
}
/* galerie poze ends*/

function go(url)
{
	box = document.forms['order'].number;
	destination = url + "&number=" + box.options[box.selectedIndex].value;
	if (destination) location.href = destination;	
}

		function formCheck_Search_Header(formobj){
			// Enter name of mandatory fields
			var fieldRequired = Array("txtTerm");
			// Enter field description to appear in the dialog box
			var fieldDescription = Array("termenul de cautare");
			// dialog message
			var alertMsg = "Va rugam sa completati:\n";
			
			var l_Msg = alertMsg.length;
			
			for (var i = 0; i < fieldRequired.length; i++){
				var obj = formobj.elements[fieldRequired[i]];
				if (obj){
					switch(obj.type){
					case "select-one":
						if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
							alertMsg += " - " + fieldDescription[i] + "\n";
						}
						break;
					case "select-multiple":
						if (obj.selectedIndex == -1){
							alertMsg += " - " + fieldDescription[i] + "\n";
						}
						break;
					case "text":
					case "password":
					case "textarea":
						if (obj.value == "" || obj.value == null){
							alertMsg += " - " + fieldDescription[i] + "\n";
						}
						break;
					default:
					}
					if (obj.type == undefined){
						var blnchecked = false;
						for (var j = 0; j < obj.length; j++){
							if (obj[j].checked){
								blnchecked = true;
							}
						}
						if (!blnchecked){
							alertMsg += " - " + fieldDescription[i] + "\n";
						}
					}
				}
			}
		
			if (alertMsg.length == l_Msg){
				return true;
			}else{
				alert(alertMsg);
				return false;
			}
		}
	
				function go1(url, man_id)
				{
					var box = document.forms['f'].cat_id;
					destination = url + "?categ_id=" + box.options[box.selectedIndex].value + "&man_id=" + man_id;
					if (destination) location.href = destination;	
				}
				
				function go2(url, cat_id)
				{
					var box = document.forms['f'].man_id;
					destination = url + "?man_id=" + box.options[box.selectedIndex].value + "&categ_id=" + cat_id;
					if (destination) location.href = destination;	
				}