// ---------------------------------------------------------------------------------------------------------------------------------
//
//     Font Face Flicker Fix
//
// ---------------------------------------------------------------------------------------------------------------------------------

(function(){
  var d = document, e = d.documentElement, s = d.createElement('style');
  if (e.style.MozTransform === ''){
    s.textContent = 'body{visibility:hidden}';
    e.firstChild.appendChild(s);
    function f(){ s.parentNode && s.parentNode.removeChild(s); }
    addEventListener('load',f,false);
    setTimeout(f,3000);
  }
})();




// ---------------------------------------------------------------------------------------------------------------------------------
//
//     Render Email
//
// ---------------------------------------------------------------------------------------------------------------------------------

function render_email(account, domain, tl, subject, title) {

	// Custom
	var email = account+'@'+domain+'.'+tl;
	var output = '<a href="mailto:'+email+'?subject='+subject+'" title="Send E-mail">'+email+'</a>';

	// Write
	document.write(output);
}



// ---------------------------------------------------------------------------------------------------------------------------------
//
//     Resize Video Display
//
// ---------------------------------------------------------------------------------------------------------------------------------

// Variables
var player;
var playerWidth;

// Constants
var displayHeight4x3 = 752;
var displayHeight16x9 = 576;
var displayInit = false;

function playerReady(obj) {

	// Check Object
	if (obj['id'] == 'display-video') {
		
		// Init
		player = document.getElementById(obj['id']);

		// Setup
		playerWidth = player.width;
		playerHeight = player.height;
		
		// Listner
		player.addControllerListener('ITEM', 'itemMonitor');
		
		// Check size
		if (displayInit == true) itemMonitor(obj);
	}
};

function itemMonitor(obj) {

	// Check Height
	if (playerHeight == displayHeight4x3) {
		playerHeightSD = 512;
	} else if (playerHeight == displayHeight16x9) {
		playerHeightSD = 392;
	}

	// Check State
	if(player.getPluginConfig('hd')['state']) {
		setFlashSize(960, playerHeight);
	} else {
		setFlashSize(960, playerHeightSD);
	}
	
};

function setFlashSize(newW, newH) {

	// Set Dimensions
	gid('display-video').style.width =  newW+'px';
	gid('display-video').style.height =  newH+'px';
	player.width =  newW;
	player.height =  newH;
};
	
function gid(name) {

	// Return
	return document.getElementById(name);
};
