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 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){
 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 linkFlash(p_width,p_height,p_file,p_author,p_copyright,p_legend){
 var popup=null;
 if(!p_file.elements){
  popup = openModal('/clicstation/jsp/map.jsp?pfile=http://www.clicrbs.com.br/flash/'+p_file+'&pwidth='+p_width+'&pheight='+p_height,p_width,p_height,p_legend);
 }
 else{
  document.joker.p_comp.value=p_form.p_comp.value;
  document.joker.p_width.value=p_form.p_width.value;
  document.joker.p_height.value=p_form.p_height.value;
  document.joker.p_legend.value=p_form.p_legend.value;
  document.joker.p_author.value=p_form.p_author.value;
  document.joker.p_copyright.value=p_form.p_copyright.value;
  document.joker.p_type.value="F";
  var v_width=p_width+60;
  var v_heigh=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 linkTrailer(nomevideo56,w56,h56,uf){
 var theURL, features;
 iw56=parseInt(w56);
 ih56=parseInt(h56);
 if (iw56<=347){iw56=348;}
 if (ih56<=359){ih56=360;}
 theURL="/clicstation/jsp/clicstation_trailers.jsp?strNomevideo56="+nomevideo56+"&w56="+iw56+"&h56="+ih56+"&struf="+uf;
 window.open(theURL,"ClicStationTreiler","width="+iw56+",height="+ih56);
}
function linkAudio(p_audio,uf){abrecs1('audio/'+p_audio,uf);}
function linkVideo(p_video,uf){abrecs1('video/'+p_video,uf);}
function linkEncode(p_video,uf){if(uf==null) uf='RS'; abrecs1(p_video,uf);}
function linkPopup(p_cat,p_tem,p_width,p_height,p_url){
	 if (p_width==0 && p_height==0){
        popup=window.open('/jsp/popup.jsp?catgid='+p_cat+'&template='+p_tem+'.dwt&p_url='+p_url, 'PopUP');
     }else{
        popup=window.open('/jsp/popup.jsp?catgid='+p_cat+'&template='+p_tem+'.dwt&p_url='+p_url, 'PopUP', 'resizable=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,scrollbars=yes,width='+p_width+',height='+p_height);
	}
}
function linkPdf(p_arq,p_width,p_height){
 popup=window.open('/pdf/'+p_arq, 'Pdf', 'resizable=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,scrollbars=no,width='+p_width+',height='+p_height); 
}
function doParceiro(domain,gif,color,dir){
 document.formParceiro.DOMAIN.value=domain;
 document.formParceiro.GIF.value=gif;
 document.formParceiro.COLOR.value=color;
 document.formParceiro.DIR.value=dir;
 document.formParceiro.submit();
}
function doInvest(domain){
 document.formInvest.DOMAIN.value = domain;
 document.formInvest.submit();
}
function doSubmit(t,n,s,l,tplt){
 document.formDefault.tab.value=t;
 document.formDefault.newsID.value=n;
 document.formDefault.subTab.value=s;
 if(l!=null) document.formDefault.l.value=l;
 if(tplt!=null) document.formDefault.template.value=tplt;
 if(t=="00000"){
  document.formDefault.action="/jsp/default.jsp";
  document.formDefault.submit();
 }else if(t=="00002"){
  document.formDefault.action="/clicnoticias/jsp/default.jsp";
  document.formDefault.submit();
 }else if(t=="00003"){
  document.formDefault.action="/clicesportes/jsp/default.jsp";
  document.formDefault.submit();
 }else if( (t=="000053") || (t=="00053") || (t=="00052") ) {
  document.formDefault.action="/especiais/jsp/default.jsp";
  document.formDefault.submit();  
 }else if( (t=="000024") || (t=="00024") ){
  document.formDefault.action="/agrol/jsp/default.jsp";
  document.formDefault.submit();
 }else if( (t=="000013") || (t=="00013") ){
  document.formDefault.action="/eleicoes/jsp/default.jsp";
  document.formDefault.submit();
 }else if(t=="00004"){
  document.formNessa.menu.value="inc/ultimas_detalhe.jsp";
  document.formNessa.conteudo.value="jsp/ultimas_detalhe.jsp";
  document.formNessa.evento.value=n.substring(1,n.indexOf('.'));;
  document.formNessa.submit();
 }else if((t=="00009")|| (t=="00010") || (t=="000010") ){
  source = n.substring(0,n.indexOf("."))+".xml";
  window.location.href="/jornais/zerohora/jsp/default2.jsp?uf=1&local=1&source="+source;
 }else if(t=="00016"){
  	 document.formDefault.action="/planeta/jsp/default.jsp";
	 document.formDefault.submit();
 }else if(t=="00050"){
  	 document.formDefault.action="/jogosolimpicos/jsp/default.jsp";
	 document.formDefault.submit();
 }else if(t=="00035"){
  	 document.formDefault.action="/expointer/jsp/default.jsp";
	 document.formDefault.submit();	
 }else if(t=="00055"){
  	 document.formDefault.action="/forum/jsp/default.jsp";
	 document.formDefault.submit();	 	
 }else if(t=="00059"){
  	 document.formDefault.action="/globaltech/jsp/default.jsp";
	 document.formDefault.submit();  
	 	 
 }else if(t.indexOf('inc')==0){
  document.formNessa.menu.value=t;
  document.formNessa.conteudo.value=n;
  document.formNessa.ctrl.value=s;
  document.formNessa.evento.value=l;
  document.formNessa.submit();
 }
}
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 linkRelacionadas(p_tab,p_fsname,p_subtab){
 if(p_tab!=null & p_fsname!=null){doSubmit(p_tab,p_fsname,p_subtab);}
 else{doSubmit('inc/ultimas_detalhe.jsp','html/'+p_tab,'200');}
}
function changeColumn(columnId){
 if(columnId!=''){
  document.formDefault.newsID.value='a'+columnId+'.htm';
  document.formDefault.submit();
 }
}
var oWindow = null;
function openModal(poUrl,poWidth,poHeight,poWindowName,poScroll){
 var oLeft,oTop,oAttr,oWindowName;
 var Nav4=((navigator.appName=="Netscape") && (parseInt(navigator.appVersion)==4));
 var Nav4plus=((navigator.appName=="Netscape") && (parseFloat(navigator.appVersion)>4.04));
 var Nav5=((navigator.appName=="Netscape") && (parseInt(navigator.appVersion)==5));
 var Nav6=((navigator.appName=="Netscape") && (parseInt(navigator.appVersion)==6));
 var IE4=((navigator.appName.indexOf("Microsoft")>-1)) && (parseInt(navigator.appVersion)==4);
 var IE5=((navigator.appName.indexOf("Microsoft")>-1)) && (parseInt(navigator.appVersion)==5);
 var IE6=((navigator.appName.indexOf("Microsoft")>-1)) && (parseInt(navigator.appVersion)==6);
 var anyIE=(IE4||IE5||IE6);
 var anyNav=(Nav4||Nav4plus||Nav5||Nav6);
 var oScroll=false;
 if(poScroll!= null) oScroll=poScroll;
 if(Nav4){
  oLeft=window.screenX+((window.outerWidth-poWidth)/2);
  oTop=window.screenY+((window.outerHeight-poHeight)/2);
  oAttr="screenX="+oLeft+",screenY="+oTop+",location=no,toolbar=no,directories=no,status=no,resizable=no,dependent=yes,width="+poWidth+",height="+poHeight;
 }else{
  oLeft=(screen.width-poWidth)/2;
  oTop=(screen.height-poHeight)/2;
  oAttr="left="+oLeft+",top="+oTop+",location=no,toolbar=no,directories=no,status=no,resizable=no,width="+poWidth+",height="+poHeight;
 }
 if(oScroll)oAttr+=",scrollbars=yes"
 if(poWindowName==null)oWindowName="modal";
 else oWindowName=poWindowName;
 if(oWindow && oWindow.open)closeModal();
 oWindow=window.open(poUrl,oWindowName,oAttr );
 oWindow.focus();
}
function closeModal(){
 oWindow.close();
 oWindow=null;
}
function doSearch(p_template,p_query,p_order,p_esq,p_tab){
 if(document.formQuery1.searchstring.value.length>0 && document.formQuery1.chanid[document.formQuery1.chanid.selectedIndex].text.indexOf("Selecione") < 0  ){
	 doQuery(p_template,p_query,p_order,p_esq,document.formQuery1.chanid[document.formQuery1.chanid.selectedIndex].value,p_tab);
 }
 else if (document.formQuery1.chanid.selectedIndex==null || document.formQuery1.chanid[document.formQuery1.chanid.selectedIndex].value.indexOf("Selecione") < 0)
   {alert("Selecione um dos canais.");}
 else
  {alert("Digite o texto a ser pesquisado.");}
 document.formQuery1.searchstring.focus();
}
function doAdvancedSearch(uf,l,tab,tplt){openModal("/jsp/rt.jsp?template=27.dwt&rootdir=/shared&uf="+uf+"&l="+l+"&tab="+tab+"&resulttplt="+tplt,530,480,"avancada");}
function doPops(uf,l,tab,tplt){openModal("/jsp/rt.jsp?template="+tplt+"&rootdir=/shared&uf="+uf+"&l="+l+"&tab="+tab,550,565,"POP" ,true);}
function doPopsPpf(uf,l,tab,tplt){openModal("http://www.clicrbs.com.br/jsp/rt.jsp?template="+tplt+"&rootdir=/shared&uf="+uf+"&l="+l+"&tab="+tab,550,565,"POP" ,true);}
function doFale(uf,l,tab,tplt){openModal("/jsp/rt.jsp?template="+tplt+"&rootdir=/shared&uf="+uf+"&l="+l+"&tab="+tab,570,570,"POP" ,true);}
function doFaq(uf,l,tab,tplt){openModal("/jsp/rt.jsp?template="+tplt+"&rootdir=/shared&uf="+uf+"&l="+l+"&tab="+tab,550,500,"FAQ" ,true);}
function doFaqPpf(uf,l,tab,tplt){openModal("http://www.clicrbs.com.br/jsp/rt.jsp?template="+tplt+"&rootdir=/shared&uf="+uf+"&l="+l+"&tab="+tab,550,500,"FAQ" ,true);}
function doPrint(newsId,chanID){openModal("/jsp/print.jsp?newsID="+newsId+"&chanID="+chanID+"&tab=00000",565,500,"PRINT",true);}
function doFriend(){openModal("/jsp/send_friend.jsp?url="+escape(document.location),550,350,"FRIEND",true);}
function doQuery(p_template,p_query,p_order,p_esq,p_channel,p_tab){
 document.formQuery1.newsID.value=p_query;
 document.formQuery1.template.value=p_template;
 document.formQuery1.source.value=p_query;
 document.formQuery1.order.value=p_order;
 document.formQuery1.l.value=p_esq;
 document.formQuery1.chanid.value=p_channel;
 if(p_tab!=null){document.formQuery1.tab.value=p_tab;}
 document.formQuery1.submit();
}
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 OpenPopup(p_url,p_window,p_width,p_height){window.open(p_url,p_window,'resizable=yes,location=no,directories=no,status=no,toolbar=no,menubar=no,scrollbars=no,width='+p_width+',height='+p_height);}
function doParceiroInd(comp){
 var ind=comp.selectedIndex;  
 if(ind==0){
   var f='';
 }else{
          var valuetosplit=comp.options[ind].value; 
          var domain = getSplit(valuetosplit,",",0);
          var gif = getSplit(valuetosplit,",",1);
          var color = getSplit(valuetosplit,",",2);
          var dir = getSplit(valuetosplit,",",3);
        //alert(dir);
        if (dir != "'atlantidafm'"){
                doParceiro(domain.substring(1,domain.length-1),gif.substring(1,gif.length-1),color.substring(1,color.length-1),dir.substring(1,dir.length-1));
        }else{
                doInvest(domain.substring(1,domain.length-1),gif.substring(1,gif.length-1),color.substring(1,color.length-1),dir.substring(1,dir.length-1));
        }
 }
}
function getSplit(poTokenized,poDelimiter,poPosition){
 var oTokens=new Array(4);
 var i = 0;
 var oTokenized = poTokenized;
 while( oTokenized.length > 0 ){
  var oToken = null;
  if( oTokenized.indexOf(poDelimiter) != -1 ){
   oToken = oTokenized.substring(0,oTokenized.indexOf(poDelimiter));
   oTokenized = oTokenized.substring(oTokenized.indexOf(poDelimiter)+1);
  }else{
   oToken = oTokenized;
   oTokenized = "";
  }
  oTokens[i] = oToken;
  i++;
 }
 return oTokens[poPosition];
}
function open_chat(){
 var user=document.chat.user.value;
 var screen=document.chat.screen.value;
 var room=document.chat.room.options[document.chat.room.selectedIndex].value;
 var chatter=document.chat.chatter.value;
 user=escape(user);
 var URL ="http://clicpapo.clicrbs.com.br/cgi-bin/inchat/inchat.pl?login=1&user="+user+"&screen="+screen+"&room="+room+"&chatter="+chatter;
 window.open(URL,"OpenInchat","width=710,height=525,top=0,left=0");
 return false;
}
function doChat(){
 if(document.chat.user.value.length==0){alert("Por favor, informe o seu apelido.");}
  else{
   if(document.chat.room.options[document.chat.room.selectedIndex].value==''){alert("Por favor, escolha uma sala.");}
   else{open_chat();}
  }
}

// JS novas para o novo layout de capa do clicRBS (alteração de checkbox para button)
function addToFavoritesBtn(){window.external.AddFavorite('http://www.clicrbs.com.br','clicRBS');}
function setHomePageBtn(){setHomePage('www.clicrbs.com.br');}
//Fim


function addToFavorites(url,vtitle){window.external.AddFavorite(url,vtitle);}
function setHome(){
 if(document.setHome.initial.checked){setHomePage('www.clicrbs.com.br');}
 if(document.setHome.favorites.checked){addToFavorites('http://www.clicrbs.com.br','clicRBS');}
}
function setHomePage(url){
 if(document.all && document.getElementById){
  if(!oHomePage.isHomePage(url)){
   oHomePage.setHomePage(url);
   var a=oHomePage.isHomePage(url)
   if(!oHomePage.isHomePage(url))return false;
  }
 }
 else
 if(document.layers && navigator.javaEnabled()){
  if(!confirm("Deseja fazer o clic sua Página Inicial"))
   return false;
  netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesWrite');
  navigator.preference('browser.startup.homepage',url);
 }
 return false;
}
function linkEnquete(p_survey_id, p_user_id){
  janela_enquete = window.open("http://www.clicrbs.com.br/servlet/SRServlet.SRSessionServlet?SURVEY_ID="+p_survey_id+"&USER_ID="+p_user_id+"&SHOW_FORM=T","janela_enquete","toolbar=no,menubar=no,resizable=yes,scrollbars=yes,width=400,height=300");
}

function doChatCapa(room_id) {
 if (room_id != null)
	window.open('/jsp/popup_ingresso_chat.jsp?room='+room_id, 'ingresso', 'toolbar=no,menubar=no,resizable=no,scrollbars=no,width=250,height=200');
}

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=570,height=700');
}

 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{
		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);
 	}
}
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=570,height=700');
}
