
var basevars = "showdigits=true&autostart=true&showfsbutton=true&lightcolor=0xF77734&backcolor=0x000000&frontcolor=0x804000&overstretch=true";

function tvto(x,t,a) {
	var extra = ""+(GET.cat?"&cat="+GET.cat:"")+(GET.vid?"&vid="+GET.vid:"")
	var FO = {	
		movie: "../katytidTV/swf/flvplayer.swf",
		width:ww,
		height:hh,
		majorversion:"7",
		build:"0",
		bgcolor:"#000000",
		flashvars: basevars + 
			"&file=video/" + x + ".flv" +
			(GET.fullScreen 
				? "&fullscreenpage="+escape(baseHref+"tool=tvp"+extra)
				: "&fullscreenpage="+escape(baseHref +"tool=tvp&fullScreen=1"+extra)
			)
	}
	if (GET.fullScreen) {
		UFO.create(FO,"player2")
	}
	else {
		UFO.create(FO,"player1");
		var href = "http://www.donnatv.it/tv/mooffanka/?tool=tvp&vid="
      +(GET.vid?GET.vid:vstart);
		
		$('#didascalia').html('<p class="vTitle">IN ONDA: <span id="onairTitle">'+t+'</span></p><p class="vText">'+a+'</p><br/><span style="font-size:80%;color:#F67631;">Link diretto a questo video: <input id="directlink" style="background:#000;color:#BF916B;width:200px;border:1px solid #404040;" value="'+ href+'" ><br/><br/></span>');
		$("#directlink").click(function() {
      $("#directlink").select();
      return false;
    });
	}
}

function tvgo(id,n,x) {
	currv = tvs[id]
	GET.vid = id
	tvto(currv.n,currv.t,currv.a)
	document.getElementById("v"+n).blur()
	if (document.getElementById("v"+n+"b")) document.getElementById("v"+n+"b").blur()
}

function resizeVideo() {
	setWH()
	tvto(currv.n,currv.t,currv.a)
}

var cat = []
var tvs = []
var currv = []
var pp, vstart, ww = 320, hh = 260


$(document).ready(function(){
	if (GET.fullScreen) setWH()
	if (GET.vid) {
		currv = tvs[GET.vid]
		tvto(currv.n,currv.t,currv.a)
	} else if (vstart) {
		currv = tvs[vstart]
		tvto(currv.n,currv.t,currv.a)
	}
	
})

function setWH() {
	var w = xClientWidth()
	var h = xClientHeight()
	var f = 1.333
	if (w>h*f) {
		hh = h
		ww = Math.floor(h*f) - 32
	}
	else {
		ww = w
		hh = Math.floor(w/f) - 24
	}
}


function xClientHeight()

{
  var h=0,d=document,w=window;
  if(d.compatMode == 'CSS1Compat' && !w.opera && d.documentElement && d.documentElement.clientHeight)
    {h=d.documentElement.clientHeight;}
  else if(d.body && d.body.clientHeight)
    {h=d.body.clientHeight;}
  else if(xDef(w.innerWidth,w.innerHeight,d.width)) {
    h=w.innerHeight;
    if(d.width>w.innerWidth) h-=16;
  }
  return h;
}




function xClientWidth()

{
  var w=0,d=document,w=window;
  if(d.compatMode == 'CSS1Compat' && !w.opera && d.documentElement && d.documentElement.clientWidth)
    {w=d.documentElement.clientWidth;}
  else if(d.body && d.body.clientWidth)
    {w=d.body.clientWidth;}
  else if(xDef(w.innerWidth,w.innerHeight,d.height)) {
    w=w.innerWidth;
    if(d.height>w.innerHeight) w-=16;
  }
  return w;
}

