function abrecanal(url,uf) {

	//alert("/clicstation/jsp/expanded_sites.jsp?canal="+ url +"&uf="+ uf +"&eurl=http://www.clicrbs.com.br/cdm/jsp/cdm_errologin.jsp","clicStation","width=492,height=271");

	top.location.href = "/clicstation/jsp/expanded_sites.jsp?canal="+ url +"&uf="+ uf;

}


function linkSmil(smil,uf) {

      window.open("/clicstation/jsp/player_compact_sr.jsp?nomeVideo=http://www.clicrbs.com.br/clicstation/smil/"+smil+"&uf="+uf+"&canal=smil","clicStation","width=250,height=300");	  

}


function abrecsPorCanal(nCanal,uf,rev){

	top.location.href = "/clicstation/jsp/expanded_sites.jsp?canal="+nCanal+"&uf="+uf+"&rev="+rev;

}



function abrecsPorCanal2( nCanal, uf, rev ){

	if( nCanal == "atlantida" || nCanal == "atlantidasc" ){

		top.location.href = "/atlantidafm/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&template=3781.dwt&section=3&rev="+rev;

	}	else if( nCanal == "itapema" || nCanal == "itapemapoa" ){

		top.location.href = "/itapemafm/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&template=3788.dwt&section=101&rev="+rev;	

	} else if( nCanal == "cidade" ){

		top.location.href = "/radios/radiocidade/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&template=3786.dwt&rev="+rev;

	} else if( nCanal == "gaucha" ){

		top.location.href = "/gaucha/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&template=3787.dwt&section=Ao%20Vivo&rev="+rev;

	} else if( nCanal == "planeta" || nCanal == "planetasc" ){

		top.location.href = "/planeta/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&template=3790.dwt&section=3&rev="+rev;

	} else if( nCanal == "rural" ){

		top.location.href = "/radiotv/ruralam/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&template=3791.dwt&rev="+rev;

	}

}



function abrecsPorCanalMC( nCanal, uf, parent ){

	var local = '1';

	if( uf == '2' ) local = '18'; else local = '1';	//define o local, a partir do uf

	if( nCanal == "atlantida" || nCanal == "atlantidasc" ){

		if( nCanal == "atlantida" ){
			window.open("http://mediacenter.clicrbs.com.br/templates/ResultadoBusca.aspx?tipo=categoria&texto=867&channel=114");
			//ANTIGA CHAMADA
			//MM_openBrWindow('http://mediacenter.clicrbs.com.br/templates/ResultadoBusca.aspx?tipo=categoria&texto=867&channel=114','player','scrollbars=no,width=1024,height=768');			

		}else if( nCanal == "atlantidasc" ){
			window.open("http://mediacenter.clicrbs.com.br/templates/ResultadoBusca.aspx?tipo=categoria&texto=867&channel=114");
			//ANTIGA CHAMADA
			//MM_openBrWindow('http://mediacenter.clicrbs.com.br/templates/ResultadoBusca.aspx?tipo=categoria&texto=867&channel=114','player','scrollbars=no,width=800,height=600');			

		}

		//top.location.href = "/atlantidafm/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&local="+local+"&template=3781.dwt&section=3";

	}else if( nCanal == "planeta" || nCanal == "planetasc" ){

		if( nCanal == "planeta" ){

			MM_openBrWindow('http://mediacenter.clicrbs.com.br/live/templates/playerAoVivo.aspx?channel=32&contentId=1186&uf=1','player','scrollbars=no,width=488,height=270');

		}else if( nCanal == "planetasc" ){

			MM_openBrWindow('http://mediacenter.clicrbs.com.br/live/templates/playerAoVivo.aspx?channel=32&contentId=1187&uf=1','player','scrollbars=no,width=488,height=270');

		}

		top.location.href = "/planeta/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&local="+local+"&template=3790.dwt&section=3";		

	}else if( nCanal == "itapema" || nCanal == "itapemapoa" ){

		if( nCanal == "itapemapoa" ){
			window.open("http://mediacenter.clicrbs.com.br/templates/ResultadoBusca.aspx?tipo=categoria&texto=868&channel=114");
			//ANTIGA CHAMADA
			//MM_openBrWindow('http://mediacenter.clicrbs.com.br/templates/ResultadoBusca.aspx?tipo=categoria&texto=868&channel=114','player','scrollbars=no,width=310,height=310');			

		}else if( nCanal == "itapema" ){
			window.open("http://mediacenter.clicrbs.com.br/templates/ResultadoBusca.aspx?tipo=categoria&texto=868&channel=114");
			//ANTIGA CHAMADA
			//MM_openBrWindow('http://mediacenter.clicrbs.com.br/templates/ResultadoBusca.aspx?tipo=categoria&texto=868&channel=114','player','scrollbars=no,width=310,height=310');			

		}

		//top.location.href = "/itapemafm/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&local="+local+"&template=3788.dwt&section=101";

	}else if( nCanal == "gaucha" ){
		//ANTIGA CHAMADA
		//MM_openBrWindow('http://mediacenter.clicrbs.com.br/templates/playerpopup.aspx?midia=20422&tipoVivo=1&channel=115','player','scrollbars=no,width=310,height=310');
		//top.location.href = "/gaucha/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&local="+local+"&section=Ao%20Vivo&template=3787.dwt";
		window.open("http://mediacenter.clicrbs.com.br/templates/player.aspx?uf="+uf+"&contentID=20422&channel=115&tipoVivo=1");	
		
	} else if( nCanal == "cidade" ){

		MM_openBrWindow('http://mediacenter.clicrbs.com.br/templates/playerpopup.aspx?midia=20421&tipoVivo=1&channel=115','player','scrollbars=no,width=310,height=310');

		top.location.href = "/radios/radiocidade/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&local="+local+"&template=3786.dwt";

	} else if( nCanal == "rural" ){

		MM_openBrWindow('http://mediacenter.clicrbs.com.br/templates/playerpopup.aspx?midia=20414&tipoVivo=1&channel=115','player','scrollbars=no,width=310,height=310');

		top.location.href = "/radiotv/ruralam/jsp/default.jsp?canal="+nCanal+"&uf="+uf+"&local="+local+"&template=3791.dwt";

	} else if( nCanal == "canalrural" ){

		MM_openBrWindow('http://mediacenter.clicrbs.com.br/live/templates/playerAoVivo.aspx?channel=32&contentId=1194&uf=1','player','scrollbars=no,width=488,height=270');

	} else if( nCanal == "tvcom" ){

		MM_openBrWindow('http://mediacenter.clicrbs.com.br/live/templates/playerAoVivo.aspx?channel=32&contentId=1303&uf=1','player','scrollbars=no,width=488,height=270');

	} else if( nCanal == "cbn" ){

		MM_openBrWindow('http://mediacenter.clicrbs.com.br/live/templates/playerAoVivo.aspx?channel=32&contentId=1190&uf=1','player','scrollbars=no,width=488,height=270');

	} else{

		MM_openBrWindow('http://mediacenter.clicrbs.com.br/live/templates/playerAoVivo.aspx?channel=32&uf=1','player','scrollbars=no,width=488,height=270');

	}

	if( parent != null ){

		if( parent != '' || parent != "" ){

			top.location.href = parent;

		}

	}

}



function playersr(nomeVideo, uf) { //v2.0

      var theURL ="/clicstation/jsp/player_compact_mode.jsp?nomeVideo=video/"+nomeVideo+"&uf="+uf;

	  var winName ="clicRBS";

	  var features ="scrollbars=no,width=250,height=300";

	  window.open(theURL,winName,features);

}



function canal(nCanal, nUf){ 

 window.open("/clicstation/jsp/player_compact.jsp?canal="+nCanal+"&uf=RS&nomeVideo=http://www.clicrbs.com.br/clicstation/videos/" +nUf+ "/"+nCanal+".smil","clicStation","width=253,height=326"); 

}



function canal2(nCanal, nUf){ 

 window.open("/clicstation/jsp/player_compact_sr.jsp?canal="+nCanal+"&uf=RS&nomeVideo=http://www.clicrbs.com.br/clicstation/videos/" +nUf+ "/"+nCanal+".smil","clicStation","width=250,height=300"); 

}



function abrecs(video,uf){

 //window.open("/clicstation/jsp/player_expanded.jsp?nomeVideo="+video+"&uf="+uf,"clicStation","width=492,height=271");

  location.href = "/clicstation/jsp/player_compact_sr.jsp?canal=nenhum&uf="+ uf +"&previousurl=http://www.clicrbs.com.br/";

}



function abrecs1(video,uf){

        window.open("/clicstation/jsp/player_compact_sr.jsp?nomeVideo="+video+"&uf="+uf,"clicStation","width=250,height=300");

}



function abrecs2(video,uf,nCanal){

 window.open("/clicstation/jsp/player_compact_sr.jsp?canal="+nCanal+"&nomeVideo="+video+"&uf="+uf,"clicStation","width=250,height=300");

}



function linkImagem(p_width,p_height,p_file,p_author,p_copyright,p_legend){

	if (document.URL.indexOf('zerohora') > -1){
		window.open("/rbs/image/"+p_file,"Zerohora","width=580,height=426");
	} else {
		var popup=null;
		popup=openModal("/jsp/rt.jsp?rootdir=/shared&width="+p_width+"&height="+p_height+"&file="+p_file+"&author="+escape(p_author)+"&copyright="+escape(p_copyright)+"&legend="+escape(p_legend)+"&template=24.dwt",p_width+100,p_height+100,"Imagem");
	}

}



function linkImagemNoticia(p_width,p_height,p_file,p_author,p_copyright,p_legend){

	var popup=null;

	if(!p_file.elements){

		popup=openModal("/jsp/rt.jsp?rootdir=/shared&width="+p_width+"&height="+p_height+"&file="+p_file+"&author="+escape(p_author)+"&copyright="+escape(p_copyright)+"&legend="+escape(p_legend)+"&template=24.dwt",p_width+100,p_height+100,"Imagem");

	}else{

		document.joker.p_comp.value=p_file.p_comp.value;

		document.joker.p_width.value=p_file.p_width.value;

		document.joker.p_height.value=p_file.p_height.value;

		document.joker.p_legend.value=p_file.p_legend.value;

		document.joker.p_author.value=p_file.p_author.value;

		document.joker.p_copyright.value=p_file.p_copyright.value;

		document.joker.p_type.value="I";

		var v_width=p_width+60;

		var v_height=p_height+100;

		popup = window.open("/rbs/html/popup.htm","RBS","resizable=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,scrollbars=no,width="+v_width+",height="+v_height);

	}

}



function linkImagemOriginal(p_width,p_height,p_file,p_author,p_copyright,p_legend){

	if(p_width==''){

		p_width=250;

	}

	if(p_height==''){

		p_height=250;

	}

	var popup=null;

	if(!p_file.elements){

		popup=openModal("/jsp/rt.jsp?rootdir=/shared&width="+p_width+"&height="+p_height+"&file="+p_file+"&author="+escape(p_author)+"&copyright="+escape(p_copyright)+"&legend="+escape(p_legend)+"&template=24.dwt",p_width+100,p_height+100,"Imagem");

	}else{

		document.joker.p_comp.value=p_file.p_comp.value;

		document.joker.p_width.value=p_file.p_width.value;

		document.joker.p_height.value=p_file.p_height.value;

		document.joker.p_legend.value=p_file.p_legend.value;

		document.joker.p_author.value=p_file.p_author.value;

		document.joker.p_copyright.value=p_file.p_copyright.value;

		document.joker.p_type.value="I";

		var v_width=p_width+60;

		var v_height=p_height+100;

		popup = window.open("/rbs/html/popup.htm","RBS","resizable=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,scrollbars=no,width="+v_width+",height="+v_height);

	}

}




function linkEncode(p_video,uf){if(uf==null) uf='RS'; abrecs1(p_video,uf);}



function doRegiao(p_uf,p_tab,p_nid,p_subtab){

	document.formDefault.uf.value=p_uf;

	if(p_uf=='1')document.formDefault.local.value='1';

	else document.formDefault.local.value='18';

	doSubmit(p_tab,p_nid,p_subtab);

}




function changeColumn(columnId){

	if(columnId!=''){

		document.formDefault.newsID.value='a'+columnId+'.htm';

		document.formDefault.submit();

	}

}



var oWindow = null;



function ajustaStr(str){
		var arrCharTrocar = new Array(/ /g);
		var arrCharResult = new Array("_");
		var aux = 0;
		str = str.toLowerCase();
		for (var i in arrCharTrocar){
			if (i == 0) aux = 0; //espaço
			str = str.replace(arrCharTrocar[i], arrCharResult[aux]);
		}
		return str;
	}



function MM_preloadImages(){

	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}

function MM_swapimgRestore(){

	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}

function MM_findObj(n, d){

	var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length) {

	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

	if(!x && document.getElementById) x=document.getElementById(n); return x;

}

function MM_swapImage(){

	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

	if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}



function MM_openBrWindow(theURL,winName,features) { //v2.0

	window.open(theURL,winName,features);

}


function popupFormArq(title,mailTo){

	var url = "http://www.clicrbs.com.br/formulario/jsp/pop_formulario_arq.jsp?titulo=" + title + "&emailAlvo=" + mailTo; 

	window.open(url,'popup','width=590,height=540,scrollbars=1');

}

function popupFormPainel(title,mailTo){

	var url = "http://www.clicrbs.com.br/formulario/jsp/pop_formulario_painel.jsp?titulo=" + title + "&emailAlvo=" + mailTo; 

	window.open(url,'popup','width=590,height=540,scrollbars=1');

}

function link_gallery(p_type, p_path, p_template, p_gallery_id, p_group_id, p_popup_width, p_popup_height, p_parameters_site, p_uf, p_local){

	if (p_uf == ' ') p_uf = "1";

	if (p_local == ' ') p_local = "1";

	var tam = p_path.length;

	if (tam > 0){

		var position = p_path.indexOf("/",0);

		if (position == 0) p_path = p_path.substring(1, tam);

		tam = p_path.length;

		position = p_path.lastIndexOf("/", tam);

		if (position == (tam - 1)) p_path = p_path.substring(0, position);

	}

 	//p_type = 1 (galeria), p_type = 2 (sequencia de fotos)

 	if (p_type == "1"){

		document.location.href = "http://www.clicrbs.com.br/"+p_path+"/jsp/default.jsp?newsID=DYNAMIC%2Cgaleria.GalleryDelivery%2CphotosGalleryXml&pg=1&template="+p_template+"&groupid="+p_group_id+"&galeriaid="+p_gallery_id+"&uf="+p_uf+"&local="+p_local+p_parameters_site;

	}else{

		if (p_path == 'especiais') 

			p_path='clicnoticias/';

		else

			p_path=p_path+'/';

		var pagina = "http://www.clicrbs.com.br/"+p_path+"jsp/default.jsp?template=1552.dwt&ids=null&initial=null&playsshow=false&b=1&arquivo_xml=galeria_"+p_gallery_id+"_"+p_group_id+".xml&uf="+p_uf+"&local="+p_local+p_parameters_site;

 		//MM_openBrWindow(pagina,'Galeria','scrollbars=auto,resizable=yes,width='+p_popup_width+',height='+p_popup_height);

		MM_openBrWindow(pagina,'Galeria','scrollbars=no,menubar=no,status=no,width=730,height=538');

 	}

}



function popupFormMsg(title,mailTo){

	var url = "http://www.clicrbs.com.br/formulario/jsp/pop_formulario_msg.jsp?titulo=" + title + "&emailAlvo=" + mailTo; 

	window.open(url,'popup','width=590,height=540,scrollbars=1');

}



function popupFormBinoculo(title,mailTo){

  var url = "http://www.clicrbs.com.br/formulario/jsp/pop_formulario_binoculo.jsp?titulo=" + title + "&emailAlvo=" + mailTo; 

  window.open(url,'popup','width=590,height=540,scrollbars=1');

}



function canal3(nCanal, nUf){ 

	window.open("/clicstation/jsp/player_compact.jsp?canal="+nCanal+"&uf=RS&nomeVideo=http://play.rbsonline.com.br/hurl.html%3fpath%3dclicstation/"+nCanal+"%26file%3d"+nCanal+".smil","clicStation","width=253,height=326"); 

}



function targetblank(domain){

	window.open("http://" + domain);

}



function linkGaleria (p_type, p_path, p_template, p_gallery_id, p_group_id, p_popup_width, p_popup_height, p_parameters_site, p_site){

	if (p_site == null || p_site == ' ') p_site = "http://www.clicrbs.com.br";

	var tam = p_path.length;

	if (tam > 0){

		var position = p_path.indexOf("/",0);

		if (position == 0) p_path = p_path.substring(1, tam);

		tam = p_path.length;

		position = p_path.lastIndexOf("/", tam);

		if (position == (tam - 1)) p_path = p_path.substring(0, position);

	}

	if (p_site.indexOf("clicrbs") != -1) {

		p_path = p_path+"/jsp";

	}

	//p_type = 1 (galeria), p_type = 2 (sequencia de fotos)

	if (p_type == "1"){

		document.location.href = p_site+"/"+p_path+"/default.jsp?uf="+uf+"&local="+local+"&newsID=DYNAMIC%2Cgaleria.GalleryDelivery%2CphotosGalleryXml&pg=1&template="+p_template+"&groupid="+p_group_id+"&galeriaid="+p_gallery_id+p_parameters_site;

	}else{

		var pagina = "http://www.clicrbs.com.br/jsp/default_galeria.jsp?uf="+uf+"&local="+local+"&template=1552.dwt&ids=null&initial=null&playsshow=false&b=1&arquivo_xml=galeria_"+p_gallery_id+"_"+p_group_id+".xml"+p_parameters_site;

		//MM_openBrWindow(pagina,'Galeria','scrollbars=auto,resizable=yes,width='+p_popup_width+',height='+p_popup_height);

		MM_openBrWindow(pagina,'Galeria','scrollbars=no,menubar=no,status=no,width=730,height=538');

	}

}





// NOVA
function chamaBannerOas($arquivo,$largura,$altura,$wmode,$cordefundo,$id){
    document.writeln('    <object id="globalnav-object" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + $largura + '" height="' + $altura + '" id="' + $id + '" name="' + $id + '">');
    document.writeln('        <param name="movie" value="' + $arquivo + '" />');
    document.writeln('        <param name="FlashVars" value="loc=en_US&htmlApp=false&gatewayURL=gwurl" />');
 	document.writeln('        <param name="allowScriptAccess" value="always">');
    document.writeln('        <param name="bgcolor" value="' + $cordefundo + '" />');
    document.writeln('        <param name="menu" value="false" />');
    document.writeln('        <param name="quality" value="high" />');
    document.writeln('        <param name="salign" value="tl" />');
    document.writeln('        <param name="scale" value="noscale" />');
    document.writeln('        <param name="wmode" value="' + $wmode + '" />');
    document.writeln('        <embed id="globalnav-embed" src="' + $arquivo + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="' + $wmode + '" flashvars="loc=en_US&htmlApp=false&gatewayURL=gwurl"  allowScriptAccess="always" bgcolor="' + $cordefundo + '" menu="false" quality="high" salign="tl" scale="noscale" id="' + $id + '" width="' + $largura + '" height="' + $altura + '"></embed>');
    document.writeln('    </object>');
}


function openNews(tab, newsid, subtab, site, especial){
	var pag = "";
	var uf = "1";
	var local = "1";
	var canal = tab;
	var materia = newsid;
	var cartola = subtab;

	if (canal == " "){
		canal = '00001';
	}
	
	if (site == "") site = "http://www.clicrbs.com.br";
		pag=site+"/jsp/default.jsp?uf="+uf+"&local="+local+"&tab="+canal+"&newsID="+materia+"&subTab="+cartola;
	
	if (especial != ""){
		pag = pag + "&espid="+especial;
	}
	
	document.location.href= pag;
}

function linkLsb(pSpevId){
	var url = "http://minutoaminuto.clicrbs.com.br/lsb/jsp/index.jsp?spev="+pSpevId;
	openModal( url, 750, 530,'lsbce',false );
}


var uploadsucess=0;
var pStr1;
var pStr2;
var data1;
var data2;
var star=0;
var estrelas = new Array(5);
estrelas[0]="star1";
estrelas[1]="star2";
estrelas[2]="star3";
estrelas[3]="star4";
estrelas[4]="star5";
var reDate = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
if (navigator.appName.indexOf('Microsoft') != -1){
clientNavigator = "IE";
}else{
clientNavigator = "Other";
}
function ValidateEmail(emailAdress)
{
if ((emailAdress.indexOf("{")>=0) || (emailAdress.indexOf("}")>=0) || (emailAdress.indexOf("(")>=0)
|| (emailAdress.indexOf(")")>=0) || (emailAdress.indexOf("<")>=0) || (emailAdress.indexOf(">")>=0)
|| (emailAdress.indexOf("[")>=0) || (emailAdress.indexOf("]")>=0) || (emailAdress.indexOf("|")>=0)
|| (emailAdress.indexOf("\"")>=0) || (emailAdress.indexOf("/")>=0) )
{
alert("Erro, Este e-mail não é válido");
return false;
}
if ((emailAdress.indexOf("&")>=0) || (emailAdress.indexOf("*")>=0) || (emailAdress.indexOf("$")>=0) || (emailAdress.indexOf("%")>=0)
|| (emailAdress.indexOf("?")>=0) || (emailAdress.indexOf("!")>=0) || (emailAdress.indexOf("^")>=0) || (emailAdress.indexOf("~")>=0)
|| (emailAdress.indexOf("`")>=0) || (emailAdress.indexOf("'")>=0) )
{
alert("Erro, Este e-mail não é válido");
return false;
}
if ((emailAdress.indexOf(",")>=0) || (emailAdress.indexOf(";")>=0) || (emailAdress.indexOf(":")>=0) || (emailAdress.indexOf("=")>=0)
|| (emailAdress.indexOf("#")>=0) )
{
alert("Erro, Este e-mail não é válido");
return false;
}
if ( (emailAdress.indexOf("@") < 0) || (emailAdress.indexOf("@") != emailAdress.lastIndexOf("@")) )
{
alert("Erro, Este e-mail não é válido");
return false;
}
if (emailAdress.lastIndexOf(".") < emailAdress.indexOf("@"))
{
alert("Erro, Este e-mail não é válido");
return false;
}
return true;
}
var currentMouseX;
var currentMouseY;
function GetMousePosition(e)
{
var nn6 = document.getElementById && !document.all;
var clientX = document.all ? event.clientX : e.clientX;
var clientY = document.all ? event.clientY : e.clientY;
var scrollLeft = nn6 ? window.pageXOffset : document.documentElement.scrollLeft;
var scrollTop = nn6 ? window.pageYOffset : document.documentElement.scrollTop;
currentMouseX = clientX + scrollLeft;
currentMouseY = clientY + scrollTop;
}
var NotifyDiv = null;
var NotifyTimeout = -1;
var NotifyOffsetX = - 30;
var NotifyOffsetY = -20;
function CreateNotify(header, text)
{
if(NotifyTimeout!=-1)
{
window.clearTimeout(NotifyTimeout);
}
if(!NotifyDiv)
{
NotifyDiv = document.createElement('div');
NotifyDiv.className = 'popBox'; //class that contains div style
NotifyDiv.style.position = 'Absolute';
document.body.appendChild(NotifyDiv);
}
NotifyDiv.style.left = currentMouseX + NotifyOffsetX + 'px';
NotifyDiv.style.top = currentMouseY + NotifyOffsetY + 'px';
NotifyDiv.innerHTML = " <div style='padding:5px; padding-left:10px; font-size: 10pt;color: #FFF;background: #1F3D79;'>"+header+"</div>"+
" <p>"+text+"</p>";
NotifyTimeout = window.setTimeout('DestroyNotify()', 2000);
}
function DestroyNotify()
{
document.body.removeChild(NotifyDiv);
NotifyDiv = null;
NotifyTimeout = -1;
}
function validateComments(areacomment,event,size)
{
if (areacomment.value.length > size){
return false
}
}
function DarNota(numeroStar){
star=0;
ApagarNota();
PreencherNota(numeroStar);
star=numeroStar;
}
function ApagarNota(){
if(star==0){
for(var i=0;i<5;i++){
var estrelaAtual = document.getElementById(estrelas[i]);
estrelaAtual.src='../skins/default/image/evaluate_star00.gif';
}
}
}
function PreencherNota(nota){
if(star==0){
for(var i=0;i<nota;i++){
var estrelaAtual = document.getElementById(estrelas[i]);
estrelaAtual.src='../skins/default/image/evaluate_star01.gif';
}
}
}
function Search_Enter(e,txt,dt1,dt2,channel){
var code;
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);
if (code == 13) {
doDate(txt,dt1,dt2,channel);
}
return true;
}
function Ajusta_Data(input, event){
if(clientNavigator == "IE"){
var tecla=(window.event)? event.keyCode:e.which;
}
else{
tecla = event.charCode;
}
if((tecla > 46 && tecla < 58))
{
DataMask(input,event);
}
else
{
if (tecla == 8 || tecla == 0)
{
DataMask(input,event);
}
else
{
return false;
}
}
if(tecla == 13)
{
document.getElementById('btBusc').click();
}
return true;
}
function DataMask(input,event){
if (input.value.length == 2 || input.value.length == 5){
if(clientNavigator == "IE"){
input.value += "/";
}
else if(event.keyCode == 0){
input.value += "/";
}
}
}
function validateRecomenda(contentID,channel){
var email0 = document.getElementsByName('email0')[0].value;
var email1 = document.getElementsByName('email1')[0].value;
var name0 = document.getElementsByName('name0')[0].value;
var name1 = document.getElementsByName('name1')[0].value;
var text = document.getElementsByName('text')[0].value;
if (email0=="" || email1=="" || name0=="" || name1=="" || text==""){
alert('Todos os dados devem ser digitados corretamente para que o envio obtenha sucesso')
}
else{
ValidateEmail(email0);
sendRecomenda(email0, email1, name0, name1,text,contentID,channel);
}
}
function sendComments(loc,userID,contentID,titulo,fullname){
var reply_id = loc.parentNode.comment_id.value;
var text = loc.parentNode.repplyComment.value;
var nome = loc.parentNode.username_reply.value;
var email = loc.parentNode.email_reply.value;
var display_email = loc.parentNode.chkReplyEmailView.checked ? 1 : 0;
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if (nome==""){
alert('Necessário Preencher o campo Nome');
}else if(email=="" || email.match(emailReg)== null){
alert('Necessário fornecer um email válido');
return false;
}
var url = 'ComentarioResponse.aspx?uf=' + getUf() + '&userID='+userID+ '&email=' +email+ '&contentID='+contentID+'&text='+escape(text)+'&reply_id='+reply_id+'&titulo='+escape(titulo)+'&fullname='+escape(nome)+ '&display_email=' + display_email;
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport)
{
var obj = transport.responseText.evalJSON();
var myTemplate = new Template('#{status}');
var valores = myTemplate.evaluate(obj);
var pgatual = document;
if(valores=="sucess"){
alert('Resposta envianda com sucesso');
backComments(loc);
loc.parentNode.username_reply.value="";
loc.parentNode.email_reply.value="";
var idx = document.getElementById('indexPag').value;
ListComment(idx,contentID,userID);
}
pgatual.close();
}
});
}
function sendRecomenda(email0, email1, name0, name1,text,contentID,channel)
{
var url = 'Recomenda.aspx?email0='+email0+'&email1='+email1+'&name0='+name0+'&name1='+name1+'&contentID='+contentID+'&channel='+channel+'&text='+text;
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport)
{
var obj = transport.responseText.evalJSON();
var myTemplate = new Template('#{status}');
var valores = myTemplate.evaluate(obj);
var pgatual = document;
if(valores=="sucess"){
document.getElementsByName('email0')[0].style.display="none";
document.getElementsByName('email1')[0].style.display="none";
document.getElementsByName('name0')[0].style.display="none";
document.getElementsByName('name1')[0].style.display="none";
document.getElementsByName('text')[0].style.display="none";
document.getElementById('feedback').style.display="block";
document.getElementById('mail0').style.display="none";
document.getElementById('mail1').style.display="none";
document.getElementById('mail2').style.display="none";
document.getElementById('mail3').style.display="none";
document.getElementById('messagetext').style.display="none";
document.getElementById('enviorecomendar').style.display="none";
}
if(valores=="failure"){
document.getElementsByName('email0')[0].style.display="none";
document.getElementsByName('email1')[0].style.display="none";
document.getElementsByName('name0')[0].style.display="none";
document.getElementsByName('name1')[0].style.display="none";
document.getElementsByName('text')[0].style.display="none";
document.getElementById('feedback').style.display="block";
document.getElementById('mail0').style.display="none";
document.getElementById('mail1').style.display="none";
document.getElementById('mail2').style.display="none";
document.getElementById('mail3').style.display="none";
document.getElementById('messagetext').style.display="none";
document.getElementById('enviorecomendar').style.display="none";
document.getElementById('feedback').innerHTML = "Sua mensagem não pode ser enviada.";
}
pgatual.close();
}
});
}
function addDenounce(text_denuncia,contentID,channel)
{
var url = 'Denounce.aspx?denuncia='+text_denuncia+'&contentID='+contentID+'&channel='+channel;
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport)
{
var obj = transport.responseText.evalJSON();
var myTemplate = new Template('#{status}');
var valores = myTemplate.evaluate(obj);
var pgatual = document;
if(valores=="sucess"){
document.getElementById('fora').style.display="none"
document.getElementById('envio').style.display="none"
document.getElementById('areadenuncia').style.display="none"
document.getElementById('feedback2').style.display="block"
}
pgatual.close();
}
});
}
function denounceValidate(contentID,channel){
var denounce=document.denounceVideo.areadenuncia.value;
if (denounce==""){
alert("É necessário cadastrar uma denúncia");
document.denounceVideo.areadenuncia.focus();
return false
}
else{
addDenounce(denounce,contentID,channel);
}
}
function BackUpload(url,channel)
{
window.location.href = url+'?channel='+channel;
}
function Go(url,channel)
{
window.location.href = url+'?channel='+channel;
}
function GoContent(url,channel,contentID)
{
window.location.href = url+'?uf=' + getUf() + '&channel='+channel+'&contentID='+contentID;
}
function Ir(url,channel,tipo,userID)
{
window.location.href = url+'?uf=' + getUf() + '&channel='+channel+'&tipo='+tipo+'&user='+userID;
}
function editarVideos(id,index,user,channel)
{
window.location.href = 'MyVideosEdit.aspx?uf=' + getUf() + '&channel='+channel+'&contentID='+id+'&index='+index+'&userID='+user;
}
function onUploadComplete(){
uploadsucess=1;
document.forms['editInfo'].submit();
}
function commentValidate(contentID,userID){
var titulo=document.comment.titulo_coment.value;
var comentario=document.comment.text_coment.value;
var fullname = encodeURI(document.getElementById("username_comment").value);
var email = encodeURI(document.getElementById("email_comment").value);
var exibirEmail = document.getElementById("chkEmailView").checked;
var display_email = (exibirEmail==true) ? 1 : 0;
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if (fullname==""){
alert('Necessário Preencher o campo Nome');
document.getElementById("username_comment").focus();
}
else if(email=="" || email.match(emailReg)== null){
alert('Necessário fornecer um email válido');
document.getElementById("email_comment").focus();
}
else if (titulo==""){
alert('Necessário Preencher o campo Título')
document.comment.titulo_coment.focus();
}
else if(comentario==""){
alert('Necessário Preencher o campo Comentário')
document.comment.text_coment.focus();
return false;
}
else{
addComment(contentID,titulo,comentario,userID, email, fullname, display_email);
}
}
function ListComment(index,contentID,userID){
var url = 'ComentarioList.aspx?uf=' + getUf() + '&contentID='+contentID+'&index='+index+'&userID='+userID;
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport)
{
var obj = transport.responseText.evalJSON();
var myTemplate = new Template('#{item}');
var valores = myTemplate.evaluate(obj);
var pgatual = document;
document.getElementById('divContentsPaging').style.display='none';
document.getElementById('list').innerHTML=valores;
atualizaQtt(contentID);
pgatual.close();
}
});
}
function addComment(contentID,titulo,comentario,userID, email, fullname, display_email)
{
var url = 'DarComentario.aspx?uf=' + getUf() + '&username_comment='+fullname+ '&email_comment='+email+ '&contentID='+contentID+'&titulo_comment='+titulo+'&text_comment='+comentario+ '&display_email='+ display_email;
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport)
{
var obj = transport.responseText.evalJSON();
var myTemplate = new Template('#{status}');
var valores = myTemplate.evaluate(obj);
var pgatual = document;
if(valores=="sucess"){
alert('Comentário enviado com sucesso!');
document.comment.titulo_coment.value="";
document.comment.text_coment.value="";
document.getElementById("username_comment").value="";
document.getElementById("email_comment").value="";
document.getElementById("chkEmailView").checked=false;
}
pgatual.close();
ListComment(1,contentID,userID);
}
});
}
function addNota(contentID){
if(star==0){
alert('Necessário clicar em uma estrela');
return false;
}else{
var url = 'DarNota.aspx?uf=' + getUf() + '&contentID='+contentID+'&star='+star;
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport)
{
var obj = transport.responseText.evalJSON();
var myTemplate = new Template('#{status}');
var valores = myTemplate.evaluate(obj);
var pgatual = document;
if(valores=="sucess"){
document.getElementById('titulo').style.display="none"
document.getElementById('estrelas').style.display="none"
document.getElementById('enviar').style.display="none"
document.getElementById('feednota').style.display="block"
}
pgatual.close();
}
});
}
}
function addFavorite(contentID){
if(userID == 0) {
mLogin(escape(location.href));
return;
}
var url = 'FavoriteVideo.aspx?contentID='+contentID;
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport)
{
var obj = transport.responseText.evalJSON();
var myTemplate = new Template('#{status}');
var valores = myTemplate.evaluate(obj);
var pgatual = document;
if(valores=="sucess"){
alert('Adicionado aos Favoritos com sucesso!');
document.getElementById('addfavorite').style.display="none";
document.getElementById('favorite').style.display="inline";
atualizaQtt(contentID);
}
else{
alert('O Video já foi adicionado como favorito!');
}
pgatual.close();
}
});
}
function doDate(tx,pStr1,pStr2,channel)
{
if (tx.length > 21){
alert('O número de caracteres ultrapassou o limite máximo de 20');
}else{
if(!(tx==""&&pStr1==""&& pStr2=="")){
data1 = pStr1;
var dt1
var dt2
var dt3
dt1 = data1.substr( 0,2 );
dt2 = data1.substr( 3,2 );
dt3 = data1.substr( 6,4 );
data1 = (dt1+"/"+dt2+"/"+dt3);
data2 = pStr2;
var dta
var dtb
var dtc
dta = data2.substr( 0,2 );
dtb = data2.substr( 3,2 );
dtc = data2.substr( 6,4 );
data2 = (dta+"/"+dtb+"/"+dtc);
if (reDate.test(data1))
{
if (reDate.test(data2))
{
var datainicial = new Date();
var datafinal = new Date();
datainicial.setFullYear(dt3,dt2,dt1);
datafinal.setFullYear(dtc,dtb,dta);
if( datainicial > datafinal)
{
alert('Data inicial é maior que a data final');
return false;
}
} else {
if (pStr2 != null && pStr2 != '') {
alert('Data final deve estar no formato dd/mm/aaaa');
return false;
}
}
} else {
if (pStr1 != null && pStr1 != '') {
alert('Data inicial deve estar no formato dd/mm/aaaa');
return false;
} else if (!(reDate.test(data2))) {
if (pStr2 != null && pStr2 != '') {
alert('Data final deve estar no formato dd/mm/aaaa');
return false;
}
}
}
if(data2=='//' && data1!='//'){
window.location.href = 'ResultadoBusca.aspx?uf=' + getUf() + '&channel='+channel+'&tipo=busca&texto='+tx+'&dInicial='+escape(data1);
}else if(data1=='//'&&data2!='//'){
window.location.href = 'ResultadoBusca.aspx?uf=' + getUf() + '&channel='+channel+'&tipo=busca&texto='+tx+'&dFinal='+escape(data2);
}else if(data1!='//'&&data2!='//'){
window.location.href = 'ResultadoBusca.aspx?uf=' + getUf() + '&channel='+channel+'&tipo=busca&texto='+tx+'&dInicial='+escape(data1)+'&dFinal='+escape(data2);
}else{
window.location.href = 'ResultadoBusca.aspx?uf=' + getUf() + '&channel='+channel+'&tipo=busca&texto='+tx;
}
}else{alert('Necessário entrar com uma Palavra Chave ou com uma data inicial ou final');}
}
}
function SomenteNumero(e)
{
var tecla=(window.event)?event.keyCode:e.which;
if((tecla > 46 && tecla < 58))
{
return true;
}
else
{
if (tecla == 8 || tecla == 0)
{
return true;
}else
{
return false;
}
}
}
function SomenteAlfaNumericos(e)
{
var tecla=(window.event)?event.keyCode:e.which;
if((tecla > 64 && tecla < 122))
{
return true;
}
else
{
if (tecla == 8 || tecla == 0)
{
return true;
}else
{
return false;
}
}
}
function backAction(action){
if (action=="denuncia"){
document.getElementById('denuncie').style.display='none'
}
if (action=="nota"){
star=0;
ApagarNota();
document.getElementById('nota').style.display='none'
}
if (action=="recomenda"){
document.getElementById('recomenda').style.display='none'
}
document.getElementById('main').style.display='block'
}
function videoAction(action,channel,userID,contentID)
{
document.getElementById('main').style.display='none';
if ((action=="denuncia"))
{
var url = 'validaSessao.aspx?userID='+userID;
new Ajax.Request(url, { method: 'get', onSuccess: function(transport)
{
var obj = transport.responseText.evalJSON();
var myTemplate = new Template('#{status}');
var valores = myTemplate.evaluate(obj);
var pgatual = document;
if(valores=="sucess")
{
if (action=="denuncia")
{
document.getElementById('denuncie').style.display="block"
document.getElementById('fora').style.display="block"
document.getElementById('envio').style.display="inline"
document.getElementById('areadenuncia').style.display="block"
document.getElementById('feedback2').style.display="none"
document.getElementById('areadenuncia').value="";
document.denounceVideo.areadenuncia.focus();
}
/*if (action=="recomenda")
{
document.getElementById('feedback').style.display="none";
document.getElementById('recomenda').style.display="block"
document.getElementById('mail').style.display="inline";
document.getElementsByName('email')[0].style.display="inline";
document.getElementById('messagetext').style.display="block";
document.getElementsByName('text')[0].style.display="inline";
document.getElementById('enviorecomendar').style.display="inline";
document.getElementsByName('email')[0].value="";
document.denounceRecomendar.email.focus();
document.getElementsByName('text')[0].value="";
}
if (action=="recomenda2")
{
document.getElementById('feedback').style.display="none";
document.getElementById('recomenda').style.display="block"
document.getElementById('mail').style.display="inline";
document.getElementsByName('email')[0].style.display="inline";
document.getElementById('messagetext').style.display="block";
document.getElementsByName('text')[0].style.display="inline";
document.getElementById('enviorecomendar').style.display="inline";
document.getElementsByName('email')[0].value="";
document.denounceRecomendar.email.focus();
document.getElementsByName('text')[0].value="";
} */
}
else
{
var loc = document.location;
mLogin(escape(loc));
}
pgatual.close();
}
});
}
if (action=="recomenda")
{
document.getElementById('feedback').style.display="none";
document.getElementById('recomenda').style.display="block"
document.getElementById('mail').style.display="inline";
document.getElementsByName('email')[0].style.display="inline";
document.getElementById('messagetext').style.display="block";
document.getElementsByName('text')[0].style.display="inline";
document.getElementById('enviorecomendar').style.display="inline";
document.getElementsByName('email')[0].value="";
document.denounceRecomendar.email.focus();
document.getElementsByName('text')[0].value="";
}
if (action=="recomenda2")
{
document.getElementsByName('email0')[0].style.display="inline";
document.getElementsByName('email1')[0].style.display="inline";
document.getElementsByName('name0')[0].style.display="inline";
document.getElementsByName('name1')[0].style.display="inline";
document.getElementsByName('text')[0].style.display="inline";
document.getElementById('feedback').style.display="none";
document.getElementById('mail0').style.display="";
document.getElementById('mail1').style.display="";
document.getElementById('mail2').style.display="";
document.getElementById('mail3').style.display="";
document.getElementById('messagetext').style.display="";
document.getElementById('feedback').style.display="none";
document.getElementById('recomenda').style.display="block"
document.getElementById('enviorecomendar').style.display="inline";
document.getElementsByName('email0')[0].value="";
document.getElementsByName('name0')[0].value="";
document.denounceRecomendar.email0.focus();
document.getElementsByName('text')[0].value="";
}
if (action=="nota"){
document.getElementById('nota').style.display="block"
document.getElementById('titulo').style.display="block"
document.getElementById('estrelas').style.display="block"
document.getElementById('enviar').style.display="inline"
document.getElementById('feednota').style.display="none"
star = 0;
}
}
function detalheshow(desc,more,tam){
if (more=='show'){
document.getElementById('show').style.display="none";
document.getElementById('hide').style.display="inline";
document.getElementById('descript').innerHTML=desc;
}
else{
document.getElementById('hide').style.display="none";
document.getElementById('show').style.display="inline";
document.getElementById('descript').innerHTML=desc.substr(0,tam)+"...";
}
}
function responseComments(loc){
var div = loc.parentNode;
while(div.tagName != "DIV") div = div.parentNode;
div = div.getElementsByTagName("DIV")[0];
div.style.display="block";
}
function backComments(loc){
loc.parentNode.getElementsByTagName("textarea")[0].value="";
loc.parentNode.getElementsByTagName("textarea")[0].focus();
loc.parentNode.parentNode.style.display="none";
}
function detalhes(desc,loc,tam){
var evento = loc.innerHTML;
if (evento.substr(0,3)=='&gt'){
loc.parentNode.childNodes[0].nodeValue=desc;
loc.innerHTML=" << ";
}
else{
loc.parentNode.childNodes[0].nodeValue=desc.substr(0,tam)+"...";
loc.innerHTML=" >> ";
}
}
function Add(index)
{
var mi = CreateMediaItem(titles[index],urls[index]);
playlistSample.add(mi);
}
function CreateMediaItem(title,url)
{
var mi = new MediaItem();
mi.title = title;
mi.setUrl(0,url);
mi.ads = new Array();
return(mi);
}
function ValidateMyVideo(){
var title = document.editInfo.videoTitle.value;
var description = document.editInfo.videoDescription.value;
var tags = document.editInfo.videoTags.value;
var arraytags = tags.split(";");
var i=0;
var arraytag;
var param;
if(title==""){
alert('Entre com o Título do Vídeo');
return false;
}
if(description ==""){
alert('É obrigatório o preenchimento da Descrição do Vídeo');
return false;
}
if(tags==""){
alert('Entrar com pelo menos 1 palavras chave (tags)');
return false;
}
if (title.length > 70){
alert('O título deverá possuir até 70 caracteres');
return false;
}
if (description.length > 500){
alert('A descrição deverá possuir até 500 caracteres');
return false;
}
if (arraytags.length > 10){
alert('Entre com no máximo 10 palavras chaves');
return false;
}
for(i=0;i<tags.length;i++){
param = trim(arraytags[i]);
if(param == ""||arraytags[i]=="" )
{
alert(' Entre com uma palavra chave após o ; ');
return false;
}
arraytag = arraytags[i].split(",");
if(arraytag.length > 1){
alert('Separar as palavras chaves por ;');
return false;
}
}
return true;
}
function trim(str)
{
if(!str || typeof str != 'string')
return null;
else
return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}
function ValidateUpload(){
var maxTags = 10;
var title = document.editInfo.videoTitle.value;
var description = document.editInfo.videoDescription.value;
var tags = document.editInfo.videoTags.value;
var arraytags = tags.split(" ");
var i=0;
var arraytag;
var param;
if(title==""){
alert('Entre com o Título do Vídeo');
return false;
}
if(description ==""){
alert('É obrigatório o preenchimento da Descrição do Vídeo');
return false;
}
if (title.length > 70){
alert('O título deverá possuir até 70 caracteres');
return false;
}
if (description.length > 500){
alert('A descrição deverá possuir até 500 caracteres');
return false;
}
if (arraytags.length > maxTags){
alert('Entre com no máximo ' + maxTags + ' palavras chaves');
return false;
}
return true;
}
function RemovMV(contentID,index,userID,tipo,titulo)
{
var f = 'RemoverMV'+contentID;
var r=confirm('Tem certeza que deseja remover o vídeo: '+titulo+'');
if (r==true)
{
window.location.href = 'DelVideo.aspx?uf=' + getUf() + '&contentID='+contentID+'&userID='+userID+'&index='+index+'&tipo='+tipo;
}
}
function RemovMF(contentID,index,userID,tipo,titulo)
{
var f = 'RemoverMF'+contentID;
var r=confirm('Tem certeza que deseja remover o vídeo: '+titulo+'');
if (r==true)
{
window.location.href = 'DelVideo.aspx?uf=' + getUf() + '&contentID='+contentID+'&userID='+userID+'&index='+index+'&tipo='+tipo;
}
return false;
}
function RemovTot(user,tipo)
{
var url='DelVideo.aspx?uf=' + getUf() + '&userID='+user+'&tipo='+tipo+'&contents='
var arrayoption = document.getElementsByName('option');
var i=0;
var titulos="";
var aux="";
var arrayseparador=new Array();
for(i=0;i < arrayoption.length; i++)
{
if (arrayoption[i].checked==true)
{
aux = arrayoption[i].value;
arrayseparador=aux.split('@@');
url=url+arrayseparador[0]+"_";
titulos=titulos+arrayseparador[1]+" ";
}
}
if(url=='DelVideo.aspx?uf=' + getUf() + '&userID='+user+'&tipo='+tipo+'&contents=')
{
alert('Não existem vídeos selecionados!');
}
else
{
url.split("_");
var r=confirm('Tem certeza que deseja remover o(s) vídeo(s): '+titulos+'');
if (r==true)
{window.location.href = url;}
}
return false;
}
function editarVideo(contentID,index,userID)
{
window.location.href = 'MyVideos.aspx?uf=' + getUf() + '&?contentID='+contentID+'&userID='+userID+'&index='+index;
}
function mudaCor(id)
{
if(id=="favorite")
{
document.getElementById(id).style.color='E7bE00';
}
else
{
document.getElementById(id).style.color='Black';
}
}
function mudaCorOriginal(id)
{
if(id=="favorite")
{
document.getElementById(id).style.color='FFDE43';
}
else
{
document.getElementById(id).style.color='#424242';
}
}
function logout()
{
document.location = 'logout.aspx?uf=' + getUf() + '&';
}
function cancelUpload01()
{
document.editInfo.videoTitle.value="";
document.editInfo.videoDescription.value="";
document.editInfo.videoTags.value="";
var categories = document.editInfo.category;
var i=0;
for(i=0;i < categories.length;i++)
{
document.editInfo.category[i].checked=false;
}
document.editInfo.notifymail.checked=false;
}
function cancelUpload01_()
{
history.back();
}
function sucessUpload()
{
if(uploadsucess==1)
{
uploadsucess=0;
return true
}
else
{
alert('É necessário fazer upload de um vídeo');
return false
}
return false
}
function mLogin(loc)
{
var url = 'login.aspx?url=';
url += escape(loc);
document.location = url;
}
function registerEvent(listenerObject, eventName, callbackFunction) {
var eventRegistered = true;
if(listenerObject.addEventListener){
listenerObject.addEventListener(eventName, callbackFunction, false);
} else if (listenerObject.attachEvent){
eventRegistered = listenerObject.attachEvent('on' + eventName, callbackFunction);
} else {
eventRegistered = false;
}
return eventRegistered;
}
function msgErro()
{
alert('123');
}
function atualizaQtt(contentID)
{
var url = 'Atualiza.aspx?uf=' + getUf() + '&?contentID='+contentID;
new Ajax.Request(url, { method: 'get', onSuccess: function(transport)
{
var obj = transport.responseText.evalJSON();
var valExib = obj.exibicoes;
var valComent = obj.comentarios;
var valFav = obj.favoritado;
var exib = document.getElementById('tExi');
var coment = document.getElementById('tCom');
var fav = document.getElementById('tFav');
exib.innerHTML = valExib;
coment.innerHTML = valComent;
fav.innerHTML = valFav;
}
});
}
toRegister = function () {
window.open('http://www.clicrbs.com.br/servlet/SignUpServlet?op=1&nexttop=21');
}
openPluginWindow = function () {
window.open("Plugin.php","plugin","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=585, height=530")
}
getUf = function () {
var uf = 1; // Valor padrão, caso não encontre um válido no cookie
var arr = document.cookie.split("; ");
var uf = 0;
for(var i=0; i<arr.length; i++) {
var pair = arr[i].split("=");
if(pair[0] == "MC_uf") {
uf = pair[1];
break;
}
}
return(uf);
}
function InstallPluginActiveX () {
xpi={'Mozilla Firefox 1.5 ActiveX Plug-in':'http://www.iol.ie/~locka/mozilla/mozactivex-ff-15.xpi'};
InstallTrigger.install(xpi);
}
function Querystring(qs) {
this.params = new Object()
this.get=Querystring_get
if (qs == null)
qs=location.search.substring(1,location.search.length)
if (qs.length == 0) return
qs = qs.replace(/\+/g, ' ')
var args = qs.split('&')
for (var i=0;i<args.length;i++) {
var value;
var pair = args[i].split('=')
var name = unescape(pair[0])
if (pair.length == 2)
value = unescape(pair[1])
else
value = name
this.params[name] = value
}
}
function Querystring_get(key, default_) {
if (default_ == null) default_ = null;
var value=this.params[key]
if (value==null) value=default_;
return value
}
function fillSearchField (check) {
var q = new Querystring();
if(check == true) {
if(q.params['tipo'] == 'busca' && q.params['texto'] != "undefined") {
if(window.attachEvent) {
window.attachEvent("onload", fillSearchField);
} else {
window.addEventListener("load", fillSearchField, false);
}
}
} else {
document.getElementsByName('texto')[0].value = q.params['texto'];
}
}
function Tools() {
this.formatSeconds = tools_FormatSeconds;
function tools_FormatSeconds(seconds) {
var hrs, min, sec;
hrs = parseInt(seconds / 3600);
seconds = seconds % 3600;
min = parseInt(seconds / 60);
if(min < 10) min = '0' + min;
sec = parseInt(seconds % 60);
if(sec < 10) sec = '0' + sec;
return ((hrs > 0) ? (hrs + ':') : '') + min + ':' + sec;
}
}
document.location.QueryString = (function (){
var params = {};
var qs=location.search.substring(1,location.search.length)
if (qs.length == 0) return
qs = qs.replace(/\+/g, ' ')
var args = qs.split('&');
for (var i=0;i<args.length;i++) {
var value;
var pair = args[i].split('=');
var name = unescape(pair[0]);
if (pair.length == 2){
value = unescape(pair[1]);
}
else{
value = name;
}
params[name] = value;
}
return function(key){
var value = params[key];
if (value !=null){
return value;
}
}
})();
function PlayerSample(playerName, playerObjName, type)
{
this.playerName = playerName;
this.currentPlaylist = null;
this.tools = new Tools();
if(type==1)
this.player = new PlayerWmSimple(this.playerName + '.player', document.getElementById(playerObjName));
else
this.player = new PlayerReal(this.playerName + '.player', document.getElementById(playerObjName));
this.getCurrentMediaDuration = player_GetCurrentMediaDuration;
this.previous = player_Previous;
this.next = player_Next;
this.playItem = player_PlayItem;
this.play = player_Play;
this.pause = player_Pause;
this.stop = player_Stop;
this.ff = player_FF;
this.rew = player_Rew;
this.fullScreen = player_FullScreen;
this.mute = player_Mute;
this.unmute = player_Unmute;
this.repeat = player_Repeat;
this.unrepeat = player_Unrepeat;
this.changeMute = player_ChangeMute;
this.set43 = player_Set43;
this.set169 = player_Set169;
this.getCurrentPlaylist = player_GetCurrentPlaylist;
this.setCurrentPlaylist = player_SetCurrentPlaylist;
this.increaseVolume = player_IncreaseVolume;
this.decreaseVolume = player_DecreaseVolume;
this.updatePlayingStatus = player_updatePlayingStatus;
this.logEvent = player_logEvent;
this.currentMediaChange = player_CurrentMediaChange;
this.updateTimeInfo = player_UpdateTimeInfo;
this.toggleVideoImage = player_ToggleVideoImage;
this.setPosition = player_Posicao;
this.registerPageHit = player_RegisterPageHit;
this.sendHttpRequest = player_SendHttpRequest;
this.realPlayTime = 0;
this.realPlayTime_Fraction = 0;
this.realPlayTime_BaseDate = new Date();
this.realPlayTime_ReportInterval = 30;
this.hasLogged = false;
this.logRetry = false;
this.lastPosition = 0;
this.pageHitRegistered = false;
this.player.onCurrentMediaChange.add(this.playerName, 'currentMediaChange');
this.player.onCurrentPositionChange.add(this.playerName, 'updateTimeInfo');
this.player.onPlayStateChange.add(this.playerName, 'toggleVideoImage');
this.player.onPlayerStateStringChange.add(this.playerName, 'updatePlayingStatus');
function player_Previous() {
this.player.previous();
}
function player_Next() {
this.player.next();
}
function player_PlayItem(index) {
this.player.playItem(index);
}
function player_Play()
{
this.player.play();
this.updateTimeInfo();
}
function player_Pause() {
this.player.pause();
this.updateTimeInfo();
}
function player_Stop() {
this.player.stop();
this.updateTimeInfo();
}
function player_FF() {
this.player.fastForward();
}
function player_Rew() {
this.player.rewind();
}
function player_FullScreen()
{
this.player.fullScreen();
}
function player_ChangeMute()
{
if(this.player.getMute())
{
this.player.setMute(false);
}
else
{
this.player.setMute(true);
}
}
function player_Mute()
{
this.player.setMute(true);
}
function player_Unmute()
{
this.player.setMute(false);
}
function player_Repeat()
{
this.player.setRepeat(true);
}
function player_Unrepeat()
{
this.player.setRepeat(false);
}
function player_GetCurrentPlaylist() {
return this.currentPlaylist;
}
function player_SetCurrentPlaylist(pl) {
this.currentPlaylist = pl;
this.player.setCurrentPlaylist(pl.playlist);
}
function player_IncreaseVolume()
{
var volume = this.player.getVolume();
volume += 10;
if(volume > 100)
volume = 100;
this.player.setVolume(volume);
if (isNaN(volume)) volume = 0;
document.getElementById('elapsedVol').style.width= Math.round(volume) +"%";
}
function player_DecreaseVolume()
{
var volume = this.player.getVolume();
volume -= 10;
if(volume < 0)
volume = 0;
this.player.setVolume(volume);
if (isNaN(volume)) volume = 0.1;
document.getElementById('elapsedVol').style.width= Math.round(volume) +"%";
}
function player_Set43()
{
this.player.resize(320,240);
}
function player_Set169()
{
this.player.resize(426,240);
}
function player_updatePlayingStatus ()
{
var divStatus = document.getElementById("currentStatus");
if(divStatus) {
if(this.player.playerObject.error && this.player.playerObject.error.errorCount > 0 && divStatus.hasError != true && this.player.getPlayState() == 1) {
var playerStatus = "Falha na execução desta mídia.<br /><br />Tente novamente <a style='font-weight: bold;' href='javascript:;' onclick='playerSample.play()'>clicando aqui</a>";
if(location.href.indexOf("player.aspx") > -1) {
playerStatus = "<img width='1' height='45%' border='0' src='/image/spacer.gif'/>" + playerStatus;
}
divStatus.style.display = "block";
divStatus.hasError = true;
if(location.href.toLowerCase().indexOf("player.aspx") > -1) {
var player = document.getElementsByName("playerObject")[0];
if(navigator.appName.indexOf("Internet Explorer") > -1) {
player.style.display = "none";
} else {
player.style.visibility = "hidden";
}
}
this.hasLogged = false;
this.logEvent();
} else {
var playerStatus = "";
divStatus.style.display = "none";
divStatus.hasError = false;
if(location.href.toLowerCase().indexOf("player.aspx") > -1) {
var player = document.getElementsByName("playerObject")[0];
if(navigator.appName.indexOf("Internet Explorer") > -1) {
player.style.display = "block";
} else {
player.style.visibility = "visible";
}
}
}
divStatus.innerHTML = playerStatus;
}
}
function player_CurrentMediaChange()
{
var current = this.player.getCurrentMedia();
var currentUrl = this.player.getCurrentMedia().mediaUrls.toString();
this.pageHitRegistered = false;
this.registerPageHit(currentUrl);
var div = document.getElementById('currentItem');
if(div) div.innerHTML = 'Current: ' + current.title;
}
function player_GetCurrentMediaDuration()
{
return this.player.getCurrentMediaDuration();
}
function player_Posicao(pos)
{
this.player.setPosition(pos * this.player.getCurrentMediaDuration());
}
function player_ToggleVideoImage () {
var state = +this.player.playerObject.playState;
if(state == 10 && this.player.playerObject.error.errorCount > 0) {
this.logEvent(1);
} else if(state == 3) {
this.logEvent(3);
} else if(state == 1 || state == 9) {
this.hasLogged = false;
}
var videoObj = this.player.playerObject;
if(videoObj.getAttribute("hasImage") != "true") return;
var videoImg = document.getElementById("videoScreenImage");
if(state <= 1) {
videoObj.style.visibility = "hidden";
if(videoImg) videoImg.style.display = "";
} else {
videoObj.style.visibility = "visible";
if(videoImg) videoImg.style.display = "none";
}
}
function player_logEvent () {
if(this.hasLogged == true) return;
if(typeof logWmp == "undefined" || logWmp == "off" || logWmp == false || logWmp == "false") return;
var eventType = 0;
var mediaUrl = escape(this.player.playerObject.currentMedia.sourceURL);
var playerVersion = this.player.playerObject.versionInfo;
var errorCode = "", errorDesc = "";
var live = (typeof isLive == "undefined" || isLive == false) ? false : true;
var parameters = "?retry=" + this.logRetry.toString() + "&mediaUrl=" + mediaUrl + "&playerVersion=" + playerVersion + "&isLive=" + live;
if(this.player.playerObject.error.errorCount > 0) {
var error = this.player.playerObject.error.item(0);
var errorCode = escape(error.errorCode);
var errorDesc = escape(error.errorDescription);
eventType = 1;
parameters += "&errorCode=" + errorCode + "&errorDesc=" + errorDesc + "&lastPosition=" + this.lastPosition;
this.logRetry = true;
this.lastPosition = 0;
} else if(logWmp == "errorsonly") {
return;
}
var urlRequest = "/wmplog.aspx";
parameters += "&eventType=" + eventType;
if(document.domain.match(/^mediacenter(.)*.clicrbs.com.br$/) == null) {
urlRequest = "http://mediacenter.clicrbs.com.br" + urlRequest;
}
/*
var httpRequest;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
try {
httpRequest.open("GET", "/wmplog.aspx?" + parameters, true);
httpRequest.send(null);
} catch {}
*/
this.sendHttpRequest(urlRequest + parameters);
this.hasLogged = true;
}
function player_RegisterPageHit(currentUrl)
{
if(this.pageHitRegistered) return;
var mediaUrl = unescape(currentUrl).toLowerCase();
if(mediaUrl.indexOf("getasx.aspx") == -1) return;
var params = mediaUrl.substring(mediaUrl.indexOf("?")+1).split("&");
var contentId = 0;
for(var i=0; i<params.length; i++) {
var param = params[i].split("=");
if(param[0] == "contentid") {
contentId = param[1];
break;
}
}
if(contentId == 0 || isNaN(contentId)) return;
var urlRequest = "/templates/Hit.aspx?c=" + contentId;
if(document.domain.match(/^mediacenter(.)*.clicrbs.com.br$/) == null) {
urlRequest = "http://mediacenter.clicrbs.com.br" + urlRequest;
}
this.sendHttpRequest(urlRequest);
this.pageHitRegistered = true;
}
function player_SendHttpRequest(url) {
if(url == "" || !url) return;
var pageDomain = document.domain;
var urlDomain = url.substring(0, url.indexOf("/", url.indexOf("//")+2)).replace("http://", "");
var crossDomainRequest = (pageDomain != urlDomain) && (url.charAt(0) != "/");
var url = url + (url.indexOf("?") > -1 ? "&" : "?") + new Date().getTime();
if(crossDomainRequest) {
var dummyImg = document.createElement("IMG");
dummyImg.width = 0;
dummyImg.height = 0;
document.body.appendChild(dummyImg);
dummyImg.src = url;
} else {
var httpRequest;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
httpRequest.open("GET", url, true);
httpRequest.send(null);
}
}
function player_UpdateTimeInfo()
{
var div = document.getElementById('currentTime');
var div2 = document.getElementById('currentStatus');
if(div)
{
var state = +this.player.playerObject.playState;
if(state == (new PlayState()).buffering)
{
document.getElementById('time').innerHTML = 'Carregando...';
}
else
{
var duration = this.player.getCurrentMediaDuration();
var currentPosition = this.player.getPosition();
var intStatus = state;
var strStatus;
if(currentPosition > this.lastPosition) this.lastPosition = currentPosition;
switch (intStatus)
{
case 0: case 1 : // Stopped
strStatus = "Parado";
break;
case 10 : // Ready
strStatus = "Parado";
break;
case 2 : // Paused
strStatus = "Pausado";
break;
case 7 : // Waiting
strStatus = "teste2";
break;
case 4 : // ScanForward
strStatus = "teste3";
break;
case 5 : // ScanReverse
strStatus = "teste4";
break;
case 3 : // Playing
strStatus = "Reproduzindo...";
break;
case 8 : // MediaEnded
strStatus = "teste5";
break;
case 9 : // Transitioning
strStatus = "Carregando...";
break;
case 11 : // Reconnecting
strStatus = "teste7";
break;
case 6 : // Buffering
strStatus = "Carregando...";
break;
default :
strStatus = "teste9";
break;
}
if(intStatus == 3) {
this.realPlayTime_Fraction = Math.round(-(this.realPlayTime_BaseDate - new Date())/1000);
/*
if((this.realPlayTime + this.realPlayTime_Fraction) % this.realPlayTime_ReportInterval == 0) {
if(typeof pageTracker != "undefined") pageTracker._trackPageview("/30sviews/");
if(typeof pageTracker1 != "undefined") pageTracker1._trackPageview("/30sviews/");
}*/
} else {
this.realPlayTime += +this.realPlayTime_Fraction;
this.realPlayTime_BaseDate = new Date();
this.realPlayTime_Fraction = 0;
}
var divVivo = document.getElementById('vivo');
var divTime = document.getElementById('time');
var btnPlayPause = document.getElementById('btnPlayPause');
var progressBar = document.getElementById("timeline_progress");
if (divVivo)
{
div.innerHTML = this.tools.formatSeconds(currentPosition);// + '      ' + strStatus;
}
else
{
div.innerHTML = this.tools.formatSeconds(currentPosition) + ' / ' + this.tools.formatSeconds(duration); //+ '      ' + strStatus;
}
var position = (currentPosition/duration);
if (isNaN(position)) position = 0;//0.1;
try {
if (!isDraging) slider.setValue(position);
} catch (e) {}
if(divTime) divTime.innerHTML = strStatus;
if(btnPlayPause) {
btnPlayPause.className = state == 3 ? "pause" : "play";
}
if(intStatus == 0 || intStatus == 1 || intStatus == 7 || intStatus == 8 || intStatus == 9 || intStatus == 10) {
this.pageHitRegistered = false;
}
if(progressBar) {
if(state == 3 || state == 2) {
var progress = Math.round((currentPosition/duration)*100).toString();
if(isNaN(progress)) progress = 0;
progressBar.style.width = progress + "%";
} else if(state == 1) {
progressBar.style.width = "0%";
}
}
this.toggleVideoImage();
if(state == 1 || state == 9) this.lastPosition = 0;
}
}
if(div2)
{
}
}
}
function PlaylistSample(playlistName)
{
this.playlistName = playlistName;
this.playlist = new Playlist();
this.add = pl_Add;
this.getItem = pl_GetItem;
this.clear = pl_Clear;
this.count = pl_Count;
this.draw = pl_Draw;
this.playlist.onChange.add(this.playlistName, 'draw');
this.playlist.adsFrequency = 2;
this.playlist.maxAdsFirst = 1;
this.playlist.maxAds = 1;
function pl_Add(item)
{
this.playlist.appendItem(item);
}
function pl_GetItem(index)
{
return (this.playlist.getItem(index));
}
function pl_Clear() {
this.playlist.clear();
}
function pl_Count() {
return (this.playlist.count());
}
function pl_Draw()
{
var div = document.getElementById('currentPlaylist');
var html = '';
if(div)
{
for(var i = 0; i < this.count(); i++)
{
var item = this.getItem(i);
html += (i+1) + ' ' + item.title + '<br>';
}
div.innerHTML = html;
}
}
}
toggleVideoImage = function (hideImage) {
var videoImg = document.getElementById("videoImage");
var videoObj = document.getElementById("playerObject");
videoObj.style.visibility = (hideImage) ? "visible" : "hidden";
}
drawPlayer = function (url, width, height, hasImage, containerID, isAudio, isEmbed) {
if(!hasImage) hasImage = false;
var playerType = GetPlayerType();
var playerVisibility = (hasImage ? 'style="visibility: hidden"' : '');
var playerClass = (playerType == new PlayerType().WindowsMedia ? ' CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" ' : ' type="application/x-ms-wmp" ');
if(isAudio) hasImage = false;
var playerHtml = "<OBJECT " +
playerVisibility +
playerClass +
' hasImage="' + hasImage + '"' +
' id="playerObject" ' +
' name="playerObject" ' +
' width="' + width + '" ' +
' height="' + height + '">';
playerHtml += '' +
'<param name="FileName" value="">'+
'<param name="AutoStart" value="False">'+
'<param name="TransparentAtStart" value="0">'+
'<param name="ShowStatusBar" value="0">'+
'<param name="ShowDisplay" value="0">'+
'<param name="AutoSize" value="1">'+
'<param name="UImode" value="none">'+
'<param name="AnimationAtStart" value="True">'+
'<param name="StretchToFit" value="True">'+
'</OBJECT>';
//var forceWmEmbed = document.location.QueryString("forceWmEmbed") == "true" ? true : false;
var playerEmbed = RenderWmpFallback(url, width, height);
var urlEmbed = location.href + '&forceWmEmbed=true';
var noPluginHtml = '' +
'<div class="pluginErrorMessage" id="pluginErrorMessage" style="width: ' + width + 'px; height: ' + height + 'px; text-align: center">' +
'<div style="height:' + (height/3) + 'px;">&nbsp</div>' +
'<div style="width: 250px; margin-left: ' + ((width-250)/2) + 'px; border: 1px solid black; background: white; opacity: 0.7; filter:alpha(opacity=70); padding: 5px; box-sizing: padding-box; -moz-box-sizing: padding-box">' +
'Seu browser não possui os plugins necessários para reproduzir este vídeo.<br /><br />' +
'<b><a href="#" onclick="openPluginWindow(); return false">Instalar Plugin</a></b></div>' +
'</div>';
var container = document.getElementById(containerID);
if(typeof container == 'undefined')
{
var container = document.getElementById('video');
}
if(0){
container ? container.innerHTML += playerEmbed : document.write(playerEmbed);
if($$(".secondColumn .videoScreen").first())
{
$$(".secondColumn .videoScreen").first().removeClassName("videoScreen");
$("videoScreen").setStyle({margin:"2px"});
}
else
{
$$(".videoScreen").first().removeClassName("videoScreen");
$("videoScreen").setStyle({marginLeft:"5px"});
}
return;
}
else if(playerType != new PlayerType().Unsupported) {
container ? container.innerHTML += playerHtml : document.write(playerHtml);
return;
}
else {
container ? container.innerHTML += noPluginHtml : document.write(noPluginHtml);
return;
}
/*
else {
var divControls = document.getElementById('videoControl');
if(divControls)
{
divControls.style.display = 'none';
}
container ? container.innerHTML += playerEmbed : document.write(playerEmbed);
}
*/
}
initPlayer = function (autoPlay) {
if(!document.getElementById("playerObject") || !document.getElementById("imgTime")) {
setTimeout(function () { initPlayer(autoPlay); }, 500);
return;
}
playerSample = new PlayerSample('playerSample','playerObject',1);
playlistSample = new PlaylistSample('playlistSample');
playerSample.setCurrentPlaylist(playlistSample);
if(urls[0] != "" && urls[0] != null) Add(0);
Add(1);
if(autoPlay == true) playerSample.play();
tm = playerSample.player.getCurrentMediaDuration();

}
function GetPlayerType()
{
var player = null;
var playerType = new PlayerType();
if (window.ActiveXObject) {
try { player = new ActiveXObject("WMPlayer.OCX.7"); } catch(e) {}
if(player) return (playerType.WindowsMedia);
}
if (window.ActiveXObject) {
try { player = new ActiveXObject("MediaPlayer.MediaPlayer.1"); } catch(e) {}
if(player) return (playerType.WindowsMedia);
}
if(HasPlugin("Windows Media Player Firefox")) {
return (playerType.WindowsMediaFirefox);
}
if (window.GeckoActiveXObject) {
try { player = new GeckoActiveXObject("MediaPlayer.MediaPlayer.1"); } catch (e) {}
if(player) return (playerType.WindowsMedia);
}
if(window.navigator.appVersion.indexOf('Chrome') >0)
{
return (playerType.WindowsMedia);
}
return (playerType.Unsupported);
}
function HasPlugin(plugin)
{
for(var i = 0; i < navigator.plugins.length; i++) {
if(navigator.plugins[i].name.indexOf(plugin) != -1) return (true);
}
return (false);
}
function PlayerType ()
{
this.Unsupported = 0;
this.WindowsMedia = 1;
this.Quicktime = 2;
this.Silverlight = 3;
this.WindowsMediaFirefox = 4;
}
function RenderWmpFallback(url, width, height, type)
{
if(height == 225)
{
height = height + 60;
}
else if (height == 300)
{
height = height + 60;
}
var sHtml = '';
sHtml += '<embed id=\"playerHtml\" type="application/x-mplayer2" ';
sHtml += 'src="' + url + '" ';
sHtml += 'width="' + width + '" ';
sHtml += 'height="' + height + '" ';
sHtml += 'ShowPositionControls=1 ';
sHtml += 'ShowTracker=1 ';
sHtml += 'ShowControls=1 ';
sHtml += 'ShowStatusBar=1 ';
sHtml += 'Volume=50 ';
sHtml += 'AutoSize=0 ';
sHtml += 'DisplaySize=0 ';
sHtml += 'StretchToFit=1 ';
sHtml += '></embed>';
return sHtml;
}
function PlayerWmSimple(objName, playerObject) {
this.getCurrentMediaDuration = wm_GetCurrentMediaDuration;
this.getPosition = wm_GetPosition;
this.setPosition = wm_SetPosition;
this.next = wm_Next;
this.pause = wm_Pause;
this.play = wm_Play;
this.playItem = wm_PlayItem;
this.playUrl = wm_PlayUrl;
this.previous = wm_Previous;
this.stop = wm_Stop;
this.fastForward = wm_FastForward;
this.rewind = wm_Rewind;
this.getMute = wm_GetMute;
this.setMute = wm_SetMute;
this.getRepeat = wm_GetRepeat;
this.setRepeat = wm_SetRepeat;
this.getVolume = wm_GetVolume;
this.setVolume = wm_SetVolume;
this.getQuality = wm_GetQuality;
this.setQuality = wm_SetQuality;
this.getCurrentPlaylist = wm_GetCurrentPlaylist;
this.setCurrentPlaylist = wm_SetCurrentPlaylist;
this.getPlayState = wm_GetPlayState;
this.getCurrentMedia = wm_GetCurrentMedia;
this.getStatus = wm_GetStatus;
this.getBitrate = wm_GetBitrate;
this.fullScreen = wm_FullScreen;
this.resize = wm_Resize;
this.onCurrentMediaChange = new EventManager(); // Occurs when the current media changes
this.onCurrentPositionChange = new EventManager(); // Occurs when the current position in the media item changes
this.onMuteChange = new EventManager(); // Occurs when the mute state changes
this.onPlayerStateStringChange = new EventManager(); // Occurs when the player state string changes
this.onPlayStateChange = new EventManager(); // Occurs when the play state changes
this.currentPlaylist = null;
this.objName = objName;
this.playerObject = playerObject;
this.playState = new PlayState();
this.quality = new Quality().low;
this.repeat = false;
this.lastCurrentPosition = 0;
this.lastMediaUrl = '';
this.lastMute = false;
this.lastPlayState = this.playState.undefined;
this.lastStateStr = '';
this.sync = wm_Sync;
this.createInternalPlaylist = wm_CreateInternalPlaylist;
this.getCurrentPlaySequenceIndex = wm_GetCurrentPlaySequenceIndex;
this.getCurrentIndex = wm_GetCurrentIndex;
this.tick = wm_Tick;
this.createInternalPlaylist();
this.manualStop = true;
setTimeout(this.objName +'.tick();', 500);
function wm_Next() {
if(this.getCurrentIndex()<this.currentPlaylist.count()-1)
{
this.playItem(this.getCurrentIndex()+1);
}
else
{
this.playItem(0);
}
}
function wm_Pause() {
this.playerObject.controls.pause();
}
function wm_Play() {
if(this.currentPlaylist!=null && this.getPlayState()!=this.playState.paused && this.getPlayState()!=this.playState.playing)
{
this.playItem(0);
}
else
{
this.playerObject.controls.play();
}
this.currentPlayState = this.playState.playing;
}
function wm_PlayItem(index)
{
if(this.currentPlaylist.count() > 0 && index < this.currentPlaylist.count())
{
var playSequence = this.currentPlaylist.getPlaySequence();
var psIndex = this.currentPlaylist.getPlaySequenceIndex(index);
this.playerObject.URL = playSequence[psIndex].mediaUrls[this.quality];
this.playerObject.controls.play();
this.manualStop = false;
}
}
function wm_PlayUrl(url) {
this.playerObject.URL = url;
this.playerObject.controls.play();
this.manualStop = false;
}
function wm_Previous() {
if(this.getCurrentIndex()>0)
{
this.playItem(this.getCurrentIndex()-1);
}
else
{
this.playItem(this.currentPlaylist.count()-1);
}
}
function wm_Stop() {
this.playerObject.controls.stop();
this.manualStop = true;
}
function wm_FastForward() {
this.playerObject.controls.fastForward();
}
function wm_Rewind() {
this.playerObject.controls.fastReverse();
}
function wm_GetCurrentMediaDuration() {
if(this.playerObject.currentMedia != null)
return this.playerObject.currentMedia.duration;
return 0;
}
function wm_GetPosition() {
if(this.playerObject)
if(this.playerObject.controls)
return parseInt(this.playerObject.controls.currentPosition);
return 0;
}
function wm_SetPosition(position) {
this.playerObject.controls.currentPosition = position;
}
function wm_SetVolume(val)
{
if(this.playerObject.settings)
{
this.playerObject.settings.volume = val;
}
}
function wm_GetVolume()
{
if(this.playerObject.settings)
{
return this.playerObject.settings.volume;
}
}
function wm_SetMute(mute)
{
if(this.playerObject.settings)
{
this.playerObject.settings.mute = mute;
}
}
function wm_GetMute()
{
if(this.playerObject)
if(this.playerObject.settings)
return this.playerObject.settings.mute;
return(false);
}
function wm_GetRepeat()
{
return(this.repeat);
}
function wm_SetRepeat(state)
{
this.repeat = state;
}
function wm_GetCurrentPlaylist() {
return(this.currentPlaylist);
}
function wm_SetCurrentPlaylist(playlist) {
this.currentPlaylist = playlist;
}
function wm_Sync() {
}
function wm_GetQuality() {
return this.quality;
}
function wm_SetQuality(quality) {
this.quality = quality;
}
function wm_GetPlayState() {
var playerState;
playerState = (this.playerObject) ? this.playerObject.playState : 0;
switch(playerState) {
case 1 : // Stopped
case 10 : // Ready
return this.playState.stopped;
case 2 : // Paused
return this.playState.paused;
case 7 : // Waiting
this.next(); // End of live, go to next and return 'playing'
case 4 : // ScanForward
return this.playState.forwarding;
case 5 : // ScanReverse
return this.playState.rewinding;
case 3 : // Playing
case 8 : // MediaEnded
return this.playState.playing;
case 6 : // Buffering
case 9 : // Transitioning
case 11 : // Reconnecting
return this.playState.buffering;
default :
return this.playState.undefined;
}
}
function wm_GetCurrentMedia() {
if(this.currentPlaylist == null)
return null;
var playSequence = this.currentPlaylist.getPlaySequence();
var index = this.getCurrentPlaySequenceIndex();
return (index >= 0) ? playSequence[index] : null;
}
function wm_GetStatus() {
return this.playerObject.status;
}
function wm_GetBitrate()
{
if(this.playerObject)
if(this.playerObject.currentMedia != null)
return this.playerObject.currentMedia.getItemInfo("Bitrate");
return 0;
}
function wm_FullScreen() {
try {
this.playerObject.fullScreen = 'true';
} catch(e) {}
try {
this.playerObject.fullScreen = true;
} catch(e) {}
}
function wm_Resize(width, height)
{
this.playerObject.width = width;
this.playerObject.height = height;
if(window.GeckoActiveXObject)
{
document.getElementsByTagName("body")[0].style.height = '1px';
window.setTimeout('document.getElementsByTagName("body")[0].style.height = \'auto\';',100); // Apparently a small delay is required
}
}
function wm_CreateInternalPlaylist() {
}
function wm_GetCurrentIndex() {
for(var i = 0; i < this.currentPlaylist.mediaItems.length; i++)
{
var url = this.currentPlaylist.mediaItems[i].mediaUrls[this.quality];
url = url.substring(url.indexOf("://") + 3);
if(this.playerObject.URL.indexOf(url)>0)
{
return i;
}
else
{
for(var j = 0; j < this.currentPlaylist.mediaItems[i].ads.length;j++)
{
var urlAd = this.currentPlaylist.mediaItems[i].ads[j].mediaUrls[this.quality];
urlAd = urlAd.substring(urlAd.indexOf("://") + 3);
if(this.playerObject.URL.indexOf(urlAd)>0)
{
return i;
}
}
}
}
return -1;
}
function wm_GetCurrentPlaySequenceIndex() {
var playSequence = this.currentPlaylist.getPlaySequence();
if(playSequence!=null && this.playerObject!=null)
{
for(i = 0; i < playSequence.length; i++)
{
var url = playSequence[i].mediaUrls[this.quality];
url = url.substring(url.indexOf("://") + 3);
if(this.playerObject.URL!=null)
{
if(this.playerObject.URL.indexOf(url)>0)
return i;
}
}
}
return -1;
}
function wm_Tick() {
var currentMedia = this.getCurrentMedia();
var currentMediaUrl = currentMedia != null ? currentMedia.mediaUrls[this.quality] : '';
if(this.getPlayState()==this.playState.stopped && !this.manualStop)
{
if(this.currentPlaylist)
{
var playSequence = this.currentPlaylist.getPlaySequence();
var currentIndex = this.getCurrentPlaySequenceIndex();
if(playSequence!=null)
{
if(currentIndex<playSequence.length-1)
{
this.playerObject.URL = playSequence[currentIndex+1].mediaUrls[this.quality];
this.playerObject.controls.play();
}
else
{
if(this.repeat)
{
this.playItem(0);
}
else
{
this.manualStop = true;
}
}
}
}
}
if(this.getStatus() != this.lastStateStr) {
this.onPlayerStateStringChange.exec();
this.lastStateStr = this.getStatus();
}
if(currentMediaUrl != this.lastMediaUrl && this.getPlayState()!=this.playState.stopped) {
this.onCurrentMediaChange.exec();
this.lastMediaUrl = currentMediaUrl;
}
if(this.lastCurrentPosition != this.getPosition()) {
this.onCurrentPositionChange.exec()
this.lastCurrentPosition = this.getPosition();
}
if(this.lastMute != this.getMute()) {
this.onMuteChange.exec();
this.lastMute = this.getMute();
}
if(this.lastPlayState != this.getPlayState()) {
this.onPlayStateChange.exec();
this.lastPlayState = this.getPlayState();
}
setTimeout(this.objName +'.tick();', 500);
}
}
function EventManager() {
this.add = em_Add;
this.exec = em_Exec;
this.eventItems = new Array();
function em_Add(obj, method) {
this.eventItems.push(new EventItem(obj, method));
}
function em_Exec() {
var i;
for(i = 0; i < this.eventItems.length; i++)
eval(this.eventItems[i].object + '.' + this.eventItems[i].method + '()');
}
}
function EventItem(object, method) {
this.object = object;
this.method = method;
}
function PlayState() {
this.undefined = 0;
this.stopped = 1;
this.paused = 2;
this.playing = 3;
this.buffering = 4;
}
function Quality() {
this.low = 0;
this.high = 1;
}
function Playlist() {
this.id = 0;
this.title = '';
this.adsFrequency = 3; // Advertisements frequency
this.maxAdsFirst = -1; // Maximum number of advertisements before the first item (negative number for all ads)
this.maxAds = -1; // Maximum number of advertisements before the media items (but the first, negative number for all ads)
this.adsStartAt = 0; // Position of the first ad (zero-based)
this.appendItem = pl_AppendItem;
this.clear = pl_Clear;
this.insertItem = pl_InsertItem;
this.getDuration = pl_GetDuration;
this.getItem = pl_getItem;
this.getPlaySequence = pl_GetPlaySequence;
this.getPlaySequenceIndex = pl_GetPlaySequenceIndex;
this.getPlayIndex = pl_GetPlayIndex;
this.indexOf = pl_IndexOf;
this.indexOfPlaySequence = pl_IndexOfPlaySequence;
this.count = pl_Count;
this.moveItem = pl_moveItem;
this.removeAt = pl_RemoveAt;
this.setShuffle = pl_setShuffle;
this.getShuffle = pl_GetShuffle;
this.onChange = new EventManager(); // Occurs when the number of items or them order changes
this.curMediaIndex = null; // Used for shuffle
this.mediaItems = new Array(); // The playlist items
this.plItemsOrder = new Array();
this.playSequence;
this.shuffle = false;
this.plIndexToPlaySequenceIndex = new Array();
this.genPlaySequence = genPlaySequence;
function pl_AppendItem(mediaItem)
{
this.mediaItems.push(mediaItem);
this.genPlaySequence();
}
function pl_Clear() {
this.mediaItems = new Array();
this.genPlaySequence();
}
function pl_Count() {
return this.mediaItems.length;
}
function pl_GetDuration()
{
var sum = 0, i;
for(i = 0; i < this.mediaItems.length; i++)
sum += this.mediaItems[i].duration;
return sum;
}
function pl_getItem(index) {
return this.mediaItems[index];
}
function pl_GetPlaySequenceIndex(plIndex)
{
return this.plIndexToPlaySequenceIndex[this.plItemsOrder[plIndex]];
}
function pl_GetPlayIndex(plIndex)
{
return this.indexOfPlaySequence(this.mediaItems[plIndex]);
}
function pl_IndexOf(mediaItem)
{
var i, j;
for(i = 0; i < this.mediaItems.length; i++)
{
if(mediaItem == this.mediaItems[i]) // Check if the wanted item is the current
{
return i;
}
else if(this.mediaItems[i].ads != null) // Search for the item in ads
{
for(j = 0; j < this.mediaItems[i].ads.length; j++)
{
if(this.mediaItems[i].ads[j] == mediaItem)
{
return i;
}
}
}
}
return -1;
}
function pl_IndexOfPlaySequence(mediaItem)
{
var i, j;
for(i = 0; i < this.playSequence.length; i++)
{
if(mediaItem == this.playSequence[i]) // Check if the wanted item is the current
{
return i;
}
else if(this.playSequence[i].ads != null) // Search for the item in ads
{
for(j = 0; j < this.playSequence[i].ads.length; j++)
{
if(this.playSequence[i].ads[j] == mediaItem)
{
return i;
}
}
}
}
return -1;
}
function pl_GetPlaySequence()
{
return this.playSequence;
}
function pl_InsertItem(index, mediaItem) {
this.mediaItems.splice(index, 0, mediaItem);
this.genPlaySequence();
}
function pl_moveItem(oldIndex, newIndex) {
var temp;
if(oldIndex == newIndex) return; // Do not exchange the same position
temp = this.mediaItems.splice(oldIndex, 1)[0];
this.mediaItems.splice(newIndex, 0, temp);
this.genPlaySequence();
}
function pl_RemoveAt(index)
{
this.mediaItems.splice(index, 1);
this.genPlaySequence();
}
function pl_setShuffle(shuffle, curItem)
{
this.shuffle = shuffle;
this.curMediaIndex = curItem;
this.genPlaySequence();
}
function pl_GetShuffle()
{
return this.shuffle;
}
function genPlaySequence()
{
var i, j, plItem;
this.plItemsOrder = new Array();
this.playSequence = new Array();
this.plIndexToPlaySequenceIndex = new Array();
for(i = 0; i < this.mediaItems.length; i++)
{
this.plItemsOrder.push(i);
}
if(this.shuffle)
{
mixArray(this.plItemsOrder, this.curMediaIndex);
}
var firstAdItem = true;
for(i = 0; i < this.plItemsOrder.length; i++)
{
plItem = this.mediaItems[this.plItemsOrder[i]];
this.plIndexToPlaySequenceIndex.push(this.playSequence.length);
var hasAds = false;
if(i>=this.adsStartAt)
{
hasAds = ((i-this.adsStartAt)%this.adsFrequency)==0;
}
if(hasAds)
{
var adCount = this.maxAds;
if(firstAdItem)
{
adCount = this.maxAdsFirst; // First position may have more ads
firstAdItem = false; // Following items will have less ads
}
mixArray2(plItem.ads);
for(j = 0; j < plItem.ads.length && (j < adCount || adCount == -1); j++)
{
if(plItem.ads[j])
{
this.playSequence.push(plItem.ads[j]);
}
}
}
this.playSequence.push(plItem);
}
this.onChange.exec();
}
function mixArray(array, cur)
{
var i, j, temp;
if(cur > 0)
{
temp = array[0];
array[0] = array[cur];
array[cur] = temp;
}
for(i = 1; i < array.length - 1; i++)
{
j = Math.round(Math.random() * (array.length - i - 2)) + i + 1;
temp = array[i];
array[i] = null;
array[i] = array[j];
array[j] = temp;
}
}
function mixArray2(array)
{
for(var i = 0, rand, temp; i < array.length; i++)
{
rand = Random(0, array.length -1);
temp = array[i];
array[i] = array[rand];
array[rand] = temp;
}
}
function Random(min, max)
{
var seed = Math.random();
return Math.round(seed * (max - min)) + min;
}
}
var lastMediaItemId = 0;
var uniqueUrl = true;
function MediaItem(id, title, image, duration, ads) {
this.contentId = id; // Media's content id
this.title = title; // Media's title
this.imgUrl = image; // Media's playlist image
this.duration = duration; // Media's duration
this.ads = ads; // Array of advertisements media items
this.getUrl = mediaItem_GetUrl; // Gets url for a quality
this.setUrl = mediaItem_SetUrl; // Sets url for a quality
this.mediaUrls = new Array(); // Holds the urls for all media item qualities
function mediaItem_GetUrl(quality) {
return this.mediaUrls[quality];
}
function mediaItem_SetUrl(quality, url)
{
if(url && url != "")
{
if(uniqueUrl)
{
if(url.indexOf('?') > -1)
{
url = url.replace('?', '?' + 'uid=' + (lastMediaItemId++) + '&');
}
else
{
url += '?' + 'uid=' + (lastMediaItemId++);
}
}
this.mediaUrls[quality] = url;
}
else
{
this.mediaUrls[quality] = "";
}
}
}
function PlayState() {
this.undefined = 0;
this.stopped = 1;
this.paused = 2;
this.playing = 3;
this.buffering = 4;
}
var Prototype = {
Version: '1.6.0.3',
Browser: {
IE: !!(window.attachEvent &&
navigator.userAgent.indexOf('Opera') === -1),
Opera: navigator.userAgent.indexOf('Opera') > -1,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
navigator.userAgent.indexOf('KHTML') === -1,
MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
},
BrowserFeatures: {
XPath: !!document.evaluate,
SelectorsAPI: !!document.querySelector,
ElementExtensions: !!window.HTMLElement,
SpecificElementExtensions:
document.createElement('div')['__proto__'] &&
document.createElement('div')['__proto__'] !==
document.createElement('form')['__proto__']
},
ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
emptyFunction: function() { },
K: function(x) { return x }
};
if (Prototype.Browser.MobileSafari)
Prototype.BrowserFeatures.SpecificElementExtensions = false;
/* Based on Alex Arnell's inheritance implementation. */
var Class = {
create: function() {
var parent = null, properties = $A(arguments);
if (Object.isFunction(properties[0]))
parent = properties.shift();
function klass() {
this.initialize.apply(this, arguments);
}
Object.extend(klass, Class.Methods);
klass.superclass = parent;
klass.subclasses = [];
if (parent) {
var subclass = function() { };
subclass.prototype = parent.prototype;
klass.prototype = new subclass;
parent.subclasses.push(klass);
}
for (var i = 0; i < properties.length; i++)
klass.addMethods(properties[i]);
if (!klass.prototype.initialize)
klass.prototype.initialize = Prototype.emptyFunction;
klass.prototype.constructor = klass;
return klass;
}
};
Class.Methods = {
addMethods: function(source) {
var ancestor = this.superclass && this.superclass.prototype;
var properties = Object.keys(source);
if (!Object.keys({ toString: true }).length)
properties.push("toString", "valueOf");
for (var i = 0, length = properties.length; i < length; i++) {
var property = properties[i], value = source[property];
if (ancestor && Object.isFunction(value) &&
value.argumentNames().first() == "$super") {
var method = value;
value = (function(m) {
return function() { return ancestor[m].apply(this, arguments) };
})(property).wrap(method);
value.valueOf = method.valueOf.bind(method);
value.toString = method.toString.bind(method);
}
this.prototype[property] = value;
}
return this;
}
};
var Abstract = { };
Object.extend = function(destination, source) {
for (var property in source)
destination[property] = source[property];
return destination;
};
Object.extend(Object, {
inspect: function(object) {
try {
if (Object.isUndefined(object)) return 'undefined';
if (object === null) return 'null';
return object.inspect ? object.inspect() : String(object);
} catch (e) {
if (e instanceof RangeError) return '...';
throw e;
}
},
toJSON: function(object) {
var type = typeof object;
switch (type) {
case 'undefined':
case 'function':
case 'unknown': return;
case 'boolean': return object.toString();
}
if (object === null) return 'null';
if (object.toJSON) return object.toJSON();
if (Object.isElement(object)) return;
var results = [];
for (var property in object) {
var value = Object.toJSON(object[property]);
if (!Object.isUndefined(value))
results.push(property.toJSON() + ': ' + value);
}
return '{' + results.join(', ') + '}';
},
toQueryString: function(object) {
return $H(object).toQueryString();
},
toHTML: function(object) {
return object && object.toHTML ? object.toHTML() : String.interpret(object);
},
keys: function(object) {
var keys = [];
for (var property in object)
keys.push(property);
return keys;
},
values: function(object) {
var values = [];
for (var property in object)
values.push(object[property]);
return values;
},
clone: function(object) {
return Object.extend({ }, object);
},
isElement: function(object) {
return !!(object && object.nodeType == 1);
},
isArray: function(object) {
return object != null && typeof object == "object" &&
'splice' in object && 'join' in object;
},
isHash: function(object) {
return object instanceof Hash;
},
isFunction: function(object) {
return typeof object == "function";
},
isString: function(object) {
return typeof object == "string";
},
isNumber: function(object) {
return typeof object == "number";
},
isUndefined: function(object) {
return typeof object == "undefined";
}
});
Object.extend(Function.prototype, {
argumentNames: function() {
var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]
.replace(/\s+/g, '').split(',');
return names.length == 1 && !names[0] ? [] : names;
},
bind: function() {
if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
var __method = this, args = $A(arguments), object = args.shift();
return function() {
return __method.apply(object, args.concat($A(arguments)));
}
},
bindAsEventListener: function() {
var __method = this, args = $A(arguments), object = args.shift();
return function(event) {
return __method.apply(object, [event || window.event].concat(args));
}
},
curry: function() {
if (!arguments.length) return this;
var __method = this, args = $A(arguments);
return function() {
return __method.apply(this, args.concat($A(arguments)));
}
},
delay: function() {
var __method = this, args = $A(arguments), timeout = args.shift() * 1000;
return window.setTimeout(function() {
return __method.apply(__method, args);
}, timeout);
},
defer: function() {
var args = [0.01].concat($A(arguments));
return this.delay.apply(this, args);
},
wrap: function(wrapper) {
var __method = this;
return function() {
return wrapper.apply(this, [__method.bind(this)].concat($A(arguments)));
}
},
methodize: function() {
if (this._methodized) return this._methodized;
var __method = this;
return this._methodized = function() {
return __method.apply(null, [this].concat($A(arguments)));
};
}
});
Date.prototype.toJSON = function() {
return '"' + this.getUTCFullYear() + '-' +
(this.getUTCMonth() + 1).toPaddedString(2) + '-' +
this.getUTCDate().toPaddedString(2) + 'T' +
this.getUTCHours().toPaddedString(2) + ':' +
this.getUTCMinutes().toPaddedString(2) + ':' +
this.getUTCSeconds().toPaddedString(2) + 'Z"';
};
var Try = {
these: function() {
var returnValue;
for (var i = 0, length = arguments.length; i < length; i++) {
var lambda = arguments[i];
try {
returnValue = lambda();
break;
} catch (e) { }
}
return returnValue;
}
};
RegExp.prototype.match = RegExp.prototype.test;
RegExp.escape = function(str) {
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
};
