var ua = navigator.userAgent.toLowerCase();

var categpid = 0;
function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
	try {
	req = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (err3) {
	  req = false;
	}
  }
}
return req;
}
var http = getXMLHTTPRequest();

function getCountyId(ob_state)
{
	if (ob_state.options.selectedIndex >= 0)
	{
		if (ob_state.options[ob_state.selectedIndex].text == 'Bucuresti')
		{
			document.form_register['suburb'].disabled = false;
		}
		else
		{
		    document.form_register['suburb'].disabled = true;
		}

		return ob_state.options[ob_state.selectedIndex].value;
	}
	else
	{
		return 0;
	}
}
function getCountyId_newad(ob_state)
{
	if (ob_state.options.selectedIndex >= 0)
	{
		if (ob_state.options[ob_state.selectedIndex].text == 'Bucuresti')
		{
			document.newad_form['suburb'].disabled = false;
		}
		else
		{
		    document.newad_form['suburb'].disabled = true;
		}

		return ob_state.options[ob_state.selectedIndex].value;
	}
	else
	{
		return 0;
	}
}
function getCountyId_search(ob_state)
{
	if (ob_state.options.selectedIndex >= 0)
	{
		if (ob_state.options[ob_state.selectedIndex].text == 'Bucuresti')
		{
			document.advsearch_form['suburb'].disabled = false;
		}
		else
		{
		    document.advsearch_form['suburb'].disabled = true;
		}

		return ob_state.options[ob_state.selectedIndex].value;
	}
	else
	{
		return 0;
	}
}
function getCategId(ob_state)
{
	if (ob_state.options.selectedIndex >= 0)
	{
	/*	if (ob_state.options[ob_state.selectedIndex].text == 'Bucuresti')
		{
			document.form_register['suburb'].disabled = false;
		}
		else
		{
		    document.form_register['suburb'].disabled = true;
		}
		*/
        categid = ob_state.options[ob_state.selectedIndex].value;
        return categid;
	}
	else
	{
		return 0;
	}
}

function md5(s){
	function Z(n,c){return(n<<c)|(n>>>(32-c))}
	function Y(q,a,b,x,s,t){return X(Z(X(X(a,q),X(x,t)),s),b)}
	function A(a,b,c,d,x,s,t){return Y((b&c)|((~b)&d),a,b,x,s,t)}
	function B(a,b,c,d,x,s,t){return Y((b&d)|(c&(~d)),a,b,x,s,t)}
	function C(a,b,c,d,x,s,t){return Y(b^c^d,a,b,x,s,t)}
	function D(a,b,c,d,x,s,t){return Y(c^(b|(~d)),a,b,x,s,t)}
	function X(x,y){var l=(x&0xFFFF)+(y&0xFFFF),m=(x>>16)+(y>>16)+(l>>16);return(m<<16)|(l&0xFFFF)}

	var w=s.length*8,i,hx="0123456789abcdef",L=(((w+64)>>>9)<<4)+15,x=Array(L+15);
	for(i=0;i<x.length;++i)x[i]=0;
	for(i=0;i<w;i+=8)x[i>>5]|=(s.charCodeAt(i/8)&255)<<(i%32);
	x[w>>5]|=0x80<<((w)%32);
	x[L-1]=w;

	var a=1732584193,b=-271733879,c=-1732584194,d=271733878;
	for(i=0;i<L;i+=16){
		var oa=a,ob=b,oc=c,od=d;
		a=A(a,b,c,d,x[i],7,-680876936);d=A(d,a,b,c,x[i+1],12,-389564586);c=A(c,d,a,b,x[i+2],17,606105819);b=A(b,c,d,a,x[i+3],22,-1044525330);
		a=A(a,b,c,d,x[i+4],7,-176418897);d=A(d,a,b,c,x[i+5],12,1200080426);c=A(c,d,a,b,x[i+6],17,-1473231341);b=A(b,c,d,a,x[i+7],22,-45705983);
		a=A(a,b,c,d,x[i+8],7,1770035416);d=A(d,a,b,c,x[i+9],12,-1958414417);c=A(c,d,a,b,x[i+10],17,-42063);b=A(b,c,d,a,x[i+11],22,-1990404162);
		a=A(a,b,c,d,x[i+12],7,1804603682);d=A(d,a,b,c,x[i+13],12,-40341101);c=A(c,d,a,b,x[i+14],17,-1502002290);b=A(b,c,d,a,x[i+15],22,1236535329);
		a=B(a,b,c,d,x[i+1],5,-165796510);d=B(d,a,b,c,x[i+6],9,-1069501632);c=B(c,d,a,b,x[i+11],14,643717713);b=B(b,c,d,a,x[i],20,-373897302);
		a=B(a,b,c,d,x[i+5],5,-701558691);d=B(d,a,b,c,x[i+10],9,38016083);c=B(c,d,a,b,x[i+15],14,-660478335);b=B(b,c,d,a,x[i+4],20,-405537848);
		a=B(a,b,c,d,x[i+9],5,568446438);d=B(d,a,b,c,x[i+14],9,-1019803690);c=B(c,d,a,b,x[i+3],14,-187363961);b=B(b,c,d,a,x[i+8],20,1163531501);
		a=B(a,b,c,d,x[i+13],5,-1444681467);d=B(d,a,b,c,x[i+2],9,-51403784);c=B(c,d,a,b,x[i+7],14,1735328473);b=B(b,c,d,a,x[i+12],20,-1926607734);
		a=C(a,b,c,d,x[i+5],4,-378558);d=C(d,a,b,c,x[i+8],11,-2022574463);c=C(c,d,a,b,x[i+11],16,1839030562);b=C(b,c,d,a,x[i+14],23,-35309556);
		a=C(a,b,c,d,x[i+1],4,-1530992060);d=C(d,a,b,c,x[i+4],11,1272893353);c=C(c,d,a,b,x[i+7],16,-155497632);b=C(b,c,d,a,x[i+10],23,-1094730640);
		a=C(a,b,c,d,x[i+13],4,681279174);d=C(d,a,b,c,x[i],11,-358537222);c=C(c,d,a,b,x[i+3],16,-722521979);b=C(b,c,d,a,x[i+6],23,76029189);
		a=C(a,b,c,d,x[i+9],4,-640364487);d=C(d,a,b,c,x[i+12],11,-421815835);c=C(c,d,a,b,x[i+15],16,530742520);b=C(b,c,d,a,x[i+2],23,-995338651);
		a=D(a,b,c,d,x[i],6,-198630844);d=D(d,a,b,c,x[i+7],10,1126891415);c=D(c,d,a,b,x[i+14],15,-1416354905);b=D(b,c,d,a,x[i+5],21,-57434055);
		a=D(a,b,c,d,x[i+12],6,1700485571);d=D(d,a,b,c,x[i+3],10,-1894986606);c=D(c,d,a,b,x[i+10],15,-1051523);b=D(b,c,d,a,x[i+1],21,-2054922799);
		a=D(a,b,c,d,x[i+8],6,1873313359);d=D(d,a,b,c,x[i+15],10,-30611744);c=D(c,d,a,b,x[i+6],15,-1560198380);b=D(b,c,d,a,x[i+13],21,1309151649);
		a=D(a,b,c,d,x[i+4],6,-145523070);d=D(d,a,b,c,x[i+11],10,-1120210379);c=D(c,d,a,b,x[i+2],15,718787259);b=D(b,c,d,a,x[i+9],21,-343485551);

		a=X(a,oa);
		b=X(b,ob);
		c=X(c,oc);
		d=X(d,od);
	}
	b=[a,b,c,d];
	s="";
	for(i=0;i<16;i++)s+=hx.charAt((b[i>>2]>>((i%4)*8+4))&0xF)+hx.charAt((b[i>>2]>>((i%4)*8))&0xF);
	return s
}

function securizareParola(where){
	if (where == 'login') {


	if (document.login_form['salt'] && document.login_form['password'] && document.login_form['secure_password']) {
		password = document.login_form['password'].value;
		secure_password = md5(password);
		salt = document.login_form['salt'].value;
		secure_password = md5(salt+secure_password);

		document.login_form['secure_password'].value = secure_password;
		//eliminate pass value from field form
		document.login_form['salt'].value = '';
		document.login_form['password'].value = '';
	}else{
		if (document.getElementById('salt') && document.getElementById('password') && document.getElementById('secure_password')) {

			password = document.getElementById('password').value;
			secure_password = md5(password);
			salt = document.getElementById('salt').value;
			secure_password = md5(salt+secure_password);
			document.getElementById('secure_password').value = secure_password;
			//eliminate pass value from field form
			document.getElementById('salt').value = '';
			document.getElementById('password').value = '';
		}
	}

 	}
 	if (where == 'center_login') {


	if (document.centerlogin_form['password_c'] && document.centerlogin_form['secure_password_c']) {

		password = document.centerlogin_form['password_c'].value;
		secure_password = md5(password);
		salt = document.centerlogin_form['salt_c'].value;
		secure_password = md5(salt+secure_password);

		document.centerlogin_form['salt_c'].value = '';
		document.centerlogin_form['password_c'].value = '';
		document.centerlogin_form['secure_password_c'].value = secure_password;
	}else{
		if (document.getElementById('password_c') && document.getElementById('salt_c') && document.getElementById('secure_password_c')) {

			password = document.getElementById('password_c').value;
			secure_password = md5(password);
			salt = document.getElementById('salt_c').value;
			secure_password = md5(salt+secure_password);

			document.getElementById('salt_c').value = '';

			document.getElementById('password_c').value = '';
			document.getElementById('secure_password_c').value = secure_password;
		}
	}
	}
	if (where == 'editinfo') {


	if (document.form_register['password_ei'] && document.form_register['secure_password_ei']) {
		password = document.login_form['password_ei'].value;
		secure_password = md5(password);
		salt_ei = document.form_register['salt_ei'].value;
		document.form_register['password_ei'].value = '';
		secure_password = md5(salt_ei+secure_password);
		document.form_register['salt_c'].value = '';
		document.form_register['password_ei'].value = '';
		document.form_register['secure_password_ei'].value = secure_password;
	}else{

		if (document.getElementById('password_ei') && document.getElementById('secure_password_ei') && document.getElementById('salt_ei')) {
			password = document.getElementById('password_ei').value;
			secure_password = md5(password);
			salt_ei = document.getElementById('salt_ei').value;
			secure_password = md5(salt+secure_password);
			document.getElementById('salt_ei').value = '';
			document.getElementById('password_ei').value = '';
			document.getElementById('secure_password_ei').value = secure_password;
		}
	}
	}
}
function securizareParola(){
	password = document.login_form['password'].value;
	secure_password = md5(password);
	salt = document.login_form['salt'].value;
 	secure_password = md5(salt+secure_password);
	document.login_form['secure_password'].value = secure_password;
	document.login_form['salt'].value = '';
	document.login_form['password'].value = '';
}

function securizareParola_ei(){
	password = document.form_register['password_ei'].value;
	secure_password = md5(password);
	salt = document.form_register['salt_ei'].value;
 	secure_password = md5(salt+secure_password);
	document.form_register['secure_password_ei'].value = secure_password;

	document.form_register['salt_ei'].value = '';
	document.form_register['password_ei'].value = '';
}

function securizareParola_c(){
	password = document.centerlogin_form['password_c'].value;
	secure_password = md5(password);
	salt = document.centerlogin_form['salt_c'].value;
 	secure_password = md5(salt+secure_password);
	document.centerlogin_form['secure_password_c'].value = secure_password;
	document.centerlogin_form['salt_c'].value = '';
	document.centerlogin_form['password_c'].value = '';
}

function retrieveSalt(ob){
	var email = ob.value;
	var myurl = "include/get_salt.php";
	myRand = parseInt(Math.random()*999999999999999);
	var modurl = myurl+ "?email="+email+"&rand="+myRand;
	http.open("GET", modurl, true);
	http.onreadystatechange = useHttpResponseSalt;
	http.send(null);
}
function retrieveSalt_c(ob){
	var email = ob.value;
	var myurl = "include/get_salt.php";
	myRand = parseInt(Math.random()*999999999999999);
	var modurl = myurl+ "?email="+email+"&rand="+myRand;
	http.open("GET", modurl, true);
	http.onreadystatechange = useHttpResponseSalt_c;
	http.send(null);
}

function getCountyCities(stateid){
	var myurl = "include/get_county_cities.php";
	myRand = parseInt(Math.random()*999999999999999);
	var modurl = myurl+"?stateid="+stateid+"&rand="+myRand;
	http.open("GET", modurl, true);
	http.onreadystatechange = useHttpResponseCities;
	http.send(null);
}

function getSubCateg(categid){
	var myurl = "include/get_subcateg.php";
	myRand = parseInt(Math.random()*999999999999999);
	var modurl = myurl+"?categid="+categid+"&rand="+myRand;
	http.open("GET", modurl, true);
	http.onreadystatechange = useHttpResponseSubCateg;
	http.send(null);
}

function useHttpResponseCities(){
   if (http.readyState == 4) {
    if(http.status == 200) {
		mytext = http.responseText;
		document.getElementById('cities_div').innerHTML = mytext;
    }
  }
}

function useHttpResponseSubCateg(){
   if (http.readyState == 4) {
    if(http.status == 200) {
		mytext = http.responseText;
		document.getElementById('allcategs').innerHTML = mytext;
    }
  }
}

function useHttpResponseSalt(){
   if (http.readyState == 4) {
	    if(http.status == 200) {
			mytext = http.responseText;
			document.login_form['salt'].value = mytext;
	    }
  }else{
 		 document.login_form['salt'].value = "";

  }
}

function useHttpResponseSalt_c(){
   if (http.readyState == 4) {
	    if(http.status == 200) {
			mytext = http.responseText;
			document.centerlogin_form['salt_c'].value = mytext;
	    }
  }else{
 		 document.centerlogin_form['salt_c'].value = "";
  }
}

function retrieveNewRandomCode(){
	var myurl = "include/randomImage.php";
	myRand = parseInt(Math.random()*999999999999999);
	var modurl = myurl+ "?rand="+myRand;
	http.open("GET", modurl, true);
	http.onreadystatechange = useHttpNewRandomCode;
	http.send(null);
}

function useHttpNewRandomCode(){
   if (http.readyState == 4) {
	    if(http.status == 200) {
			mytext = http.responseText;
			document.form_register['rndimg'].src = mytext;
	    }
  }else{
 		 document.form_register['rndimg'].src = "";
  }
}

function validateFormOnSubmit() {

var reason = "";

  reason += validateName("name", "Nume");
  reason += validateEmail("email", "Email");
  reason += validateEmpty("solicitare", "Solicitare", 5, 255);

  if (reason != "") {
    alert("Unele campuri au nevoie de corectare:\n" + reason);
    return false;
  }

  return true;
}

function validateRegisterFormOnSubmit() {
var reason = "";

  reason += validateName('firstname', 'Prenume');
  reason += validateName('lastname', 'Nume');
 if (document.getElementById('sunt_companie').style.checked = true)
 {

  reason += validateName('company', 'Nume companie');
  reason += validateName('bank', 'Banca');
  reason += validateName('city', 'Oras');
  reason += validateName('state', 'Judet');
  reason += validateEmpty("cf", "Cod fiscal", 5, 30);
  reason += validateEmpty("iban", "Cod IBAN", 5, 30);
  reason += validateEmpty("nr_reg_com", "Nr. Reg. Comertului", 5, 30);
 }
 reason += validatePhone("telephone", "Numar telefon");
 //reason += validatePhone("fax", "Numar fax");

  reason += validateEmail('email');
  if (document.getElementById('city').value == 'Bucuresti')
   {
	 reason += validateNumber('suburb','Sector', 1, 1, 6);
   }
  reason += validateNumber('postcode','Cod postal', 6, 0,0);

  if (reason != "") {
    alert("Unele campuri au nevoie de corectare:\n" + reason);
    return false;
  }


  return true;
}

function validateEmpty(fld, fld_n, min, max) {
    var error = "";

    if (document.getElementById(fld).value.length == 0) {
        document.getElementById(fld).style.background = '#C6E2FF';

        error += "Campul "+ fld_n +" nu a fost completat.\n"
    }
	if ((document.getElementById(fld).value.length < min) || (document.getElementById(fld).value.length > max)) {

        error += "Numarul de caractere al campului "+ fld_n +" este prea mare sau prea mic.\n";
    }
	if (error == "")
	{
        document.getElementById(fld).style.background = 'White';
    }
	else
	{
		document.getElementById(fld).style.background = '#C6E2FF';
	}
    return error;
}

function validateName(fld, fld_n) {
    var error = "";
    //var illegalChars = /\W/; // allow letters, numbers, and underscores
	var illegalChars = /[\\\^\-{}\]?<>~@#$%&*()+=|]/;
    if (document.getElementById(fld).value == "") {

        error += "Nu ai introdus o valoare pentru "+ fld_n +". \n";
    }
	if ((document.getElementById(fld).value.length < 5) || (document.getElementById(fld).value.length > 50)) {

        error += "Campul "+ fld_n +" este prea mic.\n";
    }
	if (illegalChars.test(document.getElementById(fld).value)) {

        error += "Campul "+ fld_n +" contine caractere nepermise.\n";
    }

	if (error == "")
	{
		document.getElementById(fld).style.background = 'White';
	}
	else {
        document.getElementById(fld).style.background = '#C6E2FF';
    }
    return error;
}
function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld, fld_n) {
    var error="";
    var tfld = trim(document.getElementById(fld).value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@.]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;

    if (document.getElementById(fld).value == "") {

        error += "Nu ai introdus adresa de email.\n";
	}
	 if (!emailFilter.test(tfld)) {              //test email for illegal characters

		error += "Introdu o adresa de email valida.\n";
	 }
	 if (document.getElementById(fld).value.match(illegalChars)) {

		error += "Adresa de email contine caractere nepermise.\n";
	 }
	 if (document.getElementById(fld).value.length > 40) {
		error += "Adresa de email introdusa este incorecta.\n";
	 }

	if (error == "")
	{
		document.getElementById(fld).style.background = 'White';
	}else{
		document.getElementById(fld).style.background = '#C6E2FF';
	}
    return error;
}


function showHideCurr(){
	if (document.getElementById){
		if (document.getElementById('hidecurr').style.display == 'none') {
	 	document.getElementById('more').style.display = 'none';
	 	document.getElementById('hidecurr').style.display = '';

	 }else{
	 if (document.getElementById('hidecurr').style.display == '') {
	 	document.getElementById('hidecurr').style.display = 'none';
	 	document.getElementById('more').style.display = '';
	 }
	}
	}else if (document.all){
	if (document.all.hidecurr.style.display == 'none') {
	 	document.all.more.style.display = 'none';
	 	document.all.hidecurr.style.display = '';

	 }else{
	 if (document.all.hidecurr.style.display == '') {
	 	document.all.hidecurr.style.display = 'none';
	 	document.all.more.style.display = '';
	 }
	}
	}
}

function showHide(idlink,idinner){
	if (document.getElementById){
		if (document.getElementById(idinner).style.display == 'none') {
	 	document.getElementById(idlink).style.display = 'none';
	 	document.getElementById(idinner).style.display = '';

	 }else{
	 if (document.getElementById(idinner).style.display == '') {
	 	document.getElementById(idinner).style.display = 'none';
	 	document.getElementById(idlink).style.display = '';
	 }
	}
	}else if (document.all){
	if (document.all.hidecurr.style.display == 'none') {
	 	document.all.more.style.display = 'none';
	 	document.all.hidecurr.style.display = '';

	 }else{
	 if (document.all.hidecurr.style.display == '') {
	 	document.all.hidecurr.style.display = 'none';
	 	document.all.more.style.display = '';
	 }
	}
	}
}


function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
return true;
}
/*if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}
*/
function conversion(e){
		var unicode=e.keyCode? e.keyCode : e.charCode;
		//alert(unicode);

		if((unicode >= 48 && unicode <= 57) || (unicode >= 96 && unicode <= 105) || unicode == 144 || unicode == 110 || unicode == 46 || unicode == 35 || unicode == 36 || unicode == 37 || unicode == 39 || unicode == 8 || unicode == 127 || unicode==190)
{
	if (document.getElementById){
	objv = document.getElementById('valuefrom');
		var value = document.getElementById('valuefrom').value;
		}else if (document.all){
		objv = document.all.valuefrom;
		var value = document.all.valuefrom.value;
		}
		var arrvalue = new Array();
		arrvalue = value.split(".");
		if (arrvalue.length>2) {
			alert("Folositi un singur semn '.' pentru delimitarea zecimalelor.");
			return;
		}
		if (arrvalue.length == 2) {
			if (arrvalue[0] == '') {
				alert("Nu plasati semnul '.' la inceputul sumei de convertit. De asemnea introduceti cel putin o zecimala dupa semnul '.'.");
				return;
			}
			if (arrvalue[1] == '') {
			if (isNaN(arrvalue[0])) {
				alert("Valoarea introdusa nu este un numar.");
				return;
			}
			value = value + "0";
			//value = value.Number();
			}
		}
		/*if (value.indexOf("0") == "0" && value.indexOf(".") == -1 ) {
				alert("Valoarea numerica introdusa nu este corecta.");
			return;
		}*/
		if (value.indexOf("0") == "" && value.indexOf(".") >= 1 && value.indexOf("0") != 0) {
				alert("Valoarea numerica introdusa nu este corecta.");
			return;
		}

		if (isNaN(value)) {
				alert("Valoarea introdusa nu este un numar.");
				return;
			}
	obfrom = document.currconvform['currfrom'];
	obto = document.currconvform['currto'];
	var unitto = 1;
	var unitfrom = 1;
	if (obfrom.options.selectedIndex >= 0)
	{
		unitfrom = obfrom.options[obfrom.selectedIndex].value;
		namefrom = obfrom.options[obfrom.selectedIndex].text;
	}
	if (obto.options.selectedIndex >= 0)
	{
		unitto = obto.options[obto.selectedIndex].value;
		var nameto = obto.options[obto.selectedIndex].text;
	}
	if (document.getElementById){

		if (value.length == 1) {
		document.getElementById('tochn').innerHTML = obto.options[obto.selectedIndex].text;
		document.getElementById('fromchn').innerHTML = obfrom.options[obfrom.selectedIndex].text;
		}
		if (value == '') {
			document.getElementById('tochn').innerHTML = '';
			document.getElementById('fromchn').innerHTML = '';
			var res = '';
		}else{

			var result = value * unitfrom/unitto;
			res = result.toFixed(3);
			res = res.wordWrap(10, "<br/>", 1);
		}

		document.getElementById('currresult').innerHTML = res;
	}else if (document.all){

		if (value.length == 1) {
			document.all.tochn.innerHTML = obto.options[obto.selectedIndex].text;
			document.all.fromchn.innerHTML = obfrom.options[obfrom.selectedIndex].text;
		}
		if (value == '') {
			document.all.tochn.innerHTML = '';
			document.all.fromchn.innerHTML = '';
			var res = '';
		}else{

		var result = value * unitfrom / unitto;
		res = result.toFixed(3);
		res = res.wordWrap(10, "<br/>", 1);
		}
		document.all.currresult.innerHTML = res;
	}

}else{
	alert("Utilizati doar cifre si semnul '.' pentru separarea zecimalelor.");

	if (document.getElementById){
	objv = document.getElementById('valuefrom');
	}else if (document.all){
		objv = document.all.valuefrom;

	}
	if (isNaN(objv.value.charAt(objv.value.length - 1))) {

		value = objv.value.slice(0,objv.value.length - 1);

		objv.value = value;
	}
}
	}






function conversionFromTo(){
if (document.getElementById){
		var value = document.getElementById('valuefrom').value;

	}else if (document.all){
		var value = document.all.valuefrom.value;
	}
if (value != '') {
	var obto = document.currconvform['currto'];
	var obfrom = document.currconvform['currfrom'];
	if (obto.options.selectedIndex >= 0)
	{


		if (obfrom.options.selectedIndex >= 0)
	{
		if (document.getElementById)
	{
		document.getElementById('tochn').innerHTML = obto.options[obto.selectedIndex].text;
		document.getElementById('fromchn').innerHTML = obfrom.options[obfrom.selectedIndex].text;
	}
	else if (document.all){
		document.all.tochn.innerHTML = obto.options[obto.selectedIndex].text;
		document.all.fromchn.innerHTML = obfrom.options[obfrom.selectedIndex].text;
	}
	//conversion();

	var arrvalue = new Array();
		arrvalue = value.split(".");
		if (arrvalue.length>2) {
			alert("Folositi un singur semn '.' pentru delimitarea zecimalelor.");
			return;
		}
		if (arrvalue.length == 2) {
			if (arrvalue[0] == '') {
				alert("Nu plasati semnul '.' la inceputul sumei de convertit. De asemnea introduceti cel putin o zecimala dupa semnul '.'.");
				return;
			}
			if (arrvalue[1] == '') {
			if (isNaN(arrvalue[0])) {
				alert("Valoarea introdusa nu este un numar.");
				return;
			}
			value = value + "0";
			//value = value.Number();
			}
		}
		if (value.indexOf("0") == "0" && (value.indexOf(".") == -1 || value.indexOf(".") >= 1 )) {
				alert("Valoarea numerica introdusa nu este corecta.");
			return;
		}
		if (isNaN(value)) {
				alert("Valoarea introdusa nu este un numar.");
				return;
			}

	var unitto = 1;
	var unitfrom = 1;
	if (obfrom.options.selectedIndex >= 0)
	{
		unitfrom = obfrom.options[obfrom.selectedIndex].value;
		namefrom = obfrom.options[obfrom.selectedIndex].text;
	}
	if (obto.options.selectedIndex >= 0)
	{
		unitto = obto.options[obto.selectedIndex].value;
		var nameto = obto.options[obto.selectedIndex].text;
	}
	if (document.getElementById){

		if (value.length == 1) {
		document.getElementById('tochn').innerHTML = obto.options[obto.selectedIndex].text;
		document.getElementById('fromchn').innerHTML = obfrom.options[obfrom.selectedIndex].text;
		}
		if (value == '') {
			document.getElementById('tochn').innerHTML = '';
			document.getElementById('fromchn').innerHTML = '';
			var res = '';
		}else{

			var result = value * unitfrom/unitto;
			res = result.toFixed(3);
			res = res.wordWrap(10, "<br/>", 1);
		}

		document.getElementById('currresult').innerHTML = res;
	}else if (document.all){

		if (value.length == 1) {
			document.all.tochn.innerHTML = obto.options[obto.selectedIndex].text;
			document.all.fromchn.innerHTML = obfrom.options[obfrom.selectedIndex].text;
		}
		if (value == '') {
			document.all.tochn.innerHTML = '';
			document.all.fromchn.innerHTML = '';
			var res = '';
		}else{

		var result = value * unitfrom / unitto;
		res = result.toFixed(3);
		res = res.wordWrap(10, "<br/>", 1);

		}

		document.all.currresult.innerHTML = res;
	}




	}
}
}
}

function conversionTo(ob){
		if (ob.options.selectedIndex >= 0)
	{
		if (document.getElementById)
	{
		document.getElementById('tochn').innerHTML = ob.options[ob.selectedIndex].text;
	}
	else if (document.all){

		document.all.tochn.innerHTML = ob.options[ob.selectedIndex].text;
	}
	conversion();
	}
}


/**
 *
 * @access public
 * @return void
 **/
function showFormDetail(frname){

	var elmessage = document.forms['frmessage'];
	var elfriend = document.forms['frfriend'];
	var elalert = document.forms['fralert'];
	if (document.all) {
	if (document.all.msgm) {
		var msgm = document.all.msgm.style;
	}
		if (document.all.msga) {
				var msga = document.all.msga.style;
		}
	if (document.all.msgf) {
			var msgf = document.all.msgf.style;
	}
	if (document.all.msgfav) {
		var msgfav = document.all.msgfav.style;
	}
	}else{
	if (document.getElementById) {
		if (document.getElementById('msgm')) {
			var msgm = document.getElementById('msgm').style;
		}
		if (document.getElementById('msga')) {
				var msga = document.getElementById('msga').style;
		}
		if (document.getElementById('msgf')) {
				var msgf = document.getElementById('msgf').style;
		}
		if (document.getElementById('msgfav')) {
			var msgfav = document.getElementById('msgfav').style;
		}

	}

	}
	if (document.getElementById('trform').style.visible == 'collapse') {
		document.getElementById('trform').style.visible = 'visible';
	}
	switch(frname){
		case 'frmessage':
			if (elfriend.style.display == '') {
				elfriend.style.display = 'none';
			}
			if (elalert.style.display == '') {
				elalert.style.display = 'none';
			}
			if (msgf && msgf.display == '') {
				msgf.display = 'none';
			}
			if (msga && msga.display == '') {
				msga.display = 'none';
			}
			if (msgfav && msgfav.display == '') {
				msgfav.display = 'none';
			}
			if (elmessage.style.display == 'none') {
				elmessage.style.display = '';
				document.forms[frname].nametxti.value = document.forms[frname].nametxtid.value;
				document.forms[frname].emailtxti.value = document.forms[frname].emailtxtid.value;
				document.forms[frname].bdytxta.value = document.forms[frname].bdytxtad.value;
			}
			break;
		case 'frfriend':
			if (elmessage.style.display == '') {
				elmessage.style.display = 'none';
			}
			if (elalert.style.display == '') {
				elalert.style.display = 'none';
			}
			if (msgm && msgm.display == '') {
				msgm.display = 'none';
			}
			if (msga && msga.display == '') {
				msga.display = 'none';
			}
			if (msgfav && msgfav.display == '') {
				msgfav.display = 'none';
			}
			if (elfriend.style.display == 'none') {
				elfriend.style.display = '';
				document.forms[frname].nametxti.value = document.forms[frname].nametxtid.value;
				document.forms[frname].emailtxti.value = document.forms[frname].emailtxtid.value;
				document.forms[frname].bdytxta.value = document.forms[frname].bdytxtad.value;
			}

			break;
		case 'fralert':
			if (elfriend.style.display == '') {
				elfriend.style.display = 'none';
			}
			if (elmessage.style.display == '') {
				elmessage.style.display = 'none';
			}
			if (msgf && msgf.display == '') {
				msgf.display = 'none';
			}
			if (msgm && msgm.display == '') {
				msgm.display = 'none';
			}
			if (msgfav && msgfav.display == '') {
				msgfav.display = 'none';
			}
			if (elalert.style.display == 'none') {
				elalert.style.display = '';
				document.forms[frname].nametxti.value = document.forms[frname].nametxtid.value;
				document.forms[frname].emailtxti.value = document.forms[frname].emailtxtid.value;
				document.forms[frname].bdytxta.value = document.forms[frname].bdytxtad.value;
			}

			break;
			case 'favorites':
			if (elfriend.style.display == '') {
				elfriend.style.display = 'none';
			}
			if (elmessage.style.display == '') {
				elmessage.style.display = 'none';
			}
			if (elalert.style.display == '') {
				elalert.style.display = 'none';
			}
			if (msgf && msgf.display == '') {
				msgf.display = 'none';
			}
			if (msgm && msgm.display == '') {
				msgm.display = 'none';
			}
			if (msga && msga.display == '') {
				msga.display = 'none';
			}
		default:
			;
	} // switch
	if (frname != 'favorites') {
		var frelem = document.forms[frname];
	}

}


/**
 *
 * @access public
 * @return void
 **/
function cleanContent(el,text){
	if (el.value == text) {
		el.value = '';
	}

}


/**
 *
 * @access public
 * @return void
 **/
 var imgRe = /^.+\.(jpg|jpeg|gif|png)$/i;
function setCoPicture(path)
{  
    if (path.search(imgRe) != -1)
    {   
		document.getElementById('imaginef').src = 'File:///' + path;
    }       
    else    
    {   
        alert("Imaginea trebuie sa fie JPG, PNG sau GIF!");
    }   
}

 
function revealCompanyFields(){
	if (document.getElementById('r1').style.display == 'none') {
		document.getElementById('r1').style.display = '';
	}
	if (document.getElementById('r2').style.display == 'none') {
		document.getElementById('r2').style.display = '';
	}
	if (document.getElementById('r3').style.display == 'none') {
		document.getElementById('r3').style.display = '';
	}
	if (document.getElementById('r4').style.display == 'none') {
		document.getElementById('r4').style.display = '';
	}
	if (document.getElementById('s1').style.display == 'none') {
		document.getElementById('s1').style.display = '';
	}
	if (document.getElementById('hidename').style.display == 'none') {
		document.getElementById('hidename').style.display = '';
	}
		if (document.getElementById('steluta').style.display == 'none') {
		document.getElementById('steluta').style.display = '';
	}
		if (document.getElementById('stel').style.display == 'none') {
		document.getElementById('stel').style.display = '';
	}


}

function hideCompanyFields(){
	if (document.getElementById('r1').style.display == '') {
		document.getElementById('r1').style.display = 'none';
	}
	if (document.getElementById('r2').style.display == '') {
		document.getElementById('r2').style.display = 'none';
	}
	if (document.getElementById('r3').style.display == '') {
		document.getElementById('r3').style.display = 'none';
	}
	if (document.getElementById('r4').style.display == '') {
		document.getElementById('r4').style.display = 'none';
	}
	if (document.getElementById('s1').style.display == '') {
		document.getElementById('s1').style.display = 'none';
	}
	if (document.getElementById('hidename').style.display == '') {
		document.getElementById('hidename').style.display = 'none';
	}
		if (document.getElementById('steluta').style.display == '') {
		document.getElementById('steluta').style.display = 'none';
	}
		if (document.getElementById('stel').style.display == '') {
		document.getElementById('stel').style.display = 'none';
	}

}



/**
 *
 * @access public
 * @return void
 **/
function showHideUPanel(setting){

	if (document.all) {
		var upanelobj = document.all.upanel;
	}else{
		if (document.getElementById) {
			var upanelobj = document.getElementById('upanel');
		}
	}
	upanelobj.style.display = setting;
	//alert(upanelobj.style.display);

}


function callShowHideUPanel(){
	//var email = ob.value;

	var myurl = "include/showHideUPanel.php";
	myRand = parseInt(Math.random()*999999999999999);
	var modurl = myurl+ "?rand="+myRand;
	http.open("GET", modurl, true);
	http.onreadystatechange = useHttpResponseUPanel;
	http.send(null);
}


function useHttpResponseUPanel(){

   if (http.readyState == 4) {
	    if(http.status == 200) {
			mytext = http.responseText;

			showHideUPanel(mytext);
	    }
  }else{

 		 //document.login_form['salt'].value = "";

  }
}

//var ua = navigator.userAgent.toLowerCase();
var divw=0;
var divh=0;

if (document.getElementById || document.all)
	document.write('<div id="imgtrailer" style="position:absolute;visibility:hidden;"></div>')


function gettrailobject()
	{
	if (document.getElementById)
		return document.getElementById("imgtrailer")
	else if (document.all)
		return document.all.trailimagid
	}

function gettrailobj()
	{
	if (document.getElementById)
		return document.getElementById("imgtrailer").style
	else if (document.all)
		return document.all.trailimagid.style
	}

function PopDown()
	{


		document.onmousemove='';
		gettrailobj().visibility="hidden";
	}

function PopUp(location,imgtitle,thw,thh,adid){



		var imgsize = '';
		gettrailobj().left="-500px";
		divthw = parseInt(thw) + 2;
		smthw = parseInt(thw) + 2;
		halfthh = 50;
		halfthh = Math.ceil(parseInt(thh)/2);
		topx = halfthh - 9;
		smthh = parseInt(thh) + 2;
		/*if (navigator.userAgent.indexOf("Opera")!=-1)
			gettrailobject().innerHTML = '<div style="background-color: #b2a99d; layer-background-color: #b2a99d; border: 1px none #808080; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #ffffff; layer-background-color: #ffffff;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+location+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.anuntulweb.ro/images/utile/loadingnew.gif"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 1px solid #808080;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.anuntulweb.ro/images/utile/sep.gif" border="0" width="'+thw+'" height="'+thh+'" ><div id="div_2" style="border-width:0px;margin:0px;z-index:53;layer-background-color: #FFFFFF;background-color:#ffffff;padding:3px;">'+imgtitle+'<br>'+(thw>=233?'<nobr>':'')+'&copy; '+'AnuntulWeb.ro'+(thw>=233?'</nobr>':'')+'<br></div></div><div class="h2" style="z-index:53;background-color: #b2a99d; layer-background-color: #b2a99d;width:'+thw+'px; border: 1px none #808080; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+'ID: '+adid+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgtitle+'<br>'+(thw>=233?'<nobr>':'')+'&copy; '+'AnuntulWeb.ro'+(thw>=233?'</nobr>':'')+'<br></div><div class="h2" style="background-color: #b2a99d; layer-background-color: #b2a99d;width:'+thw+'px; border: 1px none #808080; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+'ID: '+adid+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div>';
		if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1)
			gettrailobject().innerHTML = '<div style="background-color: #b2a99d; layer-background-color: #b2a99d; border: 1px none #808080; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #ffffff; layer-background-color: #ffffff;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+location+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.anuntulweb.ro/images/utile/loadingnew.gif"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 1px solid #808080;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.anuntulweb.ro/images/utile/sep.gif" border="0" width="'+thw+'" height="'+thh+'" ><div id="div_2" style="border-width:0px;margin:0px;z-index:53;layer-background-color: #FFFFFF;background-color:#ffffff;padding:3px;">'+imgtitle+'<br>'+(thw>=233?'<nobr>':'')+'&copy; '+'AnuntulWeb.ro'+(thw>=233?'</nobr>':'')+'<br></div></div><div class="h2" style="z-index:53;background-color: #b2a99d; layer-background-color: #b2a99d;width:'+thw+'px; border: 1px none #808080; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+'ID: '+adid+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgtitle+'<br>'+(thw>=233?'<nobr>':'')+'&copy; '+'AnuntulWeb.ro'+(thw>=233?'</nobr>':'')+'<br></div><div class="h2" style="background-color: #b2a99d; layer-background-color: #b2a99d;width:'+thw+'px; border: 1px none #808080; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+'ID: '+adid+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div>';
		if (navigator.userAgent.indexOf("MSIE")!=-1)
			gettrailobject().innerHTML = '<div style="background-color: #b2a99d; layer-background-color: #b2a99d; border: 1px none #808080; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #FFFFFF; layer-background-color: #FFFFFF;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+location+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.anuntulweb.ro/images/utile/loadingnew.gif"></div><div style="margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 1px solid #808080;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.anuntulweb.ro/images/utile/sep.gif" border="0" width="'+thw+'" height="'+thh+'"  ><div id="div_2" style="margin:0px;width:'+thw+'px;z-index:53;layer-background-color: #FFFFFF;background-color:#ffffff;padding:3px;">'+imgtitle+'<br>'+(thw>=233?'<nobr>':'')+'&copy; '+'AnuntulWeb.ro'+(thw>=233?'</nobr>':'')+'<br></div></div><div class="h2" style="z-index:53;background-color: #b2a99d; layer-background-color: #b2a99d;width:'+thw+'px; border: 1px none #808080; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+'ID: '+adid+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgtitle+'<br>'+(thw>=233?'<nobr>':'')+'&copy; '+'AnuntulWeb.ro'+(thw>=233?'</nobr>':'')+'<br></div><div class="h2" style="background-color: #b2a99d; layer-background-color: #b2a99d;width:'+thw+'px; border: 1px none #808080; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+'ID: '+adid+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div>';
*/
gettrailobject().innerHTML = '<div style="background-color: #e6ebef; layer-background-color: #e6ebef; border: 1px none #808080; padding:10px; width:'+divthw+'px; position:absolute; z-index:1000;"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px solid #808080;"><img src="'+location+'" border="0" width="'+thw+'" height="'+thh+'"><div style="padding:3px" class="blackcurrentstyle">'+imgtitle+'<br>&copy; '+'anuntulWEB.ro<br></div></div><div class=h2 style="padding:1px;">ID: '+adid+'</div></div>';
		//setTimeOut
	//	xto = setTimeout("xtimeOut('"+thumbimg+"')",100);
		gettrailobj().visibility="visible";
		divw = parseInt(thw)+25;
		divh = parseInt(thh)+130;
		document.onmousemove=followmouse;

}

function Tooltip(title,text){


		var thw=text.length*12;
		var thh=24;
		if(thw>1200)
		{
			thw=Math.ceil(thw/5);
			thh=72;
		}
		else
			if(thw>240)
			{
				thw=Math.ceil(thw/3);
				thh=48;
			}
				
		gettrailobj().left="-500px";
		divthw = parseInt(thw) + 2;
		smthw = parseInt(thw) + 2;
		halfthh = 50;
		halfthh = Math.ceil(parseInt(thh)/2);
		topx = halfthh - 9;
		smthh = parseInt(thh) + 2;
gettrailobject().innerHTML = '<table cellpadding="0" width="'+thw+'" height="'+thh+'" cellspacing="1px" border="0" bgcolor="#99CCFF" ><tr bgcolor="#9B9BFF"><td align="center">'+title+'</td></tr><tr><td align="left">'+text+'</td></tr></table>';
		//setTimeOut
	//	xto = setTimeout("xtimeOut('"+thumbimg+"')",100);
		gettrailobj().visibility="visible";
		divw = parseInt(thw)+25;
		divh = parseInt(thh)+130;
		document.onmousemove=followmouse;

}


function truebody()
	{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

function followmouse(e)
	{
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)
if(typeof e != "undefined")
	{
	if(docwidth < 15+e.pageX+divw)
		xcoord = e.pageX-divw-5;
	else
		xcoord = 15+e.pageX;
	if(docheight < 15+e.pageY+divh)
		ycoord = 15+e.pageY-Math.max(0,(divh + e.pageY - docheight - truebody().scrollTop - 30));
	else
		ycoord = 15+e.pageY;
	}
else if (typeof window.event != "undefined")
	{
	if(docwidth < 15+truebody().scrollLeft+event.clientX+divw)
		xcoord = truebody().scrollLeft-5+event.clientX-divw;
	else
		xcoord = truebody().scrollLeft+15+event.clientX;

	if(docheight < 15+truebody().scrollTop+event.clientY+divh)
		ycoord = 15+truebody().scrollTop+event.clientY-Math.max(0,(divh + event.clientY - docheight - 30));
	else
		ycoord = truebody().scrollTop+15+event.clientY;
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
	}




function agree_terms()
	{

    if (document.newad_form.terms.checked == true)
 	    {

			return true;


    	}else{
    		alert('Daca sunteti de acord cu Termenii si conditiile de utilizare a acestui site, bifati casuta corespunzatoare.');
			return false;

    	}

	}

//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/string/wordwrap [rev. #2]

String.prototype.wordWrap = function(m, b, c){
    var i, j, l, s, r;
    if(m < 1)
        return this;
    for(i = -1, l = (r = this.split("\n")).length; ++i < l; r[i] += s)
        for(s = r[i], r[i] = ""; s.length > m; r[i] += s.slice(0, j) + ((s = s.slice(j)).length ? b : ""))
            j = c == 2 || (j = s.slice(0, m + 1).match(/\S*(\s)?$/))[1] ? m : j.input.length - j[0].length
            || c == 1 && m || j.input.length + (j = s.slice(m).match(/^\S*/)).input.length;
    return r.join("\n");
};

/**
 *
 * @access public
 * @return void
 **/
function windowpage(url,title){
	//name='Tipareste: '+ title + ' | AnuntulWeb.ro';
	//alert(url +" " + title + " width=250,height=250");
	newwindow = window.open(url,"blank","width=700,height=700");
	if (window.focus) {newwindow.focus();}
}
