function createCookie(a,b,c){if(c){var d=new Date();d.setTime(d.getTime()+(c*24*60*60*1000));var e="; expires="+d.toGMTString()}else e="";document.cookie=a+"="+b+e+"; path=/"}
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
//addEvent - attach a function to an event
function jaAddEvent(a,b,c){if(a.addEventListener){a.addEventListener(b,c,false);return true}else if(a.attachEvent){var r=a.attachEvent("on"+b,c);return r}else{return false}}
function equalHeight(){var a=$('ja-col');var b=$('ja-mainbody');c=0;if(b.offsetHeight<a.offsetHeight){var c=a.offsetHeight-b.offsetHeight}if($('ja-botsl')){makeEqualHeight($('ja-botsl').getChildren(),c);c=0}makeEqualHeight($$('.jazin-box'),c)}

function makeEqualHeight(c,d){if(!d)d=0;if(!c||c.length<2)return;var e=0;c.each(function(a,i){var b=a.getCoordinates().height;e=(e<b)?b:e},this);e+=d;c.each(function(a,i){a.setStyle('height',e-a.getStyle('padding-top').toInt()-a.getStyle('padding-bottom').toInt())},this)}function getDeepestDiv(a){while(a.getChildren().length==1&&(a.getChildren()[0].tagName=='DIV')){a=a.getChildren()[0]}return a}
function preloadImages(){var a=new Array();for(var i=0;i<arguments.length;i++){var b=arguments[i];a[i]=new Image();a[i].src=b}}

//Add span to module title
function addSpanToTitle(){var a=getElementsByClass('module.*',null,"div");if(!a)return;for(var i=0;i<a.length;i++){var b=a[i];var c=b.getElementsByTagName("h3")[0];if(c){text=c.innerHTML;var d=text.indexOf(' ');if(d!=-1){c.innerHTML="<span>"+text.substr(0,d)+"</span>"+text.substr(d)}else{c.innerHTML="<span>"+text+"</span>"}}}}

function makeTransBg(f,g,h,i,j){var k=f;if(!k)return;if($type(k)!='array')k=[k];if(!h)h='crop';if(!j)j=0;var l=siteurl+'images/blank.png';k.each(function(b){var c=g;if(b.tagName=='IMG'){if(!c)c=b.src;if(!(/\.png$/i).test(c)||(/blank\.png$/i).test(c))return;b.setStyle('height',b.offsetHeight);b.setStyle('width',b.offsetWidth);b.src=l;b.setStyle('visibility','visible');b.setStyle('filter',"progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+c+", sizingMethod='"+h+"')")}else{if(!c)c=b.getStyle('backgroundImage');var d=new RegExp('url\s*[\(\"\']*([^\'\"\)]*)[\'\"\)]*');if((m=d.exec(c)))c=m[1];if(!(/\.png$/i).test(c)||(/blank\.png$/i).test(c))return;if(!i){b.setStyles({'background':'none'});if(b.getStyle('position')!='absolute'&&b.getStyle('position')!='relative'){b.setStyle('position','relative')}b.getChildren().each(function(a){if(a.getStyle('position')!='absolute'&&a.getStyle('position')!='relative'){a.setStyle('position','relative')}a.setStyle('z-index',2)});var e=new Element('IMG');e.src=l;e.width=b.offsetWidth-j;e.height=b.offsetHeight-j;e.setStyles({'position':'absolute','top':0,'left':-b.getStyle('padding-left').toInt()});e.className='TransBG';e.setStyle('filter',"progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+c+", sizingMethod='"+h+"')");e.inject(b,'top')}else{b.setStyle('filter',"progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+c+", sizingMethod='"+h+"')")}}}.bind(this))}

function isIE6(){version=0;if(navigator.appVersion.indexOf("MSIE")!=-1){temp=navigator.appVersion.split("MSIE");version=parseFloat(temp[1])}return(version&&(version<7))}
function getElementsByClass(a,b,c){var d=new Array();var j=0;if(b==null)b=document;if(c==null)c='*';var e=b.getElementsByTagName(c);var f=e.length;var g=new RegExp('(^|\\s)'+a+'(\\s|$)');for(var i=0;i<f;i++){if(g.test(e[i].className)){d[j]=e[i];j++}}return d}

//Add 1st item identity
function jaAddFirstItemToTopmenu(){li=$E('#ja-footer ul li');if(li){li.addClass('ja-firstitem')}}
function jaRemoveLastContentSeparator(){var a=$$('#ja-content .article_separator');if(a&&a.length)a[a.length-1].remove()}
function jaRemoveLastTrBg(){var a=$$('#ja-topsl3 tr');if(!a||a.length<1)return;var b=a[a.length-1];if(a[a.length-1].innerHTML.trim()==''&&a.length>2){b.remove();b=a[a.length-2]}if(b)b.setStyle('background','none')}
function fixMenuWidth(){var a=$('ja-mainnav').getElement('ul').getChildren();if(a.length){var w=Math.floor($('ja-mainnav').offsetWidth/a.length);a.setStyle('width',w)}}
window.addEvent('domready', function() {

//proceduri legale accordion
if($('proceduri_legale')){var accordion=new Accordion($$('.toggler'),$$('.element'),{start:-1,opacity:0,onActive:function(a){a.setStyles({'background':'#F6F6F6','color':'#A41010','font-weight':'bold','border-left':'1px solid #ddd','border-top':'1px solid #ddd','border-right':'1px solid #ddd','padding':'5px'},'all')},onBackground:function(a){a.setStyles({'background':'#fff','color':'#666','font-weight':'normal','border':'0','padding':'0px'},'all')}})}


//register									 
if($('cbfr_58')){
	if(!$('cbf27').checked){
		$('cbfr_58').setStyle('display','none');
		$('cbf26').checked = true;
	}
	$('cbfv_62').addEvent('click',function(){
		if($('cbf27').checked)
			$('cbfr_58').setStyle('display','table-row');
			else
			$('cbfr_58').setStyle('display','none');
	});
}

//mootips
	var tooltips = new Tips($$('.tooltips'),{
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 50, wait: false}).set(0);
		},
		onShow: function(toolTip){ this.fx.start(1); },
		onHide: function(toolTip){ this.fx.start(0); }
	});

/* Smoothscroll */
new SmoothScroll({ duration: 500, transition: Fx.Transitions.Expo.easeOut });

/* logo */
if($('header')){var ball=$('header').getElement('h1');var ballfx=new Fx.Styles(ball,{duration:1000,'transition':Fx.Transitions.Elastic.easeOut});new Drag.Base(ball,{onComplete:function(){ballfx.start({'top':23,'left':6})}})}
//dictionar auto
if($('dictionar_auto')){var letters=new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');for(i=0;i<letters.length;i++){$('show_'+letters[i]).addEvent('click',function(){$$('div.dictionar_container').each(function(a,x){a.setStyle('display','none')});$('container_'+this.id.substr(5)).setStyle('display','block')})}}
//footer
var clicked1 = false;
$('more_auto').addEvent('click',function(){
   if(!clicked1){
	   $('ul1').className = 'footer_full_height';
	   this.setStyle('background-position','0px -13px');
	   clicked1 = true;	   
   }else{
	   $('ul1').className ='footer_height';
	   this.setStyle('background-position','0px 0px');	   
	   clicked1 = false;	   
   }
});

var clicked2 = false;
$('more_ocazii').addEvent('click',function(){
   if(!clicked2){
	   $('ul2').className = 'footer_full_height';
	   this.setStyle('background-position','0px -13px');
	   clicked2 = true;	   
   }else{
	   $('ul2').className ='footer_height';
	   this.setStyle('background-position','0px 0px');	   
	   clicked2 = false;	   
   }
});

var imoClicked = false;
$('more_imo').addEvent('click',function(){
   if(!imoClicked){
	   $('ul-imo').className = 'footer_full_height';
	   this.setStyle('background-position','0px -13px');
	   imoClicked = true;	   
   }else{
	   $('ul-imo').className ='footer_height';
	   this.setStyle('background-position','0px 0px');	   
	   imoClicked = false;	   
   }
});





});

var boxes = [];
function showBox(box) {
	box = $(box);
	if (!box) return;
	boxes.include(box);
	if (box.getStyle('display') == 'none') {
		box.setStyles({
			display: 'block',
			opacity: 0
		});
	}
	if (box.status == 'show') {
		//hide
		box.status = 'hide';
		var fx = new Fx.Style (box,'opacity');
		fx.stop();
		fx.start (box.getStyle('opacity'), 0);
	} else {
		boxes.each(function(box1){
			if (box1!=box && box1.status=='show') {
				box1.status = 'hide';
				var fx = new Fx.Style (box1,'opacity');
				fx.stop();
				fx.start (box1.getStyle('opacity'), 0);
			}
		},this);
		box.status = 'show';
		var fx = new Fx.Style (box,'opacity',{onComplete:function(){}});
		fx.stop();
		fx.start (box.getStyle('opacity'), 1);
	}
}


/* myscripts */
function explode(delimiter,item) {
tempArray=new Array(1);
var Count=0;
var tempString=new String(item);

while (tempString.indexOf(delimiter)>0) {
tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
Count=Count+1
}

tempArray[Count]=tempString;
return tempArray;
} 

/* ajax */
var XMLHttpArray = [
        function() {return new XMLHttpRequest()},
        function() {return new ActiveXObject("Msxml2.XMLHTTP")},
        function() {return new ActiveXObject("Msxml2.XMLHTTP")},
        function() {return new ActiveXObject("Microsoft.XMLHTTP")}
];

var http = false;
for(var i=0; i<XMLHttpArray.length; i++){
	try{
			http = XMLHttpArray[i]();
	}catch(e){
			continue;
	}
	break;
}



function ajax_post(url,params,funtionReturn){
//var url = "post_data.php";
//var params = "lorem=ipsum&name=binny";
http.open("POST", url, true);

//ajax post method
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		//response
		funtionReturn(http);
	}
}

http.send(params);
}

//ajax get method
function ajax_get(url,params,funtionReturn){
//var url = "get_data.php";
//var params = "lorem=ipsum&name=binny";
http.open("GET", url+"?"+params, true);
http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		//response	
		funtionReturn(http);
		//alert(http.responseText);
	}
}
http.send(null);
}

//results
function update_results(req){
	var respText=req.responseText;	
	document.getElementById('id_'+respText).style.border = '1px solid green';
	document.getElementById('id_'+respText).style.color = 'green';	
}////
//tabs
function changeTabTo(nr){var min_height;var current=$('current_tab').value;if(current!=nr){$('tab_'+current).className='';$('container_'+current).style.display='none';$('tab_'+nr).className='active';$('container_'+nr).style.display='block';$('current_tab').value=nr}
//var myFx = new Fx.Scroll(window).toElement('top_sponsorizate');
}
//checkemail
function checkemail(a){var b=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(b.test(a))testresults=true;else{testresults=false}return testresults}

//tips
/*var tooltip=function(){var f='tt';var g=3;var j=3;var k=300;var m=10;var n=20;var o=98;var p=0;var q,t,c,b,h;var r=document.all?true:false;return{show:function(v,w){if(q==null){q=document.createElement('div');q.setAttribute('id',f);t=document.createElement('div');t.setAttribute('id',f+'top');c=document.createElement('div');c.setAttribute('id',f+'cont');b=document.createElement('div');b.setAttribute('id',f+'bot');q.appendChild(t);q.appendChild(c);q.appendChild(b);document.body.appendChild(q);q.style.opacity=0;q.style.filter='alpha(opacity=0)';document.onmousemove=this.pos}q.style.display='block';c.innerHTML=v;q.style.width=w?w+'px':'auto';if(!w&&r){t.style.display='none';b.style.display='none';q.style.width=q.offsetWidth;t.style.display='block';b.style.display='block'}if(q.offsetWidth>k){q.style.width=k+'px'}h=parseInt(q.offsetHeight)+g;clearInterval(q.timer);q.timer=setInterval(function(){tooltip.fade(1)},n)},pos:function(e){var u=r?event.clientY+document.documentElement.scrollTop:e.pageY;var l=r?event.clientX+document.documentElement.scrollLeft:e.pageX;q.style.top=(u-h)+'px';q.style.left=(l+j)+'px'},fade:function(d){var a=p;if((a!=o&&d==1)||(a!=0&&d==-1)){var i=m;if(o-a<m&&d==1){i=o-a}else if(p<m&&d==-1){i=a}p=a+(i*d);q.style.opacity=p*.01;q.style.filter='alpha(opacity='+p+')'}else{clearInterval(q.timer);if(d==-1){q.style.display='none'}}},hide:function(){clearInterval(q.timer);q.timer=setInterval(function(){tooltip.fade(-1)},n)}}}();*/

//update_valuta
function update_valuta(a){var b=valuta_EUR;b=b.replace(/,/,".");var c=valuta_USD;c=c.replace(/,/,".");lei_value=1;un_eur=1/b;un_usd=1/c;un_usd_eur=b/c;un_eur_usd=b/c;if(a.id=='val_lei'){euro_v=a.value*un_eur;$('val_eur').value=euro_v.toFixed(4);usd_v=a.value*un_usd;$('val_usd').value=usd_v.toFixed(4)}if(a.id=='val_eur'){lei_v=a.value*parseFloat(b);$('val_lei').value=lei_v.toFixed(4);usd_v=a.value*(b/c);$('val_usd').value=usd_v.toFixed(4)}if(a.id=='val_usd'){lei_v=a.value*parseFloat(c);$('val_lei').value=lei_v.toFixed(4);euro_v=a.value*(c/b);$('val_eur').value=euro_v.toFixed(4)}}function update_zero(){$('val_lei').value='';$('val_eur').value='';$('val_usd').value=''}
