
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
function myWin(myLink)
{
	window.open(myLink,'','width=320, height=330, scrollbars=yes, toolbar=no');
}
function webTV(id,width,height) {
	//window.open('webtv.php?id='+id,'','width=550, height=550, scrollbars=no, toolbar=no');
	window.open('/webtv_mq.php?id='+id,'','width=740, height=600, scrollbars=no, toolbar=no');
}
function webTV_hq(id,width,height) {
	window.open('/webtv_hq.php?id='+id,'','width=1044, height=750, scrollbars=no, toolbar=no');
}
function webTV_mq(id,width,height) {
	window.open('/webtv_mq.php?id='+id,'','width=740, height=600, scrollbars=no, toolbar=no');
}
function webTVlive(lang) {
	//window.open('http://avaus_dev.webcast.vlp.fi/?prefix=sport&lang='+lang,'','width=740, height=800, top=50,left=50, toolbar=no,location=no, directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no');
	if(lang=='en')	{
		window.open('http://avaa.anviawebcasting.com/en/sport','Player','width=900,height=715,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	}
	
	else if(lang=='fi')	{
		//window.open('http://avaus.anviawebcasting.com/?prefix=sport&lan='+lang,'','width=740, height=800, top=50,left=50, toolbar=no,location=no, directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no');
		window.open('http://avaa.anviawebcasting.com/fi/sport','Player','width=900,height=715,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	}
	else	{
		window.open('http://avaa.anviawebcasting.com/sv/sport','Player','width=900,height=715,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	}
}
		
		
	

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


// these functions are caught by the JavascriptView object of the player.
function sendEvent(typ,prm) { thisMovie("playlist").sendEvent(typ,prm); };
function getUpdate(typ,pr1,pr2,pid) {
	if(pid != "null") {
		//alert(pid+"fdfd");
		//document.getElementById("pid").innerHTML = "(received from the player with id <i>"+pid+"</i>)";
		if((typ == "state")&&(pr1 != undefined)&&(pid=="promovideojs")) { 
			currentState = pr1; 
			if(currentState=="3") { document.location.href=redirectURL; }
		}

	}
	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);
	
};

// These functions are caught by the feeder object of the player.
function loadFile(obj) { thisMovie("playlist").loadFile(obj);  };
function addItem(obj,idx) { thisMovie("playlist").addItem(obj,idx); }

function removeItem(idx) { thisMovie("playlist").removeItem(idx); }
function getItemData(idx) {
	var obj = thisMovie("playlist").itemData(idx);
	var nodes = "";
	for(var i in obj) { 
		nodes += "<li>"+i+": "+obj[i]+"</li>"; 
	}
	//document.getElementById("data").innerHTML = nodes;
};

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

function switchVideo(obj, autostart) {
	//alert(obj);
	loadFile(obj);
		
	if (autostart) sendEvent('playpause');
}

var t1 = 0;
var t2 = 0;

function jumpVideo(obj, autostart) {
	//alert(obj);	
	if (obj['ad']=='true') {					
		loadFile(obj);	
		//t1 = setTimeout("addAd1('"+obj['title']+"')", 1000);	
		t2 = setTimeout("addAd2('"+obj['title']+"')", 1000);		
		sendEvent('playpause');	
	} else {
		if (t2) {
			//clearTimeout(t1);
			clearTimeout(t2);
		}
		
		switchVideo(obj, autostart);
		return true;	
	}
		 	
}


function addAd1(settitle) {	
	addItem({file:'http://video.vaasansport.fi/mainos/esitys1.swf',title:settitle+', Vaasa Science Park',id:'playlist'}, 0);		
	
}
function addAd2(settitle) {	
	addItem({file:'http://video.vaasansport.fi/mainos/loppuosa2.swf',title:settitle+', Vaasa Science Park',id:'playlist'}, 2);		
}

function locationVideo(url) {
	location.href=url;
}

function videoOver(aRow, aID) {
	//aRow.style.backgroundColor='#CE3C41';\n
	document.getElementById('link1_'+aID).style.backgroundColor='#CE3C41';
	document.getElementById('link2_'+aID).style.backgroundColor='#CE3C41';
	document.getElementById('link3_'+aID).style.backgroundColor='#CE3C41';
	document.getElementById('link2_'+aID).style.color='#FFFFFF';
	document.getElementById('link3_'+aID).style.color='#FFFFFF';
	document.getElementById('link8_'+aID).style.color='#FFFFFF';
	//document.getElementById('link4_'+aID).style.color='#FFFFFF';
	//document.getElementById('link5_'+aID).style.color='#FFFFFF';
	//document.getElementById('link6_'+aID).style.color='#FFFFFF';
	//alert('sdf');
}
function videoOut(aRow, aID) {
	//aRow.style.backgroundColor='#FAE9EA';\n
	document.getElementById('link1_'+aID).style.backgroundColor='#FAE9EA';
	document.getElementById('link2_'+aID).style.backgroundColor='#FAE9EA';
	document.getElementById('link3_'+aID).style.backgroundColor='#FAE9EA';
	document.getElementById('link2_'+aID).style.color='#CE3C41';
	document.getElementById('link3_'+aID).style.color='#CE3C41';
	document.getElementById('link8_'+aID).style.color='#CE3C41';
	//document.getElementById('link4_'+aID).style.color='#CE3C41';
	//document.getElementById('link5_'+aID).style.color='#CE3C41';
	//document.getElementById('link6_'+aID).style.color='#CE3C41';
}
