﻿var fo_obj_queue = new Array();
var fo_div_queue = new Array();

function init(exec) {
	for (var i=0; i < fo_obj_queue.length; i++) {
		if(!fo_obj_queue[i].write(fo_div_queue[i]))
			fo_div_queue[i].innerHTML = '<table align="center"><tr><td><div style="color:gray; padding: 80px 0 0 0;"><a href="http://www.adobe.com/go/getflash"><img src="/content/framework/images/noflash.jpg" border="0" /></a></div></td></tr></table>';
	}
	handleResize();
	if (window.addEventListener){
		window.addEventListener('resize', handleResize, false);
	} else if (window.attachEvent) {
		window.attachEvent('onresize', handleResize);
	}
	prepareLinks();
}

function OpenNewWindow(fn) {
	window.open(fn);
}

function popup(x,y,w,h,f) {
	window.open(f,'descr','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbar=0,scrollbars=1,resizable=1,copyhistory=0,width=' + w + ',height=' + h + ',top=' + y + ',left=' + x);
}

function winopen(url) {
	window.open(url);
}

function openlegal(url) {
	var pop = window.open(url+'.html', "LEGAL", "width=500,height=400,scrollbars=1,resizable=0,menubar=0");
	pop.focus();
}

function log(a, b, c, d){
}

function enqueue(obj, div) {
	fo_obj_queue[fo_obj_queue.length] = obj;
	fo_div_queue[fo_div_queue.length] = div;
}

function handleResize(){
	document.getElementById("player").style.height = getHeight() - getHeightOfFooter() + 'px';
}

function getHeightOfFooter() {
	var h = document.getElementById("footer").clientHeight;
	if (!h){
		return document.getElementById("footer").offsetHeight;
	}
	return h;
}

function getHeight(){
	var height = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		height = window.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
		height = document.documentElement.clientHeight;
	} else if( document.body && document.body.clientHeight ) {
		//IE 4 compatible
		height = document.body.clientHeight;
	}
	return height;
}

function prepareLinks() {

	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
		if (links[i].getAttribute("className")) {
			if (links[i].getAttribute("classname") == "external") {
				if (links[i].getAttribute('title') == '') {
					links[i].setAttribute("title","(opens in a new window)");
				}
				links[i].onclick = function() {
					OpenNewWindow(this.getAttribute('href'));
					return false;
				}
			} else if (links[i].getAttribute('classname').substring(0,6) == 'popup_') {
				links[i].setAttribute('title','this is a popup');
				links[i].onclick = function() {
					popup(10,20,this.getAttribute('classname').split('_')[1],this.getAttribute('classname').split('_')[2],this.getAttribute('href'));
					return false;
				}
			}
		} else if (links[i].getAttribute("class")) {
			if (links[i].getAttribute("class")) {
				if (links[i].getAttribute("class") == "external") {
					if (links[i].getAttribute('title') == '') {
						links[i].setAttribute("title","(opens in a new window)");
					}
					links[i].onclick = function() {
						OpenNewWindow(this.getAttribute('href'));
						return false;
					}
				} else if (links[i].getAttribute('class').substring(0,6) == 'popup_') {
					links[i].setAttribute('title','this is a popup');
					links[i].onclick = function() {
						popup(50,50,this.getAttribute('class').split('_')[1],this.getAttribute('class').split('_')[2],this.getAttribute('href'));
						return false;
					}
				}
			}
		}
  	}
}