setFloaterPos = function(){
	
	var top = document.viewport.getHeight()/2 - $('player_container').getHeight()/2 + $(document.body).cumulativeScrollOffset()[1];
	var left = document.viewport.getWidth()/2 - $('player_container').getWidth()/2;
	
	$('player_container').setStyle({
		position: 'absolute',
		top: Math.round(top) +'px',
		left: Math.round(left) +'px'
	});
};


function callExternalInterface() {
    try{thisMovie("sapStockFootage").quitFlash();}
		catch(e){}
};

function callExternalInterface2(id) {
    try{thisMovie("sapStockFootage").startFlash(id);}
		catch(e){}
};

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    }
    else {
        return document[movieName];
    }
};

function hideFloater() {
	if (thisMovie("sapStockFootage"))
		callExternalInterface();

	$('player_container').hide();
	$('bg').hide();

	document.body.style.overflow = "visible";
};

function setDescription(clipObj) {
	return true;
};

setPlayerMeta = function(ro){
	$('descHead').update(_curList[_curClip].titel);
	$('descCopy').update(Utf8.decode(custnavdecode(_curList[_curClip].desc)));
	
	$('player_meta').update(_curList[_curClip].meta);
	
	var tbhtml = '<ul>';
	if(_curList[_curClip].preview.url.length > 0){
		tbhtml += '<li class="download"><a href="#" onclick="tracker(\''+_curList[_curClip].titel.replace(/\'/g,"\\\'")+'\', \''+_curList[_curClip].id+'\', \'download preview\');downloadFile(\''+_curList[_curClip].preview.url+'\');return false;">Download Preview</a><br /><em>'+_curList[_curClip].preview.infos+'</em>';
	} else {
		tbhtml += '<li class="download_disabled"><span>No preview available</span><br /><em>n/a</em>';
	}
	tbhtml += '				</li>\
										<li class="email"><a href="#" onclick="tracker(\''+_curList[_curClip].titel.replace(/\'/g,"\\\'")+'\', \''+_curList[_curClip].id+'\', \'email\');mailURL(\''+custnavencode(_curList[_curClip].titel)+'\', \''+custnavencode(Utf8.decode(custnavdecode(_curList[_curClip].desc)))+'\', \''+_curList[_curClip].mailurl+'\');return false;">E-Mail Download Link</a></li>\
										<li class="cleanfeed" id="cfl_'+_curList[_curClip].id+'p"><a href="#" onclick="showCleanfeed(\''+_curList[_curClip].id+'p\', '+_curList[_curClip].sources.toJSON().replace(/\'/g,"\\\'").replace(/"/g, '\'')+');return false;">Download in high-res</a></li>\
								</ul>';
	$('player_toolbox').innerHTML = tbhtml;
};
setPlayerNav = function(){
	$('count').update((_curClip+1)+' of '+_curList.length);
};
playerNav = function(d){
	var nClip = _curClip+parseInt(d,10);
	if(nClip < 0) nClip = _curList.length-1;
	if(nClip > _curList.length-1) nClip = 0;
	startPreview(nClip);
	tracker(_curList[nClip].titel, _curList[nClip].id, 'view');
};


var so1 = new SWFObject("flash/main.swf", "sapStockFootage", "432", "295", "8", "#EFEFEF");
so1.addVariable("playerFormat","4");
so1.addVariable("isFloater", "true");
so1.addParam("allowScriptAccess", "always");
so1.addParam("allowFullScreen", "true");

/*
function startFloater(_ID, _lang) {
	
	setFloaterPos();
	
	new Effect.Appear($('bg'), { duration: 0.5,  to: 0.9 });
	
	$('player_container').show();
	
	document.body.style.overflow = "hidden";
	
	if(_ID) {
		so1.addVariable("vidID",_ID);
		so1.addVariable("l",_lang);
		so1.write("flash_content");
	} else {		
		so1.write("flash_content");
	}
	
}
*/

function endFlash(vidID){
	if (vidID == 3198 || vidID == 3234)
		hideFloater();
};

adBCheck = function(){
	var i, l;
	l = $('flash_content').getElementsByTagName('a');
	for(i=0;i<l.length;i++){
		if(l[i].getAttribute('title') && l[i].getAttribute('title').toLowerCase().indexOf('adblock') >= 0) $('flash_content').removeChild(l[i]);
	}
};



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
};
