/* author: Ovidiu Sopa */

/* Creation date: 30.03.2006 */



function confirmLink(theLink, theSqlQuery)

{

    // Confirmation is not required in the configuration file

    if (confirmMsg == '') {

        return true;

    }



    var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);

    if (is_confirmed) {

        theLink.href += '&is_js_confirmed=1';

    }



    return is_confirmed;

}





function high(id)

{

document.getElementById(id).className='high'}

function low(id)

{

document.getElementById(id).className='low'}



function detshow(elemname,idnum)

{

//alert(elemname+" | "+idnum);

if(document.getElementById){

if(document.getElementById(elemname+""+idnum)){

var elem = document.getElementById(elemname+idnum);



//var hdr = document.getElementById("faqHeader"+idnum)

if(elem == null) { 



return; }

if(elem.style.display == "none")

{

//if(hdr != null){hdr.className="faqHeaderOpen";}

elem.style.display = "";

if(document.getElementById("sagj"+idnum)){document.getElementById("sagj"+idnum).style.display = "none";}

if(document.getElementById("sags"+idnum)){document.getElementById("sags"+idnum).style.display = "";}

}

else

{

elem.style.display = "none";

//if(hdr != null){hdr.className="faqHeaderClosed";}

if(document.getElementById("sagj"+idnum)){document.getElementById("sagj"+idnum).style.display = "";}

if(document.getElementById("sags"+idnum)){document.getElementById("sags"+idnum).style.display = "none";}

}

}

window.event.cancelBubble = true;

return false;

}

}



function form_fail(msg,field)

{

alert(msg);

if(field != 'suprafata-teren' || field != 'accept_termeni')

{

	eval('document.contact.'+field).focus();

}

return false;

}









function textCounter(field, countfield, maxlimit) {

if (field.value.length > maxlimit) // if too long...trim it!

field.value = field.value.substring(0, maxlimit);

// otherwise, update 'characters left' counter

else 

countfield.value = maxlimit - field.value.length;

}



function open_window(link, width, height)

{

     window.open(link,"","toolbar=0,top=0,scrollbars=yes, width="+width+",height="+height+"");

}





function form_verification()

{

	var elnumber = document.forms["contact"].elements.length;

//alert(elnumber);

//	alert("In script");



elNum = document.forms["contact"].elements.length;

//alert("Nr de campuri"+elnum);

for (i=0;i<=elNum-1;i++) {

	if (document.forms["contact"].elements[i].name == 'author' || document.forms["contact"].elements[i].name == 'name' || document.forms["contact"].elements[i].name == 'firstname'){

		if(document.forms["contact"].elements[i].value == '')

		{

			form_fail('You must insert your name !',document.forms["contact"].elements[i].name);

			return false;

		}

	}

// pentru creare cont firma si creare cont persoana fizica

	if (document.forms["contact"].elements[i].name == 'email'){

	//alert("In email");

		if (document.forms["contact"].elements[i].value.indexOf('@', 0) == -1 || document.forms["contact"].elements[i].value.indexOf('.', 0) == -1){ 

			form_fail('Trebuie sa introduceti o adresa de e-mail valida !',document.forms["contact"].elements[i].name);

			return false;

		}

	}

	

	

} // end for

}







function switch_layers(show_this){

	alert(document.getElementById(show_this).className);

	if(document.getElementById(show_this).className = 'ascunde') document.getElementById(show_this).className = 'show';

	else if(document.getElementById(show_this).className = 'show') document.getElementById(show_this).className = 'ascunde';

}



function change_value(element,new_val_field){

	var elem = 'document.calculator.'+element;

	elem = eval(elem);

	

	var new_v = 'document.calculator.'+new_val_field;

	new_v = eval(new_v);

	

	alert(elem+'=0000=-'+new_v);

	

	

	elem.value = new_v.value;

	}