// Replaces oldS with newS in the string fullS   
var mybrowser = 'IE7';
function replaceString(oldS,newS,fullS)
{
	for (var i=0; i<fullS.length; i++) 
	{      
		if (fullS.substring(i,i+oldS.length) == oldS)
		{	fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length);
		}
	}
	return fullS;
}

function CountChar(str,ch)
{
	c = 0;
	for(i=0; i<str.length; i++) {
			if(str.charAt(i)==ch) ++c;
	}
	return(c);
}

function LastCharIndex(str,ch)
{
	c = -1;
	for(i=0; i<str.length; i++) {
		if(str.charAt(i)==ch) c=i;
	}
	return(c);	
}

function showerro(s)
{
	msgWindow=window.open("","ErrorWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=250,height=250");
	msgWindow.document.write("<CENTER><BIG><B>ERROR</B></BIG><BR><BR>");
	str = replaceString("\n", "<br>", s);
	msgWindow.document.write(str+"</CENTER><BR>");	
	msgWindow.status = "GoNet Web Design";
}

function ShowQuotes()
{
	w=window.open("","Quotes","menubar=no,toolbar=no,scrollbars=no,resizable=no,status=no,width=240,height=200");
	if(w) {
		w.document.write("<center><br>");
		w.document.write("<SCRIPT TYPE='text/javascript' SRC='http://www.brainyquote.com/link/quotebr.js'></SCRIPT>");
		w.document.write("</center>");
	} else alert('A popup window was blocked!');
}

/* 
 Para tocar uma midi usando writesqlbox_counter.php. A midi tem que estar no database.
 dir pode ser './" ou "../" , coisas assim, num é o # do record no database
 */
function play(dir,num)
{
	href = dir+"writesqlbox_counter.php?num="+num+"&back=0";
	w=window.open(href,"PlayWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=600,height=500");
	if(!w) alert('A popup window was blocked!');
}

// mesmo que play(), mas verifica e dá preferência para MP3 se houver
function plaympx(dir,num)
{
	href = dir+"writesqlbox_counter.php?num="+num+"&back=0&mp3=1";
	w=window.open(href,"PlayWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=600,height=500");
	if(!w) alert('A popup window was blocked!');
}

// midi e mp3 =0 ou 1 se auto play
function Player2(dir,num,mp3,midi)
{
	href = dir+"player2.php?num="+num+"&mp3="+mp3+"&midi="+midi;
	w=window.open(href,"Player","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=600,height=500");
	if(!w) alert('A popup window was blocked!');
}

// Player de MP3-only
function mp3play(dir,num)
{
	href = dir+"mp3play.php?num="+num;
	w=window.open(href,"PlayWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=600,height=500");
	if(!w) alert('A popup window was blocked!');
}

function myplay(dir,num,rate)
{
	href = dir+"lp_play.php?num="+num+"&mp3=0&rate="+rate;
	w=window.open(href,"PlayWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=600,height=520");
	if(!w) alert('A popup window was blocked!');
}

function midmp3play(dir,num)
{
	href = dir+"lp_play.php?num="+num+"&mp3=1&rate=1";
	w=window.open(href,"PlayWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=600,height=520");
	if(!w) alert('A popup window was blocked!');
}

// Player para mp3 via url
function mymp3play(dir,url)
{
	var href = dir+"frameplayer.php?num=0&mp3=1&midi="+url;
	w=window.open(href,"PlayMP3Window","menubar=no,toolbar=no,scrollbars=no,resizable=no,status=no,width=260,height=118");
	if(!w) alert('A popup window was blocked!');
}

// precisa de swfobject.js
function AudioPlay(idtag,src,auto)
{
   if(auto) sauto='true'; else sauto='false';
	 var fo = new SWFObject('webplayer.swf',idtag,'299','62','7','#FFFFFF');
   fo.addVariable('width','299');
   fo.addVariable('height','62');
	 fo.addVariable('src',src);
   fo.addVariable('autostart',sauto);
   fo.addVariable('loop','false');
   fo.addVariable('volume','50');
   fo.addParam('menu','false');
   fo.addParam('scale','noscale');
   fo.addParam('wmode','transparent');
   fo.write(idtag);
}

function myopen(xurl)
{
	x = window.open(xurl,"showWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=500,height=500");
	if(!x) alert('A popup window was blocked!');
	return(x);
}

function myopen2(xurl,w,h)
{
	str = "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width="+w+",height="+h;
	x = window.open(xurl,'MCC',str);
	if(!x) alert('A popup window was blocked!');
	return(x);
}

function open_window(xurl,titulo)
{
	x = window.open(xurl,titulo);
	if(!x) alert('A popup window was blocked!');
	return(x);
}

function open_window2(xurl,titulo,width,height)
{
	str = "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width="+width+",height="+height;
	x = window.open(xurl,titulo,str);
	if(!x) alert('A popup window was blocked!');
	return(x);
	
}

function OpenWindow(xurl,titulo,width,height)
{
	str = "menubar=no,toolbar=no,scrollbars=yes,resizable=no,status=yes,width="+width+",height="+height;
	x = window.open(xurl,titulo,str);
	if(!x) alert('A popup window was blocked!');
	return(x);
}

function open_window3(FileName,WindowName,w,h,x,y)
{
	str="Resizable=yes,ScrollBars=yes,MenuBar=No,Directories=No,ToolBar=No,Location=No,Status=No,Width="+w+",Height="+h+",ScreenX=0,ScreenY=0,Top="+y+",Left="+x;
	newWindow=window.open(FileName,WindowName,str);
	if (newWindow.opener == null) { newWindow.opener = self; }
	if (newWindow.focus) { newWindow.focus(); }
	return(newWindow);
}

function open_down(dir,file)
{
	open_window2(dir+"lp_down.php?file="+file,'Download',300,300);
}

function mp3down(dir,file)
{
	open_window2(dir+"lp_down.php?mpx=1&file="+file,'Download',300,300);
}

function confirm_delete() { 
  return confirm("Do you really want to delete this Entry ?!")
} 

function rate_it(dir,n,midi)
{
	if(n>0)
	{	href = dir+"lp_rateit.php?num="+n+"&midi="+midi;
		w=window.open(href,"RateIt","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=800,height=540");
		if(!w) alert('A popup window was blocked!');
	} else alert("No midi selected.");
}

function getCookieVal(offset)
{	var endstr=document.cookie.indexOf(";",offset); 
	if(endstr==-1) endstr=document.cookie.length; return unescape(document.cookie.substring(offset,endstr));
}

function GetCookie(name)
{
	var arg=name+"="; var alen=arg.length; var clen=document.cookie.length; var i=0;
	while(i<clen){
		var j=i+alen; 
		if(document.cookie.substring(i,j)==arg) return getCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if(i==0) break;
	}
	return null;
}

function SetCookie(name,value)
{	
	var argv=SetCookie.arguments; 
	var argc=SetCookie.arguments.length; 
	var expires=(argc>2)? argv[2]:null;
	var path=(argc>3)? argv[3]:null;
	var domain=(argc>4)? argv[4]:null;
	var secure=(argc>5)? argv[5]:false;
	document.cookie=name+"="+escape(value)+((expires==null)? "":("; expires="+expires.toGMTString()))+
		((path==null)? "":("; path="+path))+((domain==null)? "":("; domain="+domain))+((secure==true)? "; secure":"");
}

function WriteCookie(nome, valor, dias) 
{	
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime() + 60*60*24*dias*1000);	// days
	SetCookie(nome, valor, expires);
}

function WriteCookieMins(nome,valor,mins)
{	
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime() + 60*mins*1000);	// minutos
	SetCookie(nome,valor,expires);
}

function WriteCookieDays(nome,valor,dias)
{	
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime() + 60*60*24*dias*1000);	// dias
	SetCookie(nome,valor,expires);
}

function deleteCookie(name)
{
  var expdate = new Date();   
  expdate.setMonth(expdate.getMonth() - 1);
  SetCookie(name,"",expdate);
}

function CheckCookie(nome, valor)
{
	if(GetCoookie(nome)!=valor) return(false); else return(true);
}

function WindowCenter(w,h)
{	//  Centralizar a janela
	windowWidth=w;	// width
	windowHeight=h;	// height
	if (parseInt(navigator.appVersion) >= 4) window.moveTo((screen.width/2)-(windowWidth/2+10),(screen.height/2)-(windowHeight/2+20));
}

function WindowMoveTo(x, y)
{
	if (parseInt(navigator.appVersion) >= 4) window.moveTo(x, y);
}

function WindowTitle(x)
{
	parent.document.title = x;
}

// Abre janela de Help geral; cod contém o código de help
function CallHelp(dir,cod,w,h)
{
	href = dir+"help.php?cmd="+cod;
	s = "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width="+w+",height="+h;
	w=window.open(href,"HelpWindow",s);
	if(!w) alert('A popup window was blocked!');
}

// // tipo=0 => alert, tipo=1 => abre janelinha, 2=> página self, 3=> msg simples self
function CallMsg(tipo,dir,msg,w,h)
{
	if(tipo==1) {
		msg = replaceString("-n-","<br>",msg);
		href = dir+"msg.php?msg="+msg;
		s = "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width="+w+",height="+h;
		window.open(href,"MsgWindow",s);
	} else if(tipo==0) {
		alert(msg);
	} else if(tipo==2) {
		location.href=dir+'msg-model.php?msg='+msg;
	} else if(tipo==3) {
		location.href=dir+'msg.php?msg='+msg;
	}
}
// Troca direto no objeto texto aspas simples e duplas por `
function TrocarAspas(obj)
{	var x = new String(obj.value);
	var i = 0;
	if(x.indexOf('"')!=-1) { x = replaceString('"','`',x); i++; }
	if(x.indexOf("'" )!=-1) { x = replaceString("'",'`',x); i++; }
	if(i>0) obj.value = x;
}

// Retorna o novo string com as aspas trocadas
function TirarAspas(str)
{	var x = new String(str);
	var i = 0;
	if(x.indexOf('"')!=-1) { x = replaceString('"','`',x); i++; }
	if(x.indexOf("'" )!=-1) { x = replaceString("'",'`',x); i++; }
	return(x);
}

function FiltrarTudo(str,nivel)
{
	var x = new String(str);
	if(x.indexOf("é")!=-1) x = replaceString("é",'e',x);
	if(x.indexOf("É")!=-1) x = replaceString("É",'E',x);
	if(x.indexOf("ã")!=-1) x = replaceString("ã",'a',x);
	if(x.indexOf("á")!=-1) x = replaceString("á",'a',x);
	if(x.indexOf("ú")!=-1) x = replaceString("ú",'u',x);
	if(x.indexOf("ç")!=-1) x = replaceString("ç",'c',x);
	if(x.indexOf("õ")!=-1) x = replaceString("õ",'o',x);
	if(x.indexOf("í")!=-1) x = replaceString("í",'i',x);
	if(x.indexOf("à")!=-1) x = replaceString("à",'a',x);
	if(x.indexOf("ó")!=-1) x = replaceString("ó",'o',x);
	if(x.indexOf("_")!=-1) x = replaceString("_",'-',x);
	if(x.indexOf("ñ")!=-1) x = replaceString("ñ",'n',x);
	if(nivel==2) {
		if(x.indexOf('"')!=-1) x = replaceString('"','`',x);
		if(x.indexOf("'")!=-1) x = replaceString("'",'`',x);
		if(x.indexOf("+")!=-1) x = replaceString("+",'and',x);
		if(x.indexOf("&")!=-1) x = replaceString("&",'&amp;',x);
	}
	if(nivel==1) {
		if(x.indexOf('"')!=-1) x = replaceString('"','`',x);
		if(x.indexOf("'")!=-1) x = replaceString("'",'`',x);
		if(x.indexOf("+")!=-1) x = replaceString("+",'-',x);
		if(x.indexOf("&")!=-1) x = replaceString("&",'-',x);
	}
	if(nivel==3) {
		if(x.indexOf('"')!=-1) x = replaceString('"','',x);
		if(x.indexOf("'")!=-1) x = replaceString("'",'',x);
		if(x.indexOf("+")!=-1) x = replaceString("+",'-',x);
		if(x.indexOf("&")!=-1) x = replaceString("&",'-',x);
		if(x.indexOf('/')!=-1) x = replaceString('/','',x);
		if(x.indexOf("\\")!=-1) x = replaceString("\\",'',x);
	}
	return(x);	
}

function UserShow(root,nusu,det)
{
	if(nusu<=0) return;
	x = root+"lp_usershow.php?num="+nusu+"&det="+det;
	switch(det) {
		case 1: h=200; break;
		case 2: h=400; break;
		default: h=600; break;
	}
	w = window.open(x,"ShowUserWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=700,height="+h);
	if(!w) alert('A popup window was blocked!');
	else {
		if (parseInt(navigator.appVersion) >= 4) w.window.focus();
	}
}

function MedalShow(root,local)
{
	if(local!='') x = root+"db_medals.php?local="+local; else x = root+"db_medals.php";
	w = window.open(x,"ShowMedalWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=700,height=700");
	if(!w) alert('A popup window was blocked!');
	else {
		if (parseInt(navigator.appVersion) >= 4) w.window.focus();
	}
}

function MedalMP3Show(root,local)
{
	if(local!='') x = root+"mp3medals.php?local="+local; else x = root+"mp3medal.php";
	w = window.open(x,"ShowMedalWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=700,height=700");
	if(!w) alert('A popup window was blocked!');
	else {
		if (parseInt(navigator.appVersion) >= 4) w.window.focus();
	}
}

function UploadProgress(root,filename)
{
	if(filename!='') href = root+"lp_upprog.php?filename="+filename; else href = root+"lp_upprog.php";
	var winl = (screen.width - 300) / 2;
	var wint = (screen.height - 200) / 2;
	props = 'height=200,width=300,top='+wint+',left='+winl+',scrollbars=no,resizable=no,status=no,toolbar=no,menubar=no';
	w = window.open(href,'UploadWindow',props);
	if(!w) alert('A popup window was blocked!');
	else {
		if (parseInt(navigator.appVersion) >= 4) w.window.focus();
	}
	return(w);
}

function Confirmar(url,msg)
{
	if(confirm(msg)) location.href = url;
}

function MidiShow(dir,num)
{
	xurl = dir+'db_show2.php?num='+num;
	w=window.open(xurl,"showWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=500,height=500");
	if(!w) alert('A popup window was blocked!');
}

function MP3Show(dir,num)
{
	xurl = dir+'mp3show.php?num='+num;
	w=window.open(xurl,"MP3Show","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width=500,height=500");
	if(!w) alert('A popup window was blocked!');
}

function Navegador()
{
	tipoBrowser = navigator.appName;
	//alert(tipoBrowser);
	return(tipoBrowser);
}

function GetIEVer()
{
 var ua=window.navigator.userAgent
 //alert(ua);
 var msie=ua.indexOf("MSIE")
 if (msie>0 && window.navigator.platform=="Win32")
  return parseInt(ua.substring(msie+5,ua.indexOf(".", msie)));
 else
  return 0;
}

function BrowserCheck() {
 ms=navigator.appVersion.indexOf("MSIE");
 ie = (ms>0);
 return (ie);
}

function maximizeWin()
{
	if (window.screen)
	{
		var aw = screen.availWidth;
		var ah = screen.availHeight;
		window.moveTo(0, 0);
		window.resizeTo(aw, ah);
	}
}

function ShowHide(id)
{
	var obj = document.getElementById(id);
	if(obj.style.display=='none') obj.style.display=''; else obj.style.display='none';
}

function HitCounter(root,down,filen)
{
	x = root+'lp_hitcount.php?down='+down+'&filen='+filen;
	window.open(x,'HitCount',"menubar=no,toolbar=no,scrollbars=no,resizable=no,status=no,width=40,height=40");
}

function AlertError(root,msg,show)
{
	x = root + 'jslogerror.php?msg=' + msg;
	w=window.open(x,'JSLogError',"menubar=no,toolbar=no,scrollbars=no,resizable=no,status=no,width=40,height=40");
	if(!w) alert('A popup window was blocked!');
	if(show) alert(msg);	
}

// Exemplo: preload("meter0", "arquivo.gif");
function ImgPreload(imgObj,imgSrc,nova)
{
	if(document.images) {
		window.status = 'PRELOADING ' + imgSrc;
		if(nova) eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
		window.status = '';
		return(imgObj);
	}
	return(null);
}

function ById(idx)
{	var x = document.getElementById(idx); 
	return(x);
}

var album='';
function PlaylistClick()
{
	w=window.open('working.php?act=hit&album='+album,'RadioHit',"menubar=no,toolbar=no,scrollbars=no,resizable=no,status=no,width=250,height=250");
	if(!w) alert('A popup window was blocked!');
}

function PlayAlbum(alb)
{
	w=window.open('working.php?act=hit&album='+alb,'RadioHit',"menubar=no,toolbar=no,scrollbars=no,resizable=no,status=no,width=200,height=200");
	if(!w) alert('A popup window was blocked!');
}

function MyPiclib(img,title)
{
	var s = "<center><img src='"+img+"' border=0></center>";
	return overlib(s,CAPTION,'<center>'+title+'</center>',BELOW,RIGHT);
}

function MyTxtlib(s,title)
{
	return overlib(s,CAPTION,'<center>'+title+'</center>',BELOW,RIGHT);
}

function Ampliar(im,n)
{
	nw = n + 50;
	nh = n + 40;
	x = window.open("","PicWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width="+nw+",height="+nh);
	if(!x) alert('A popup window was blocked!');
	else {
		x.document.write("<center><img src='" + im + "' border=0></center>");
		x.status = ":-)";
	}
}

function Ampliar2(im,nw,nh)
{
	nw = nw + 50;
	nh = nh + 40;
	x = window.open("","PicWindow","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,width="+nw+",height="+nh);
	if(!x) alert('A popup window was blocked!');
	else {
		x.document.write("<center><img src='" + im + "' border=0></center>");
		x.status = ":-)";
	}
}

function SendEmail(dir,msg,idto)
{
	w=window.open(dir+"SendEmail.php?idto="+idto+"&msg="+msg,"SendEmail","menubar=no,toolbar=no,scrollbars=no,resizable=no,status=no,width=10,height=10");
	if(!w) alert('A popup window was blocked!');
}

function Mybgsound(x)
{
	if(BrowserCheck()) { document.write("<bgsound src='"+x+"' loop=0>"); }
	else { 
		document.write("<div style='position:absolute; top:-100px'><embed src='"+x+"' type='application/x-mplayer2' autostart='true' hidden='true' width=0 height=0 loop='false'></embed></div>");
	}
}

function MoreBgsound(x)
{
	if (navigator.appName == "Microsoft Internet Explorer") {
		document.write('<bgsound src="'+x+'" LOOP="false">');
	}
	else {
		document.write('<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" Name="MediaPlayer" src="'+x+'" AutoStart="true" ShowStatusBar="0" ShowControls="0" ShowDisplay="0" volume="1" HEIGHT="1" WIDTH="1" loop="false">');
	}
}

function WritePlayer(x,w,h,auto)
{
	if(w<=0) w=300;
	if(h<=0) h=60;
	document.write('<TABLE BORDER="3" CELLSPACING="0" CELLPADDING="0" BORDERCOLOR="#99CCFF" BORDERCOLORLIGHT="#DBEDFF" BORDERCOLORDARK="#5B7997"><tr><td>');
	document.write('<object id="MediaPlayer1" width="'+w+'" height="'+h+'" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902" standby="Loading Microsoft Windows Media Player..." type="application/x-oleobject">');
	document.write('<param name="FileName" value="'+x+'">');
	document.write('<param name="animationatStart" value="false">');
	document.write('<param name="transparentatStart" value="true">');
	document.write('<param name="autoStart" value="'+auto+'">');
	document.write('<param name="showControls" value="true">');
	document.write('<param name="Volume" value="-100">');
	document.write('<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" Name="MediaPlayer" src="'+x+'" AutoStart="true" ShowStatusBar="1" volume="-1" HEIGHT="'+h+'" WIDTH="'+w+'"></embed></object>');
	document.write('</td></tr></table>');
}

function MidiTime(x)
{	var playerobj = document.getElementById(x);
	if(playerobj)
	{	var s = 'Duration: ';
		if(playerobj.openState == 13 || playerobj.openState == 6) // playing or buffering
		{	if(playerobj.currentMedia) {
				if(playerobj.currentMedia.durationString) s = s + playerobj.currentMedia.durationString;
				if(playerobj.currentMedia.duration) s = s + ', ' + playerobj.currentMedia.duration + ' secs';
				alert(s);
			} else alert('No currentMedia property');
		} else alert('Status: ' + playerobj.openState);
	} else alert('Null object');
}

function mysfloat(x,n,def)
{
	sx = x.toString();
	ponto = sx.indexOf(".");
	if(ponto>=0) ret = sx.substring(0,ponto) + "." + sx.substring(ponto+1,ponto+n+1);
	else ret = sx + def;
	return(ret);
}

function isDigit(c)
{	return ((c >>= "0") && (c << "9"));
}

function isNumber(s)
{ 
  var i=0, c;
  if(s=='') return false;
  if(s.charAt(i) == "-") i++;
  for(i = 0; i << s.length; i++) { 
    // Check if all characters are numbers or decimal point
    c = s.charAt(i);
    if(c!='.' && !isDigit(c)) return false;
  }
  return true;
}

function IsAccented(s)
{
	var pattern = /[áãàâçéêèóôõòíúîûùÁÃÀÂÇÉÊÈÓÔÕÒÍÚÎÛÙñÑ{}]+/;
	if(pattern.test(s)) {
		//alert('Error: Accented or control character in filename.');
		return(true);
	}
	return(false);
}

function SeeReviews(roo,x)
{	w=window.open(roo+'db_allreviews.php?num='+x, 'AllReviews', 'width=800, height=480, resizable=yes, scrollbars=yes')
	if(!w) alert('A popup window was blocked!');
}

function OpenRevGraph(num)
{	w=window.open('db_results_graph.php?tipo=1&num='+num, 'AllReviews', 'width=780, height=360, resizable=yes, scrollbars=yes');
	if(!w) alert('A popup window was blocked!');
}

function GetOnlyFilename(x)
{
	var s = "";
	p = x.lastIndexOf("\\");
	if(p == -1) p = x.lastIndexOf("/");
	if(p>=0) s = x.substring(p+1, x.length); else s = x;
	return(s);
}

function GetBrowser()
{
	x = navigator.userAgent;
	if(x.indexOf('MSIE 7.0')>=0) { WriteCookieMins('BROWSER','IE7',60); x='IE7'; }
	else if(x.indexOf('MSIE 9.0')>=0) { WriteCookieMins('BROWSER','IE9',60); x='IE9'; }
	else if(x.indexOf('Firefox')>=0) { WriteCookieMins('BROWSER','Firefox',60); x='Firefox'; }
	else if(x.indexOf('ChromePlus')>=0) { x='ChromePlus'; WriteCookieMins('BROWSER','ChromePlus',60); }
	else if(x.indexOf('Chrome/')>=0) { WriteCookieMins('BROWSER','Chrome',60); x='Chrome'; }
	else if(x.indexOf('Maxthon')>=0) { WriteCookieMins('BROWSER','Maxthon',60); x='Maxthon'; }
	else if(x.indexOf('Opera')>=0) { WriteCookieMins('BROWSER','Opera',60); x='Opera'; }
	else if(x.indexOf('Iron')>=0) { WriteCookieMins('BROWSER','Iron',60); x='Iron'; }
	else if(x.indexOf('Safari')>=0) { WriteCookieMins('BROWSER','Safari',60); x='Safari'; }
	else { WriteCookieMins('BROWSER','IE7',60); x='IE7'; }
	mybrowser = x;
	return(x);
}

// js/jwplayer.js ou playtv.php
function JWPlayer(id,src,w)
{
	jwplayer(id).setup({
	autostart: false,
	file: src,
	flashplayer: 'js/player.swf',
	volume: 60,
	width: w,
	controlbar: 'bottom',
	idlehide: false,
	skin: 'js/beelden.zip',
	image: 'js/preview.jpg',
	stretching: 'none'
	});
}

var extra1=999;
var extra2=0;
// lp_ajax.js, playtv.php
function JWPlayList(id,src,wv,hv,xp,pos,idhits)
{	
	if(pos=='bottom') {
		if(hv==0) {	hv=5*wv/3; xp=wv; }
		stretch='exactfit';
	}
	if(pos=='right') {
		if(hv==0) { x=(wv-20)/3; hv=x; xp=2*x;	}
		stretch='uniform';
	}
 jwplayer(id).setup({
	playlistfile: src,
	autostart: false,
	flashplayer: 'js/player.swf',
	volume: 60,
	width: wv,
	height: hv,
	controlbar: 'bottom',
	idlehide: false,
	'playlist.position': pos,
	'playlist.size': xp,
	stretching: stretch,
	skin: 'js/beelden.zip',
	image: 'js/preview.jpg',
	events: {
		onPlaylist: function(event) {
			arrplist = event.playlist;
		},
		onPlaylistItem: function(event) {
			extra2 = event.index;
		},
		onPlay: function(event) {
			f = arrplist[extra2].file;
			//alert(event.oldstate);
			if((extra1!=extra2) && (event.oldstate=='BUFFERING')) {
				x = 'inchits.php?arq='+f;
				if(idhits!=undefined && idhits!='') open_url(x,idhits);
			}
			extra1=extra2;
		}
	}
 });
}

