var max_marime_stiri = 140;
var min_marime_stiri = 50;
var curr_size = 100;
var streamer_const="rtmp://media.3netmedia.ro/fastplay";
var streamer_live="rtmp://media2.3netmedia.ro/live";
var auxstream1="politica";
var k=138;
var http = false;
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]};
var currentPlaylist = null;
var currentLength = 0;
var player = null;
var movie_player = null;
var podcast = null;
var playlist_timmer;
BrowserDetect.init();
//Ulilitare
function footer(pic){
	document.getElementById("logo_footer").style.backgroundPosition="0px -"+pic+"px";}
function get_content(element,page) {
  document.getElementById(element).innerHTML = '<div align="center">Incarc continut<br><img src="/rraonline/img/loader.gif"></div>';
  http.open("GET",page , true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById(element).innerHTML = http.responseText;
    }
  }
  http.send(null);}
function webcam(x){
	if(document.getElementById("livefeed")){document.getElementById("livefeed").className="webcam";}
	if(document.getElementById("livefeed2")){document.getElementById("livefeed2").className="webcam";}
	switch(x){
	case "webcam1":	
		document.getElementById("webcam_2").className="webcam";
		document.getElementById("webcam_1").className="webcam_selected";
		document.getElementById("podcast_name").style.display="none";
		player.sendEvent('LOAD',{file:"RRActualitati1",streamer:"rtmp://media2.3netmedia.ro/live",type:"rtmp"});
	break;
	case "webcam2":	
		document.getElementById("webcam_1").className="webcam";
		document.getElementById("webcam_2").className="webcam_selected";
		document.getElementById("podcast_name").style.display="none";
		player.sendEvent('LOAD',{file:"RRActualitati2",streamer:"rtmp://media2.3netmedia.ro/live",type:"rtmp"});
	break;
	}
	if (podcast){
		podcast.sendEvent('STOP');
		document.getElementById("podcast").style.display="none";
		document.getElementById("podcast_name").style.display="none";
	}
	}
function livefeed(x){
	if (x==1){
		//document.getElementById("livefeed2").className="webcam";
		document.getElementById("webcam_2").className="webcam";
		document.getElementById("webcam_1").className="webcam";
		document.getElementById("livefeed").className="webcam_selected";
		player.sendEvent('LOAD',{file:auxstream1,streamer:"rtmp://media2.3netmedia.ro/live",type:"rtmp"});
	} else {
		document.getElementById("livefeed").className="webcam";
		document.getElementById("webcam_2").className="webcam";
		document.getElementById("webcam_1").className="webcam";
		document.getElementById("livefeed2").className="webcam_selected";
		player.sendEvent('LOAD',{file:"/playlist2.xml"});
	}}
function search_clear(){
  document.getElementById("search_box").value ='';	}
function getHTTPPage(url) {
		var xmlhttp
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		  try {
		  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
		 } catch (e) {
		  try {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		  } catch (E) {
		   xmlhttp=false
		  }
		 }
		@else
		 xmlhttp=false
		@end @*/
	if (!xmlhttp){
		try{
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	xmlhttp.open("GET",url ,false);
	xmlhttp.send(null);
	var ret = xmlhttp.responseText;
	xmlhttp = null ;
	return ret;}
function playlist(){
	if (document.getElementById("playlist").style.display!="block"){
		document.getElementById("playlist").style.display="block";
		document.getElementById("player").style.visibility="hidden";
		clearTimeout(playlist_timmer);
		playlist_timmer=setTimeout("hideplaylist()",6000);
	} else {
		document.getElementById("playlist").style.display="none";
		document.getElementById("player").style.display="block";
		clearTimeout(playlist_timmer);		
	}}
function hideplaylist(){
	if (document.getElementById("playlist").style.display!="none")
		document.getElementById("player").style.visibility="visible";
		document.getElementById("playlist").style.display="none";}
function hideplaylist_timmer(){
	playlist_timmer=setTimeout("hideplaylist()",500);}
function clearPlaylistTimmer(){
	clearTimeout(playlist_timmer);}
function schimb_tab(t1,t2){
	document.getElementById("tab"+t1+px[t1]).style.display="none";
	document.getElementById("tab"+t1+t2).style.display="block";
	document.getElementById("cap"+t1+px[t1]).className="";
	document.getElementById("cap"+t1+t2).className="select";
	px[t1]=t2;}
function expand(){
	document.getElementById("expand").innerHTML=(k==138) ? "Top 3" : "Top 10";
	document.getElementById("expander").src= webroot+"images/"+((k==138) ? "up.png" : "down.png");
	document.getElementById("TOP30").style.height= (k==138) ? "404px" : "138px";
	k = (k==138)?408:138;}
function refresh_captcha(){
	document.getElementById('captcha').src = '/rrapages/captcha/'+ Math.random();}
function vremea(cale,local){
	var s=getHTTPPage(cale+"vremea.php?r="+100000*Math.random()+"&local="+local);
	document.getElementById("vremea").innerHTML=s;}
//VideoPlayer
function createFlashContent(content,theFile,wm,fs,w,h,cb,ct,bg){
            var flashvars = {
                    xmlfile:theFile,
					dimx:w,
					dimy:h,
					culoare:cb,
					culoaretxt:ct,
					backgnd:bg
            }
            var params = {
                    allowfullscreen:fs, 
                    allowscriptaccess:"always",
					scale:"noscale",
					wmode:wm,
					menu:"false",
					expressinstall:"/flash/expressInstall.swf"
            }
            var attributes = {
                    id:content,  
                    name:content
            }
            swfobject.embedSWF("/flash/"+content+".swf","container_"+content,w,h,"9.0.0.0",false,flashvars,params,attributes);}
function createPlayer(obiect,container,theFile,theStreamer,w,h,theMute,ctrlbar, theAutostart){
		if (!theAutostart){
			var theAutostart="true";
		}
            var flashvars = {
                    file:theFile,
					streamer:theStreamer,
					mute:theMute,
					controlbar:ctrlbar,
					type:"rtmp",
                    autostart:theAutostart, 
					logo:"/images/video_logo.png",
					volume:80,
					skin:"/flash/modieus"
            }
            var params = {
                    allowfullscreen:"true", 
                    allowscriptaccess:"always"
            }
            var attributes = {
					bgcolor:"#000000",
                    id:obiect,  
                    name:obiect
            }
            swfobject.embedSWF("/flash/player.swf",container,w,h,"9.0.0.0",false,flashvars,params,attributes);}
function playerReady(thePlayer){
	player=window.document["player"];
	/*if (document.getElementById("livefeed")) {
		document.getElementById("webcam_2").className="webcam";
		document.getElementById("webcam_1").className="webcam";
		document.getElementById("livefeed").className="webcam_selected";
		player.sendEvent('LOAD',{file:auxstream1,streamer:streamer_live,type:"rtmp"})
		player.sendEvent('MUTE','false');
	}*/
	
	if(window.document["movie_player"]){
		movie_player=window.document["movie_player"];
	}
	if(window.document["podcast"]){
		podcast=window.document["podcast"];
		podcast.addModelListener('STATE','stateMonitor');
	}
	}
function stateMonitor(obj){
	state = obj.newstate;
	if(state == 'IDLE' || state == 'COMPLETED')
        {
			document.getElementById("podcast").style.display="none";
			document.getElementById("podcast_name").style.display="none";
		}}
function direct_load(id){
	if (!podcast){
			createPlayer("podcast","podcast_container","RRAOnline/audio/"+id+".mp3",streamer_const,255,32,"false");
	} else{
		if(document.getElementById("podcast").style.display=="none"){
			player.sendEvent('MUTE','true');
		} else {
			podcast.sendEvent('LOAD',{file:"RRAOnline/audio/"+id+".mp3",streamer:streamer_const,type:"rtmp"})
		}
	}
	document.getElementById("podcast").style.display="block";
	document.getElementById("podcast_name").style.display="block";}
function loadFile(theFile,fileType,linkuri,img,id) {
	switch (fileType){
		case "video":
			var mount="fastplay";
			getHTTPPage("/videofiles/addview/"+id);
			theFile=linkuri+"/video/"+theFile+".flv";
			img="http://media.3netmedia.ro/media/"+linkuri+"/video/thumbs/"+theFile+".png";
		break;
	}
	if (movie_player){
		movie_player.sendEvent('LOAD', [{file:theFile,streamer:"rtmp://media.3netmedia.ro/"+mount,image:img}]);
		movie_player.sendEvent('PLAY',true);
	} else {
		player.sendEvent('LOAD', [{file:theFile,streamer:"rtmp://media.3netmedia.ro/"+mount,image:img}]);
		player.sendEvent('PLAY',true);
	}}

