var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
var top=80;
var opac=0.38;
var tt=0;
var lungs=Array();

function strr( string ){
	string=string.replace(/\n/g,'');
	string=string.replace('function anonymous(){','');
	string=string.replace('}','');
	string=string.replace("this.src='","");
	string=string.replace("'","");
return string;
}

function strrr( string ){
	string=string.replace(/\n/g,'');
	string=string.replace('function anonymous(){','');
	string=string.replace('}','');
return string;
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         { 
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	if(img.onmouseover) { mo=strr(''+img.onmouseover); moo=strr(''+img.onmouseout);  }
if(img.onclick) { onc=strrr(''+img.onclick); }
            var strNewHTML = "<span ";
	if(img.onclick) strNewHTML += " onClick=\""+onc+"\" ";
	if(img.onmouseover) strNewHTML += " onMouseOver=\"this.style.position='relative'; this.style.top='0px';this.style.filter=''; this.style.background='url("+mo+")'\" onMouseOut=\"this.style.filter=''; this.style.background='url("+moo+")'\"";
		strNewHTML += imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
	
            i = i-1
         }
      }
   }    
}

function ArataTooltip(f)
{
document.getElementById("tooltext").innerHTML=f;
document.getElementById("tooltip").style.display='block';
document.onmousemove=follow;
}

function mouseX(evt)
{
if (!evt) evt = window.event; if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return 0;}
function mouseY(evt) {if (!evt) evt = window.event; if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return 0;}

function follow(evt)
{
if(evt=='stop') { document.onmousemove=null; document.getElementById("tooltip").style.display='none'; return false; }
if (document.getElementById) {var obj = document.getElementById("tooltip").style; obj.display = 'block';
obj.left = (parseInt(mouseX(evt)))+10+'px';
obj.top = (parseInt(mouseY(evt)))-40+'px';}
}


function gojos(div,cur,max,cat)
{
scr=document.getElementById('divpoza-'+div).scrollTop;
if(scr<cur)
	{
scr=scr+2;
	document.getElementById('divpoza-'+div).scrollTop=scr;
	setTimeout("gojos('"+div+"',"+cur+","+max+","+cat+")",1);
	}
else
	{

document.getElementById('divpoza-'+div).scrollTop=cur;

if(isIE6) var check=max+100-document.getElementById('divpoza-'+div).offsetHeight;
	else var check=max+104-document.getElementById('divpoza-'+div).offsetHeight;

if(cur==check)
	{
	document.getElementById('gojos-'+div).onclick='';
	document.getElementById('gojos-'+div).innerHTML='<img src="/general/sageti/butgal_disabled-jos.png" alt="s"/>';
	document.getElementById('gojos-'+div).style.cursor='default';
	}
else
	{
	document.getElementById('gojos-'+div).onclick=new Function("gojos("+div+","+(cur+100)+","+max+","+cat+")");
	document.getElementById('gojos-'+div).innerHTML='<img src="/general/sageti/butgal'+cat+'-jos.png" alt="s"/>';
	document.getElementById('gojos-'+div).style.cursor='pointer';
	}

document.getElementById('gosus-'+div).onclick=new Function("gosus("+div+","+(cur-100)+","+max+","+cat+")");
document.getElementById('gosus-'+div).innerHTML='<img src="/general/sageti/butgal'+cat+'-sus.png" alt="s"/>';
document.getElementById('gosus-'+div).style.cursor='pointer';
correctPNG();
	}
}

function gosus(div,cur,max,cat)
{
scr=document.getElementById('divpoza-'+div).scrollTop;
if(scr>cur)
	{
scr=scr-2;
	document.getElementById('divpoza-'+div).scrollTop=scr;
	setTimeout("gosus('"+div+"',"+cur+","+max+","+cat+")",1);
	}
else
	{
document.getElementById('divpoza-'+div).scrollTop=cur;
if(cur==0)
	{
	document.getElementById('gosus-'+div).onclick='';
	document.getElementById('gosus-'+div).innerHTML='<img src="/general/sageti/butgal_disabled-sus.png" alt="s"/>';
	document.getElementById('gosus-'+div).style.cursor='default';
	}
else
	{
	document.getElementById('gosus-'+div).onclick=new Function("gosus("+div+","+(cur-100)+","+max+","+cat+")");
	document.getElementById('gosus-'+div).innerHTML='<img src="/general/sageti/butgal'+cat+'-sus.png" alt="s"/>';
	document.getElementById('gosus-'+div).style.cursor='pointer';
	}

document.getElementById('gojos-'+div).onclick=new Function("gojos("+div+","+(cur+100)+","+max+","+cat+")");
document.getElementById('gojos-'+div).innerHTML='<img src="/general/sageti/butgal'+cat+'-jos.png" alt="s"/>';
document.getElementById('gojos-'+div).style.cursor='pointer';
correctPNG();
	}
}

function gojos2(div,cur,max,cat)
{
scr=document.getElementById('divpoza-'+div).scrollTop;
if(scr<cur)
	{
scr=scr+2;
	document.getElementById('divpoza-'+div).scrollTop=scr;
	setTimeout("gojos2('"+div+"',"+cur+","+max+","+cat+")",1);
	}
else
	{

document.getElementById('divpoza-'+div).scrollTop=cur;

if(cur>=(max+116-document.getElementById('divpoza-'+div).offsetHeight)-10)
	{
	document.getElementById('gojos-'+div).onclick='';
	document.getElementById('gojos-'+div).innerHTML='<img src="/general/sageti/butgal_disabled-jos.png" alt="s"/>';
	document.getElementById('gojos-'+div).style.cursor='default';
	}
else
	{
	document.getElementById('gojos-'+div).onclick=new Function("gojos2("+div+","+(cur+115)+","+max+","+cat+")");
	document.getElementById('gojos-'+div).innerHTML='<img src="/general/sageti/butgal'+cat+'-jos.png" alt="s"/>';
	document.getElementById('gojos-'+div).style.cursor='pointer';
	}

document.getElementById('gosus-'+div).onclick=new Function("gosus2("+div+","+(cur-115)+","+max+","+cat+")");
document.getElementById('gosus-'+div).innerHTML='<img src="/general/sageti/butgal'+cat+'-sus.png" alt="s"/>';
document.getElementById('gosus-'+div).style.cursor='pointer';
correctPNG();
	}
}

function gosus2(div,cur,max,cat)
{
scr=document.getElementById('divpoza-'+div).scrollTop;
if(scr>cur)
	{
scr=scr-2;
	document.getElementById('divpoza-'+div).scrollTop=scr;
	setTimeout("gosus2('"+div+"',"+cur+","+max+","+cat+")",1);
	}
else
	{
document.getElementById('divpoza-'+div).scrollTop=cur;
if(cur==0)
	{
	document.getElementById('gosus-'+div).onclick='';
	document.getElementById('gosus-'+div).innerHTML='<img src="/general/sageti/butgal_disabled-sus.png" alt="s"/>';
	document.getElementById('gosus-'+div).style.cursor='default';
	}
else
	{
	document.getElementById('gosus-'+div).onclick=new Function("gosus2("+div+","+(cur-115)+","+max+","+cat+")");
	document.getElementById('gosus-'+div).innerHTML='<img src="/general/sageti/butgal'+cat+'-sus.png" alt="s"/>';
	document.getElementById('gosus-'+div).style.cursor='pointer';
	}

document.getElementById('gojos-'+div).onclick=new Function("gojos2("+div+","+(cur+115)+","+max+","+cat+")");
document.getElementById('gojos-'+div).innerHTML='<img src="/general/sageti/butgal'+cat+'-jos.png" alt="s"/>';
document.getElementById('gojos-'+div).style.cursor='pointer';
correctPNG();
	}
}

function ValidateLocatie()
{
var er=0;
	if(!document.getElementById('tiploc').value)
		{
		alert('Alege tipul locatiei !');
		document.getElementById('tiploc').focus();
		return false;
		}
	if(!document.getElementById('nume').value)
		{
		alert('Completeaza numele locatiei !');
		document.getElementById('nume').select();
		document.getElementById('nume').focus();
		return false;
		}
}

function jsUpload(upload_field)
{
    upload_field.form.submit();
document.getElementById("loading1").style.display='block';
//    upload_field.disabled = true;
    return true;
}

function ValidateContact()
{
contact.contnume.style.border='solid 1px #b8b8b8';
contact.contnume.style.color='#a2a2a2';
contact.contprenume.style.border='solid 1px #b8b8b8';
contact.contprenume.style.color='#a2a2a2';
contact.conttel.style.border='solid 1px #b8b8b8';
contact.conttel.style.color='#a2a2a2';
contact.contemail.style.border='solid 1px #b8b8b8';
contact.contemail.style.color='#a2a2a2';
contact.contsubiect.style.border='solid 1px #b8b8b8';
contact.contsubiect.style.color='#a2a2a2';
contact.contmesaj.style.border='solid 1px #b8b8b8';
contact.contmesaj.style.color='#a2a2a2';
var len=contact.contemail.value.length;

var ok=1;

if(!contact.contnume.value || contact.contnume.value=='Nume')
	{
	contact.contnume.style.border='solid 1px #ff0000';
	contact.contnume.style.color='#ff0000';
	ok=0;
	}
if(!contact.contprenume.value || contact.contprenume.value=='Prenume')
	{
	contact.contprenume.style.border='solid 1px #ff0000';
	contact.contprenume.style.color='#ff0000';
	ok=0;
	}
if(!contact.conttel.value || contact.conttel.value=='Telefon')
	{
	contact.conttel.style.border='solid 1px #ff0000';
	contact.conttel.style.color='#ff0000';
	ok=0;
	}
if(!contact.contemail.value || contact.contemail.value.indexOf('@')==-1 || contact.contemail.value.indexOf('@')==0 || 
contact.contemail.value.indexOf('@')==len || contact.contemail.value.indexOf('.')==-1 || contact.contemail.value.indexOf('.')==0 
|| contact.contemail.value.indexOf('@')==1 || contact.contemail.value.indexOf('.')==2 || contact.contemail.value.indexOf('.')==len || 
len<7)
	{
	contact.contemail.style.border='solid 1px #ff0000';
	contact.contemail.style.color='#ff0000';
	ok=0;
	}
if(!contact.contsubiect.value || contact.contsubiect.value=='Subiectul mesajului')
	{
	contact.contsubiect.style.border='solid 1px #ff0000';
	contact.contsubiect.style.color='#ff0000';
	ok=0;
	}
if(!contact.contmesaj.value || contact.contmesaj.value=='Mesaj')
	{
	contact.contmesaj.style.border='solid 1px #ff0000';
	contact.contmesaj.style.color='#ff0000';
	ok=0;
	}
if(!ok) return false;
return true;
}

function ValidateContact1()
{
contact1.nume.style.border='solid 1px #b8b8b8';
contact1.nume.style.color='#a2a2a2';
contact1.tel.style.border='solid 1px #b8b8b8';
contact1.tel.style.color='#a2a2a2';
contact1.email.style.border='solid 1px #b8b8b8';
contact1.email.style.color='#a2a2a2';
contact1.oras.style.border='solid 1px #b8b8b8';
contact1.oras.style.color='#a2a2a2';
contact1.mesaj.style.border='solid 1px #b8b8b8';
contact1.mesaj.style.color='#a2a2a2';
var len=contact1.email.value.length;

var ok=1;

if(!contact1.nume.value || contact1.nume.value=='Nume')
	{
	contact1.nume.style.border='solid 1px #ff0000';
	contact1.nume.style.color='#ff0000';
	ok=0;
	}
if(!contact1.tel.value || contact1.tel.value=='Telefon')
	{
	contact1.tel.style.border='solid 1px #ff0000';
	contact1.tel.style.color='#ff0000';
	ok=0;
	}
if(!contact1.email.value || contact1.email.value.indexOf('@')==-1 || contact1.email.value.indexOf('@')==0 || 
contact1.email.value.indexOf('@')==len || contact1.email.value.indexOf('.')==-1 || contact1.email.value.indexOf('.')==0 
|| contact1.email.value.indexOf('@')==1 || contact1.email.value.indexOf('.')==2 || contact1.email.value.indexOf('.')==len || 
len<7)
	{
	contact1.email.style.border='solid 1px #ff0000';
	contact1.email.style.color='#ff0000';
	ok=0;
	}
if(!contact1.oras.value || contact1.oras.value=='Localitate')
	{
	contact1.oras.style.border='solid 1px #ff0000';
	contact1.oras.style.color='#ff0000';
	ok=0;
	}
if(!contact1.mesaj.value || contact1.mesaj.value=='Mesaj')
	{
	contact1.mesaj.style.border='solid 1px #ff0000';
	contact1.mesaj.style.color='#ff0000';
	ok=0;
	}
if(!ok) return false;
return true;
}

function XHTMLDobitocCareEstiTu()
{
var len=newsl.newsmail.value.length;
if(!newsl.newsmail.value || newsl.newsmail.value.indexOf("@")==-1 || newsl.newsmail.value.indexOf("@")==0 || 
newsl.newsmail.value.indexOf("@")==len || newsl.newsmail.value.indexOf(".")==-1 || newsl.newsmail.value.indexOf(".")==0 
|| newsl.newsmail.value.indexOf("@")==1 || newsl.newsmail.value.indexOf(".")==2 || newsl.newsmail.value.indexOf(".")==len || 
len<7)
	{
	alert("Adresa de email incorecta");
	return false;
	}
}

function topjos(div)
{
$('#'+div.id).animate({top: '0px'}, 200);
//div.style.top=(parseInt(div.style.top)+3)+'px';
//if(parseInt(div.style.top)<0) setTimeout("topjos(document.getElementById('"+div.id+"'))","1");
}

function Promote(loc_id) {
	$.post('/ajax/admin_ajax.php',{action:'promote',loc_id: loc_id});
	$('#adminloclist tr').each(
		function()
		{
			$(this).css({background: 'none'});
		}
	);
	$('.promote').each(
		function()
		{
			if($(this).html()=='Despromote') {
				$(this).html('Promote');
				var id=$(this).attr('id').split('promote_');
				id=id[1];
				document.getElementById($(this).attr('id')).onclick = new Function("Promote('"+id+"'); return false");
			}
		}
	);
	$('#loc_'+loc_id).css({background: '#cfad23'});
	$('#promote_'+loc_id).html('Despromote');
	document.getElementById('promote_'+loc_id).onclick = new Function("Despromote('"+loc_id+"'); return false");
}

function Despromote(loc_id) {
	$.post('/ajax/admin_ajax.php',{action:'despromote',loc_id: loc_id});
	$('#loc_'+loc_id).css({background: 'none'});
	$('#promote_'+loc_id).html('Promote');
	document.getElementById('promote_'+loc_id).onclick = new Function("Promote('"+loc_id+"'); return false");
}