// JavaScript Document

var uid = new Date().getTime();
var flashProxy = new FlashProxy(uid, 'JavaScriptFlashGateway.swf');

var DOMINIOWEB = "www.canalboda.tv";

var infovideo = null;
var codivideo = null;
var permalink = null;

var fblink = null;

function inicialitzaVideo()
{
	infovideo = document.getElementById("auxDadesTD");
	codivideo = document.getElementById("codi");
	permalink = document.getElementById("permalink");
	
	fblink = document.getElementById("fblink");
}

function veureVideo(id, tipus) 
{ 
	myalert(id+" - "+tipus)
	flashProxy.call('jsVeureVideo',id, "t="+tipus);
	window.scrollTo(0,0);
	
	veureDadesPlayer(id);
}

function veureDadesPlayer(id) 
{

	var aux_innerHTML = "&nbsp;"; //document.getElementById("clientvideo"+id).innerHTML; //id="clientvideo<?php echo $row_llistatvideos1_rs['id']; ?>"
	var aux_durada = document.getElementById("duradavideo"+id);
	
	if (aux_durada && aux_durada.innerHTML) aux_innerHTML += " Durada " + aux_durada.innerHTML;
	
	infovideo.innerHTML = aux_innerHTML;
	
	codivideo.value = "<object width=\"468\" height=\"303\"><param name=\"movie\" value=\"http://" + DOMINIOWEB + "/v/" + id + "\"></param><param name=\"wmode\" value=\"transparent\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"http://" + DOMINIOWEB + "/v/" + id + "\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" allowFullScreen=\"true\" width=\"468\" height=\"303\"></embed></object>";

	permalink.value = "http://" + DOMINIOWEB + "/video=" + id;
	
	fblink.href = 'http://www.facebook.com/sharer.php?u=' + escape(permalink.value);
}
	
function veureDadesVideo(id) 
{
	//carregarCapaXHTML("dadesvideo","dadesvideoINC.php?video="+id);

	AjaxRequest.get(
	  {
		'url':"dadesvideoINCN.php?video="+id
		,'onSuccess':function(req){ document.getElementById("dadesvideo").innerHTML = req.responseText; }
		,'onError':function(req){ alert('Error!\n '+req.statusText+'\n '+req.responseText);}
		,'timeout':8000
		,'onTimeout':function(req){ window.status = req.url+' timeout!'; }    
	  }
	);	
	
	veureDadesPlayer(id);
}


function cercarVideo() 
{ 
	
	var texte = document.getElementById("cercar").value;

	if (texte != "") {	

		AjaxRequest.get(
		  {
			'url':"llistavideosINCN.php?cercar="+texte
			,'onSuccess':function(req){ document.getElementById("llistatvideos1").innerHTML = req.responseText; }
			,'onError':function(req){ alert('Error!\n '+req.statusText+'\n '+req.responseText);}
			,'timeout':8000
			,'onTimeout':function(req){ window.status = req.url+' timeout!'; }    
		  }
		);
				
		
	}
	
	return false;

}

function llistatCategoria(codi) 
{ 

	window.scrollTo(0,0);
	
	AjaxRequest.get(
	  {
		'url':"llistavideosINCN.php?categoria="+codi
		,'onSuccess':function(req){ document.getElementById("llistatvideos1").innerHTML = req.responseText; }
		,'onError':function(req){ alert('Error!\n '+req.statusText+'\n '+req.responseText);}
		,'timeout':8000
		,'onTimeout':function(req){ window.status = req.url+' timeout!'; }    
	  }
	);	
	
}

function veurePagina(url)
{
	var url_params = url.split("?",2)[1];
	
	window.scrollTo(0,0);
	
	AjaxRequest.get(
	  {
		'url':"llistavideosINCN.php?"+url_params
		,'onSuccess':function(req){ document.getElementById("llistatvideos1").innerHTML = req.responseText; }
		,'onError':function(req){ alert('Error!\n '+req.statusText+'\n '+req.responseText);}
		,'timeout':8000
		,'onTimeout':function(req){ window.status = req.url+' timeout!'; }    
	  }
	);	
	
	
}

function llistatMesvistos(mode) 
{
	
	window.scrollTo(0,0);
	
	AjaxRequest.get(
	  {
		'url':"llistavideosINCN.php?categoria=MESVISTOS&mode="+mode
		,'onSuccess':function(req){ document.getElementById("llistatvideos1").innerHTML = req.responseText; }
		,'onError':function(req){ alert('Error!\n '+req.statusText+'\n '+req.responseText);}
		,'timeout':8000
		,'onTimeout':function(req){ window.status = req.url+' timeout!'; }    
	  }
	);
	
}	

function myalert(texte) 
{
	window.status = texte;
}

function texteCarregantVideo(texte)
{
	document.getElementById("auxDadesTD").innerHTML = "iniciant video...";
}

function texteErrorVideo(texte)
{
	document.getElementById("dadesvideo").innerHTML="error! "+texte;	
}

function obrirInfoGN(id) {
	url = "http://guianupcial.com/anuncis/redireccio.php?id="+id+"&sw=info&cc=GN.TV";
	open(url,"popInfo"+id,"titlebar=no,left=300,top=25,width=468,height=520,alwaysRaised=yes");
}
