// Globale Scripts
// Browser-Check
var ua = window.navigator.userAgent;
var jsReady = false;
var seekToTime = null;
var isMSIE = true;
if (ua.indexOf("MSIE") == -1) {
	isMSIE = false;			   
}
// Vars
var playerExpanded = false;

function init() {
	jsReady = true;
	$("div#srch_params_advance").hide();
	document.getElementById("srch_adv").style.display = "block";
}

// jQuery
$(document).ready(function() {
	init();
/* Tab-Navigation *****************************************************************************************/
	$("a#navigatorTab_L").click(function () {
		tpsTab();
	});
	$("a#navigatorTab_M").click(function () {
		iavTab();
	});
	$("a#navigatorTab_R").click(function () {
		mtkTab();
	});
	$("a#srch_adv").click(function () {
		$("div#srch_params_advance").slideToggle("normal");	
	});
	var searchString = "undefined";
});
// Funktionen
function tpsTab() {
	$("a#navigatorTab_L").css("z-index", "3");
	$("a#navigatorTab_M").css("z-index", "2");
	$("a#navigatorTab_R").css("z-index", "1");	
}
function iavTab() {
	$("a#navigatorTab_L").css("z-index", "2");
	$("a#navigatorTab_M").css("z-index", "3");
	$("a#navigatorTab_R").css("z-index", "1");	
}
function mtkTab() {
	$("a#navigatorTab_L").css("z-index", "1");
	$("a#navigatorTab_M").css("z-index", "2");
	$("a#navigatorTab_R").css("z-index", "3");	
}
function togglePlayerSize() {
	if (playerExpanded == false) {
		expandPlayer();
	} else {
		shrinkPlayer();
	}
}
function expandPlayer() {
	document.getElementById("player").style.width = "820px";
	document.getElementById("player").style.height = "383px";
//	document.getElementById("filmtitle").style.width = "820px";
	document.getElementById("features").style.display = "none";
	document.getElementById("navigatorPanel").style.display = "none";
	playerExpanded = true;
}
function shrinkPlayer() {
	document.getElementById('player').style.width = "440px";
	document.getElementById('player').style.height = "277px";
//	document.getElementById("filmtitle").style.width = "440px";
	document.getElementById("features").style.display = "block";
	document.getElementById("navigatorPanel").style.display = "block";
	playerExpanded = false;
}

// Player
function isReady() {
	return jsReady;
}

function getObject(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? top.window[movieName] : top.document[movieName];
}

function jumpTo(time) {
	getObject("p_wrapper").seek(time);
}

function showInfosite(num) {
	//
}

// Suche
function updateSForm() {
	searchString = document.getElementById("srch_form").srch_string.value;
	mtkTab();
	shrinkPlayer();
}
// Popups
function popup(url, w, h) {
  hPos = window.innerWidth / 2 - w / 2;
  vPos = window.innerheight / 2 - h / 2;
  wdw = window.open("popups/" + url,"Popup","width=" + w + ",height=" + h + ",location=no,scrollbars=yes,menubar=no");
  wdw.focus();
}

// Hinweise
function showTip(text, pos, timeout) {
	var posY = pos[0] - 20;
	var posX = pos[1] + 20;
	var style = "position:absolute;top:" + posY + "px; left:" + posX + "px;background:#000;color:#fff;font-size:12px;padding:3px 6px;-moz-box-shadow: 0 0 3px #000;-webkit-box-shadow: 0 0 3px #000;box-shadow: 0 0 3px #000;-moz-border-radius: 3px;-webkit-border-radius: 3px;border-radius: 3px;z-index:8;border:1px solid #ddd;";
	var note = document.createElement('p');
	note.setAttribute('id', 'note');
	note.setAttribute('style', style);
	note.innerHTML = text;
	document.getElementById('site').appendChild(note);
	// Eventslistener
	if (isMSIE == false) {
		note.addEventListener("mouseover",removeTip,false);
	} else {
		note.attachEvent("onmouseover",removeTip);
	}
	var to = setTimeout("removeTip();",timeout*1000);
}
function removeTip() {
	var ste = document.getElementById('site');
	var nte = document.getElementById('note');
	ste.removeChild(nte);
}
function getPos(et) {
	var position = new Array();
	position.push(et.offsetTop + et.offsetParent.offsetTop);
	position.push(et.offsetLeft + et.offsetParent.offsetLeft);
	return position;
}
