var show_img = "http://img.bestjobs.ro/common/header/show.gif";
var hide_img = "http://img.bestjobs.ro/common/header/hide.gif";
function swapImg() {
	document.getElementById("show_hide_img").src = (document.getElementById("show_hide_img").src == show_img) ? hide_img : show_img;
}
function showHide(defX) {
	// Show or hide floating div
	if ($('#lang_selector_2').is(':hidden'))
	{
		var pos1 = $('#lang_selector_1').position();
		var pos2 = $('#lang_selector_2').position();
		if (pos2.left < pos1.left) { $('#lang_selector_2').css({ 'left' : pos1.left + 'px'}); }
		if (pos2.top < 0) { $('#lang_selector_2').css({ 'top' : $('#above-logo').height() + 'px'}); }
		$('#lang_selector_2').slideDown();
	}
	else
	{
		$('#lang_selector_2').slideUp();
	}
}
function changeLocation(un_lang, loc, nurl) {
	window.location = loc + un_lang + '/nextUrl/' + nurl;
}
function getPos(theObj) {
	x = y = 0;
	h = theObj.offsetHeight;
	w = theObj.offsetWidth;
	while(theObj) {
		x += theObj.offsetLeft;
		y += theObj.offsetTop;
		theObj = theObj.offsetParent;
	}
	return {x:x, y:y, height:h, width:w}
}
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x) curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y) curtop += obj.y;
	return curtop;
}
var Request = new Object();

Request.send = function(url, method, callback, data) {
	var req;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
			return;
	}
	req.onreadystatechange = function() {
		if (req.readyState == 4) {// only if req shows "loaded"
			if (req.status < 400) {// only if "OK"
				(method=="POST") ? callback(req) : callback(req,data);
			} else {
				//alert("There was a problem saving your changes :\n" + req.status+ "/" + req.statusText);
			}
		}
	}
	if (method=="POST") {
		req.open("POST", url, true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send(data);
	} else {
		req.open("GET", url, true);
		req.send(null);
	}
	return req;
}

Request.sendGET = function(url, callback, args) {
	return Request.send(url, "GET", callback, args);
}
Request.sendPOST = function(url, data, callback) {
	Request.send(url, "POST", callback, data);
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function check_mail(em)
{
	var ok=true;
	if (em.length==0){ok=false;};
	if ( (em != "") && ((em.indexOf('@', 0) == -1) || (em.indexOf('.', 0) == -1) || (em.lastIndexOf('@') == em.length-1) ||(em.lastIndexOf('.') == em.length-1) ||(em.indexOf('@', 0) != em.lastIndexOf('@'))) ) {ok=false};

	return ok;
}
function php_urldecode( txt ) {
    var stuff = {};
    var ret = txt.toString();

    var replacement = function(search, replace, txt) {
        var tmp_arr = [];
        tmp_arr = txt.split(search);
        return tmp_arr.join(replace);
    };

    stuff["'"]   = '%27';
    stuff['(']   = '%28';
    stuff[')']   = '%29';
    stuff['*']   = '%2A';
    stuff['~']   = '%7E';
    stuff['!']   = '%21';
    stuff['%20'] = '+';
    for (replace in stuff) {
        search = stuff[replace];
        ret = replacement(search, replace, ret);
    }
    ret = decodeURIComponent(ret);
    return ret;
}
function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie (name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf ("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf (prefix);
		if (begin != 0) return null;
	} else begin += 2;
	var end = document.cookie.indexOf (";", begin);
	if (end == -1)
	end = dc.length;
	return unescape (dc.substring (begin + prefix.length, end));
}
function open_window(theURL,width,height)
{
	var options = 'toolbar=0,status=0,menubar=0,scrollbars=1,' + 'resizable=0,width='+width+',height='+height
	window.open(theURL,'', options);
}
function close_select_orase() {
    // inchide fereastra
    var sdiv = document.getElementById("select_orase");
    sdiv.style.display="none";
    document.body.removeChild(sdiv);
    // inchide si iframe-ul
    var sdiv0 = document.getElementById("whiteframe");
    if (sdiv0) {
        sdiv0.style.display="none";
        document.body.removeChild(sdiv0);
    }
}

var subm = [];
function toggleMenuItem (item, className, itemnr, displ)
{
	var submenu = document.getElementById ('ddMenu'+itemnr);

	item.className = className;
	submenu.style.display = displ ? 'block' : 'none';

	if (!subm[itemnr])
	{
		var submenuCont = document.getElementById ('ddMenuCont'+itemnr);
		var submenuRight = document.getElementById ('ddMenuRight'+itemnr);
		var submenuFooter = document.getElementById ('ddMenuFooter'+itemnr);
		var hiddenframe = document.getElementById ('hidden_frame'+itemnr);

		subm[itemnr] = 1;
		submenuRight.style.height = submenu.offsetHeight - 14;
		if (submenu.offsetWidth < submenuCont.offsetWidth + 7) submenu.style.width = submenuCont.offsetWidth + 7;
		submenuFooter.style.width = submenu.offsetWidth - 14;
		if (hiddenframe)
		{
			hiddenframe.style.height = submenu.offsetHeight - 1;
			hiddenframe.style.width = submenu.offsetWidth;
		}
	}
}

function ifr_add (ifr_src, obj) {
	var urlstat_ifr = document.createElement ("iframe");
	urlstat_ifr.style.width = "0px";
	urlstat_ifr.style.height = "0px";
	urlstat_ifr.style.margin = "0px";
	urlstat_ifr.style.display = "none";
	urlstat_ifr.src = ifr_src;
	obj.parentNode.appendChild (urlstat_ifr);
	return;
}

function trackThis (idurl, obj) {
	if (arguments[2]) {//poate sa fie un al treilea parametru,care restrictioneaza trackerul pentru o singura tara
		if (parseInt (arguments[2])==parseInt (7)) {
			ifr_add ("http://url.neogen.md/index/increment/"+idurl+"/"+escape(uip)+"/"+escape(urf),obj);
		}
	} else {
		ifr_add ("http://url.neogen.md/index/increment/"+idurl+"/"+escape(uip)+"/"+escape(urf),obj);
	}
}
document.getElementsByClassName = function(className) {
    var children = document.getElementsByTagName('*') || document.all;
    var elements = new Array();

    for (var i = 0; i < children.length; i++) {
        var child = children[i];
        var classNames = child.className.split(' ');
        for (var j = 0; j < classNames.length; j++) {
            if (classNames[j] == className) {
                elements.push(child);
                break;
            }
        }
    }
    return elements;
}
function saveVisitedDomCity (sw, id)
{
	if (id == 0 || id  == '') return;

	if (sw == 0)
		var cookieName = 'bjVisDom';
	else
		var cookieName = 'bjVisCity';

	var date = new Date ();
	date.setFullYear (date.getFullYear () + 1);

	var curCookie = getCookie(cookieName);
	if (curCookie == null)
	{
		setCookie (cookieName, id, date);
	}
	else
	{
		var ids = curCookie.split ('|');
		var newIds = new Array ();
		newIds.push (id);
		for (var i in ids) if (ids[i] != id) newIds.push (ids[i])
		if (newIds.length > 5) newIds.length = 5;
		setCookie (cookieName, newIds.join ('|'), date);
	}
}


function savePollResult(obj) {

	var pollelements = document.getElementsByClassName('pollelements');
	var params = '';
	var idpoll = document.getElementById('idpoll').value;

	for(var i=0;i < pollelements.length;i++)
	{
		if (pollelements[i].checked)
		{
			if (pollelements[i].type == 'radio') params = 'idanswer=' + pollelements[i].value;
			else
			if (pollelements[i].type == 'checkbox') params+= 'idanswer[]=' + pollelements[i].value + '&';
		}
	}

	if (params)
	{
		destUrl = 'http://www.bestjobs.md/common/poll/savepoll/idpoll/' + idpoll;
		Request.sendPOST(destUrl, params, savePollResponse);
		obj.parentNode.innerHTML=" Salvare... ";
	}

	return false;
}

function savePollResponse(response)
{
	var rp=response.responseText.split("||");

	if(rp[0]>0)
	{
		var obj=document.getElementById("poll_"+rp[0]);
		obj.innerHTML = rp[1];
	}
	return;
}

function toggleDaySelect (state)
{
	document.getElementById ('ziuaalertei').disabled = state;
}

function addEmail() /* bestjobs invite */
{
	var e4 = document.getElementById('email4');
	var e5 = document.getElementById('email5');
	var e6 = document.getElementById('email6');
	if (e4.style.display == "none") e4.style.display = "inline";
	else if (e5.style.display == "none") e5.style.display = "inline";
	else if (e6.style.display == "none") e6.style.display = "inline";
}

function showHideMore(obj)
{
	var stat=obj.getAttribute("status");
	var display_to_set=(stat=="0") ? "block" : "none";
	var status_to_set=(stat=="0") ? "1" : "0";

	obj.parentNode.nextSibling.style.display=display_to_set;
	obj.setAttribute("status",status_to_set);
}
function closeMore(obj)
{
	obj.parentNode.parentNode.style.display="none";
}
/* new left menu - mybestjobs */
var defValue = "Cuvant cheie";
function clearValue(obj)
{
	obj.value = '';
}
function updateValue(obj)
{
	if(obj.value == '') obj.value = defValue;
}
function checkValue()
{
	var kObj = document.getElementById("c_keywords");
	if (kObj.value == defValue) kObj.value = '';
}

function showHideVote(obj,act) {
	var tmp=obj.id.split("_");
	var vtdiv=document.getElementById("vt_"+tmp[1]);
	var imgdiv=document.getElementById("imgcont_"+tmp[1]);

	if(act=='show') {
		imgdiv.style.opacity=0.5;
		imgdiv.style.filter='alpha(50)';

		vtdiv.firstChild.style.visibility='visible';
		vtdiv.lastChild.style.visibility='visible';
		vtdiv.style.backgroundColor='#F4F4F4';
	}
	else {
		imgdiv.style.opacity=1;
		imgdiv.style.filter='alpha(100)';

		vtdiv.firstChild.style.visibility='hidden';
		vtdiv.lastChild.style.visibility='hidden';
		vtdiv.style.backgroundColor='#FFFFFF';
	}
}
function votePrefCmp(idcmp,idcluster) {
	var actUrl="http://www.bestjobs.md/index/_setpreferred";
	var data="idcmp="+idcmp+"&idcluster="+idcluster;

	Request.sendPOST(actUrl,data,afterVote)
}
function countVotes() {
	var vtimg=document.getElementById("selected_logos").childNodes;
	var cnt=0;
	for(var i=0;i < vtimg.length; i++) {
		if(vtimg[i].getAttribute("stat")=="1") cnt++;
	}
	return cnt;
}
function replaceVoteImg(idcmp,nrvotes) {
	var obj=document.getElementById("imgcont_"+idcmp);
	var vtimg=document.getElementById("vtimg_"+idcmp);
	var blnks=document.getElementById("selected_logos");
	var imgSrc=obj.firstChild.src;
	var clen=blnks.childNodes.length;
	var cmpdivs=document.getElementById("cmpdivs").childNodes;

	var cntVotes=countVotes();

	for(var i=0;i < clen; i++) {
		var stat=blnks.childNodes[i].getAttribute("stat");
		if(stat!="1") {

			blnks.childNodes[i].setAttribute("stat","1");
			blnks.childNodes[i].firstChild.firstChild.src=imgSrc;
			blnks.childNodes[i].lastChild.innerHTML='<a name="show-gala-invite" href="#">&nbsp;&raquo;</a>';
			blnks.childNodes[i].lastChild.setAttribute("cmpid", idcmp);
			$('#gala-invite-content').hide();
			$('a[name=show-gala-invite]').click(function(e) {
					e.preventDefault();
					$('#gala-sent-ok').hide();
					$('#gala-sent-fail').hide();
					$('#gala-invite-content').slideDown('normal');
					var cmpId = $(this).parent().attr("cmpid");
					$('input[name=cmpid]').val(cmpId);
					$('#cmp-name').text(arrCompanies[cmpId]);
					$('textarea[name=emails]').val('');
				});

			vtimg.src="http://img.bestjobs.ro/common/bestjobs/checked.gif";
			vtimg.style.marginTop="3px";
			vtimg.onclick=function () {};

			if(cntVotes==2) {
				document.getElementById("thankyoudiv").style.display="block";
				for(var j=0;j< cmpdivs.length;j++) {
					var tmmp=cmpdivs[j].id.split("_");
					document.getElementById("vt_"+tmmp[1]).lastChild.innerHTML="";
				}
			}

			return false;
			break;
		}
	}

}
function afterVote(response) {
	var rt=response.responseText;
	if(rt=='0') {//saving failed
		alert('');
	}
	else {
		var tmp=rt.split("|");
		replaceVoteImg(tmp[0],tmp[1]);
	}
}
$(document).ready(function() {

	$('a[name=login]').click(function(e) {

		e.preventDefault();

		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		var winW = $(window).width();

		dv = document.createElement("div");
		dv.id = "loginDiv";

var content = "<form name='loginPopup' id='loginPopup' method='post' action='http://www.bestjobs.md/myaccount/ajaxlogin' onsubmit='return(doLogin());'>";
content += "<input type='hidden' name='nextUrl' value='"+$(this).attr('href')+"'>";
content += "<table width='100%' border=0 cellpadding=7 cellspacing=7><tr><td align='right' colspan=2>";
content += "<a href='http://www.bestjobs.md/registration/jobs'>Inregistreaza-te</td></tr>";
content += "<tr><td style='padding-bottom:5px;'><b>Email:</b></font></td>";
content += "<td align='right' style='padding-bottom:5px;'><input class='loginbox_input' type='text' name='pemail' id='pemail'></td>";
content += "</tr><tr>";
content += "<td style='padding-bottom:10px;'><b>Parola:</b></font></td>";
content += "<td align='right' style='padding-bottom:10px;'><input class='loginbox_input' type='password' name='ppassword' id='ppassword'></td></tr>";
content += "<tr><td colspan=2><table width='100%' cellpadding=0 cellspacing=0><tr><td><input type='checkbox' name='premember' id='premember' value='1'>";
content += "&nbsp;<span class='lr_font_13' style='width:80px;'>Pastreaza-ma logat</span>";
content += "</td><td align='right'><input type='image' src='http://img.bestjobs.ro/languages/rm/gmodules/login_reg/signin.gif'>";
content += "</td></tr></table></td></tr></table></form>";

		dv.innerHTML = content;

		$('#login_body').empty();

		$('#login_body').append(dv);

		$('#loginbox').css('left', winW/2-$('#loginbox').width()/2);

		$('#loginbox').fadeIn(1000);
	});

	$('a[name=close_login]').click(function(e) {
		e.preventDefault();
		$('.window').hide();
	});

	$('#gala-invite-content').hide();
	$('#gala-sent-ok').hide();
	$('#gala-sent-fail').hide();
	$('a[name=show-gala-invite]').click(function(e) {
		e.preventDefault();
		$('#gala-sent-ok').hide();
		$('#gala-sent-fail').hide();
		$('#gala-invite-content').slideDown('normal');
		var cmpId = $(this).parent().attr("cmpid");
		$('input[name=cmpid]').val(cmpId);
		$('#cmp-name').text(arrCompanies[cmpId]);
		$('textarea[name=emails]').val('');
	});
	$('#do-invite').click(function (e) {
		var cmpId = $('input[name=cmpid]').val(cmpId);
		var emails = $('textarea[name=emails]').val();
		var actUrl="http://www.bestjobs.md/index/_invitetogala";
		var data="idcmp="+cmpId+"&emails="+emails;
		Request.sendPOST(actUrl, data, afterInviteGala);
	});
	/* new suggestions */
	$('#openSuggestions').click(function (e) {
		e.preventDefault();
		var crypt = $(this).attr('rel');
		if ($(this).attr('name') == 'user')
		{
			var isUser = 1;
			var sText = "Ne intereseaza ce crezi despre BestJobs! Ai o sugestie despre cum am putea imbunatati serviciile? Ne-ar placea sa o auzim. Scrie-ne folosind formularul de mai jos.";
			var sTitle = "Adauga sugestia ta:";
			var sButton = "Trimite mesajul!";
		}
		else
		{
			var isUser = 0;
			var sText = "La BestJobs, intelegem importanta parerilor dvs.,  clientii nostri. Pentru o continua dezvoltare a serviciilor noastre, pentru a va  oferi cele mai performante solutii de recrutare, va rugam sa ne trimiteti feedback-ul dvs. ";			
			var sTitle = "Adaugati sugestia dvs.";
			var sButton = "Trimiteti-ne mesajul dvs.!";
			
		}
		if ($('#suggestions').is(':visible'))
		{
			$('#suggestions').slideUp('slow').remove();
			$('#whiteframe').remove();
		}
		else
		{
			var siteUrl = "http://www.bestjobs.md/";
			var content;
			content = "<form name='sugest_form' id='sugest_form' method='post' action='" + siteUrl +  "common/wtd/savesuggest/isuser/" + isUser + "/crypt/" + crypt + "'  onsubmit='return(saveSuggestions());'>";
				content += "<table width='100%'>";
					content += "<tr><td class='save_search_close' style='text-align:right;'>";
						content += "<a href=# onclick='closeSuggestions()'><img src='http://img.bestjobs.ro/common/bestjobs/xx.gif' border=0></a>";
					content += "</td></tr>";
					content += "<tr><td class='save_search_content' align='center'>";
						content +="<table>";
							content +="<tr><td style='color:#666666;text-align:left; font-size:13px'>" + sText + "</td></tr>";
							content +="<tr><td style='color:#666666;font-size:14px;padding-top:5px;text-align:left'><b>" + sTitle + "</b></td></tr>";
							content +="<tr><td><textarea name='txt' id='txt' style='width: 330px; height: 100px; border: 1px solid #3d4575; overflow:auto;'></textarea></td></tr>";
							content +="<tr><td><br></td></tr>";
						content += "<tr><td id='save_button' align='center' valign='middle'><input type='button' value ='" + sButton + "' onclick='saveSuggestions();'></td></tr></table>";
					content +="</td></tr>";
				content +="</table>";
			content	+="</form>";

			// suggestion form size
			var sHeight = 300;
			var sWidth = 350;			

			left = $(window).width() - sWidth - 12; /* 10px padding + 2 px border */
			top = $(window).height() - $('#scontainer').height() - sHeight - 2 + $(window).scrollTop();

			// fixes
			if ($.browser.opera == true)			{
				var top = screen.height - 500;
				$('html, body').animate({scrollTop:0}, 'quick');
			}

			var dv = document.createElement("div");
				dv.id="suggestions";
				dv.style.position="absolute";
				dv.style.display="none";
				dv.style.paddingLeft="5px";
				dv.style.paddingRight="5px";
				dv.style.paddingTop="0px";
				dv.style.paddingBottom="1px";
				dv.style.left=left+"px";
				dv.style.top=top+"px";
				dv.style.borderStyle="solid";
				dv.style.borderWidth="1px";
				dv.style.borderColor="#3d4575";
				dv.style.width=sWidth + "px";
				dv.style.height=sHeight + "px";
				dv.style.backgroundColor="#FFFFFF";
				dv.style.zIndex=+1;

			var down_layer = document.createElement("iframe");
				down_layer.id = "whiteframe";
				down_layer.style.position="absolute";
				down_layer.style.left=left+"px";
				down_layer.style.top=top+"px";
				down_layer.style.backgroundColor="transparent";
				down_layer.style.width=(sWidth+10+2)+"px";
				down_layer.style.borderWidth=0;

			$(dv).html(content);
			document.body.appendChild(dv);
			document.body.appendChild(down_layer);
			$('#suggestions').slideDown('slow');
			down_layer.style.height = dv.offsetHeight;
		}
	});
});
function doLogin()
{
	var loginForm = document.getElementById('loginPopup');
	var formAction = loginForm.action;
	if(loginForm.premember.checked) var rm = '&remember_me=1'; else var rm = '';
	var postVars = "&email="+loginForm.pemail.value+"&password="+loginForm.ppassword.value+rm+"&nextUrl="+loginForm.nextUrl.value;
	Request.sendPOST(formAction, postVars, afterLogin);
	return false;
}
function afterLogin(response)
{
	var respText = response.responseText;
	if(respText == 'false')	{
		var errorDiv = document.getElementById('loginbox_error_msg');
		errorDiv.style.padding = '5px';
		errorDiv.innerHTML = "Atentie: ai gresit nume utilizator/emailul sau parola.";
	}
	else if(respText.search(/captcha/i) > 0) {
		alert('miert jon ide? '+respText.search(/captcha/i));
		var arr = respText.split("|");
		window.location = 'http://www.bestjobs.md/account/signin/url/'+arr[0];
	}
	else {
		trackThis(650,document.getElementById('closeLink'));
		window.location = respText;
	}
}
function afterInviteGala(response)
{
	$('#gala-invite-content').hide();
	if(response.responseText==1) {
		$('#gala-sent-ok').css({'color' : 'green'});
		$('#gala-sent-ok').slideDown('fast');
	}
	else {
		$('#gala-sent-fail').css({'color' : '#FF0000'});
		$('#gala-sent-fail').slideDown('fast');
	}
}
function showHideAllPt(obj) {
	var box1=document.getElementById('ptbox1');
	var box2=document.getElementById('ptbox2');
	var box3=document.getElementById('ptbox3');
	var stat=obj.getAttribute("rel");

	var cln=(stat=="0") ? "block" : "none";
	var maxlimit=(cln=="none") ? 7 : 0;

	if(box1) {
		var cnt=0;
		for(var i=0;i< box1.childNodes.length;i++) {
			if(box1.childNodes[i].nodeType==1) {
				if(cnt>=maxlimit) box1.childNodes[i].style.display=cln;
				cnt++;
			}
		}
	}
	if(box2) {
		var cnt1=0;
		for(var j=0;j< box2.childNodes.length;j++) {
			if(box2.childNodes[j].nodeType==1)  {
				if(cnt1>=maxlimit) box2.childNodes[j].style.display=cln;
				cnt1++;
			}
		}
	}
	if(box3) {
		var cnt=0;
		for(var i=0;i< box3.childNodes.length;i++) {
			if(box3.childNodes[i].nodeType==1) {
				if(cnt>=maxlimit) box3.childNodes[i].style.display=cln;
				cnt++;
			}
		}
	}
	obj.innerHTML=(stat=="0") ? "Ascunde &raquo;" : "Vezi toate &raquo;";
	obj.setAttribute("rel",(stat=="0" ? 1 : 0))
}

function glueLast(dvs) {
	var tl=0;
	for(var i=0;i< dvs.length;i++) {
		if(dvs[i].id!="b2_lasttab") tl+=dvs[i].offsetWidth;
	}
	document.getElementById('b2_lasttab').style.width=parseInt($('#b2_catmenus').width()-tl)+"px";
}
function chaTab(obj,nr) {
	var nds=document.getElementById('b2_catmenus').childNodes;
	var dvs=new Array();
	var cnt_tabs=0;

	for(var i=0;i< nds.length;i++) {

		if(nds[i].nodeType==1) {
			dvs.push(nds[i]);
		}
	}

	for(j=0;j < dvs.length;j++) {
		if(dvs[j].className=="b2_activetab" || dvs[j].className=="b2_inactivetab") {

			if(cnt_tabs==nr) {
				if(nr==0) {
					dvs[j-1].className="b2_af";
				}
				else {
					dvs[j-1].className="b2_al";
				}
				dvs[j].className="b2_activetab";
				dvs[j+1].className="b2_ar";

				document.getElementById('inner_cont_'+cnt_tabs).style.display="block";
			}
			else {
				if(cnt_tabs==0) {
					dvs[j-1].className="b2_if";
				}
				else {
					dvs[j-1].className="b2_il";
				}
				dvs[j].className="b2_inactivetab";
				dvs[j+1].className="b2_ir";

				document.getElementById('inner_cont_'+cnt_tabs).style.display="none";
			}
			cnt_tabs++;
		}
	}
	glueLast(dvs);
}

/*
	reason to reject contact/recommendation/sugestion request
	var operationType =	1 - reject contact sugestion
						2 - reject contact request
*/
var position = -1;

function chooseReason(contactId, operationType, obj)
{
	switch(operationType)
	{
		case 1:
			break;
		case 2:
			//reject contact request
			var objTmp = document.getElementById("contact_" + parseInt(contactId));
			var tmp = objTmp.value;
			userData = tmp.split('_');
			position = contactId;
			contactId = userData[0];
			break;
	}

	var left = findPosX(obj);
	var top = findPosY(obj);

	var choose_dv = document.createElement("div");
	choose_dv.id = "chooseDiv_"+contactId;
	choose_dv.style.position = "absolute";
	choose_dv.style.width = "200px";
	choose_dv.style.left = (left-200)+"px";
	choose_dv.style.top = (top+15)+"px";
	choose_dv.style.border = "1px solid #CCCCCC";
	choose_dv.style.backgroundColor = "#FFFFFF";
	var content = '';
	var reasons = new Array();
	reasons[1] = 'nu il/o cunosc';
	reasons[2] = 'stiu prea putine despre el/ea';
	reasons[3] = 'alte motive';
	content += '<div style="padding: 5px; width:190px; background-color:#7F7F7F; color:#FFFFFF;font-weight:bold;">Nu doresc acest contact...</div>';
	for(i=1;i<=3;i++)
	{
		content += '<div style="padding: 0px 5px 0px 5px; width:190px;background-color:#FFFFFF" onmouseover="this.style.backgroundColor = \'#EEEEEE\';" onmouseout="this.style.backgroundColor = \'#FFFFFF\'"><span class="ui-jobs-button" style="padding-left:5px;"><a href="javascript:void(0)" onclick="saveReason('+contactId+', '+operationType+', '+i+')">'+reasons[i]+'</a></span></div>';
	}
	content += '<div style="padding: 0px 5px 0px 5px; width:190px;background-color:#FFFFFF" onmouseover="this.style.backgroundColor = \'#EEEEEE\';" onmouseout="this.style.backgroundColor = \'#FFFFFF\'" align="right"><span style="line-height:22px;padding-left:5px;"><a href="javascript:void(0)" onclick="closeReasonDiv('+contactId+')">Inchide</a></span></div>';
	choose_dv.innerHTML = content;
	document.body.appendChild(choose_dv);
}

function closeReasonDiv(contactId)
{
	var dv = document.getElementById("chooseDiv_"+contactId);
	document.body.removeChild(dv);
}

function saveReason( contactId, operationType, reason)
{
	Request.sendPOST("http://www.bestjobs.md/contacts/_savereason", "contactid="+contactId+"&optype="+operationType+"&reason="+reason, prepareOperation);
}

function prepareOperation(response)
{
	if(response)
	{
		var opParams = response.responseText.split("_");
		var contactId = parseInt(opParams[0]);
		var operationType = parseInt(opParams[1]);
		switch(operationType)
		{
			case 1:
				//reject contact sugestion
				contactTipAction(contactId, 2, null);
			break;
			case 2:
				//reject contact request
				processContact('refuse', position);
				break;
		}
		closeReasonDiv(contactId);
	}
}

/*END reason*/

/* new suggestions */
function closeSuggestions() {
	$('#sugests').remove();
	$('#suggestions').remove();
	$('#whiteframe').remove();
	return false;
}
function saveSuggestions() {
	var sugestion = document.getElementById ('sugest_form');
	var sugestion_action = sugestion.action;
	var post_vars = "";
	post_vars += "&txt="+sugestion.txt.value;

	Request.sendPOST(sugestion_action, post_vars, suggestionCB);
	return false;
}
function suggestionCB(response) {
	$('#suggestions').hide().css({ 'height' : '50px' }).html(response.responseText).show();
	$('#whiteframe').remove();
	return false;
}
/* END new suggestions */

var Element = new Object();
Element.toggle = function(element) {
	element = document.getElementById(element);
	if(element.style.display == "none") 
		element.style.display="inline";
	else element.style.display="none";
	return element;
}
Element.scrollTo = function(element) {
	element = document.getElementById(element);
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      element = element.offsetParent;
    } while (element);
    window.scrollTo(valueL, valueT);
    return element;
}
function cropDefault(obj) {
	if(obj.value.trim()=="Cuvant cheie") obj.value="";
}