function base64encode(str){
    var out, i, len;
    var c1, c2, c3;
    len = str.length;
    i = 0;
    out = "";
    while(i < len){
	c1 = str.charCodeAt(i++) & 0xff;
	if(i == len){
	    out += base64EncodeChars.charAt(c1 >> 2);
	    out += base64EncodeChars.charAt((c1 & 0x3) << 4);
	    out += "==";
	    break;
	}
	c2 = str.charCodeAt(i++);
	if(i == len){
	    out += base64EncodeChars.charAt(c1 >> 2);
	    out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
	    out += base64EncodeChars.charAt((c2 & 0xF) << 2);
	    out += "=";
	    break;
	}
	c3 = str.charCodeAt(i++);
	out += base64EncodeChars.charAt(c1 >> 2);
	out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
	out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));
	out += base64EncodeChars.charAt(c3 & 0x3F);
    }
    return out;}
function base64decode(str){
    var c1, c2, c3, c4;
    var i, len, out;
    len = str.length;
    i = 0;
    out = "";
    while(i < len){
	/* c1 */
	do{
	    c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
	}while(i < len && c1 == -1);
	if(c1 == -1) break;
	/* c2 */
	do{
	    c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
	} while(i < len && c2 == -1);
	if(c2 == -1) break;
	out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
	/* c3 */
	do {
	    c3 = str.charCodeAt(i++) & 0xff;
	    if(c3 == 61)
		return out;
	    c3 = base64DecodeChars[c3];
	} while(i < len && c3 == -1);
	if(c3 == -1) break;
	out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
	/* c4 */
	do {
	    c4 = str.charCodeAt(i++) & 0xff;
	    if(c4 == 61)
		return out;
	    c4 = base64DecodeChars[c4];
	} while(i < len && c4 == -1);
	if(c4 == -1) break;
	out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
    }
    return out;}
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 empty_field(obj){
	switch(obj.id){
		case "search_":
		case "search":
			if (obj.value.indexOf("Search")>-1){
				temp=obj.value;
				obj.value="";
			}		
		break;
		case "CommentCaptcha":
			if (obj.value=="Captcha"){
				obj.value="";
				obj.className="c_selected";
			}
		break;
		case "CommentCreator":
			if (obj.value=="Name"){
				obj.value="";
				obj.className="c_selected";
			}
		break;
		case "CommentComment":
			if (obj.value=="Add comment"){
				obj.value="";
				obj.className="c_selected";
			}		
		break;
		default:
	}}
function reset_field(obj){
	switch(obj.id){
		case "search_":
		case "search":
			if (obj.value==""){
				obj.value=temp;
			}
		break;
		case "CommentCaptcha":
			if (obj.value==""){
				obj.value="Captcha";
				obj.className="";
			}
		break;
		case "CommentCreator":
			if (obj.value==""){
				obj.value="Name";
				obj.className="";
			}
		break;
		case "CommentComment":
			if (obj.value==""){
				obj.value="Add comment";
				obj.className="";
			}
		break;
		case "vremea_autocomplete":
			if (obj.value==""){
				obj.value="Alege alt oraș";
			}
		break;
		default:
	}}
function refresh_captcha(x){
document.getElementById('captcha_'+x).innerHTML = '<img border="0" src="/pages/captcha/'+x+'">';} 
//Functia se poate aplica pentru gaseste ce battle e acum
//function now_on_air(){
	//var s=getHTTPPage("/grilas/grila_java/?r="+Math.round(Math.random()*10000));
	//document.getElementById("Emisiune").innerHTML=s;
	//tt=setTimeout("now_on_air()",20000);
//	}

//function vremea(local){
//	if (local=="" || local==null){ local="Bucuresti"}
//	var s=getHTTPPage("/vremea.php?local="+local+"&r="+Math.round(Math.random(10000)*10000));
//	document.getElementById("vremea").innerHTML=s;
//}
//function footer(pic){
//	document.getElementById("logo_footer").style.backgroundPosition="0px -"+pic+"px";}
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",
	   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(theFile,place,ctrlbar,plst,w,h,mut,icon,clici,wmod,logo_,bc,lc,fc,sc){
if (theFile.file){
	theFilex=theFile.file;
	img=theFile.image;
	tip=theFile.type;
} else {
	theFilex=theFile;
	img="";
	tip="";
}
var flashvars = {
	autostart:"false",
	file:theFilex,
	type:tip,
	image:img,
	controlbar:ctrlbar,
	mute:mut,
	displayclick:clici,
	icons:icon,
	playlist:plst,
	playlistsize:120,
	skin:"/flash/modieus",
	//logo:"/img/tv_logo.png",
	backcolor:bc,
	lightcolor:lc,
	frontcolor:fc,
	screencolor:sc,
	volume:30,
	abouttext:"REC",
	aboutlink:"http://www.rockbattle.ro",
	bufferlength:10,
	streamer:"rtmp://dev.rockbattle.ro/live"
	}
var params = {
	allowfullscreen:"true", 
	allowscriptaccess:"always",
	wmode:wmod,
	bgcolor:"#000000",
	expressinstall:"/flash/expressInstall.swf"
	}
var attributes = {
	id:place,  
	name:place
	}
swfobject.embedSWF("/flash/player.swf",place,w,h,"9.0.115",false,flashvars,params,attributes);}
function playerReady(thePlayer){
	player=window.document[thePlayer.id];}
function loadFile(theFile,fileType,img,obj,cale) {
	var k="";
	switch (fileType){
		case 3:
			img="http://img.youtube.com/vi/"+base64decode(theFile)+"/3.jpg";
			player.sendEvent('LOAD', [{file:'http://www.youtube.com/watch?v='+base64decode(theFile),image:img,type:'youtube'}]);
		break;
		default:
			player.sendEvent('LOAD', [{file:'http://www.youtube.com/watch?v=uE1IeA-2U1Y',image:img,type:'youtube'}]);
	}
	player.sendEvent('PLAY',true);
};
//Jcloud
(function(a){"use strict",a.fn.jQCloud=function(b,c){var d=this,e=d.attr("id"),f={width:d.width(),height:d.height(),center:{x:d.width()/2,y:d.height()/2},delayedMode:b.length>50,randomClasses:0,nofollow:!1,shape:!1};typeof c=="function"&&(c={callback:c}),c=a.extend(f,c||{}),d.addClass("jqcloud");var g=function(){var f=function(a,b){var c=function(a,b){return Math.abs(2*a.offsetLeft+a.offsetWidth-2*b.offsetLeft-b.offsetWidth)<a.offsetWidth+b.offsetWidth&&Math.abs(2*a.offsetTop+a.offsetHeight-2*b.offsetTop-b.offsetHeight)<a.offsetHeight+b.offsetHeight?!0:!1},d=0;for(d=0;d<b.length;d++)if(c(a,b[d]))return!0;return!1};for(var g=0;g<b.length;g++)b[g].weight=parseFloat(b[g].weight,10);b.sort(function(a,b){return a.weight<b.weight?1:a.weight>b.weight?-1:0});var h=c.shape==="rectangular"?18:2,i=[],j=c.width/c.height,k=function(g,k){var l=e+"_word_"+g,m="#"+l,n=typeof c.randomClasses=="number"&&c.randomClasses>0?" r"+Math.ceil(Math.random()*c.randomClasses):a.isArray(c.randomClasses)&&c.randomClasses.length>0?" "+c.randomClasses[Math.floor(Math.random()*c.randomClasses.length)]:"",o=6.28*Math.random(),p=0,q=0,r=0,s=Math.round((k.weight-b[b.length-1].weight)/(b[0].weight-b[b.length-1].weight)*9)+1,t=a("<span>").attr("id",l).attr("class","w"+s).addClass(n).addClass(k.custom_class||null).attr("title",k.title||k.text||""),u;k.url?(u=a("<a>").attr("href",encodeURI(k.url).replace(/'/g,"%27")).text(k.text),!c.nofollow||u.attr("rel","nofollow")):u=k.text,t.append(u);if(!!k.handlers)for(var v in k.handlers)k.handlers.hasOwnProperty(v)&&typeof k.handlers[v]=="function"&&a(t).bind(v,k.handlers[v]);d.append(t);var w=t.width(),x=t.height(),y=c.center.x-w/2,z=c.center.y-x/2,A=t[0].style;A.position="absolute",A.left=y+"px",A.top=z+"px";while(f(document.getElementById(l),i)){if(c.shape==="rectangular"){q++,q*h>(1+Math.floor(r/2))*h*(r%4%2===0?1:j)&&(q=0,r++);switch(r%4){case 1:y+=h*j+Math.random()*2;break;case 2:z-=h+Math.random()*2;break;case 3:y-=h*j+Math.random()*2;break;case 0:z+=h+Math.random()*2}}else p+=h,o+=(g%2===0?1:-1)*h,y=c.center.x-w/2+p*Math.cos(o)*j,z=c.center.y+p*Math.sin(o)-x/2;A.left=y+"px",A.top=z+"px"}i.push(document.getElementById(l)),typeof k.callback=="function"&&k.callback.call(t)},l=function(a){a=a||0,a<b.length?(k(a,b[a]),setTimeout(function(){l(a+1)},10)):typeof c.callback=="function"&&c.callback.call(this)};c.delayedMode||c.delayed_mode?l():(a.each(b,k),typeof c.callback=="function"&&c.callback.call(this))};return setTimeout(function(){g()},10),this}})(jQuery)
