function postPopUp(url, name, params) {
	return window.open(url, name, params);
}
var newWindow;
function debugBanners()
{
  if (newWindow.closed) {
        makeNewWindow();
    }
    newWindow.focus()
    var newContent = "<HTML><HEAD><TITLE>A New Doc</TITLE></HEAD>"
    newContent += "<BODY BGCOLOR='coral'><H1>This document is brand new.</H1>"
    newContent += "</BODY></HTML>"
    newWindow.document.write(newContent)
    newWindow.document.close() // close layout stream	

}

// JavaScript Document
/*document.write = function(native) {
	if(console && console.log) console.log(native);	
}*/
var to_submenu='';
var ajax_responses = new Array();
function change_submenu(a,b,url,post)
{
	act_item = 0;
	for(i=1;i<=b;i++)
	{
		if($('menu_item_'+i).className == 'menu_item_act_2 text_8 serif_bold color_1')
		{
			if(i!=a)
				$('menu_item_'+i).className = 'menu_item text_8 serif_bold color_1';
			act_item = i;
		}
		else if($('menu_item_'+i).className == 'menu_item_act menu_item_act_2 text_8 serif_bold color_1')
		{
			if(i!=a)
				$('menu_item_'+i).className = 'menu_item_act text_8 serif_bold color_1';
			act_item = i;
		}
	}
	//if(act_item==a) return;
	if(a!=0)
	{
		if(ajax_responses[a]!=undefined)
		{
			if(ajax_responses[a]!='0') 
			{
				$('new_submenu').style.display = '';
				$('new_submenu').innerHTML = ajax_responses[a];
				if($('menu_item_'+a).className == 'menu_item text_8 serif_bold color_1')
					$('menu_item_'+a).className = 'menu_item_act_2 text_8 serif_bold color_1';
				else if($('menu_item_'+a).className == 'menu_item_act text_8 serif_bold color_1')
					$('menu_item_'+a).className = 'menu_item_act menu_item_act_2 text_8 serif_bold color_1';
			}
			else
				$('new_submenu').style.display = 'none';
		}
		else new Ajax.Updater(
			'new_submenu', 
			url,
			{
				parameters:post, 
				method:'post',
				onComplete:function(resp)
				{
					ajax_responses[a] = resp.responseText;
					if(resp.responseText!='0') 
					{
						$('new_submenu').style.display = '';
						if($('menu_item_'+a).className == 'menu_item text_8 serif_bold color_1')
							$('menu_item_'+a).className = 'menu_item_act_2 text_8 serif_bold color_1';
						else if($('menu_item_'+a).className == 'menu_item_act text_8 serif_bold color_1')
							$('menu_item_'+a).className = 'menu_item_act menu_item_act_2 text_8 serif_bold color_1';
					}
					else
						$('new_submenu').style.display = 'none';
				}
			}
		);
	}
	else
	{
		$('new_submenu').style.display = 'none';
	}
}
function google_track(a,b,c,d)
{
	//alex parametrii la asincron sunt la fel ca la singron _gaq.push(['_trackEvent', 'category', 'action', 'opt_label', opt_value])
	//if(pageTracker) pageTracker._trackEvent(a,b,c,d); //_trackEvent(category, action, optional_label, optional_value)
	//pageTracker._trackPageview("/"+a+"/"+b+"/"+c+"/"+d);
	
	if(a==undefined || b==undefined) return;
	if(c==undefined && d==undefined){
		_gaq.push(['_trackEvent',a,b]);

	}
	if(d==undefined){
		_gaq.push(['_trackEvent',a,b,c]);

	}
	else{
		_gaq.push(['_trackEvent',a,b,c,d]);

	}
}

function change_submenu_wait(a,b,url,post)
{
	clearTimeout(to_submenu);
	if(a==-1)
	{
		return;
	}
	to_submenu=setTimeout(function(){
		change_submenu(a,b,url,post);
	},200)
}
function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}
function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
	//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}
function handle_adocean_emission(slot,zona_banner)
{
	slot;
	//if(test()) alert('cu emisie: '+slot);
	if(slot=='branding_laterala_st' || slot=='branding_laterala_dr' || slot=='article')
		branding_prepare();
	return false;
}
var empty_banners = new Array();

var cAds = { 'site':'gsp.ro'};	
function handle_adocean_emission_empty(slot,zona_banner)
{
	empty_banners.push(slot);
	if(slot=='floating')
	{
		insertJavaScript('http://ctx.inin.ro/underline.js');
	}
	slot;
}
function branding_prepare()
{
//	return;
	$('branding_prepare').className = 'branding_prepare';
	$('branding_prepare_up').style.backgroundColor='#050E15';
	document.body.style.background = 'url(/images/dark_color.png) 0 0 repeat-x';
}
function radio_value(obj)
{
	for(i=0;i<obj.length;i++)
	{
		if(obj[i].checked) return obj[i].value;
	}
}

var sto = new Array();
function change_menu(options)
{
	//total,current,prefix,class
	for(i=1;i<=options.total;i++)
	{
		$(options.prefix+i).className = $(options.prefix+i).className.replace(' '+options.myclass,'');
		$(options.prefix+i).className = $(options.prefix+i).className.replace(options.myclass,'');
	}
	$(options.prefix+options.current).className = $(options.prefix+options.current).className+' '+options.myclass;
}
function nav_content(options)
{
	if(options.stop == 1)
	{
		clearTimeout(sto[options.myclass]);
		return;
	}
	if(options.stop_and_play == 1)
	{
		clearTimeout(sto[options.myclass]);
	}
	if($(options.myclass+'_curent')==undefined)
	{
		input_curent = document.createElement('input');
		input_curent.setAttribute('id',options.myclass+'_curent');
		input_curent.setAttribute('type','hidden');
		input_curent.setAttribute('value',0);
		document.body.appendChild(input_curent);
	}
	if(options.direction==undefined || options.direction!='down') options.direction = 'up';
	
	curent = parseInt($(options.myclass+'_curent').value);
	
	if(options.direction == 'up')
		next = 1+curent;
	else
		next = curent-1;
	if(next>options.total) next = 1;
	else if(next<1) next = options.total;
	
	if(curent!=0)
		$(options.myclass+'_item_'+curent).fade({duration:0.5});
	$(options.myclass+'_item_'+next).appear();
	
	$(options.myclass+'_curent').value = next;
	
	if(options.auto==1)
	{
		sto[options.myclass] = setTimeout("nav_content({total:"+options.total+",auto:1,myclass:'"+options.myclass+"',direction:'"+options.direction+"'});",5000);
	}
}
function nav_content_new(options)
{
	if(options.stop == 1)
	{
		clearTimeout(sto[options.myclass]);
		return;
	}
	if(options.stop_and_play == 1)
	{
		clearTimeout(sto[options.myclass]);
	}
	if($(options.myclass+'_curent')==undefined)
	{
		input_curent = document.createElement('input');
		input_curent.setAttribute('id',options.myclass+'_curent');
		input_curent.setAttribute('type','hidden');
		input_curent.setAttribute('value',0);
		document.body.appendChild(input_curent);
	}
	if(options.direction==undefined || options.direction!='down') options.direction = 'up';
	
	curent = parseInt($(options.myclass+'_curent').value);
	
	if(options.direction == 'up')
		next = 1+curent;
	else
		next = curent-1;
	if(next>options.total) next = 1;
	else if(next<1) next = options.total;
	
	if(curent!=0)
		$(options.myclass+'_item_'+curent).fade({duration:0.5});
	$(options.myclass+'_item_'+next).appear();
	
	$(options.myclass+'_curent').value = next;
	
	if(options.auto==1)
	{
		sto[options.myclass] = setTimeout("nav_content({total:"+options.total+",auto:1,myclass:'"+options.myclass+"',direction:'"+options.direction+"'});",5000);
	}
}
function cnt_balancer(a)
{
	my_elements = $$('.'+a+'_td');
	total_elements = my_elements.length;
	for (i=0;i<total_elements;i++)
	{
		my_elements[i].style.display = '';
	}
	body_width = window.document.body.clientWidth;
	if(body_width<1002) body_width = 1002;
	cnt_width = $(a+'_cnt').clientWidth;
	//alert(body_width+'-'+cnt_width);
	if(body_width<cnt_width)
	{
		for (i=1;i<=total_elements;i++)
		{
			el_width = my_elements[total_elements-i].clientWidth;
			my_elements[total_elements-i].style.display = 'none';
			cnt_width = cnt_width - el_width;
			if(body_width>=cnt_width)
			{
				break;
			}
		}
	}
}
function menu(options){
	for(i=1;i<=options.total;i++)
	{
		if($(options.prefix+'_clp_'+i).className == 'webcam webcam_selected' || $(options.prefix+'_clp_'+i).className == 'webcam') $(options.prefix+'_clp_'+i).className = 'webcam';
		else
			$(options.prefix+'_clp_'+i).className = options.class_inact;
	}
	if(options.close == 1)
	{
		$(options.prefix).style.display = 'none';
		return;
	}
	$(options.prefix).style.display = '';
	$(options.prefix+'_clp_'+options.curent).className = options.class_act;
	new Ajax.Updater(options.prefix, options.page, {
		evalScripts:true, parameters: {}
	});
}
function in_array (needle, haystack, argStrict) {
   var key = '', strict = !!argStrict;

	if (strict) {
		for (key in haystack) {
			if (haystack[key] === needle) {
				return true;
			}
		}
	} else {
		for (key in haystack) {
			if (haystack[key] == needle) {
				return true;
			}
		}
	}

	return false;
}

function explode (delimiter, string, limit) {
    // http://kevin.vanzonneveld.net
    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']
 
    var emptyArray = { 0: '' };
    
    // third argument is not required
    if ( arguments.length < 2 ||
        typeof arguments[0] == 'undefined' ||
        typeof arguments[1] == 'undefined' ) {
        return null;
    }
 
    if ( delimiter === '' ||
        delimiter === false ||
        delimiter === null ) {
        return false;
    }
 
    if ( typeof delimiter == 'function' ||
        typeof delimiter == 'object' ||
        typeof string == 'function' ||
        typeof string == 'object' ) {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
    
    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}


String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
    return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
    return this.replace(/\s+$/,"");
}

function open_window(url,width,height)
{
	xpoz=Math.round((screen.width-width)/2);
	ypoz=Math.round((screen.height-height)/2);
	if (xpoz<0) xpoz=10;
	if (ypoz<0) ypoz=10;
	newWindow=window.open (url ,'gsp_window','toolbar=no,scrollbars=yes,width='+width+',height='+height+', left='+xpoz+', top='+ypoz);
	newWindow.focus();
	false;
}
/*
* DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/
/*
function echeck(str) {
	//var alert_str='Adresa de email invalida';
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	  // alert(alert_str)
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   //alert(alert_str)
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		//alert(alert_str)
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		//alert(alert_str)
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		//alert(alert_str)
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		//alert(alert_str)
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		//alert(alert_str)
		return false
	 }

	 return true					
}
*/
function echeck(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = email;
   if(reg.test(address) == false) {
      return false;
   }
   return true;
}


/* verfica comentarii*/
/* autor Tudor */
function check_comentarii(){
    var err="";
    if (!$F("nume_com").trim() > " ") err += " - Numele dumneavoastra!\n";
    if (!$F("subiect_com").trim() > " ") err += " - Titlul comentariului!\n";	
	if (!$F("comentariu_articol").trim() > " " && $F("comentariu_articol").trim() == "Comentariul tău...") err += " - Comentariul dumneavoastra!\n";
    if (($F("email_com") > " ") && (echeck($('email_com').value)==false)) err += " - Email-ul dumneavoastra!\n";	
	if (err >" "){
        alert("Urmatoarele campuri nu sunt completate corect: \n"+err);
        return false;
    } else{
		$('date_valide').value="1";	
	}	
    return true;
}

/* verfica comentarii*/
/* autor Tudor */
function check_comentarii_login(login){
    var err="";
    if(login!=1){
		if (!$F("nume_com").trim() > " ") {
			err += " - Numele dumneavoastra\n";
			$("nume_com").className = 'incorect';
			$("nume_com").focus();
		}
	    if (!($F("email_com") > " ") || (echeck($('email_com').value)==false)) {
			err += " - Email-ul dumneavoastra\n";
			$("email_com").className = 'incorect';
			$("email_com").focus();
		}
	}	
    //if($("subiect_com")!=null) if (!$F("subiect_com").trim() > " ") err += " - Titlul comentariului\n";	
	if (!$F("comentariu_articol").trim() > " " || $F("comentariu_articol").trim() == "Comentariul tău...") {
		err += " - Comentariul dumneavoastra\n";
		$("comentariu_articol").className = 'incorect';
		$("comentariu_articol").focus();		
	}
	
	if (err >" "){
        alert("Urmatoarele campuri nu sunt completate corect: \n"+err);
        return false;
    } else{
		$('date_valide').value="1";	
	}	
    return true;
}

function textAreaDefault(){
	if($F('comentariu_articol')=='Comentariul tău...') $('comentariu_articol').value='';
	//if($F('comentariu_articol')=='') $('comentariu_articol').value='Comentariul tău...';		
}

/* START functii pentru salvare oferta */
function submit_formular_comentarii(){
	 if($('review_to_article').onsubmit()==true){//this check triggers the validations
		$('review_to_article').submit();
	 }
}

function submit_formular_comentarii_live(parere){
	url = "/index.php?section=comentarii&screen=index";
	var err ="";
	if (!$F("comentariu_articol_"+parere).trim() > " " || $F("comentariu_articol_"+parere).trim() == "Comentariul tău...") {
		err += " - Comentariul dumneavoastra\n";
		//$("comentariu_articol_"+parere).className = 'incorect';
		$("comentariu_articol_"+parere).focus();
		alert("Urmatoarele campuri nu sunt completate corect: \n"+err);
		return;		
	}
	//alert(1);
	var param = "&object_id="+$F('object_id_'+parere)+"&object_parinte="+$F('object_parinte_'+parere)+"&object_type="+$F('object_type_'+parere)+"&comentariu="+$F('comentariu_articol_'+parere)+"&interval_timp="+$F('interval_timp_'+parere)+"&vot_object="+$F('vot_object_'+parere)+"&date_valide=1&ajax=1";
	new Ajax.Request(url,{
					onComplete: function(resp) {
						load_comentarii_useri($F('object_id_'+parere));
						$("comentariu_articol_"+parere).value = "Comentariul tău...";
						alert("Comentariul tau a fost adaugat!");
					},
					parameters:param, 
					method:'post'
	}); 
}

function quote(id){
	$('add_comentariu').show();
	$('object_parinte').value = id;
	new Effect.ScrollTo('add_comentariu');
	if($('comentariu_articol')) $('comentariu_articol').focus();
}
function quote_live(id,parere){
	$('add_comentariu_'+parere).show();
	$('object_parinte_'+parere).value = id;
	new Effect.ScrollTo('add_comentariu_'+parere);
	if($('comentariu_articol_'+parere)) $('comentariu_articol_'+parere).focus();
}
function comentarii_reports(id, object_type){
	var val_like = parseInt($('imi_place_'+id).innerHTML);
	url = "/index.php?section=articol&screen=comentarii_reports&id="+id+"&object_type="+object_type;
	new Ajax.Request(url,{
					 onComplete: function(resp) {
						 			//alert(val_like);
						 			if(resp.responseText!="Ati votat deja acest comentariu!") $('imi_place_'+id).innerHTML = val_like+1;
									alert(resp.responseText);
								 }
	});
}

var vot_img_title = new Array();
vot_img_title[1] = "Slab";
vot_img_title[2] = "Ok";
vot_img_title[3] = "Bun";
vot_img_title[4] = "Foarte bun";
vot_img_title[5] = "Excelent";
/* functii pentru voting object*/
/* autor Tudor */
function show_full_stars(i,total,object_type,img1_name,img2_name){
	for(j=1;j<=i;j++)
	{
		$(object_type+"_"+j).src=img1_name;
		$(object_type+"_"+j).title=vot_img_title[j];
	}
	for(j=i+1;j<=total;j++)
	{
		$(object_type+"_"+j).src=img2_name;
		$(object_type+"_"+j).title=vot_img_title[j];
	}
}
function hide_full_stars(i,total,object_type,img1_name,img2_name)
{
	for(j=1;j<=i;j++)
	{
		$(object_type+"_"+j).src=img1_name;
	}
	for(j=i+1;j<=total;j++)
	{
		$(object_type+"_"+j).src=img2_name;
	}
}
function vote_object(object_id,object_type,nota){
	var url="/?section=voting&screen=index&object_id="+object_id+"&object_type="+object_type+"&nota="+nota;
	new Ajax.Request(
		url,
		{
		onCreate: function() {$('votare').update("<div style='se_incarca'>Se incarca ...</div>");},
		onSuccess: function(resp) {$('votare').update(resp.responseText);}
		}
	);				
}
function mm_update_cnt(a)
{
	$('galerie_poz').innerHTML = a;
}

var more_text = 1;
function show_hide_more_text(){
	if(more_text==1){
		$('text_mult').show();
		$('text_mult_text').innerHTML = "Mai puţin text";
		more_text=2;
	} else{
		$('text_mult').hide();
		$('text_mult_text').innerHTML = "Mai mult text";
		more_text=1;		
	}
}


function show_hide_more_article(id){
	if(eval('more_article_'+id+'==1')){
		$('articole_cnt_'+id).show();
		$('articole_text_'+id).innerHTML = "Mai puţine articole";
		eval('more_article_'+id+'=2;');
	} else{
		$('articole_cnt_'+id).hide();
		$('articole_text_'+id).innerHTML = "Mai multe articole";
		eval('more_article_'+id+'=1;');
	}
}
function load_hp_news(url,post,a)
{
	new Ajax.Updater('hp_news', url,{parameters:post, method:'post' });
	$("hp_news_clp_1").className = 'clp a_clp_1 sans_bold';
	$("hp_news_clp_2").className = 'clp a_clp_2 sans_bold';
	$("hp_news_clp_3").className = 'clp a_clp_1 sans_bold';
	$("hp_news_clp_"+a).className = 'clp a_clp_1 sans_bold a_clp_act';
}
function load_hp_news2(url,post,a)
{
	new Ajax.Updater('hp_news', url,{parameters:post, method:'post' });
	$("hp_news_clp_1").className = 'clp a_clp_1 sans3_bold';
	$("hp_news_clp_2").className = 'clp a_clp_2 sans3_bold';
	$("hp_news_clp_3").className = 'clp a_clp_1 sans3_bold';
	$("hp_news_clp_"+a).className = 'clp a_clp_1 sans3_bold a_clp_act';
}

function showHideMoreArticle(id,articole_ids){
//	var param="cat_id="+id+"&from="+from;	
	var param = {};
	param.cat_id = id;
	param.articole_ids=articole_ids.toJSON();
	if(eval('more_article_'+id+'==1')){
		if($('articole_cnt_'+id).innerHTML>' '){

		} else{
			new Ajax.Updater('articole_cnt_'+id, '/index.php?section=section&screen=more_articles', {parameters:param, method:'post' });
		}
		$('articole_cnt_'+id).show();
		$('articole_text_'+id).innerHTML = "Restrânge caseta";
		eval('more_article_'+id+'=2;');
	} else{
		$('articole_cnt_'+id).hide();
		$('articole_text_'+id).innerHTML = "Mai multe articole";
		eval('more_article_'+id+'=1;');
	}
}

function showHideTitleBox(id){
	if(eval('show_var_'+id+'==2')){
		$('show_cnt_'+id).hide();
		$('show_img_'+id).src="/images/deschide_categoria.png";		
		eval('show_var_'+id+'=1;');
	} else{
		$('show_cnt_'+id).show();
		$('show_img_'+id).src="/images/inchide_categoria.png";		
		eval('show_var_'+id+'=2;');
	}
}

var show_explicatie = 1;
function showExplicatieFoto(){
	if(show_explicatie==1){
		show_explicatie = 0;
		//nav.options.show_explicatie=0;
		$('explicatie_galerie').innerHTML = "Afisează explicaţia";
		$$('.banda_explicatii_text').each(
			function (poElement){
				poElement.hide();
			}
		);
		$$('.banda_explicatii').each(
			function (poElement){
				poElement.hide();
			}
		);		
	} else{
		show_explicatie = 1;
		//nav.options.show_explicatie=1;
		$('explicatie_galerie').innerHTML = "Ascunde explicaţia";
		$$('.banda_explicatii_text').each(
			function (poElement){
				poElement.show();
			}
		);
		$$('.banda_explicatii').each(
			function (poElement){
				poElement.show();
			}
		);				
	}
}

function expand(divToExpand_ext, divToExpand_int, expandIcon,cssClass){
	
	 //update all input fields with class MyClass under this row
    searchStr = 'li.'+cssClass+'_li';
    results = $$(searchStr);
    results.each(function(elem){
        //call helper function to do other cool stuff
		//alert(elem.id);
		
        elem.removeClassName('open');
		elem.addClassName('closed');
     });
	 
	 
	searchStr = 'div.'+cssClass+'_ext';
    results = $$(searchStr);
    results.each(function(elem){
        //call helper function to do other cool stuff
		//alert(searchStr);
		
       // elem.removeClassName('open');
		elem.morph('height:0px');
     });
	 
	searchStr = 'img.'+cssClass+'_img';
    results = $$(searchStr);
    results.each(function(elem){
        //call helper function to do other cool stuff
		//alert(searchStr);
		
       // elem.removeClassName('open');
		elem.setStyle({'background':'url("/images/icons/plus.png") no-repeat scroll 0 0 transparent'});
     });
	 
	 
	
	if($(divToExpand_ext).offsetHeight == 0){
		var h = $(divToExpand_int).offsetHeight;
		$(divToExpand_ext).morph('height:'+h+'px');
		$(expandIcon).setStyle({'background':'url("/images/icons/minus.png") no-repeat scroll 0 0 transparent'});
	} else {
		$(divToExpand_ext).morph('height:0px');
		$(expandIcon).setStyle({'background':'url("/images/icons/plus.png") no-repeat scroll 0 0 transparent'});
	}
}

//functie ce returneaza numarul caractere available la un moment la un comentariu
/* autor Tudor */
function comentariu_change()
{
	max_length = 700;
	length_val = $('comentariu_articol').value.length;
	$('comentariu_status').innerHTML = max_length-length_val;
	if(length_val>max_length)
	{
		$('comentariu_articol').value = $('comentariu_articol').value.substr(0,max_length);
		$('comentariu_status').innerHTML = 0;
		$('comentariu_articol').scrollTop = $('comentariu_articol').scrollHeight;
	}
	if($('comentariu_status').innerHTML==0) $('comentariu_status').style.color = "#CA0002";
	else $('comentariu_status').style.color = "#777777";
}

/* deschide un popup centrat neresizeble*/
function print_article(url,width,height)
{
	xpoz=Math.round((screen.width-width)/2);
	ypoz=Math.round((screen.height-height)/2);
	if (xpoz<0) xpoz=10;
	if (ypoz<0) ypoz=10;
	newWindow=window.open (url ,'mywindow','toolbar=no, scrollbars=yes, resizable=no ,width='+width+',height='+height+', left='+xpoz+', top='+ypoz);
	newWindow.focus();
}

/* functii folosite la selectare de editie pdf*/
function timeOutOfRange(date, year, month, day, hours, minutes) {
	//alert(date.print("%Y-%m-%d"));
	if(in_array(date.print("%Y-%m-%d"),RD)) return true;
	
	
	var today = new Date();
	today.setDate(today.getDate());
	
	if ( date.getTime() >= today.getTime()  ||  date.getDay() == 0 || date.getDay() == 6) { //No weekend
		return true;
	}
	
	
	return false;
}

function closeCal(cal){
	
		var date = explode('-',$('calendar').value);
		$('zi').value = date[2];
		$('luna').value = date[1];
		$('an').value= date[0];
		
	
		cal.hide();
			pdfChangeDate();
		
}

function pdfChangeDate(){
		var d = $('an').value+'-'+$('luna').value+'-'+$('zi').value;
		document.location = '/pdf-'+d+'.html';	
}

/* end functii folosite la selectare de editie pdf*/


function togglim(cnt,img)
{
	$(cnt).toggle();
	//alert($(img).src);
	if($(img).src == 'http://www.jurnalul.ro/images/icons/login_arr.png')
	{
		$(img).src = '/images/inchide_categoria.png';
	}
	else if($(img).src == 'http://wwww.jurnalul.ro/images/icons/login_arr.png')
	{
		$(img).src = '/images/inchide_categoria.png';
	}
	else $(img).src = '/images/icons/login_arr.png';
	
}

function chCop(src,text)
{
	$('cop1').src = src;
	$('copt1').innerHTML = text;
	
	$('cop2').hide();
	$('copt2').hide();
	
	$('cop3').hide();
	$('copt3').hide();
	
}
function create_cookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function read_cookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function erase_cookie(name) {
	createCookie(name,"",-1);
}


function reseteaza_preview() {
	document.cookie = "editie_preview='';expires=Thu, 01-Jan-1970 00:00:01 GMT;path=/";
	window.location='/';
}

/*meteo*/
function changeClap(clapeta,prefix_clapeta,nr_clapete)
{
	for(var i=1;i<=nr_clapete;i++){
		$(prefix_clapeta+i).removeClassName("act");
	}
	$(prefix_clapeta+clapeta).addClassName("act");
}

function changeShop(categorie,colectie,i)
{
	
	if(i>0)
	{
		for(j=1;j<=2;j++)
		{
			if(j!=i)
			{
				 $('shop'+j).removeClassName('act');
				
			}
		}
	
		$('shop'+i).addClassName('act');
	}
	
	
	url = "/index.php?section=ajax&screen=shop_jurnalul&categorie="+categorie+"&colectie="+colectie;
	new Ajax.Updater('aj_shop', url, {
		evalScripts:true, parameters: {}
	});
	
	
}

function laminutHide(i)
 {
	var searchStr;
	var results;
	if(i=='toate')
	{
		searchStr = 'li.stirelaminut';
		results = $$(searchStr);
		results.each(function(elem){
			//call helper function to do other cool stuff
			//alert(elem);
			elem.style.display = '';
		 });	
		 return;
		
	}
	
	searchStr = 'li.stirelaminut';
    results = $$(searchStr);
    results.each(function(elem){
        //call helper function to do other cool stuff
		//alert(elem);
        elem.style.display = 'none';
     });
	
	
  //update all input fields with class MyClass under this row
    searchStr = 'li.stire'+i;
    results = $$(searchStr);
    results.each(function(elem){
        //call helper function to do other cool stuff
		//alert(elem);
        elem.style.display = '';
     });
	 
	 
 }
 
function change_video(articol_id,video_id){
	var param = "&articol_id="+articol_id+"&video_id="+video_id;
	new Ajax.Updater('galerie_video', '/?section=articol&screen=ivm', {evalScripts:true,parameters:param, method:'post' });
} 
 
function show_top_autor(selected,autor_id){
	var param = "&selected="+selected+"&autor_id="+autor_id;
	new Ajax.Updater('top_cnt', '/?section=cautare&screen=info_autor', {evalScripts:true,parameters:param, method:'post' });
}

var cur_pag = -1;
function change_pagina_blog(pagina, caseta_id){
	if(cur_pag!=pagina){
		cur_pag = pagina;
		var param = "&pagina="+pagina+"&caseta_id="+caseta_id;
		new Ajax.Updater('blogsport', '/?section=ajax_casete&screen=blogsport', {evalScripts:true,parameters:param, method:'post' });
	}
}

function insertIvmIntoId(guid,id,width,height) {
//        document.getElementById('playButton').style.display = 'none';
//        activeHighlights = 0;
 //       var elem = document.getElementById('homePlayer');
//        elem.innerHTML = '';
//        elem.style.display = 'block';
        var script = document.createElement('script');
        script.setAttribute("type","text/javascript");
        var src = 'http://ivm.inin.ro/js/embed.js?wide=auto&width='+width+'&height='+height+'&id='+guid + '&div_id='+id;
        script.setAttribute("src", src);
      //  document.getElementById('highlightsImage' + selectedHighlight).style.display = 'none';
        document.getElementsByTagName('head')[0].appendChild(script); 
}


function insertJavaScript(JavaScriptUrl) {
        var script = document.createElement('script');
        script.setAttribute("type","text/javascript");
        var src = JavaScriptUrl;
        script.setAttribute("src", src);
        document.getElementsByTagName('head')[0].appendChild(script); 
}


function insertEmbed(embed,id) {
 	$(id).innerHTML = embed;
}

fs_original= 14;
fs_pas = 0;
fs_actual = 0;
function plus_text() {
	fs_pas+=2;
	fs_actual = fs_original + fs_pas;
	if(fs_actual>=20){
		fs_actual = 20;
		fs_pas = 6;
	}
	$("only_text").style.fontSize = fs_actual + "px";
}
function minus_text() {
	fs_pas-=2;
	if(-fs_pas>fs_original)
	{
		fs_pas = -fs_original;
		return;
	}
	fs_actual = fs_original + fs_pas;
	if(fs_actual<=8){
		fs_actual = 8;
		fs_pas = -6;
	}	
	
	$("only_text").style.fontSize = fs_actual + "px";
}

function pop_up_spec_events(a,b,c,d)
{
	Event.observe($(a),'mouseover',function(){
		eval(c+'=1;');
		pop_up_spec_show(a,b,c,d)
	});
	Event.observe($(b),'mouseover',function(){
		eval(c+'=1;');
		pop_up_spec_show(a,b,c,d)
	});
	Event.observe($(a),'mouseout',function(){
		eval(c+'=0;');
		pop_up_spec_show(a,b,c,d)
	});
	Event.observe($(b),'mouseout',function(){
		eval(c+'=0;');
		pop_up_spec_show(a,b,c,d)
	});	
}

function pop_up_spec_show(a,b,c,d)
{
	c = eval(c);
	if(c==0)
	{
		$(b).style.display = 'none';
		if(d==1) $(a).src = '/images/articol/share/share_plus.gif';
	}
	else
	{
		$(b).style.display = 'inline';
		if(d==1) $(a).src = '/images/articol/share/share_minus.gif';
	}	
}

//start nav caseta arrows prev next
function caseta_get_prev_news(id_caseta,callBack){
	var tmp =  id_caseta;
	
	item_str = 'cid_' + tmp + '_';
	next = 'next_' + tmp;
	prev = 'prev_' + tmp;
	current_item = eval("caseta_current_news_" + tmp);
	
	if(current_item == 0){
		return false;	
	}else{
		$(next).src = '/images/icons/right_miniarr.png';
		caseta_get_current_news(current_item-1,id_caseta);
		if(callBack>" "){
			eval(callBack+"("+(current_item - 1)+","+id_caseta+")");	
		}
		if(current_item == 1){
			$(prev).src = '/images/icons/left_miniarr_inact.png';
		}
		return true;
	}
}

function caseta_get_next_news(id_caseta,caseta_max_news,callBack){
	var tmp =  id_caseta;
	
	item_str = 'cid_' + tmp + '_';
	next = 'next_' + tmp;
	prev = 'prev_' + tmp;
	current_item = eval("caseta_current_news_" + tmp);
	//alert(eval("caseta_additionals_"+id_caseta));
	if(current_item == caseta_max_news-1){
		return false;
	}else{
		$(prev).src = '/images/icons/left_miniarr.png';
		caseta_get_current_news(current_item + 1,id_caseta);
		if(callBack>" "){
			eval(callBack+"("+(current_item + 1)+","+id_caseta+")");	
		}
		//alert(id_caseta);
		if(current_item == caseta_max_news-2){
			$(next).src = '/images/icons/right_miniarr_inact.png';
		}
		return true;
	}
}	


function caseta_get_prev_news_rotate(id_caseta,caseta_max_news,callBack){
	var tmp =  id_caseta;
	current_item = eval("caseta_current_news_" + tmp);
	if(current_item == 0){
		current_item = caseta_max_news-1;
		caseta_get_current_news(current_item,id_caseta);
		return false;	
	}else{
		caseta_get_current_news(current_item-1,id_caseta);
		if(callBack>" "){
			eval(callBack+"("+(current_item - 1)+","+id_caseta+")");	
		}
		return true;
	}
}

function caseta_get_next_news_rotate(id_caseta,caseta_max_news,callBack){
	var tmp =  id_caseta;
	current_item = eval("caseta_current_news_" + tmp);
	if(current_item == caseta_max_news-1){
		current_item = 0;
		caseta_get_current_news(current_item,id_caseta);
		return false;
	}else{
		caseta_get_current_news(current_item + 1,id_caseta);
		if(callBack>" "){
			eval(callBack+"("+(current_item + 1)+","+id_caseta+")");	
		}
		return true;
	}
}



function rotate(caseta_id, all_news){
	eval("var current =  " +caseta_id + ";");
	if(current == (all_news-1)){
		eval("caseta_current_news_" +caseta_id + " = 0;");
		$('cid_' + caseta_id + '_' + (all_news-1)).hide();
		$('cid_' + caseta_id + '_0').show();
		//eval("clearInterval(intervalNews_" + caseta_id + ");");
		return false;
	}
	
	caseta_get_next_news_rotate(caseta_id,all_news);
	//eval("caseta_get_next_news_rotate('"+caseta_id+"',"+all_news+");");
	//eval("clearInterval(intervalNews_" + caseta_id + ");");
	eval("var current = caseta_current_news_" +caseta_id + ";");
}

function caseta_get_current_news(selected_item,id_caseta){
	var tmp =  id_caseta;
	item_str = 'cid_' + tmp + '_';
	if($(item_str+eval('caseta_current_news_'+id_caseta)) != null){
		$(item_str+eval('caseta_current_news_'+id_caseta)).hide();
	}else{
		return false;	
	}
	caseta_current_news = eval("caseta_current_news_" + id_caseta + " = "+selected_item);
	$(item_str+caseta_current_news).show();
	return false;
}
function caseta_change_additionals(selected_item,id_caseta){
	var tmp =  id_caseta;
	caseta_current_news = eval("caseta_current_news_"  + id_caseta + " = "+selected_item);
	$('cid_' + id_caseta+"_img").src= eval("imgArr"+id_caseta)[caseta_current_news]['url'];
	$('cid_' + id_caseta+"_img").alt= eval("imgArr"+id_caseta)[caseta_current_news]['desc'];
	$('cid_' + id_caseta+"_lnk").title= eval("imgArr"+id_caseta)[caseta_current_news]['desc'];
	$('cid_' + id_caseta+"_lnk").href= eval("imgArr"+id_caseta)[caseta_current_news]['link'];
	return false;
}

function show_quicklinks(par){
	if(par==1){
		$('arrow_img').src = "/images/arrow_down.png";
		$('quicklinks').style.display = "block";
		$('show_quicklinks').className = "menu_item serif_bold quicklinks_over";
	}else{
		$('arrow_img').src = "/images/arrow_right.png";		
		$('quicklinks').style.display = "none";
		$('show_quicklinks').className = "menu_item serif_bold";				
	}
}

function show_secondsubmenu(par){
	if(par==1){
		if($('arrow_img_submenu')) {
			$('arrow_img_submenu').src = "/images/arrow_down_submenu.png";
			$('secondsubmenu').style.display = "block";
			$('show_secondsubmenu').className = "submenu_item serif_bold text_6 color_2 secondsubmenu_over";
		}
	}else{
		if($('arrow_img_submenu')) {
			$('arrow_img_submenu').src = "/images/arrow_right_submenu.png";		
			$('secondsubmenu').style.display = "none";
			$('show_secondsubmenu').className = "submenu_item serif_bold text_6 color_2";
		}
	}
}

//end nav caseta arrows prev next



function isPopupBlockerOn(){
	var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
	if(mine)
		var popUpsBlocked = false
	else
		var popUpsBlocked = true
	mine.close()
	return popUpsBlocked;
}

function ads_debug(){
	if(isPopupBlockerOn()){
		alert('Va rugam sa dati accept la aparitia popupurilor pentru acest feature');
	}
 	var generator=window.open('http://nou.gsp.ro/index.php?section=empty&screen=index','gsp_debug','height=500,width=600,scrollbars');
	
	generator.focus();
	if(generator && !generator.closed)
	{
		//generator.document.body.parentNode.innerHTML = '';
	}
    generator.document.write('<html><head><title>Gsp Ads Debug - zona '+ zona_banner +'</title></head><body><h3>Zona '+ zona_banner +'</h4>');
	ids = document.getElementsByTagName('div');
	var buff  = '';
//	alert(ids);
	var current_id = '';
	for (var i = 0; i < ids.length; i++)
	{
		current_id = ids[i].id;
		if(current_id.indexOf('adocean',0)==0)
		{
			if(ids[i].innerHTML == '')
			{
				slot = "<span style='background:#ff0'>&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;<strong style='color:#666;font-size:14px;'>" + current_id + "</strong> ("+ adsdbg_slot_by_id[current_id] + ")";
				$('span_debug_'+current_id).style.backgroundColor = '#ff0';
				$('span_debug_'+current_id).style.color = '#000';
				mesaj = '&nbsp;&nbsp;&nbsp;codul nu a livrat';
			}
			else
			{
				slot = "<span style='background:#7f7'>&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;<strong style='color:#666;font-size:14px;'>" + current_id + "</strong> ("+ adsdbg_slot_by_id[current_id] + ")";
				mesaj = '&nbsp;';
			}
			
			buff+=report_row(slot,mesaj);
		}
	}
	for(k in banner_slot_missing_added_codes)
	{
		slot = "<span style='background:#f00'>&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;<strong style='color:#666;font-size:14px;'>" + k + "</strong> ("+ banner_slot_missing_added_codes[k] + ")";
		mesaj = '&nbsp;&nbsp;&nbsp;cod neintrodus in pagina';
		buff+=report_row(slot,mesaj);
	}
	for(k in banner_slot_missing)
	{
		slot = "<span style='background:#f90'>&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;<strong style='color:#666;font-size:14px;'>" + k + "</strong>";
		mesaj = '&nbsp;&nbsp;&nbsp;lipsa cod';
		buff+=report_row(slot,mesaj);
	}
	
/*	banner_slot_missing_added_codes.each(function(v,k){
		slot = k + "( "+ v + " ) ";
		mesaj = 'lipsa';
		buff+=report_row(slot,mesaj);
	})*/

	generator.document.write(report_header());
	generator.document.write(buff);
	generator.document.write(report_footer());
    generator.document.write('</body></html>');
    generator.document.close();
}

function gsp_tv_links(ID){
	
	//show right content
	$('right_videos').cleanWhitespace();
	
	var tmpArr = $('right_videos').childNodes;
	var countAll = tmpArr.length;
	
	$$('.categ_divs').each(
		function (poElement){
			poElement.hide();
		}
	);
	$('categ_' + ID).show();
	
	ID = 'gds_tv_id_' + ID;
	$('ul_categories').cleanWhitespace();
	var tmpArr = $('ul_categories').childNodes;
	var countAll = tmpArr.length;
	
	$$('.selected_gsp_tv_lin_kink').each(
		function (poElement){
			poElement.removeClassName('selected_gsp_tv_lin_kink');
		}
	);
	
	$(ID).addClassName('selected_gsp_tv_lin_kink');
	last_gsp_tv_link = ID;
	catContor = parseInt(last_gsp_tv_link.substr(last_gsp_tv_link.lastIndexOf("_")+1));
	if(catContor <= 1){
		//obj.writeAttribute("src","/images/icons/arrow_up_disabled.png");
		//IE Fix
		z = document.createAttribute('src');
		z.value = '/images/icons/arrow_up_disabled.png';
		$('nav_up').setAttributeNode(z);
	}else{
		z = document.createAttribute('src');
		z.value = '/images/icons/arrow_up.png';
		$('nav_up').setAttributeNode(z);	
	}
	if(catContor >= countAll){
		//obj.writeAttribute("src","/images/icons/arrow_down_disabled.png");
		//IE Fix
		z = document.createAttribute('src');
		z.value = '/images/icons/arrow_down_disabled.png';
		$('nav_down').setAttributeNode(z);
	}else{
		z = document.createAttribute('src');
		z.value = '/images/icons/arrow_down.png';
		$('nav_down').setAttributeNode(z);	
	}
	
}
function gsp_tv_go_to_categ(obj,direction){
	$('ul_categories').cleanWhitespace();
	var tmpArr = $('ul_categories').childNodes;
	var countAll = tmpArr.length;
	
	$$('.selected_gsp_tv_lin_kink').each(
		function (poElement){
			poElement.removeClassName('selected_gsp_tv_lin_kink');
		}
	);
	if(direction == 'up'){
		if(catContor != 1){
			catContor = parseInt(last_gsp_tv_link.substr(last_gsp_tv_link.lastIndexOf("_")+1)) - 1;
			if($('categ_' + parseInt(catContor+1))){
				$('categ_' + parseInt(catContor+1)).hide();
				$('categ_' + catContor).show();
			}
			last_gsp_tv_link = catContor;
			//obj.next().writeAttribute("src","/images/icons/arrow_down.png");
			//IE Fix
			var tmpObj = obj.nextSibling;
			z = document.createAttribute('src');
			z.value = '/images/icons/arrow_down.png';
			tmpObj.setAttributeNode(z);
		}
	}else{
		if(catContor != countAll){
			catContor = parseInt(last_gsp_tv_link.substr(last_gsp_tv_link.lastIndexOf("_")+1)) + 1;
			last_gsp_tv_link = catContor;
			if($('categ_' + parseInt(catContor+1))){
				$('categ_' + parseInt(catContor-1)).hide();
				$('categ_' + catContor).show();
			}
			//obj.previous().writeAttribute("src","/images/icons/arrow_up.png");
			//IE Fix
			var tmpObj = obj.previousSibling;
			z = document.createAttribute('src');
			z.value = '/images/icons/arrow_up.png';
			tmpObj.setAttributeNode(z);
		}
	}
	last_gsp_tv_link = 'gds_tv_id_' + catContor;
	if($(last_gsp_tv_link)){
		$(last_gsp_tv_link).addClassName('selected_gsp_tv_lin_kink');
	}
	//alert(last_gsp_tv_link);
	
	if(catContor == 1){
		//obj.writeAttribute("src","/images/icons/arrow_up_disabled.png");
		//IE Fix
		z = document.createAttribute('src');
		z.value = '/images/icons/arrow_up_disabled.png';
		obj.setAttributeNode(z);

	}
	if(catContor == countAll){
		//obj.writeAttribute("src","/images/icons/arrow_down_disabled.png");
		//IE Fix
		z = document.createAttribute('src');
		z.value = '/images/icons/arrow_down_disabled.png';
		obj.setAttributeNode(z);
	}
}

function get_current2(no_pic,src,url,caseta_id){
	Event.observe('img_' + no_pic + '_' + caseta_id, 'click', function(event) {
		Event.cancelBubble = true;
		if (Event.stopPropagation) Event.stopPropagation();
	});
	//to work on IE6 to
	z = document.createAttribute('href');
	z.value = url;
	$('a_pic' + '_' + caseta_id).setAttributeNode(z);

	//to work on IE6 to
	z = document.createAttribute('src');
	z.value = src;
	$('img_pic' + '_' + caseta_id).setAttributeNode(z);
}

function get_prev_next(no_pic,max_pics,caseta_id){
	if(no_pic == 0 || no_pic > max_pics){
		return false;
	}else{
		if(no_pic != 1 && no_pic != max_pics){
			$('img_' + no_pic + '_' + caseta_id).className = "middle";
			$('img_' + parseInt(no_pic-1) + '_' + caseta_id).className = "sides";
			$('img_' + no_pic + '_' + caseta_id).show();
			
			$('img_' + parseInt(no_pic+1) + '_' + caseta_id).className = "sides";
			
			if($('img_' + parseInt(no_pic-2) + '_' + caseta_id)){
				$('img_' + parseInt(no_pic-2) + '_' + caseta_id).hide();
			}
			if($('img_' + parseInt(no_pic+2) + '_' + caseta_id)){
				$('img_' + parseInt(no_pic+2) + '_' + caseta_id).hide();
			}
			
			$('img_' + parseInt(no_pic-1) + '_' + caseta_id).show();
			$('img_' + parseInt(no_pic+1) + '_' + caseta_id).show();
			eval("current_pic_" + caseta_id + " = no_pic;")
		} 
	}
}





//by adrian
var lang_msg = new Array();
lang_msg['no_last_name'] = 'Nu ati completat numele';
lang_msg['no_first_name'] = 'Nu ati completat prenumele';
lang_msg['no_email'] = 'Nu ati completat adresa de email';
lang_msg['invalid_email'] = 'Adresa de email nu este valida';
lang_msg['no_address'] = 'Nu ati completat adresa';
lang_msg['no_city'] = 'Nu ati completat localitatea';
lang_msg['no_county'] = 'Nu ati completat judetul';
lang_msg['no_disclaimer'] = 'Nu sunteti de acord cu termenii si conditiile';


// echivalentul functiei implode din PHP
function implode(chunk, array)
{
	var maxim = array.length;
	var response = '';
	for (I=0; I<maxim; I++)
	{
		response += array[I];
		if (I < (maxim-1))
		{
			response += chunk;
		}
	}
	return response;
}

function concurs_validation(arr,form,vFld)
{	
	if(form===undefined){ form = "my_form"; }
	if(vFld===undefined){ vFld = "checkSend"; }
	var err = new Array();
	
	var I = 0;
	
	for(var i=0;i<arr.length;i++){
		if($(arr[i]).value.length < 1){
			err[I] = ' '+lang_msg['no_'+arr[i]];
			I++;
		} else 
		if($(arr[i]).name=='email' && !concurs_validate($(arr[i]).value)){
			err[I] = ' '+lang_msg['invalid_email'];
			I++;
		} else
		if ($(arr[i]).type=="checkbox"&&!$(arr[i]).checked){
			err[I] = ' '+lang_msg['no_disclaimer'];
			I++;	
		}
	}
	
	if (err.length > 0)
	{
		alert(implode("\r\n", err));
		return false;
	}
	else
	{
		$(vFld).value=")(*&^%";
		return true;
	}
	return false;
}

function concurs_validate(email)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if(reg.test(email) == false)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function setQuoteCookie(id){
	var curCookie = "quote="+id+";path=/";
	document.cookie = curCookie;
}

function showHideOptions(){
	if(showOpt == false){
		$('div_options').style.display='block';
		showOpt = true;
	}else{
		$('div_options').style.display='none';
		showOpt = false;
	}
}
function selectOption(obj,id,nume){
	//$('alege_postul_1').innerHTML = obj.innerHTML;
	//showHideOptions();	
	window.location.href = '/program-tv/'+nume+'-'+id+'.html';
}

function showHideDateOptions(obj){
	//alert(obj.style.display); return false;
	
	if(obj.style.display == 'none'){
		obj.style.display='block';
	}else{
		obj.style.display='none';
		return false;
	}

	
	obj.click_out_in = 'out';
	Event.observe(obj,'mouseout',function(){
		obj.click_out_in='out';
	});
	Event.observe(obj,'mousedown',function(){
		obj.click_out_in='in';
	});
	Event.observe(obj,'mouseleave',function(){
		obj.click_out_in='out';
	});
	Event.observe(obj,'mouseenter',function(){
		obj.click_out_in='in';
	});

	Event.observe(document,'mousedown',function(){
		if(obj.click_out_in=='out' && obj && obj.style.display!='none'){
			obj.hide();
		}
	});
}

function goToURL(url){
	window.location.href = url;
}
function select_all_new_radio(){
    	$('radioscript').focus();
    	$('radioscript').select();
}

/*Start caseta convertor valutar*/
function convert(obj){
	var valToChange = obj.value;
	var rate = $('moneda_in').getAttributeNode('value').value;
	var from = $('moneda_from').getAttributeNode('value').value;
	$('rezultat').innerHTML = (valToChange*from/rate).toFixed(2);	
	$('rezultat_tva').innerHTML = (valToChange*from/rate*1.24).toFixed(2);
	$('valoare_tva').innerHTML = (valToChange*from/rate*1.24*0.24).toFixed(2);
}
function change_moneda(obj,obj_to_set,obj_label){
	obj_to_set.getAttributeNode('value').value = obj.getAttributeNode('value').value;
	obj_label.innerHTML = obj.innerHTML;
	
	if($('sum').value){
		convert($('sum'));
	}
	obj.parentNode.style.display = 'none';			
}
function interchange_currency(obj_from,obj_label_from,obj_in,obj_label_in){
	var from_val = obj_from.getAttributeNode('value').value;
	var from_label = obj_label_from.innerHTML;
	var in_val = obj_in.getAttributeNode('value').value;
	var in_label = obj_label_in.innerHTML;
	obj_from.getAttributeNode('value').value = in_val;
	obj_label_from.innerHTML = in_label;
	obj_in.getAttributeNode('value').value = from_val;
	obj_label_in.innerHTML = from_label;
	if($('sum').value){
		convert($('sum'));
	}
}
/*END caseta convertor valutar*/

/* pentru sondaj concurs*/

function voteaza_superlative(nr){
	form_name = eval("document.myform_"+nr);
	captcha = $("captcha"+nr).value;
	var t_option = '';
	for(i=0;i<form_name.sondaj.length;i++)
	{
		if(form_name.sondaj[i].checked)
		{
			t_option = form_name.sondaj[i].value;
			break;
		}
	}
	if (t_option=='') {alert("Trebuie sa alegi o optiune");}
	else{
		var url="/?section=concursuri&screen=voting&ajax=1&tip_sondaj="+nr+"&id_nume="+t_option+'&captcha='+captcha;
		
		new Ajax.Request(
			url,
			{
			//onCreate: function() {$('sondaj_'+nr).update("<div style='width:320px; font-size:12px; font-weight:bold'>Se incarca ...</div>");},
			onSuccess: function(resp){
				if(resp.responseText=='eroare captcha') {
					alert('Te rugam sa completezi codul captcha!');
					return;
				}
				$('sondaj_'+nr).update(resp.responseText);
				
			}
			}
		);
	}
}

