__messages = [
			  ["Nu ati completat campul", "You did not complete the field:"],
			  ["Nu ati selectat", "You did not select"],
			  ["Parolele introduse nu coincid.", "Passwords don't match."],
			  ["Adresa de e-mail este invalida.", "E-mail address is invalid."],
			  ["Numele de utilizator specificat a fost deja preluat.", "The specified username has been already taken."],
			  ["Adresa de e-mail specificata a fost deja utilizata.", "The specified e-mail address has been already used."],
			  ["Campul cautare nu poate fi gol", "The search field cannot be empty"],
			  ["Trebuie sa fiti logat pentru a avea acces la aceasta facilitate", "You need to be logged in to have access to this feature"],
			  ["Campul intrebare nu poate fi gol", "The question field cannot be empty"],
			  ["Campul de adresa de e-mail nu poate fi gol.", "The e-mail address field cannot be empty."],
			  ["Nu ati completat ambele campuri 'parola noua'", "You did not complete both fields 'new password'"],
			  ["Campul 'nume' nu poate fi gol.", "The field 'last name' cannot be empty."],//11
			  ["Campul 'prenume' nu poate fi gol.", "The field 'first name' cannot be empty."],
			  ["Campul de adresa de e-mail nu poate fi gol.", "The e-mail address field cannot be empty."],
			  ["Trebuie sa selectati o categorie de cautare", "You must to select one search category"],
			  ["Completati mai intai numele de utilizator.", "Please first complete the username."],
			  ["Completati mai intai parola.", "Please first complete the password."],
			  ["Va rugam sa introduceti e-mailul prietenului dvs.", "Please insert your friend e-mail."],
			  ["Campul 'comentariu' nu poate fi gol.", "The field 'comment' cannot be empty."],
			  ["Campul 'mesaj' nu poate fi gol.", "The field 'message' cannot be empty."],
			  ["Specificati cantitatea.", "Specify the quantity."],//20
			  ["Nu puteti alege produse ce nu se afla pe stoc", "You cannot choose products which are not on stock"]
			  ];
if (language=="ro")
	lang_nr = 0;
if (language=="en")
	lang_nr = 1;

function show_hsalf()
{
	document.write('<embed src="/flash/banner_index.swf" width="660" height="232" wmode="transparent" scale="exactfit"></embed>');
}

function contNou()
{

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var address = document.forms['cont'].elements['email'].value;
	if(reg.test(address) == false) {
	  alert('Ati introdus adresa de email gresit. Va rugam sa verificati din nou acest aspect! Adresa email este obligatorie.');
	  return false;
	}
	
	__fields = ["user", "parola", "parola2", "nume", "prenume", "email", "telefon", "strada", "nrstrada", "oras"];
	__name_f = ["utilizator", "parola", "parola de confirmare", "nume", "prenume", "e-mail", "telefon", "strada", "numar strada", "orasul"];
	__name_f_en = ["user", "password", "confirmation password", "last name", "first name", "e-mail", "phone", "street", "street number", "town"];
	__types  = ["", "", "", "", "", "", "", "", "", "0"];
	
	__fieldsfirma = ["companie", "cod_fiscal", "nr_reg", "cstrada", "cnrstrada", "banca", "cont"];
	__name_firma = ["companie", "cod fiscal", "nr. registrul comertului", "strada", "numar strada", "banca", "cont IBAN"];
	__types_firma = ["", "", "", "", "", "", ""];	

	for (i=0;i<__fields.length;i++)
	{
		if (document.getElementById(__fields[i]).value==__types[i])
		{
			if (__types[i]=="")
			{
				if (language=="ro")
					alert(__messages[0][lang_nr]+" '"+__name_f[i]+"'");
				else
					alert(__messages[0][lang_nr]+" '"+__name_f_en[i]+"'");
			}
			else
			{
				if (language=="ro")
					alert(__messages[1][lang_nr]+" '"+__name_f[i]+"'");
				else
					alert(__messages[1][lang_nr]+" '"+__name_f_en[i]+"'");
			}
			document.getElementById(__fields[i]).focus();
			return false;
		}
	}
	

	if (document.getElementById('firma').checked == true)
	{

		for (i=0;i<__fieldsfirma.length;i++)
		{
			if (document.getElementById(__fieldsfirma[i]).value==__types_firma[i])
			{
				if (__types_firma[i]=="")
				{
					alert(__messages[0]+" '"+__name_firma[i]+"'");
				}
				document.getElementById(__fieldsfirma[i]).focus();
				return false;
			}
		}
	}
	
	if ((document.getElementById("parola").value) != (document.getElementById("parola2").value))
	{
		alert(__messages[2][lang_nr]);
		document.getElementById("parola2").focus();
		return false;
	}

	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("email").value)))
	{
		alert(__messages[3][lang_nr]);
		document.getElementById("email").focus();
		return false;
	}
	
	if (document.getElementById("user_token"))
	{
		if (document.getElementById("user_token").value=="preluat")
		{
			alert(__messages[4][lang_nr]);
			document.getElementById("user").focus();
			return false;
		}
	}

	if (document.getElementById("email_token"))
	{
		if (document.getElementById("email_token").value=="preluat")
		{
			alert(__messages[5][lang_nr]);
			document.getElementById("email").focus();
			return false;
		}
	}
}

function construct_search_news()
{
	var search_string = document.getElementById('stireCautata').value
	if (search_string == "")
	{
		alert(__messages[6][lang_nr]);
		document.getElementById('stireCautata').focus;
	}
	else
	{
		search_string = search_string.replace(/ /gi, "_");
		search_string = search_string.toLowerCase();
		document.location='/stiri_cautare/'+search_string+'/pagina_1.html';
	}
}

function expandQuestion()
{
	if (logat)
	{
		if (document.getElementById("f_intrebari").style.display == "none")
			document.getElementById("f_intrebari").style.display = '';
		else
			document.getElementById("f_intrebari").style.display = 'none';
	}
}

function construct_search_howto()
{
	var search_string = document.getElementById('howto_cautat').value
	if (search_string == "")
	{
		alert(__messages[6][lang_nr]);
		document.getElementById('howto_cautat').focus;
	}
	else
	{
		search_string = search_string.replace(/ /gi, "_");
		search_string = search_string.toLowerCase();
		document.location='/cum_sa_cautare/'+search_string+'/pagina_1.html';
	}
}

function CheckCompletition()
{
	if (document.getElementById("intrebare").value=="")
	{
		alert(__messages[8][lang_nr]);
		document.getElementById("intrebare").focus();
		return false;
	}
}

function checkEmailNL()
{
	email = document.getElementById("email_nl").value;
	if (email=="")
	{
		alert(__messages[9][lang_nr]);
		document.getElementById("email_nl").focus();
		return false;
	}

	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)))
	{
		alert(__messages[3][lang_nr]);
		document.getElementById("email_nl").focus();
		return false;
	}
}

function check_logat()
{
	//if (!(logat))
	//{
	//	alert(__messages[7][lang_nr]);
	//	return false;
	//}
}

function save_quantity(cod, linia)
{
	if (document.getElementById("cantitate"+linia).value!="")
		document.location='/modifica_cos_'+cod+'_'+document.getElementById("cantitate"+linia).value+'.html';
	else
		alert(__messages[20][lang_nr]);
}

function CheckNumeric(control_input)
{
	content = document.getElementById(control_input).value;
	val='';
	for(i=0;i<=content.length;i++)
	{
		char = content.charCodeAt(i);
		if(char>=48 && char<=57)
			val+=content.substr(i,1);
	}
	if(content!=val)
		document.getElementById(control_input).value=val;
}

function checkPass()
{
	if ((document.getElementById("pass1").value=="") || (document.getElementById("pass2").value==""))
	{
		alert(__messages[10][lang_nr]);
		if (document.getElementById("pass1").value=="")
			document.getElementById("pass1").focus();
		else
			document.getElementById("pass2").focus();
		return false;
	}
	if (document.getElementById("pass1").value!=document.getElementById("pass2").value)
	{
		alert(__messages[2][lang_nr]);
		document.getElementById("pass2").focus();
		return false;
	}
}

function checkEmailFields()
{
	if (document.getElementById("nume").value=="")
	{
		alert(__messages[11][lang_nr]);
		document.getElementById("nume").focus();
		return false;
	}
	if (document.getElementById("prenume").value=="")
	{
		alert(__messages[12][lang_nr]);
		document.getElementById("prenume").focus();
		return false;
	}
	email = document.getElementById("email_address").value;
	if (email=="")
	{
		alert(__messages[13][lang_nr]);
		document.getElementById("email_address").focus();
		return false;
	}

	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)))
	{
		alert(__messages[3][lang_nr]);
		document.getElementById("email_address").focus();
		return false;
	}
}

function expand_row(id)
{
	if (document.getElementById("comenzi_"+id).style.display=="none")
	{
		document.getElementById("comenzi_"+id).style.display="";
		document.getElementById("arrow_"+id).src = "/img/expanded.gif"
	}
	else
	{
		document.getElementById("comenzi_"+id).style.display="none";
		document.getElementById("arrow_"+id).src = "/img/arrow.gif"
	}
}

function search_content()
{
	var search_string = document.getElementById('search').value
	if (search_string == "")
	{
		alert(__messages[6][lang_nr]);
		document.getElementById('search').focus();
	}
	else if (document.getElementById('search_place').selectedIndex==0)
	{
		alert(__messages[14][lang_nr]);
		document.getElementById('search_place').focus();
	}
	else
	{
		search_string = search_string.replace(/ /gi, "_");
		search_string = search_string.replace(/\?/gi, "");
		search_string = search_string.replace(/&/gi, "");
		search_string = search_string.toLowerCase();
		document.location='/cautare/'+document.getElementById('search_place').value+'/'+search_string+'/pagina_1.html';
	}
	return false;
}

function initialize()
{
	if (search_place!="")
	{
		document.getElementById('search_place').value   = search_place;
		search_content_string = search_content_string.replace(/_/gi, " ");
		document.getElementById('search').value = search_content_string;
	}
}

function expand(mod, minim, maxim, nums, min2, max2, colapser)
{
	if (mod=="numbers")
	{
		numbers = nums.split("|");
		if (document.getElementById("line_"+numbers[1]).style.display == 'none')
		{
			for (i=0;i<numbers.length;i++)
				document.getElementById("line_"+numbers[i]).style.display = '';
			document.getElementById("colapser_"+colapser).innerHTML = " - ";
		}
		else
		{
			if (min2!=0)
			{
				for (i=parseInt(min2);i<=parseInt(max2);i++)
					document.getElementById("line_"+i).style.display = 'none';
			}
			else
			{
				for (i=0;i<numbers.length;i++)
					document.getElementById("line_"+numbers[i]).style.display = 'none';
			}
			document.getElementById("colapser_"+colapser).innerHTML = "+";
			if (min2!=0)
			{
				for (i=min2;i<=max2;i++)
				{
					if (document.getElementById("colapser_"+i))
						document.getElementById("colapser_"+i).innerHTML = "+";
				}
			}
		}
	}
	
	if (mod=="range")
	{
		if (document.getElementById("line_"+parseInt(minim)).style.display == 'none')
		{
			for (i=parseInt(minim);i<=parseInt(maxim);i++)
				document.getElementById("line_"+i).style.display = '';
			document.getElementById("colapser_"+colapser).innerHTML = " - ";
		}
		else
		{
			for (i=parseInt(minim);i<=parseInt(maxim);i++)
				document.getElementById("line_"+i).style.display = 'none';
			document.getElementById("colapser_"+colapser).innerHTML = "+";
		}
	}
}

function check_login()
{
	if (document.getElementById("username").value=="")
	{
		alert(__messages[15][lang_nr]);
		document.getElementById("username").focus();
		return false;
	}

	if (document.getElementById("password").value=="")
	{
		alert(__messages[16][lang_nr]);
		document.getElementById("password").focus();
		return false;
	}
}

function check_login_popup()
{
	if (document.getElementById("usernamepopup").value=="")
	{
		alert(__messages[15][lang_nr]);
		document.getElementById("usernamepopup").focus();
		return false;
	}

	if (document.getElementById("passwordpopup").value=="")
	{
		alert(__messages[16][lang_nr]);
		document.getElementById("passwordpopup").focus();
		return false;
	}
}

function check_email_address_transaction()
{
	if (document.getElementById("adresa_livrare").value=="")
	{
		alert(__messages[13][lang_nr]);
		document.getElementById("adresa_livrare").focus();
		return false;
	}
	
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var address = document.getElementById("adresa_livrare").value;
	if(reg.test(address) == false) {
	  alert('Ati introdus adresa de email gresit. Va rugam sa verificati din nou acest aspect! Adresa email este obligatorie.');
	  return false;
	}	
}

var current_gadget = "";
function showGadget(gadget)
{
	if (current_gadget!="")
		document.getElementById(current_gadget).style.display='none';
	if (current_gadget==gadget)
	{
		document.getElementById(gadget).style.display='none';
		current_gadget = "";
	}
	else
	{
		document.getElementById(gadget).style.display='';
		current_gadget = gadget;
	}
}

function send_to_friend()
{
	if ((document.getElementById('trimite_prieten_email').value=='') || (document.getElementById('trimite_prieten_email').value=='Your friend e-mail') || (document.getElementById('trimite_prieten_email').value=='Numele dvs'))
	{
		alert(__messages[17][lang_nr]);
		document.getElementById('trimite_prieten_email').focus();
		return false;
	}
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("trimite_prieten_email").value)))
	{
		alert(__messages[3][lang_nr]);
		document.getElementById('trimite_prieten_email').focus();
		return false;
	}

	nume  = document.getElementById('trimite_prieten_nume').value
	email = document.getElementById('trimite_prieten_email').value
	mesaj = document.getElementById('trimite_prieten_mesaj').value
	sendToAjax('/fast_pages/send_to_friend.php?nume='+nume+'&email='+email+'&mesaj='+mesaj, 'status_trimite_prieten');
	document.getElementById("trimite_prieten_email").value = "";
}

function post_comment(category)
{
	if ((document.getElementById('comment_name').value=='') || (document.getElementById('comment_name').value=='Numele dvs') || (document.getElementById('comment_name').value=='Your name'))
	{
		alert(__messages[11][lang_nr]);
		document.getElementById('comment_name').focus();
		return false;
	}

	if ((document.getElementById('comment_mesaj').value=='') || (document.getElementById('comment_mesaj').value=='Comentariu') || (document.getElementById('comment_mesaj').value=='Comment'))
	{
		alert(__messages[18][lang_nr]);
		document.getElementById('comment_mesaj').focus();
		return false;
	}
	
	nume  		= document.getElementById('comment_name').value;
	comentariu  = document.getElementById('comment_mesaj').value;
	addComment(nume, comentariu)
	sendToAjax('/fast_pages/comment.php?nume='+nume+'&comentariu='+comentariu+'&category='+category, 'status_comentariu');
	document.getElementById("comment_name").value = "";
	document.getElementById("comment_mesaj").value = "";
}

function update_this(category)
{
	if ((document.getElementById('update_nume').value=='') || (document.getElementById('update_nume').value=='Your name') || (document.getElementById('update_nume').value=='Numele dvs'))
	{
		alert(__messages[11][lang_nr]);
		document.getElementById('update_nume').focus();
		return false;
	}

	if ((document.getElementById('update_mesaj').value=='') || (document.getElementById('update_mesaj').value=='Update') || (document.getElementById('update_mesaj').value=='Update'))
	{
		alert(__messages[19][lang_nr]);
		document.getElementById('update_mesaj').focus();
		return false;
	}
	
	nume   = document.getElementById('update_nume').value;
	mesaj  = document.getElementById('update_mesaj').value;
	sendToAjax('/fast_pages/update_this.php?nume='+nume+'&mesaj='+mesaj+'&category='+category, 'status_update');
	document.getElementById("update_nume").value = "";
	document.getElementById("update_mesaj").value = "";
}

function addComment(nume, comentariu)
{
	//ins_com = document.getElementById("instant_comments").innerHTML;
	
	//instant_commments = '<br /><div style="background-color:#E7F5FF;border:1px solid #D1E6F3;padding:4px;color:#0066AD;">';
	//instant_commments += '<b>'+nume+'</b>';
	//instant_commments += '<div style="height:10px;"></div>';
	//instant_commments += comentariu;
	//instant_commments += '</div>';
	//instant_commments += ins_com;
	//document.getElementById("instant_comments").innerHTML = instant_commments;
}

function check_quantity()
{
	var quantity = document.getElementById("quantity").value;
	if (quantity=="")
	{
		alert(__messages[20][lang_nr]);
		document.getElementById("quantity").focus();
		return false;
	}
}
function CheckOnStock()
{
	if (document.getElementById("valoare").value=="nu este pe stoc")
	{
		alert(__messages[21][lang_nr]);
		document.getElementById("valoare").focus();
		return false;
	}
}
