loader = '<div align="center"><br><img src="/media/img/layout/loader.gif"><br></div>';
var ajax;
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;
		}

		ajax =  new Ajax.Updater(
			"div_recomanda",
			"/cgi2.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,
			{method:'get'});

		return false;
}

function check_newsletter()
{
	if (document.newsletter.email_one.value=="") {
		alert("Va rugam adaugati adresa de e-mail pentru a continua.");
		document.newsletter.email_one.focus();
		return false;
	} else {
		ast=document.newsletter.email_one.value.indexOf("@");
		dot=document.newsletter.email_one.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_one.focus();
			return false;
	}}
	
	
	
	
	email = document.newsletter.email_one.value;
	//
	
	ajax =  new Ajax.Updater(
         "add_newsletter",
         "/phpBIN/ajax.newsletter.php?email="+email,
         { method:'get'});	
	
	//document.getElementById("newsletter_field2").innerHTML = '';
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




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 view_promo(type,plus_left,plus_right)
{

		var left = getAbsoluteLeft(type);		
		var top = getAbsoluteTop(type);
		var resp = document.getElementById('response');
		resp.style.top = top+plus_left+'px';
		resp.style.left = left-plus_right+'px';
		
		document.getElementById('response').style.display='';
	
		ajax =  new Ajax.Updater(
	         "response",
	         "/phpBIN/ajax.promo.php?type="+type,
	         { method:'get'});
		 
}

function close_promo()
{
	//document.getElementById('response').style.display='none';
	new Effect.Fade('response');
}

function add_education(label,id)
{
		
	
	document.getElementById("education").innerHTML = loader;	
	
	ajax =  new Ajax.Updater(
         "education",
         "/phpBIN/ajax.education.php?label="+label+"&id="+id,
         { method:'get'});
}

function upd_education(label,id,item,ed_label,ed_status,ed_city,ed_city2,ed_start,ed_end,ed_label2,ed_location,ed_description)
{
	
	
	document.getElementById("education").innerHTML = loader;	
	
	ajax =  new Ajax.Updater(
         "education",
         "/phpBIN/ajax.education.php?label="+label+"&id="+id+"&item="+item+"&ed_label="+ed_label+"&ed_status="+ed_status+"&ed_city="+ed_city+"&ed_city2="+ed_city2+"&ed_start="+ed_start+"&ed_end="+ed_end+"&ed_label2="+ed_label2+"&ed_location="+ed_location+"&ed_description="+ed_description+"&ed_description="+ed_description,
         { method:'get'});
}

function add_edu()
{
		
	cat_id = document.update_education.cat_id.value;
	ed_label = document.update_education.ed_label.value;
	ed_status = document.update_education.ed_status.value;
	ed_city = document.update_education.ed_city.value;
	ed_city2 = document.update_education.ed_city2.value;
	ed_start = document.update_education.ed_start.value;
	ed_end = document.update_education.ed_end.value;
	
	ed_label2 = document.update_education.ed_label2.value;
	ed_location = document.update_education.ed_location.value;
	ed_description = document.update_education.ed_description.value;

	d_s = document.update_education.d_s.value;
	m_s = document.update_education.m_s.value;
	y_s = document.update_education.y_s.value;
	
	d_e = document.update_education.d_e.value;
	m_e = document.update_education.m_e.value;
	y_e = document.update_education.y_e.value;

	if (cat_id==" " || ed_label==" " || ed_status=="0" || ed_city=="0" || ed_city2==" " || ed_start=="0" || ed_end=="0" || ed_label2==" " || ed_location==" " || d_s=="0" || m_s=="0" || y_s=="0" || d_e=="0" || m_e=="0" || y_e=="0"){
			alert("Va rugam completati toate campurile pentru a continua.");			
			
			return false;
	} else {
	
	document.getElementById("cat_edu").innerHTML = loader;	
	ajax =  new Ajax.Updater(
         "cat_edu",
         "/phpBIN/ajax.cat_edu.php?cat_id="+cat_id+"&ed_label="+ed_label+"&ed_status="+ed_status+"&ed_city="+ed_city+"&ed_city2="+ed_city2+"&ed_start="+ed_start+"&ed_end="+ed_end+"&ed_label2="+ed_label2+"&ed_location="+ed_location+"&ed_description="+ed_description+"&d_s="+d_s+"&m_s="+m_s+"&y_s="+y_s+"&d_e="+d_e+"&m_e="+m_e+"&y_e="+y_e,
         { method:'get'});
		 
	document.getElementById("education").innerHTML = '<div align="center" class="borderBottom"><br><h3>A fost adaugat!</h3><br></div>';	
	
	}
}

function upd_edu()
{
	
	document.getElementById("cat_edu").innerHTML = loader;	
	cat_id = document.update_education.cat_id.value;
	ed_label = document.update_education.ed_label.value;
	ed_status = document.update_education.ed_status.value;
	ed_city = document.update_education.ed_city.value;
	ed_city2 = document.update_education.ed_city2.value;
	ed_start = document.update_education.ed_start.value;
	ed_end = document.update_education.ed_end.value;
	item = document.update_education.item.value;
	
	
	ed_label2 = document.update_education.ed_label2.value;
	ed_location = document.update_education.ed_location.value;
	ed_description = document.update_education.ed_description.value;
	
	d_s = document.update_education.d_s.value;
	m_s = document.update_education.m_s.value;
	y_s = document.update_education.y_s.value;
	
	d_e = document.update_education.d_e.value;
	m_e = document.update_education.m_e.value;
	y_e = document.update_education.y_e.value;
	
	
	ajax =  new Ajax.Updater(
         "cat_edu",
         "/phpBIN/ajax.cat_edu.php?cat_id="+cat_id+"&ed_label="+ed_label+"&ed_status="+ed_status+"&ed_city="+ed_city+"&ed_city2="+ed_city2+"&ed_start="+ed_start+"&ed_end="+ed_end+"&item="+item+"&ed_label2="+ed_label2+"&ed_location="+ed_location+"&ed_description="+ed_description+"&d_s="+d_s+"&m_s="+m_s+"&y_s="+y_s+"&d_e="+d_e+"&m_e="+m_e+"&y_e="+y_e,
         { method:'get'});
		 
	document.getElementById("education").innerHTML = '<div align="center" class="borderBottom"><br><h3>A fost actualizat!</h3><br></div>';	
}

function delete_edu(id)
{
	if(confirm("Esti sigur ca vrei sa stergi?")){
		ajax =  new Ajax.Updater(
	         "cat_edu",
	         "/phpBIN/ajax.cat_edu.php?delete="+id,
	         { method:'get'});
	}
}

function close_w(id){
	document.getElementById(id).innerHTML = '';	
}

function test()
{
	alert("xxx");
}
function control_tara(type) {
	if(type==1){
		document.getElementById('tara').style.display='';
	} else {
		document.getElementById('tara').style.display='none';
		document.update_education.ed_location.value='';
	}
}
function work_data()
{
	if(document.expprof.prezent.checked==true){
		document.expprof.d_e.disabled=true;
		document.expprof.m_e.disabled=true;
		document.expprof.y_e.disabled=true;
	} else {
		document.expprof.d_e.disabled=false;
		document.expprof.m_e.disabled=false;
		document.expprof.y_e.disabled=false;
	}
}

function delete_ep(id)
{
	if(confirm("Esti sigur ca vrei sa stergi?")){		
		ajax =  new Ajax.Updater(
	         "ep",
	         "/phpBIN/ajax.view_ep.php?delete="+id,
	         { method:'get'});
	}
}

function OnOver(TheId) {
	document.getElementById(TheId).style.background='#f4f4f4';
}

function OnOut(TheId) {
	
	document.getElementById(TheId).style.background='#FFFFFF';
}

function lightup2(TheId){
	document.getElementById(TheId).className='bg_jobs_over';	
}

function lightup(TheId){
	document.getElementById(TheId).className='bg_jobs';	
}
function alert_job()
{
	if(confirm("Daca doriti sa aplicati la acest job trebuie sa fiti inregistrat.")){
		location.href='/myspace';
	}
}

function key(){
		if (document.search.q.value=="" || document.search.q.value=="cuvinte cheie"){
			alert("Va rugam adaugati textul cautat.");
			document.search.q.value="";
			document.search.q.focus();
			return false;
		}
		if(document.search.q.value!="") {
			if(document.search.q.value.length<3) {
			alert("Va rugam introduceti minim 3 caractere pentru cautare");
			document.search.q.focus();
			return false;
		}}
}

function check_l_munca()
{
		if (document.l_munca.lm_exp.value=="0"){
			alert("Va rugam selectati raspunsul pentru Experienta pentru a continua.");			
			document.l_munca.lm_exp.focus();
			return false;
		}
		
		if (document.l_munca.lm_post.value=="0"){
			alert("Va rugam adaugati postul urmarit pentru a continua.");			
			document.l_munca.lm_post.focus();
			return false;
		}

		if (document.l_munca.lm_money.value=="0"){
			alert("Va rugam selectati salariul pentru a continua.");			
			document.l_munca.lm_money.focus();
			return false;
		}		

}

function check_apti()
{
		
		if (document.apti.ap_opc.value=="0"){
			alert("Va rugam selectati raspunsul pentru Operare PC pentru a continua.");			
			document.apti.ap_opc.focus();
			return false;
		}	
		
		if (document.apti.ap_apti.value=="" || document.apti.ap_apti.value==" "){
			alert("Va rugam adaugati aptitudini pentru a continua.");			
			document.apti.ap_apti.focus();
			return false;
		}	
}

function check_expprof()
{
		
		if (document.expprof.ep_label.value=="" || document.expprof.ep_label.value==" "){
			alert("Va rugam adaugati postul pentru a continua.");			
			document.expprof.ep_label.focus();
			return false;
		}

		if (document.expprof.ep_firm.value=="" || document.expprof.ep_firm.value==" "){
			alert("Va rugam adaugati firma pentru a continua.");			
			document.expprof.ep_firm.focus();
			return false;
		}

		if (document.expprof.ep_domain.value=="0"){
			alert("Va rugam adaugati domeniul de activitate pentru a continua.");			
			document.expprof.ep_domain.focus();
			return false;
		}		
		
		if (document.expprof.d_s.value=="0" || document.expprof.m_s.value=="0" || document.expprof.y_s.value=="0"){
			alert("Va rugam selectati data inceput pentru a continua.");			
			document.expprof.d_s.focus();
			return false;
		}
		
		if (document.expprof.prezent.checked==false){
			if (document.expprof.d_e.value=="0" || document.expprof.m_e.value=="0" || document.expprof.y_e.value=="0"){
				alert("Va rugam selectati data finalizare pentru a continua.");			
				document.expprof.d_e.focus();
				return false;
			}
		}
		
		
}		

function chck_profile()
{
		if (document.profile.name.value=="" || document.profile.name.value==" "){
			alert("Va rugam adaugati numele pentru a continua.");			
			document.profile.name.focus();
			return false;
		}
		
		if (document.profile.password.value=="" || document.profile.password.value==" "){
			alert("Va rugam adaugati parola pentru a continua.");			
			document.profile.password.focus();
			return false;
		}
		
		if (document.profile.password_again.value=="" || document.profile.password_again.value==" "){
			alert("Va rugam adaugati rescrieti parola pentru a continua.");			
			document.profile.password_again.focus();
			return false;
		}
	
	if (document.profile.password.value!="" && document.profile.password_again.value!=""){
		if (document.profile.password.value!=document.profile.password_again.value){
			alert("Atentie! La rescriere parola nu se potriveste!");			
			document.profile.password.focus();
			return false;
		}
	}
		
}

function check_personal()
{
		if (document.personal.fname.value=="" || document.personal.fname.value==" "){
			alert("Va rugam adaugati numele pentru a continua.");			
			document.personal.fname.focus();
			return false;
		}
		
		if (document.personal.lname.value=="" || document.personal.lname.value==" "){
			alert("Va rugam adaugati prenumele pentru a continua.");			
			document.personal.lname.focus();
			return false;
		}

		if (document.personal.email.value=="" || document.personal.email.value==" "){
			alert("Va rugam adaugati adresa de email pentru a continua.");			
			document.personal.email.focus();
			return false;
		}		
		
		if (document.personal.addr.value=="" || document.personal.addr.value==" "){
			alert("Va rugam adaugati adresa pentru a continua.");			
			document.personal.addr.focus();
			return false;
		}

		if (document.personal.city.value=="0"){
			alert("Va rugam selectati orasul pentru a continua.");			
			document.personal.city.focus();
			return false;
		}
		
		if (document.personal.city2.value=="0"){
			alert("Va rugam selectati judetul pentru a continua.");			
			document.personal.city2.focus();
			return false;
		}
		
		if (document.personal.phone.value=="" || document.personal.phone.value==" "){
			alert("Va rugam adaugati telefonul pentru a continua.");			
			document.personal.phone.focus();
			return false;
		}	

		if (document.personal.d.value=="0" || document.personal.m.value=="0" || document.personal.y.value=="0"){
			alert("Va rugam selectati data de nastere pentru a continua.");			
			document.personal.d.focus();
			return false;
		}
		
		if (document.personal.sex.value=="0"){
			alert("Va rugam selectati sex pentru a continua.");			
			document.personal.sex.focus();
			return false;
		}
		
		if (document.personal.stat.value=="0"){
			alert("Va rugam selectati starea civila pentru a continua.");			
			document.personal.stat.focus();
			return false;
		}		
		
}

function clear_field(field,name)
{
		if(field.value==name){
			field.value="";
		}
}

function check_fpassword_form()
{
	if (document.f_password.fpass_email.value=="" || document.f_password.fpass_email.value=="adresa@email") {
		alert("Va rugam adaugati adresa de email pentru a continua.");
		document.f_password.fpass_email.focus();
		return false;
	}
}

function check_register(thisform)
{
	if (document.register.name.value=="") {
		alert("Va rugam adaugati Numele pentru a continua.");
		document.register.name.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;
	}
/*	
	if (document.register.conditii.checked==false) {
		alert("Pentru a continua trebuie sa fiti de acord cu regulamentul.");
		document.register.conditii.focus();
		return false;
	}
*/
	return true;
}

function viewcv(){
	var we=640
	var hi=600
	var top=100
	var left=100

	var features = "width="+we+", height="+hi+", top="+top+", left="+left+", scrollbars=yes";
	w=window.open('/viewcv/',"details",features);
	w.focus();
}

function check_login()
{	
	if (document.login.email.value=="" || document.login.email.value=="adresa@email") {
		alert("Va rugam adaugati adresa de email pentru a continua.");
		document.login.email.focus();
		return false;
	}
	
	if (document.login.password.value=="") {
		alert("Va rugam adaugati parola pentru a continua.");
		document.login.password.focus();
		return false;
	}
	return true;
}

function lightup3(obj){
	obj.className=(obj.className=='vote_color'?'vote_color_hover':'vote_color')
} 