function windowPop(url, t, w, h)
{
	window.open(url,t,
		'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=yes,'+
		'scrollbars=no,width='+w+',height='+h+',left=200,top=200');
	return true;
}

function printArticle( aid )
{
	url = 'printArticle.php?aid='+aid;
	t   = 'articlePrint';
	w   = 550;
	h   = 400;
	window.open(url,t,
		'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=yes,'+
		'scrollbars=yes,width='+w+',height='+h+',left=200,top=200');
}

//CRAWL
var currentCrawlNode = 1;
function changeCrawl()
{
	if( currentCrawlNode<crawlItems/2 ) currentCrawlNode++;
	else currentCrawlNode = 1;
	t = 36*(currentCrawlNode-1)*(-1);
	$('#crawl').children('ul').animate({top:t},500);
	setTimeout('changeCrawl()',5000);
}
$(document).ready(function(){setTimeout('changeCrawl()',5000)});


//ANIMEAZA TEXT
function changeTextPart( wNr, tm, h, parts )
{
	if( currentTextPart[wNr]<parts ) currentTextPart[wNr]++;
	else currentTextPart[wNr] = 1;
	t = h*(currentTextPart[wNr]-1)*(-1);
	$('#text_anim_'+wNr).children('div').animate({top:t},500);
	ttm = tm*1000;
	setTimeout('changeTextPart('+wNr+','+tm+','+h+','+parts+')',ttm);
}
//$(document).ready(function(){setTimeout('changeCrawl()',5000)});


//Harta RFI
function arataHarta()
{
	var newdiv = document.createElement('div');
   	newdiv.setAttribute('id', 'hartaRFI');
	document.body.appendChild(newdiv);
	rNr = Math.random();
	flashvars = {
		xmlList:"harta_parteneri/harta.xml?r="+rNr
	};
	params = {
		wmode: "transparent",
		allowScriptAccess: "always",
		allowNetworking: "all",
		allowFullScreen: "true"
	};
	attributes = { wmode: "transparent" };
	rNr = Math.random();
	swfobject.embedSWF("harta_parteneri/harta2.swf?r="+rNr, 'hartaRFI', 850, 600, "10","swfobject/expressInstall.swf", flashvars, params, attributes);
	theH = $(window).height();
	theW = $(window).width();
	theT = (theH-600)/2;
	theL = (theW-850)/2;
	$('#hartaRFI').css('top',theT+'px');
	$('#hartaRFI').css('left',theL+'px');
	$('#hartaRFI').css('position','fixed');
	$('#hartaRFI').css('border','2px solid #FFF');
	$('#hartaRFI').show(500);
}
function inchideHarta()
{
	$('#hartaRFI').remove();
}

//Arhiva
function arhivaGo( theid, thedir )
{
	c = $('#arhiva_'+theid).children('.arhivaContinut');
	$(c).html('<img src="images/design/loading_s2.gif" />');
	t = $('#arhiva_'+theid).children('.arhivaLuna');
	if( thedir == "st" ) thedir = "-";
	else thedir = "+";
	$.post($('base').attr('href')+'widgets/getArhiva.php',{data:$(t).attr('title'), dir: thedir, Widget: theid},function(data){
		$('#arhiva_'+theid).html(data);								  
	})
}
/* SONDAJE WIDGET */
function arataVotareW(theid,wId)
{
	$('#sondaj_votare_w_'+wId+'_'+theid).slideDown(500);
	$('#sondaj_rezultat_w_'+wId+'_'+theid).slideUp(500);
}
function arataRezultateW(theid,wId)
{
	$('#sondaj_rezultat_w_'+wId+'_'+theid).html('<img src="images/design/loading_s2.gif" />');
	$.post('ajax/getSondaj.php',{sondaj: theid},function(data){
		$('#sondaj_rezultat_w_'+wId+'_'+theid).html(data);			   
	})
	$('#sondaj_votare_w_'+wId+'_'+theid).slideUp(500);
	$('#sondaj_rezultat_w_'+wId+'_'+theid).slideDown(500);
}
function VoteazaW(theid,wId)
{
	vot = $('input[name=sondaj_intrebare_w_'+wId+'_'+theid+']:checked').val();
	if( vot == null )
	{
		alert('Trebuie sa alegeti o optiune!');
		return false;
	}
	$('#sondaj_rezultat_w_'+wId+'_'+theid).html('<img src="images/design/loading_s2.gif" />');
	$.post('ajax/voteazaSondaj.php',{sondaj: theid, v: vot},function(data){
		arataRezultateW(theid,wId);
	});
}
/*SONDAJE PAGINA*/
function arataVotare(theid)
{
	$('#sondaj_votare_'+theid).slideDown(500);
	$('#sondaj_rezultat_'+theid).slideUp(500);
}
function arataRezultate(theid)
{
	$('#sondaj_rezultat_'+theid).html('<img src="images/design/loading_s2.gif" />');
	$.post('ajax/getSondaj.php',{sondaj: theid},function(data){
		data = data.replace(/snd_filled/g,$('#sondaj_rezultat_'+theid).attr('title'));
		$('#sondaj_rezultat_'+theid).html(data);		   
	})
	$('#sondaj_votare_'+theid).slideUp(500);
	$('#sondaj_rezultat_'+theid).slideDown(500);
}
function Voteaza(theid)
{
	vot = $('input[name=sondaj_intrebare_'+theid+']:checked').val();
	if( vot == null )
	{
		alert('Trebuie sa alegeti o optiune!');
		return false;
	}
	$('#sondaj_rezultat_'+theid).html('<img src="images/design/loading_s2.gif" />');
	$.post('ajax/voteazaSondaj.php',{sondaj: theid, v: vot},function(data){
		arataRezultate(theid);
	});
}
/* AUDIO */
var curListened = '';
function widgetPlayAudio( holder, audioFile )
{
	//alert(curListened);
	if( curListened != "" && document.getElementById(curListened) )
		document.getElementById(curListened).SetVariable("player:jsStop", "");
	$($('#'+holder).parent()).html('<div id="'+holder+'"></div>');
	//holder = $(who).attr('id');
	who    = $('#'+holder);
	curListened = holder;
	//theid  = holder.split('_');
	$(who).html('<img src="images/design/loading_s2.gif" />');
	w = $(who).width();
	$.post('ajax/getAudioFile.php',{audioId: audioFile},function(data){
		data = data.replace(/\r/g,'');
		data = data.replace(/\n/g,'');
		flashvars = {
			mp3: data,
			width: w,
			autoplay: 1,
			showstop: 1,
			showvolume: 1,
			loadingcolor: "00f5f5"
		};
		params = {
			wmode: "transparent",
			allowScriptAccess: "always",
			allowNetworking: "all",
			allowFullScreen: "true"
		};
		attributes = { wmode: "transparent" };
		r = Math.random();
		swfobject.embedSWF("audio_player/player_mp3_maxi.swf?r="+r, holder, w, "20", "10","swfobject/expressInstall.swf", flashvars, params, attributes);
	});
}
/* TOPURI */
function topPlayAudio( holder, audioFile )
{
	if( curListened != "" && document.getElementById(curListened) )
		document.getElementById(curListened).SetVariable("player:jsStop", "");
	who    = $('#'+holder);
	$(who).html('<img src="images/design/loading_s2.gif" />');
	w = $(who).width();
	curListened = holder;
	flashvars = {
		mp3: 'audio/fisiere_topuri/'+audioFile,
		width: w,
		autoplay: 1,
		showstop: 1,
		showvolume: 1,
		loadingcolor: "00f5f5"
	};
	params = {
		wmode: "transparent",
		allowScriptAccess: "always",
		allowNetworking: "all",
		allowFullScreen: "true"
	};
	attributes = { wmode: "transparent" };
	r = Math.random();
	swfobject.embedSWF("audio_player/player_mp3_maxi.swf?r="+r, holder, w, "20", "10","swfobject/expressInstall.swf", flashvars, params, attributes);
}
function topStarOn( ts )
{
	holder = $(ts).parent();
	nrstar = $(ts).attr('title').replace(/star/,'')*1;
	$(holder).children('.ratingStarOn').addClass('ratingStarOff');
	$(holder).children('.ratingStarOn').removeClass('ratingStarOn');
	for( i=1; i <= nrstar; i++ )
	{
		$(holder).children('[title=star'+i+']').removeClass('ratingStarOff');
		$(holder).children('[title=star'+i+']').addClass('ratingStarOn');
	}
}
function topStarOff( ts )
{
	holder = $(ts).parent();
	h      = $(holder).attr('id').split('_');
	nrstar = $('[name=theratingTop_'+h[2]+'_For_'+h[3]+']').val()*1;
	$(holder).children('.ratingStarOn').addClass('ratingStarOff');
	$(holder).children('.ratingStarOn').removeClass('ratingStarOn');
	for( i=1; i <= nrstar; i++ )
	{
		$(holder).children('[title=star'+i+']').removeClass('ratingStarOff');
		$(holder).children('[title=star'+i+']').addClass('ratingStarOn');
	}
}
function topStarSet( ts )
{
	holder = $(ts).parent();
	h      = $(holder).attr('id').split('_');
	nrstar = $(ts).attr('title').replace(/star/,'')*1;
	$('[name=theratingTop_'+h[2]+'_For_'+h[3]+']').val(nrstar);
}
/* METEO */
var curTown = 0;
var meteoData = Array();
function initMeteo()
{
	$.post('ajax/getMeteo.php',{},function(data){
		data = data.split("\n");
		for( i=0; i<data.length;i++ ){
			if( data[i] != "" )
			{
				d = data[i].split('|');
				meteoData.push(d);
			}
		}
		showMeteo();
	});
}
function showMeteo()
{
	$('#infoMeteoImg').html('<img src="http://www.rfi.fr/meteo/commun/img/pictos/'+meteoData[curTown][1]+'.png" height="50" />');
	$('#infoMeteoTemp').html(meteoData[curTown][2]+'&deg;C');
	$('#infoMeteoTown').html('<strong>'+meteoData[curTown][0]+'</strong>');
	curTown++;
	if( curTown > meteoData.length-1 ) curTown = 0;
	setTimeout('showMeteo()',3000);
}

/* INFO EMISIUNE SI BLOGURI */
$(document).ready(function(){
	progr = $('div[id^=program_]');
	for( i=0; i<progr.length;i++)
	{
		progr_name = $(progr[i]).attr('id');
		hover_name = progr_name.replace('program_','hover_program_');
		$('#'+hover_name).width(211);
		$('#'+hover_name).height($(progr[i]).height()+15);
		poz = $(progr[i]).offset();
		$('#'+hover_name).css('top',poz.top);	
		$('#'+hover_name).css('left',poz.left);
		$('#'+hover_name).show();
	}
});
function arataInfoEmisiune( starter, theid, parte )
{
	poz  = $(starter).offset();
	tleft = poz.left+$(starter).width()+5;
	ttop  = poz.top+$(starter).height()/2-37.5;
	if( parte == 'dreapta' )
	{
		tleft = poz.left-95;
		ttop  = poz.top-$(starter).height()/2-10;
	}
	$('div[class*=floaterInfoArrow_]').hide();
	$('div.floaterInfoArrow_'+parte).show();
	$('#floaterInfo').css('top',ttop);
	$('#floaterInfo').css('left',tleft);
	$('#floaterInfo').show();
	$('#floaterInfo_html').html('<img src="images/design/loading_s2.gif" alt="" />');
	$.get($('base').attr('href')+'ajax/infoEmisiune.php',{Id:theid},function(data){
		if( data != "" )
		{
			$('#floaterInfo_html').hide();
			$('#floaterInfo_html').html(data);
			$(document).ready(function(){
				$('#floaterInfo_html').show();
				if( parte == 'dreapta' )
				{
					tleft = poz.left-75-$('#floaterInfo_html').width();
					$('#floaterInfo').css('left',tleft);
				}
			});
		}
		else
			$('#floaterInfo').hide();			
	});
}
function arataInfoBlog( starter, theid, parte )
{
	$('#floaterInfo').show();
	$('#floaterInfo_html').html($('.info_blog_'+theid).html());
	h = $('#floaterInfo_html').height();
	$('#floaterInfo_sup').height(h);
	$('#floaterInfo_html').show();
	poz  = $(starter).offset();
	tleft = poz.left+$(starter).width()+5;
	ttop  = poz.top+$(starter).height()/2-62.5;
	if( parte == 'dreapta' )
	{
		tleft = poz.left-75-$('#floaterInfo_html').width();
		ttop  = poz.top-$(starter).height()/2+62.5;
	}
	$('#floaterInfo').css('top',ttop);
	$('#floaterInfo').css('left',tleft);
	$('div[class*=floaterInfoArrow_]').hide();
	$('div.floaterInfoArrow_'+parte).show();
}
function getBlogInfo( theid )
{
	$.get($('base').attr('href')+'ajax/infoBlog.php',{Id:theid},function(data){
		$('.info_blog_'+theid).html(data);														 
	});
}
function ascundeInfoEmisiune()
{
	$('#floaterInfo').hide();
}
function ascundeInfoBlog()
{
	$('#floaterInfo').hide();
}
/* FLOATING VIDEO PLAYER */
function hideFloatingVideoPlayer()
{
	$('#floatingVideoPlayer').animate({opacity:0},250);
	setTimeout("$('#floatingVideoPlayer').hide()",250);
	setTimeout("$('#underFloatingVideoPlayer').hide()",250);
	$('#floating_video_player').html('');
	$('#closeFloatingVideoPlayer').hide();
}
function initFloatingVideoPlayer()
{
	w = $(document).width();
	h = $(document).height();
	$('#underFloatingVideoPlayer').width(w);
	$('#underFloatingVideoPlayer').height(h);
	$('#underFloatingVideoPlayer').animate({opacity:0.5},0);
	$('#underFloatingVideoPlayer').click(function(){hideFloatingVideoPlayer()});
	$('#underFloatingVideoPlayer').show();
	l = ( $(window).width()-556 )/2;
	t = ( $(window).height()-$('#floatingVideoPlayer').height() )/2;
	$('#floatingVideoPlayer').css('left',l);
	$('#floatingVideoPlayer').css('top',t);
	$('#floatingVideoPlayer').show();
	$('#floatingVideoPlayer').animate({opacity:0},0)
							.animate({
									  opacity: 1
									  },500);
	l2 = l+525;
	t2 = t-10;
	$('#closeFloatingVideoPlayer').css('left',l2);
	$('#closeFloatingVideoPlayer').css('top',t2);
	$('#closeFloatingVideoPlayer').show();
	$('#closeFloatingVideoPlayer').click(function(){hideFloatingVideoPlayer()});
}
/* EMAIL SENDER */
var artToRecommend = "";
function trimiteRecomandareEmail()
{
	$('#raspunsEmailSender').hide();
	if( $('#CatreEmailSender').val() == "" || $('#DeLaEmailSender').val() == "" )
	{
		$('#raspunsEmailSender').show();
		$('#raspunsEmailSender').html('Completeaza campurile obligatorii!');
		$('#raspunsEmailSender').removeClass();
		$('#raspunsEmailSender').addClass('errorMsg');
		return false;
	}
	$('#raspunsEmailSender').show();
	$('#btnTrimiteEmailSender').hide();	
	$('#raspunsEmailSender').html('In curs de trimitere.');
	$('#raspunsEmailSender').removeClass();
	$('#raspunsEmailSender').addClass('succesMsg');
	$.post('ajax/recomandaArticol.php',{ c: $('#CatreEmailSender').val(), d: $('#DeLaEmailSender').val(), m: $('#MesajEmailSender').val(), art: artToRecommend  }, function(data){
		data = data.split('|');
		$('#raspunsEmailSender').html(data[1]);
		$('#raspunsEmailSender').removeClass();
		$('#raspunsEmailSender').addClass(data[0]);
		$('#btnTrimiteEmailSender').show();	
	});
}
function emailThis( art )
{
	artToRecommend = art;
	$('#raspunsEmailSender').hide();
	w = $(document).width();
	h = $(document).height();
	$('#underFloatingEmailSender').width(w);
	$('#underFloatingEmailSender').height(h);
	$('#underFloatingEmailSender').animate({opacity:0.5},0);
	$('#underFloatingEmailSender').click(function(){hideFloatingEmailSender()});
	$('#underFloatingEmailSender').show();
	l = ( $(window).width()-556 )/2;
	t = ( $(window).height()-$('#floatingEmailSender').height() )/2+150;
	$('#floatingEmailSender').css('left',l);
	$('#floatingEmailSender').css('top',t);
	$('#floatingEmailSender').show();
	$('#floatingEmailSender').animate({opacity:0},0)
							.animate({
									  opacity: 1
									  },500);
	l2 = l+525;
	t2 = t-10;
	$('#closeFloatingEmailSender').css('left',l2);
	$('#closeFloatingEmailSender').css('top',t2);
	$('#closeFloatingEmailSender').show();
	$('#closeFloatingEmailSender').click(function(){hideFloatingEmailSender()});
}
function hideFloatingEmailSender()
{
	$('#floatingEmailSender').animate({opacity:0},250);
	setTimeout("$('#floatingEmailSender').hide()",250);
	setTimeout("$('#underFloatingEmailSender').hide()",250);
	$('#closeFloatingEmailSender').hide();
}
function playWidgetVideo( pic, vid, t, d )
{
	holder = "floating_video_player";
	w = 500;
	h = 400;
	flashvars = {
		flv:vid,
		startimage:pic,
		width:500,
		height:400,
		volume:75,
		margin:0,
		showstop:1,
		showvolume:1,
		showtime:1,
		showfullscreen:1,
		playercolor:"FF0000",
		playeralpha:50,
		loadingcolor:"FFFFFF",
		buttoncolor:"FFFFFF",
		slidercolor1:"333333",
		slidercolor2:"000000",
		sliderovercolor:"FFFFFF",
		showiconplay:1,
		iconplaycolor:"FFFFFF",
		iconplaybgalpha:50,
		shortcut:1
	};
	params = {
		wmode: "transparent",
		allowScriptAccess: "always",
		allowNetworking: "all",
		allowFullScreen: "true"
	};
	attributes = { wmode: "transparent" };
	swfobject.embedSWF("flash_player/player_flv_maxi.swf", holder, w, h, "10","swfobject/expressInstall.swf", flashvars, params, attributes);
	$('#floating_video_player_text').html('<strong class="title_red">'+t+'</strong><br />'+d);
	setTimeout('initFloatingVideoPlayer()',100);
}
function changeVideo(wNr,dir)
{
	pages  = $('#videoPg_'+wNr).children('span[id^=pg_]');
	curpag = $('#videoPg_'+wNr).children('.curVPag');
	curpagnr = $(curpag).html();
	reqp = (curpagnr*1)+(dir*1);
	if( reqp >= 1 && reqp<=pages.length )
	{
		l = (reqp-1)*(-195);
		$('#holderVideo_'+wNr).animate({left:l},500);
		$(curpag).removeClass('curVPag');
		$(curpag).addClass('vPag');
		$('#pg_'+reqp).removeClass('vPag');
		$('#pg_'+reqp).addClass('curVPag');
	}
}
function gotoVideoPg(wNr,thepg)
{
	pages  = $('#videoPg_'+wNr).children('span[id^=pg_]');
	curpag = $('#videoPg_'+wNr).children('.curVPag');
	curpagnr = $(curpag).html();
	reqp = thepg;
	if( reqp >= 1 && reqp<=pages.length )
	{
		l = (reqp-1)*(-195);
		$('#holderVideo_'+wNr).animate({left:l},500);
		$(curpag).removeClass('curVPag');
		$(curpag).addClass('vPag');
		$('#pg_'+reqp).removeClass('vPag');
		$('#pg_'+reqp).addClass('curVPag');
	}
}
/* BLOGURI */

function changeBlog(wNr,dir)
{
	pages  = $('#bloguriPg_'+wNr).children('span[id^=pg_]');
	curpag = $('#bloguriPg_'+wNr).children('.curBPag');
	curpagnr = $(curpag).html();
	reqp = (curpagnr*1)+(dir*1);
	if( reqp >= 1 && reqp<=pages.length )
	{
		l = (reqp-1)*(-199-6);
		$('#holderBloguri_'+wNr).animate({left:l},500);
		$(curpag).removeClass('curBPag');
		$(curpag).addClass('bPag');
		$('#pg_'+reqp).removeClass('bPag');
		$('#pg_'+reqp).addClass('curBPag');
	}
}
function gotoBlogPg(wNr,thepg)
{
	pages  = $('#bloguriPg_'+wNr).children('span[id^=pg_]');
	curpag = $('#bloguriPg_'+wNr).children('.curBPag');
	curpagnr = $(curpag).html();
	reqp = thepg;
	if( reqp >= 1 && reqp<=pages.length )
	{
		l = (reqp-1)*(-195);
		$('#holderBloguri_'+wNr).animate({left:l},500);
		$(curpag).removeClass('curBPag');
		$(curpag).addClass('bPag');
		$('#pg_'+reqp).removeClass('bPag');
		$('#pg_'+reqp).addClass('curBPag');
	}
}