if (vroot==undefined) {
	var vroot = "http://www.centrofarm.ro/";
}

function ratingart(rating) {
	document.images.imgrat1.src = vroot+"parts/vote-staroff.gif";
	document.images.imgrat2.src = vroot+"parts/vote-staroff.gif";
	document.images.imgrat3.src = vroot+"parts/vote-staroff.gif";
	document.images.imgrat4.src = vroot+"parts/vote-staroff.gif";
	document.images.imgrat5.src = vroot+"parts/vote-staroff.gif";

	if (rating >= 1) {document.images.imgrat1.src = vroot+"parts/vote-staron.gif";}
	if (rating >= 2) {document.images.imgrat2.src = vroot+"parts/vote-staron.gif";}
	if (rating >= 3) {document.images.imgrat3.src = vroot+"parts/vote-staron.gif";}
	if (rating >= 4) {document.images.imgrat4.src = vroot+"parts/vote-staron.gif";}
	if (rating >= 5) {document.images.imgrat5.src = vroot+"parts/vote-staron.gif";}

	document.fcomentariu.ratingh.value = rating;
}

function validcoment(){
	var cond = true;

	if (document.fcomentariu.ratingh.value == "0") {
		alert ("Va rugam sa acordati un numar de \"stelute\" comentariului dumneavoastra");
		return false;
		cond = false;
	}

	if (document.fcomentariu.comment.value == "") {
		document.fcomentariu.comment.focus();
		alert ("Va rugam sa introduceti comentariul dumneavoastra");
		return false;
		cond = false;
	}

	if (document.fcomentariu.comment_nume.value == "") {
		document.fcomentariu.comment_nume.focus();
		alert ("Va rugam completati numele dumneavoastra");
	return false;
	cond = false;}


	if (document.fcomentariu.comment_email.value == "") {
		document.fcomentariu.comment_email.focus();
		alert ("Va rugam sa introduceti adresa dumneavoastra de mail");
	return false;
	cond = false;}
	else {
		if (!validate_email(document.fcomentariu.comment_email, 'Va rugam sa introduceti o adresa de mail valida')) { document.fcomentariu.comment_email.focus(); return false; }
	}

	if (document.fcomentariu.security_code.value == "") {
		document.fcomentariu.security_code.focus();
		alert ("Va rugam sa completati codul de siguranta.");
	return false;
	cond = false;}

return cond;
}

function gal_open_mic(url) {
	w = 500; 	h = 150;
	sw = screen.width;
	sh = screen.height;
	l = (sw - w) / 2;
	t = (sh - h) / 2;
	window.open(url, 'Recomanda Benessere', 'width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=no,resizable=no');
	return false;
}

function gal_open(url) {
	w = 500; 	h = 850;
	sw = screen.width;
	sh = screen.height;
	l = (sw - w) / 2;
	t = (sh - h) / 2;
	window.open(url, 'Recomanda Benessere', 'width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=no,resizable=no');
	return false;
}

function gal_open700(url) {
	w = 700; 	h = 550;
	sw = screen.width;
	sh = screen.height;
	l = (sw - w) / 2;
	t = (sh - h) / 2;
	window.open(url, 'Recomanda', 'width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=yes,resizable=no');
	return false;
}

function createXMLHttpRequest() {
	var ua;

	if(window.XMLHttpRequest) {
	try {
		ua = new XMLHttpRequest();
		}
	catch(e) {
		ua = false;
		}
	} else if(window.ActiveXObject) {
		try {
			ua = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e) {
			ua = false;
		}
	}
	return ua;
}


var req = createXMLHttpRequest();

function changeContent(id_produs){
	if(id_produs){
		if(id1 != 'ofspeciale') {
			req.open('get', '../../../include/change_ofspec.php?idprod='+id_produs);
		} else {
			req.open('get', 'include/change_ofspec.php?idprod='+id_produs);
		}
		req.onreadystatechange = handleResponse;
		req.send(null);
	}
}

function handleResponse() {
	if(req.readyState == 4){
		if(req.status == 200){
			document.getElementById('kkt').innerHTML = req.responseText;
		} else {
			document.getElementById('kkt').innerHTML = 'Server bussy';
		}
	}
}

/* From funct.php */


function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {
    begin = document.cookie.indexOf(NameOfCookie+"=");
    if (begin != -1) {
      begin += NameOfCookie.length+1;
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
    }
  }
  return null;
}

function setCookie(NameOfCookie, value, expiredays) {
	var ExpireDate = new Date();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

	  document.cookie = NameOfCookie + "=" + escape(value) +
	  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function disp(el) { x=document.getElementById(el);
		if (x.style.display == "none")	{
					x.style.display="";
					setCookie(el,'1',365);
					document.getElementById(el + "1").innerHTML = '...restrange';
					document.images[el+"_img0"].src=vroot+"parts/"+member_lang+"/arrow-up.gif";

		} else {
			x.style.display="none";
			setCookie(el,'0',365);
			document.getElementById(el + "1").innerHTML = '...mai multe';
			document.images[el+"_img0"].src=vroot+"parts/"+member_lang+"/arrow-down.gif";
		}
}

	function loadEval(el) { x=document.getElementById(el);
		if (getCookie(el) =='1') {
						x.style.display="";
						document.images[el+"_img0"].src=vroot+"parts/"+member_lang+"/arrow-up.gif";
						document.getElementById(el + "1").innerHTML = '...restrange';
		} else {
		 x.style.display="none";
		document.getElementById(el + "1").innerHTML = '...mai multe';
		}
}

function getCookie2(NameOfCookie){
    if (document.cookie.length > 0) {
    begin = document.cookie.indexOf(NameOfCookie+"=");
    if (begin != -1) {
      begin += NameOfCookie.length+1;
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
    }
  }
  return null;
}
function setCookie2(NameOfCookie, value, expiredays) {
var ExpireDate = new Date();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
 document.cookie = NameOfCookie + "=" + escape(value) +
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}
function disp2(el) 	{
		x=document.getElementById(el);
		if (x.style.display=="none") 		{
			x.style.display="";
			setCookie2(el,'1',365);
		} else {
			x.style.display="none";
			setCookie2(el,'0',365);
		}
	}
function loadEval2(el) {
		x=document.getElementById(el);
		if (getCookie2(el)=='0') {
			x.style.display="none";
		} else {
			x.style.display="";
		}
	}

function openWindow(myfile) {
leftVal = (screen.width - 550 ) / 2;
topVal = (screen.height - 550) / 2;

newWindow = window.open(myfile, '', 'toolbar=no, addressbar=no, resizable=yes, width=550, height=550, left='+leftVal+',top='+topVal); return false;

}

function validate_form()
{
frm=document.login;
if (!ck_text(frm.user,"","Completati campul Utilizator!")) return false;

if (frm.user.value.length<4)
{
 alert("Numele de utilizator trebuie sa aiba minim 4 litere!");
 frm.user.select();
 return false;
}

if (!ck_text(frm.pass,"","Completati campul Parola !")) return false;

if (frm.pass.value.length<4)
{
 alert("Parola trebuie sa aiba minim 4 litere!");
 frm.pass.select();
 return false;}
 return true;
}

function emptyvalidation(entered, alertbox)
{
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function formvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(cautare,"Va rugam alegeti un criteriu de cautare!!!")==false) {cautare.focus(); return false;}
if (emptyvalidation(textbox,"Va rugam sa introduceti un cuvant pentru cautare!!!")==false) {textbox.focus(); return false;}
}
return true;
}


 function doSel(obj)
 {
     for (i = 1; i < obj.length; i++)
        if (obj[i].selected == true)
           eval(obj[i].value);
}

function validate_news()
{
frm=document.news;
if (!validate_email(frm.email, "Adresa de email este incorecta !")) return false;
return true;
}


var haveSubmitted=false;
function FirstSubmitOnly()
{
	if(haveSubmitted) return false;
	haveSubmitted=true;
	return true;    //we want the first click to occur.
}


/* from funct.php */


/* from header.php */

function ValidTextFind(what){

	if (what.textfind.value == "" || what.textfind.value == "cauta produs"){
		alert ("Va rog sa introduceti cuvantul");
		return false;
	}
	return true;
}
function valid_login(){
	if (document.login.user.value == "") {
		alert ("Introduceti utilizatorul");
		return false;
	}
	if (document.login.password.value == "") {
		alert ("Introduceti parola");
		return false;
	}
	return true;
}

function jslacatel(){
	if(document.login.remember.value=='on') {
		document.login.remember.value='off';
		var AdrPoza = "http://www.centrofarm.ro/parts/secure-open.gif";
	} else {
		document.login.remember.value='on';
		var AdrPoza = "http://www.centrofarm.ro/parts/secure-closed.gif";
	}
	document.lacatel.src = AdrPoza;
}
function disableSelection(target){
	if (typeof target.onselectstart!="undefined") //IE route
		target.onselectstart=function(){return false}
	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
		target.style.MozUserSelect="none"
	else //All other route (ie: Opera)
		target.onmousedown=function(){return false}
	target.style.cursor = "default"
}

/* from header.php */


function emptysearch(){
	if(document.fcauts.textfind.value=='cauta produs'){document.fcauts.textfind.value='';}
}

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		if (!navRoot) return;
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}

	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("owninv");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

window.onload=startList;

function afiseaza_m() {
 part1="comenzi"
 part2="centrofarm"
 part3="ro"
 str = part1+String.fromCharCode(eval(64))+part2+String.fromCharCode(eval(46))+part3;
 document.write ("<a href='ma"+"ilto:"+str+"'>"+str+"</a>");
}

/* DETALII PRODUS */

function validate_email(field, alert_str) {
	var str = field.value;
	if (window.RegExp) {
		var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
		var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
		var reg1 = new RegExp(reg1str);
		var reg2 = new RegExp(reg2str);
		if (!reg1.test(str) && reg2.test(str)) {
			return true;
		}
		alert(alert_str);
		field.select();
		return false;
	} else {
		if(str.indexOf("@") >= 0)
		{
			return true;
		}
		alert(alert_str);
		field.select();
		return false;
	}
}

/* DETALII PRODUS */

function show_hide(id) {
	element = document.getElementById(id);

	if (element.style.display == 'none' || element.style.display == '') {
		element.style.display = 'block';
	} else 
		{
		element.style.display = 'none';
	}
	return false;
}

//
function js_doresc(form){
	if (!validate_email(form.email_d, "Va rugam sa introduceti o adresa de mail valida.")){ return false;}
	return true;
}

/* Indexul masei corporale */
function validtestg(form){
	if (!(form.greutate.value>3 && form.greutate.value<200)) {
		form.greutate.focus();
		alert ("Va rog sa introduceti greutatea");
		return false
	}
	if (!(form.inaltime.value>0.3 && form.inaltime.value<2.5)) {
		form.inaltime.focus();
		alert ("Va rog sa introduceti inaltimea");
		return false
	}
	return true;
}

/* Newsletter */

function validate_email_newsletter(form) {
	
	if(form.okconf.checked){
		var str = form.newsletter.value;
		if (window.RegExp) {
			var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
			var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
			var reg1 = new RegExp(reg1str);
			var reg2 = new RegExp(reg2str);
			if (!reg1.test(str) && reg2.test(str)) {
				form.submit();
				return true;
			}
			alert("Adresa de e-mail invalida !");
			document.newsletter.newsletter.select();
			return false;
		} else {
			if(str.indexOf("@") >= 0)
			{
				form.submit();
				return true;
			}
			alert("Adresa de e-mail invalida !");
			form.newsletter.select();
			return false;
		}
	} else {
		alert("Trebuie sa fiti de acord cu Termenii de Confidentialitate");
		return false;
	}
}

/* Rezervare produs */ 

	function verifica_rezervare(what) {
		if (what.nume.value=='') {
			what.nume.focus();
			alert('Completati Numele dumneavoastra.');
			return false;
		}

		if (what.prenume.value=='') {
			what.prenume.focus();
			alert('Completati Prenumele dumneavoastra.');
			return false;
		}


		if (what.email.value=='') {
			what.email.focus();
			alert('Completati cu adresa dumneavoastra de email.');
			return false;
		}

		if (what.telefon.value=='') {
			what.telefon.focus();
			alert('Completati telefonul dumneavoastra.');
			return false;
		}

		if (what.cantitate.value=='') {
			what.cantitate.focus();
			alert('Completati cantitatea dorita.');
			return false;
		}

		return true;
	}
/* End rezervare produs */

/* REGISTER */

function IsPhone(sText) {
   var ValidChars = "0123456789.-+";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   }
   
   
function checkCard(obj){
	if (obj.value != "") {
		if(obj.value.length > 13){	
			alert ("Codul de bare trebuie sa aiva maxim 13 caractere");
			document.register.codcard.value='';
			return false;
		}
		if((obj.value.length != 7) && (obj.value.length != 12) && (obj.value.length != 13)){	
			alert ("Codul de bare trebuie sa contina cel putin ultimele 7 sau 12 cifre");
			document.register.codcard.value='';
			return false;
		}

		req.open('get', 'include/check_card.php?id=' + obj.value); 
		req.onreadystatechange = handleResponseCheck; 
		req.send(null);
	} else {
		obj.value = '';
		document.getElementById('cc').innerHTML = '';  
	}
	return true;
} 

function handleResponseCheck() { 
	if(req.readyState == 4){ 
		if(req.responseText == 'ok'){
			document.getElementById('cc').innerHTML = '<span style="color: #00CC00;">Codul a fost validat, va rugam continuati!</span>';  
		} else {
			document.getElementById('cc').innerHTML = '<span style="color: #CC0000;">Codul introdus nu este valid!</span>';  
			document.register.codcard.value='';
		}
	} else {
		document.getElementById('cc').innerHTML = '<span style="color: #00CC00;">Cerere in aprobare ...</span>';
	}
} 



function valid_register(){
	if (document.register.codcard.value != "") {
		if(document.register.codcard.value.length > 13){	
			alert ("Codul de bare trebuie sa aiva maxim 13 caractere");
			return false;
		}
		if((document.register.codcard.value.length != 7) && (document.register.codcard.value.length != 12) && (document.register.codcard.value.length != 13)){	
			alert ("Codul de bare trebuie sa contina cel putin ultimele 7 sau 12 cifre");
			return false;
		}
	}

	if (document.register.username.value=="") {alert (" Introduceti utilizatorul"); return false;}
	if ((document.register.pass1.value=="") || (document.register.pass1.value != document.register.pass2.value)) {alert ("Introduceti parola"); return false;}
	if (document.register.nume.value == "") {alert ("Introduceti numele"); return false;}
	if (document.register.prenume.value == "") {alert ("Introduceti prenumele"); return false;}
	if (!validate_email(document.register.email,"Adresa de email este incorecta"))  return false;
	if (document.register.data_nasterii.value ==""){alert ("Introduceti data nasterii"); return false;}
	if ((!document.register.sex[0].checked) && (!document.register.sex[1].checked)) {alert ("Alegeti sexul"); return false;}
	if (document.register.telefon.value == "") {alert ("Introduceti numarul de telefon"); return false;}
	if (!IsPhone(document.register.telefon.value)) {alert ('Introduceti numarul de telefon');return false;}
	if (document.register.strada.value == "") {alert ("Introduceti numele strazii"); return false;}
	if (document.register.nr.value == "") {alert ("Introduceti numarul la care locuiti"); return false;}
	
	if(document.register.judet.options[document.register.judet.selectedIndex].value==""){alert ('Alegeti judet/sector'); return false;}
	
	if (document.register.oras.value == "") {alert ("Introduceti orasul in care locuiti"); return false;}
	if (!document.register.terms.checked) {alert ("Trebuie sa fiti de acord cu prevederile \'Termeni si Conditii\'"); return false;}
	//if (!document.register.termsconf.checked) {alert ("Trebuie sa fiti de acord termenii de confidentialitate"); return false;}
	return true;
}

/* End Rezervare */

/* recuperare parola */

function validlogin(form) {
	if (!validate_email(form.email, "Adresa de email este incorecta")) return false;
	return true;
}

/* end recuperare parola */

/* PAS 2 */

function valid_step3() {
  if (document.cos_step2.tip_factura[0].checked) { valueX = document.cos_step2.pf_nume.options[document.cos_step2.pf_nume.selectedIndex].value; }
  if (document.cos_step2.tip_factura[1].checked) { valueX = document.cos_step2.pj_nume.options[document.cos_step2.pj_nume.selectedIndex].value; }
	if (valueX=="") {alert ('Va rugam introduceti datele de facturare'); return false; 
		} else {
	return true;}
}

	function modificaPF(){
		ar_tmp = document.cos_step2.pf_nume.value.split("||");
		location.href = "<?=$vroot?>pf" + ar_tmp[0] + "/aliaspf.html";
	}

	function modificaPJ(){
		ar_tmp = document.cos_step2.pj_nume.value.split("||");
		if(ar_tmp[0]){
			location.href = "<?=$vroot?>pj" + ar_tmp[0] + "/aliaspj.html";
		} else {
			alert("Selectati o persoana juridica mai intii !");
			document.cos_step2.tip_factura[1].checked = true;
		}
	}
/* END PAS 2 */

/* PAS 3 */

function modificaAdresa(){
	for (var i=0; i < document.cos_step3.tip_livrare.length; i++){
		if (document.cos_step3.tip_livrare[i].checked){
			id_adresa = document.cos_step3.tip_livrare[i].value;
			location.href = "<?=$vroot?>pf" + id_adresa + "/aliasadr.html";
			return true;
		}
   }
	alert("<?=t('Alegeti o adresa mai intai')?>");
}


/* END PAS 3 */


/* ALIAS */

function valid_alias(form){
	if (form.strada.value == "") {alert ("Introduceti numele strazii"); return false;}
	if (form.nr.value == "") {alert ("Introduceti numarul"); return false;}
	if (form.judet.options[document.register.judet.selectedIndex].value == "") {alert ("Alegeti judet/sector"); return false;}
	if (form.oras.value == "") {alert ("Introduceti un oras"); return false;}
	if (form.tara.value == "") {alert ("Introduceti Tara"); return false;}
	return true;
}

/* ALIAS END */ 

/* COS */
function editAliasPF(form) {
	var adauga_alias_pf = $j('input#adauga_alias_pf').val();
	
	if ($j('div#EditAliasPF').css('display') == 'none' || adauga_alias_pf) {
		if ($j('select#pf_nume').val()) {
			what = $j('select#pf_nume').val();
			$j.get('get_ajax.php?ajax=1&what=alias&id='+what, null, function(data){
				$j('div#EditAliasPF').html(data);
				$j('input#adauga_alias_pf').val('0');
			}, 'html');
		}
		
	}
	
	if ($j('div#EditAliasPF').css('display') != 'none' && adauga_alias_pf) {
		
	} else {
		$j('div#EditAliasPF').slideToggle();
	}
	$j('input#adauga_alias_pf').val('0');
	
	return false;
}

function alegePF(form, what) {

	$j('input#adauga_alias_pf').val('-1');
	if (what) {
		$j('div#EditAliasPF').slideUp();
		$j.get('get_ajax.php?ajax=1&what=alias&id='+what, null, function(data){
			$j('div#EditAliasPF').html(data);
			//$j('div#EditAliasPF').slideToggle();
		}, 'html');
	}

}

function addAliasPF(form) {
	$j('input#adauga_alias_pf').val('1');
	
	$j('input#fact_pf_nume').val('');
	$j('input#fact_pf_prenume').val('');
	$j('input#fact_pf_email').val('');
	$j('input#fact_pf_telefon').val('');
	$j('input#fact_pf_strada').val('');
	$j('input#fact_pf_bloc').val('');
	$j('input#fact_pf_scara').val('');
	$j('input#fact_pf_etaj').val('');
	$j('input#fact_pf_nr').val('');
	$j('input#fact_pf_apartament').val('');
	$j('select#fact_pf_judet').val('');
	$j('input#fact_pf_oras').val('');
	$j('input#fact_pf_tara').val('');

	if ($j('div#EditAliasPF').css('display') == 'none')
		$j('div#EditAliasPF').slideDown();

	return false;

}

/* PJ */

function editAliasPJ(form) {
	var adauga_alias_pj = $j('input#adauga_alias_pj').val();
	if ($j('div#EditAliasPJ').css('display') == 'none' || adauga_alias_pj) {
		if ($j('select#pj_nume').val()) {
			what = $j('select#pj_nume').val();
			$j.get('get_ajax.php?ajax=1&what=alias&id='+what, null, function(data){
				$j('div#EditAliasPJ').html(data);
				$j('input#adauga_alias_pj').val('0');
				//$j('div#EditAliasPJ').slideToggle();
			}, 'html');
		}
		
	}
	
	if ($j('div#EditAliasPJ').css('display') != 'none' && adauga_alias_pj) {
		
	} else {
		if ($j('select#pj_nume').val()) {
			$j('div#EditAliasPJ').slideToggle();
		}
	}
	$j('input#adauga_alias_pj').val('0');
	
	return false;
}

function alegePJ(form, what) {
	$j('input#adauga_alias_pj').val('0');
	if (what) {
		$j('div#EditAliasPJ').slideUp();
		$j.get('get_ajax.php?ajax=1&what=alias&id='+what, null, function(data){
			$j('div#EditAliasPJ').html(data);
			$j('div#EditAliasPJ').slideToggle();
		}, 'html');
	}

}

function addAliasPJ(form) {
	$j('input#adauga_alias_pj').val('1');
	$j('input#fact_pj_nume').val('');
	$j('input#fact_pj_cui').val('');
	$j('input#fact_pj_rc').val('');
	$j('input#fact_pj_iban').val('');
	$j('input#fact_pj_banca').val('');
	$j('input#fact_pj_iban').val('');
	$j('input#fact_pj_iban').val('');
	
	
	$j('input#fact_pj_strada').val('');
	$j('input#fact_pj_bloc').val('');
	$j('input#fact_pj_scara').val('');
	$j('input#fact_pj_etaj').val('');
	$j('input#fact_pj_nr').val('');
	$j('input#fact_pj_apartament').val('');
	$j('select#fact_pj_judet').val('');

	$j('input#fact_pj_cod').val('');

	$j('input#fact_pj_oras').val('');
	$j('input#fact_pj_tara').val('');

	if ($j('div#EditAliasPJ').css('display') == 'none')
		$j('div#EditAliasPJ').slideDown();

	return false;

}

/* PJ end */

/* ADRESA */

var adauga_adresa;
adauga_adresa = false; 
function editAliasLivrare(form) {
	if ($j('div#EditAliasLivrare').css('display') == 'none' || adauga_adresa) {
		//alert('1');
		
		if ($j('input#tip_livrare_hid').val()) {
			what = $j('input#tip_livrare_hid').val();
			$j.get('get_ajax.php?ajax=1&what=alias_adresa&id='+what, null, function(data){
				$j('div#EditAliasLivrare').html(data);
				adauga_adresa = false;
				//$j('div#EditAliasLivrare').slideToggle();
			}, 'html');
		}
		
	}
	
	if ($j('div#EditAliasLivrare').css('display') != 'none' && adauga_adresa) {
		
	} else {
		if ($j('input#tip_livrare_hid').val()) {
			$j('div#EditAliasLivrare').slideToggle();
		}
	}
	adauga_adresa = false;
	
	return false;
}


function alegeAliasLivrare(form, what) {
	adauga_adresa = false;
	if (what) {
		$j('div#AliasLivrare').slideUp();
		$j.get('get_ajax.php?ajax=1&what=alias&id='+what, null, function(data){
			$j('div#AliasLivrare').html(data);
			$j('div#AliasLivrare').slideToggle();
		}, 'html');
	}
	return false;
}

function addAliasLivrare(form) {
	adauga_adresa = true;
	$j('input#livrare_strada').val('');
	$j('input#livrare_nr').val('');
	$j('input#livrare_bloc').val('');
	$j('input#livrare_scara').val('');
	$j('input#livrare_etaj').val('');
	$j('input#livrare_apartament').val('');
	$j('input#livrare_cod').val('');
	$j('select#livrare_judet').val('');

	
	
	$j('input#livrare_oras').val('');
	$j('input#livrare_tara').val('');

	if ($j('div#EditAliasLivrare').css('display') == 'none')
		$j('div#EditAliasLivrare').slideDown();

	return false;

}

/* ADRESA END */

function valid_step234(form) {
	/* PERSOANA FIZICA */
	if ($j('input#tip_factura_pf').attr('checked')) {
	
		$j('div#EditAliasPF').show();
		if (!$j('input#fact_pf_nume').val()) {
			
			alert('Completeaza numele');
			$j('input#fact_pf_nume').focus();
			return false;
		}
		
		if (!$j('input#fact_pf_prenume').val()) {
			alert('Completeaza prenumele');
			$j('input#fact_pf_prenume').focus();
			return false;
		}
		
		if (!$j('input#fact_pf_email').val()) {
			alert('Completeaza email');
			$j('input#fact_pf_email').focus();
			return false;
		}

		if (!$j('input#fact_pf_telefon').val()) {
			alert('Completeaza telefonul');
			$j('input#fact_pf_telefon').focus();
			return false;
		}

		if (!$j('input#fact_pf_strada').val()) {
			alert('Completeaza strada');
			$j('input#fact_pf_strada').focus();
			return false;
		}

		if (!$j('input#fact_pf_nr').val()) {
			alert('Completeaza nr');
			$j('input#fact_pf_nr').focus();
			return false;
		}

		if (!$j('select#fact_pf_judet').val()) {
			alert('Completeaza judetul');
			$j('select#fact_pf_judet').focus();
			return false;
		}

		if (!$j('input#fact_pf_oras').val()) {
			alert('Completeaza oras');
			$j('input#fact_pf_oras').focus();
			return false;
		}
		
		$j('div#EditAliasPF').hide();
	}
	/* END PERSOANA FIZICA */
	
	/* PERSOANA JURIDICA */
	if ($j('input#tip_factura_pj').attr('checked')) {
	
		$j('div#EditAliasPJ').show();
		if (!$j('input#fact_pj_nume').val()) {
			alert('Completeaza numele');
			$j('input#fact_pj_nume').focus();
			return false;
		}
		
		if (!$j('input#fact_pj_cui').val()) {
			alert('Completeaza CUI');
			$j('input#fact_pj_cui').focus();
			return false;
		}
		
		if (!$j('input#fact_pj_rc').val()) {
			alert('Completeaza J');
			$j('input#fact_pj_rc').focus();
			return false;
		}

		if (!$j('input#fact_pj_iban').val()) {
			alert('Completeaza IBAN');
			$j('input#fact_pj_iban').focus();
			return false;
		}

		if (!$j('input#fact_pj_banca').val()) {
			alert('Completeaza banca');
			$j('input#fact_pj_banca').focus();
			return false;
		}

		if (!$j('input#fact_pj_strada').val()) {
			alert('Completeaza strada');
			$j('input#fact_pj_strada').focus();
			return false;
		}

		if (!$j('input#fact_pj_nr').val()) {
			alert('Completeaza nr');
			$j('input#fact_pj_nr').focus();
			return false;
		}

		if (!$j('select#fact_pj_judet').val()) {
			alert('Completeaza judetul');
			$j('select#fact_pj_judet').focus();
			return false;
		}

		if (!$j('input#fact_pj_oras').val()) {
			alert('Completeaza oras');
			$j('input#fact_pj_oras').focus();
			return false;
		}
		
		$j('div#EditAliasPF').hide();
	}
	/* END PERSOANA FIZICA */
	
	/* LIVRARE */
	
		$j('div#EditAliasLivrare').show();
		if (!$j('input#livrare_strada').val()) {
			alert('Completeaza strada');
			$j('input#livrare_strada').focus();
			return false;
		}

		if (!$j('input#livrare_nr').val()) {
			alert('Completeaza nr');
			$j('input#livrare_nr').focus();
			return false;
		}

		if (!$j('select#livrare_judet').val()) {
			alert('Completeaza judetul');
			$j('select#livrare_judet').focus();
			return false;
		}

		if (!$j('input#livrare_oras').val()) {
			alert('Completeaza oras');
			$j('input#livrare_oras').focus();
			return false;
		}

		if (!$j('input#livrare_tara').val()) {
			alert('Completeaza tara');
			$j('input#livrare_tara').focus();
			return false;
		}
	$j('div#EditAliasLivrare').hide();
	
	/* END LIVRARE */

return true;
}

/* CONTACT */
function verifica_contact(form) {
	if (form.nume.value == "") 
	{
		form.nume.focus();
		alert ("Va rugam sa introduceti numele");
		return false;
	}
	if (!validate_email(form.email,"Adresa dumneavoastra de email este incorecta"))
	{
		form.email.focus();
		return false;
	}
	if (form.comment.value == "") 
	{
		form.comment.focus();
		alert ("Va rugam sa scrieti mesajul");
		return false;
	}
	if (form.security_code.value.length != 5)
	{
		form.security_code.focus();
		alert ("Cod de securitate invalid");		
		return false;
	}
	return true;
}

/* END CONTACT */ 
/* RETEAUA CENTROFARM */
function composeMail2(nume, domeniu, root){
	action = "mailto:";
	return ('<a href = "'+ action + nume + '@' + domeniu + '.' + root + '">'+ nume + '@' + domeniu + '.' + root +'</a>');
}
/* END RETEAUA CENTROFARM */

/* APLICA CARD */

function validform_aplica(form) 
{
	if (form.nume.value=="") 
	{
		form.nume.focus();
		alert ("Va rog sa introduceti numele");
		return false;
	}

	if (form.prenume.value=="") {
		form.prenume.focus();
		alert ("Va rog sa introduceti prenumele");
		return false;
	}

	if (form.data_nasterii.value == "") {
		//form.data_nasterii.focus();
		alert ('Introduceti data de nastere');
		return false;
	}
	
	if (!$j('input#sex_1').attr('checked') && !$j('input#sex_2').attr('checked')) {
		$j('input#sex_1').focus();
		alert ("Alegeti sexul");
		return false;
	}

	if (form.localitate.value==""){
		form.localitate.focus();
		alert ("Introduceti localitatea");
		return false;
	}
	
	if (form.adresa.value=="") {
		form.adresa.focus();
		alert ("Introduceti adresa");
		return false;
	}
	
	if (form.email.value == "")
	{
		form.email.focus();
		alert ("Introduceti adresa de email");
		return false;
	}
	
	if (!validate_email(form.email, "Adresa de email este incorecta !")) 
	{
		form.email.focus();
		return false;
	}

	if (form.telefonFix.value=="") {
		form.telefonFix.focus();
		alert ("Introduceti tefonul fix!\n\rDaca nu aveti telefon fix completati cu  NU");
		return false;
	}

	if (form.telefonMobil.value=="") 
	{
		form.telefonMobil.focus();
		alert ("Introduceti telefonul mobil!\n\rDaca nu aveti telefon mobil completati cu  NU");
		return false;
	}
	
	if (!$j('input#acord').attr('checked')){
		form.acord.focus();
		alert ("Trebuie sa fiti de acord Termenii si Conditiile de folosire a cardului Centrofarm");
		return false;
	}
	
	return true; 
}
/* END APLICA CARD */



function show_hide(id) {
	element = document.getElementById(id);

	if (element.style.display == 'none' || element.style.display == '') {
		element.style.display = 'block';
	} else 
		{
		element.style.display = 'none';
	}
	return false;
}

function change_size(get_size_from) {
	size = $j('select#'+get_size_from+'_size').val();
	if (get_size_from == 'prod2') {
		if (size == "T38")
		{
			//$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006496/detalii_produs.html');
			$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006496/cos_step1.html');
		}
		else if (size == "T40")
		{
			//$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006498/detalii_produs.html');
			$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006498/cos_step1.html');
		}
		else if (size == "T42")
		{
			//$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006500/detalii_produs.html');
			$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006500/cos_step1.html');
		}
		else if (size == "T44")
		{
			//$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006502/detalii_produs.html');
			$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006502/cos_step1.html');
		} else {
			$j('a#'+get_size_from+'_buy').attr('href', '#');
		}
		$j('em#'+get_size_from+'_price').html('309.99');
				
	} else if (get_size_from == 'prod3') {
		if (size == "T40")
		{
			//$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006504/detalii_produs.html');
			$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006504/cos_step1.html');
		}
		else if (size == "T44")
		{
			//$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006506/detalii_produs.html');
			$j('a#'+get_size_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006506/cos_step1.html');
		} 
		else {
			$j('a#'+get_size_from+'_buy').attr('href', '#');
		}
		
		$j('em#'+get_size_from+'_price').html('269.99');
		
	} else if (get_size_from == 'prod1') {
		$j('a#'+get_size_from+'_buy').attr('href', '#');
		$j('select#'+get_size_from+'_color').val('Selecteaza..');
		
		if (size == "Guler rotund - S" || size == "Guler rotund - M" || size == "Guler rotund - L" || size == "Guler rotund - XL")
		{
			var options = '';
			options += '<option>Selecteaza..</option>';
			options += '<option>Alba</option>';
			options += '<option>Verde</option>';
			$j('select#'+get_size_from+'_color').html(options);
			$j('em#'+get_size_from+'_price').html('144.99');

		}
		else if (size == "Guler V - S" || size == "Guler V - M")
		{
			var options = '';
			options += '<option>Selecteaza..</option>';
			options += '<option>Neagra</option>';
			options += '<option>Verde</option>';
			$j('select#'+get_size_from+'_color').html(options);
			$j('em#'+get_size_from+'_price').html('129.99');
			
		} 
		else if (size == "Guler V - L" || size == "Guler V - XL")
		{
			var options = '';
			options += '<option>Selecteaza..</option>';
			options += '<option>Roz</option>';
			options += '<option>Verde</option>';
			$j('select#'+get_size_from+'_color').html(options);
			$j('em#'+get_size_from+'_price').html('129.99');
		} 

	}


}

function change_color(get_color_from) {
	var color = $j('select#'+get_color_from+'_color').val();
	var size = $j('select#'+get_color_from+'_size').val();

	if ((size == "Guler rotund - S" || size == "Guler rotund - M") && color=='Alba') {
//		$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/ccC039X006480/detalii_produs/Lytess---Bluza-Cu-Efect-De-Slabire,-Maneci-Lungi,-Guler-Rotund,-Alba,-S-m.html');
		$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/ccC039X006480/cos_step1.html');
	}

	else if ((size == "Guler rotund - S" || size == "Guler rotund - M") && color=='Verde') {
		//$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006484/detalii_produs.html');
		$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006484/cos_step1.html');
	}

	else if ((size == "Guler rotund - L" || size == "Guler rotund - XL") && color=='Alba') {
		//$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006482/detalii_produs.html');
		$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006482/cos_step1.html');
	}

	else if ((size == "Guler rotund - L" || size == "Guler rotund - XL") && color=='Verde') {
		//$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006486/detalii_produs.html');
		$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006486/cos_step1.html');
	}

	else if ((size == "Guler V - S" || size == "Guler V - M") && color=='Neagra') {
		//$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006488/detalii_produs.html');
		$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006488/cos_step1.html');
	}

	else if ((size == "Guler V - S" || size == "Guler V - M") && color=='Verde') {
		//$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006492/detalii_produs.html');
		$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006492/cos_step1.html');
	}


	else if ((size == "Guler V - L" || size == "Guler V - XL") && color=='Roz') {
		//$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006490/detalii_produs.html');
		$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006490/cos_step1.html');
	}

	else if ((size == "Guler V - L" || size == "Guler V - XL") && color=='Verde') {
		//$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006494/detalii_produs.html');
		$j('a#'+get_color_from+'_buy').attr('href', 'http://www.centrofarm.ro/idC039X006494/cos_step1.html');
	}


}

function verifica_buy(link) {
	if ($j('a#'+link).attr('href') == "#") {
		alert('Alege dimensiunea si culoarea');
		return false;
	}
}


function mai_multe_informatii(prod) {
//alert($j('a#'+prod+'_buy').attr('href'));

	if ($j('a#'+prod+'_buy').attr('href') != '#') 
	{
		var linkx = $j('a#'+prod+'_buy').attr('href'); 
		linkx = linkx.replace('cos_step1', 'detalii_produs');
		window.location.href = linkx;
	}
	return false;
}
