function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oLeft = o.offsetLeft ;           // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent ;   // Get parent object reference
		oLeft += oParent.offsetLeft; // Add parent left position
		o = oParent;
	}
	// Return left postion
	return oLeft;
}



function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oTop = o.offsetTop       ;     // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent ; // Get parent object reference
		oTop += oParent.offsetTop; // Add parent top position
		o = oParent;
	}
	// Return top position
	return oTop;
}

function set_banner(){
var id = "banner_position";
		var w = screen.width
		var left = getAbsoluteLeft(id);
		var top = getAbsoluteTop(id);
		
		var resp = document.getElementById('banner_new');
		resp.style.top = top+0+'px';
		resp.style.left = left-60+'px';
		
		document.getElementById('banner_new').style.display='';

}

function check_register()
{

	if (document.register.type.value==0) {
		alert("Selectati tipul contului.");
		document.register.type.focus();
		return false;
	}

	if (document.register.email.value=="" || document.register.email.value=="adresa@email") {
		alert("Va rugam adaugati adresa de e-mail pentru a continua.");
		document.register.email.value="";
		document.register.email.focus();
		return false;
	} else {
		ast=document.register.email.value.indexOf("@");
		dot=document.register.email.value.lastIndexOf(".");
		if(!(ast>0 && dot>0 && dot>ast)){
			alert("Va rugam adaugati o adresa de e-mail valida pentru a continua.");
			document.register.email.focus();
			return false;
	}}

	if (document.register.email_again.value!=document.register.email.value) {
		alert("Atentie adresa de email este gresita la rescriere.");
		document.register.email_again.focus();
		return false;
	}
	
	if (document.register.password.value=="") {
		alert("Va rugam adaugati parola pentru a continua.");
		document.register.password.focus();
		return false;
	}

	if (document.register.password_again.value!=document.register.password.value) {
		alert("Atentie parola este gresita la rescriere.");
		document.register.password_again.focus();
		return false;
	}

	if (document.register.code.value=="") {
		alert("Va rugam adaugati codul de siguranta din imaginea de mai sus pentru a continua.");
		document.register.code.focus();
		return false;
	}
	
	
	return true;
}


function focusField(field) {
	field.style.background = '#fdf2c6';
}

function update_register()
{


	if (document.update_security.password.value=="") {
		alert("Va rugam adaugati parola pentru a continua.");
		document.update_security.password.focus();
		return false;
	}

	if (document.update_security.password_again.value!=document.update_security.password.value) {
		alert("Atentie parola este gresita la rescriere.");
		document.update_security.password_again.value="";
		document.update_security.password_again.focus();
		return false;
	}

	return true;
}

function check_active_form()
{
	if (document.active_form.active.value=="") {
		alert("Va rugam adaugati codul de activare a contului, primit in adresa dumneavoastra de email pentru a continua.");
		document.active_form.active.focus();
		return false;
	}
	return true;
}

function check_fpassword_form()
{

	if (document.f_password.fpass_email.value=="" || document.f_password.fpass_email.value=="-") {
		alert("Va rugam adaugati adresa de e-mail pentru a continua.");
		
		document.f_password.fpass_email.focus();
		return false;
	} else {
		ast=document.f_password.fpass_email.value.indexOf("@");
		dot=document.f_password.fpass_email.value.lastIndexOf(".");
		if(!(ast>0 && dot>0 && dot>ast)){
			alert("Va rugam adaugati o adresa de e-mail valida pentru a continua.");
			document.f_password.fpass_email.value="";
			document.f_password.fpass_email.focus();
			return false;
	}}

	return true;
}

function check_topic()
{

	if (document.add_subject.subject.value=="") {
		alert("Va rugam adaugati subiectul pentru a continua.");
		document.add_subject.subject.focus();
		return false;
	}
	if (document.add_subject.text.value=="") {
		alert("Va rugam adaugati textul pentru a continua.");
		document.add_subject.text.focus();
		return false;
	}


	return true;
}

function check_post()
{

	if (document.add_post.name.value=="") {
		alert("Va rugam adaugati numele pentru a continua.");
		document.add_post.name.focus();
		return false;
	}
	if (document.add_post.title.value=="") {
		alert("Va rugam adaugati titlul pentru a continua.");
		document.add_post.title.focus();
		return false;
	}
	if (document.add_post.text.value=="") {
		alert("Va rugam adaugati textul pentru a continua.");
		document.add_post.text.focus();
		return false;
	}


	return true;
}


	function check_form()
	{
	
		if (document.contact_form.name.value=="" || document.contact_form.name.value=="-") {
			alert("Va rugam adaugati numele dumneavoastra pentru a continua.");
			document.contact_form.name.focus();
			return false;
		}
		if (document.contact_form.company.value=="" || document.contact_form.company.value=="-") {
			alert("Va rugam adaugati firma pentru a continua.");
			document.contact_form.company.focus();
			return false;
		}
		if (document.contact_form.email.value=="" || document.contact_form.email.value=="-") {
			alert("Va rugam adaugati email-ul pentru a continua.");
			document.contact_form.email.focus();
			return false;
		}
	
		if (document.contact_form.message.value=="" || document.contact_form.message.value=="-") {
			alert("Va rugam adaugati mesajul dumneavoastra pentru a continua.");
			document.contact_form.message.focus();
			return false;
		}
	
		return true;
	}



		function newsletter_(){
		if (document.newsletter.email.value=="" || document.newsletter.email.value=="adresa@email") {
			alert("Va rugam adaugati adresa de e-mail pentru a continua.");
			document.newsletter.email.value="";
			document.newsletter.email.focus();
			return false;
		} else {
			ast=document.newsletter.email.value.indexOf("@");
			dot=document.newsletter.email.value.lastIndexOf(".");
			if(!(ast>0 && dot>0 && dot>ast)){
				alert("Va rugam adaugati o adresa de e-mail valida pentru a continua.");
				document.newsletter.email.focus();
				return false;
		}}
	}
	
	function clear_newsletter(){
	if (document.newsletter.email.value=="adresa@email") {
		document.newsletter.email.value="";
		document.newsletter.email.focus();
		return false;
	}
	}


	var cp = new cpaint();
	cp.set_response_type('text');
	cp.set_debug(0);



	function response(result) {
		document.getElementById('response').innerHTML = result;
	}

	function check_recomanda(r_link)
	{

		if (document.recomanda.name_exp.value=="" || document.recomanda.name_exp.value=="Nume expeditor") {
			alert("Va rugam adaugati numele dvs pentru a continua.");
			document.recomanda.name_exp.focus();
			return false;
		}
		if (document.recomanda.email_exp.value=="" || document.recomanda.email_exp.value=="E-mail expeditor") {
			alert("Va rugam adaugati e-mailul dvs pentru a continua.");
			document.recomanda.email_exp.focus();
			return false;
		}
		if (document.recomanda.name_dest.value=="" || document.recomanda.name_dest.value=="Nume destinatar") {
			alert("Va rugam adaugati numele destinatarului pentru a continua.");
			document.recomanda.name_dest.focus();
			return false;
		}
		if (document.recomanda.email_dest.value=="" || document.recomanda.email_dest.value=="E-mail destinatar") {
			alert("Va rugam adaugati e-mailul destinatarului pentru a continua.");
			document.recomanda.email_dest.focus();
			return false;
		}

		
		cp.call('cgi.php',"&r_link="+r_link+"&name_exp="+document.recomanda.name_exp.value+"&name_dest="+document.recomanda.name_dest.value+"&email_dest="+document.recomanda.email_dest.value+"&email_exp="+document.recomanda.email_exp.value, response);

		return false;
	}

	function clear_field(field,name)
	{
		if(field.value==name){
			field.value="";
		}
	}


	function check_alert()
	{
		alert("Optiune disponibila doar utilizatorilor inregistrati.");
		document.alert_form.alert_check.disabled = true;
	}


	function key(){
		if (document.search.q.value==""){
			alert("Va rugam adaugati textul cautat.");
			document.search.q.focus();
			return false;
		}
		if(document.search.q.value!="") {
			if(document.search.q.value.length<4) {
			alert("Va rugam introduceti minim 4 caractere pentru cautare");
			document.search.q.focus();
			return false;
		}}
	}


function del_blog(){
	
	if(confirm("Esti sigur ca vrei sa stergi?")) {
			return true;
	}

	return false;
}