var where=window.location.href;
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function SetLang (lang, exp) {
document.cookie = 'mylang='+lang;
window.location.reload();
}
/*
$(document).ready(function() {
$('div#fancy a').Tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    opacity: 1, 
    fixPNG: true, 
    showBody: " - ", 
    extraClass: "pretty fancy", 
    top: -15, 
    left: 5 
}); 
}); */
$(document).ready(function() {
	$("#16").css('color', 'red');
	//if(screen.width < 900)$(function(){ $("span").ImageAutoSize2(400,400);});
	var dstr = "";
	if (location.href.indexOf("/archive")!=-1){
		var docref=location.href.split("/archive"); 
		date2 = docref[1].split(".html")[0];
		var datearr = date2.split("-");
		dstr = datearr[0]+'-'+ datearr[1] + '-'+datearr[2];
	}
    jQuery.post('rotator.php', 'pg=2&date='+ dstr, function(dat) {
    	$("#rota").html(dat);
	});
}); 
jQuery.fn.ImageAutoSize2 = function(width,height)
{
    $("img",this).each(function()
    {
        var image = $(this);
		if(image.width()>width)image.width(width);
        //$(image).attr("border",0);
		//$(image).attr("align",'left');
        var sc = $(image).attr("src");
        var link = '<a href="'+sc+'" title="" class="thickbox" rel="pp"></a>'
		$(image).wrap(link);
		

    });
    tb_init('a.thickbox, area.thickbox, input.thickbox'); 
}

//$(function(){ $("span").ImageAutoSize2(300,200);});


	// some variables to save
	var currentPosition;
	var currentVolume;
	var currentItem;

	// these functions are caught by the JavascriptView object of the player.
	function sendEvent(typ,prm) { thisMovie("mpl").sendEvent(typ,prm); };
	function getUpdate(typ,pr1,pr2,pid) {
		if(typ == "time") { currentPosition = pr1; }
		else if(typ == "volume") { currentVolume = pr1; }
		else if(typ == "item") { currentItem = pr1; setTimeout("getItemData(currentItem)",100); }
		var id = document.getElementById(typ);
		id.innerHTML = typ+ ": "+Math.round(pr1);
		pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
		if(pid != "null") {
			document.getElementById("pid").innerHTML = "(received from the player with id <i>"+pid+"</i>)";
		}
	};

	// These functions are caught by the feeder object of the player.
	function loadFile(obj) { thisMovie("mpl").loadFile(obj); };
	function addItem(obj,idx) { thisMovie("mpl").addItem(obj,idx); }
	function removeItem(idx) { thisMovie("mpl").removeItem(idx); }
	function getItemData(idx) {
		var obj = thisMovie("mpl").itemData(idx);
		var nodes = "";
		for(var i in obj) { 
			nodes += "<li>"+i+": "+obj[i]+"</li>"; 
		}

if(obj['title'].indexOf('|') != -1)$("#tstore").val(obj['title']);
		var myArr = $("#tstore").val().split("[|]");
		var linkArr = myArr[0].split(",");
	if(linkArr.length < 146)
	{
		var link = "";
		for(var x in linkArr){
			var linkArr2 = linkArr[x].split("|;|");
			j=parseFloat(x)+1;
			jj=(parseFloat(x)==parseFloat(idx))?"<font color='red'>"+j+"</font>":j;
			if(parseFloat(x)==parseFloat(idx))mytitle=linkArr2[1].substring(0, 26);
			link += '<a class="fancytitle" href="'+x+'" title="'+linkArr2[1]+'">'+jj+'</a> ';
			}

			$("#fancy").html(link);

	}

	document.getElementById("data3").innerHTML = '<a href="'+obj["link"]+'"><span style="font-size: 13px;">'+mytitle+'</span></a>';
	$('div#fancy a').Tooltip({ 
	    track: true, 
	    delay: 0, 
	    showURL: false, 
	    opacity: 1, 
	    fixPNG: true, 
	    showBody: " - ", 
	    extraClass: "pretty fancy", 
	    top: 8, 
	    left: -300
	}); 
	//$('div#data5 a').cluetip({splitTitle: '|'});
    $('div#fancy a').bind("click", function(){
       var alink = this.href;
       j = alink.substr(alink.lastIndexOf('/') + 1, alink.length)
       sendEvent('playitem',j)
       this.blur();
       return false;
    });


	};

	// This is a javascript handler for the player and is always needed.
	function thisMovie(movieName) {
	    if(navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName];
		} else {
			return document[movieName];
		}
	};

