//--------------------------------------
// Centrage de l'application
//--------------------------------------
function getWindowHeight() 
{
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function getWindowWidth() 
{
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}
function onResize() 
{	
	var windowHeight = getWindowHeight();
	var windowWidth = getWindowWidth();
	if (windowHeight > 0) {
		var contentElement = document.getElementById('global-wrapper');
		var contentHeight = contentElement.offsetHeight;
		var contentWidth = contentElement.offsetWidth;
		contentElement.style.position = 'absolute';
		if (windowHeight - contentHeight > 0) {
			contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
			contentElement.style.left = ((windowWidth / 2) - (contentWidth / 2)) + 'px';
		}else{
			contentElement.style.top = '0px';
			contentElement.style.left = ((windowWidth / 2) - (contentWidth / 2)) + 'px';
		}
	}
}
function redir(){
        window.location.replace("/faq/test/comp.html");
}
function affPopup(url){
	var h=480;
	var w=620;
	var left=Math.round((screen.availWidth - w)/2);
	var top=Math.round((screen.availHeight - h)/2);
	window.open (url,'m6pop', config='height='+h+', width='+w+', toolbar=no, menubar=no, scrollbars=1, resizable=1, location=no, directories=no, status=no,top='+top+',left='+left+'');
}
//player
function launchVideo(url)
{
	MxPlayer.display();
	MxPlayer.playVideo(ASX_BASE + url);
	//alert('dartPlayer NOW');
	//dartPlayer = new DartPlayer(myRPOjbect, DARTReady);        
}
function playVideo(url)
{
	MxPlayer.playVideo(url);
}

// check if the firefox WMP update has already been installed
// http://port25.technet.com/videos/downloads/wmpfirefoxplugin.exe
function isWMVPatchInstalled() {
    var isWMVPatchInstalled;

    for (var i in navigator.plugins) {
        var n = navigator.plugins[i].name;
        if (n != null && n.indexOf("Windows Media") >= 0 && n.indexOf("Microsoft") >= 0) {
            isWMVPatchInstalled = true;
        }
    }

    //alert('isWMVPatchInstalled='+isWMVPatchInstalled);

    return isWMVPatchInstalled;

}

function canDoFullScreen() {
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf("msie") != -1 || isWMVPatchInstalled()) {     
		return true;
	}
	return false;
}

function fullScreen(id, alternateMessage) {

    var player = document.getElementById(id);
    // on IE and with the updated WMV plugin, player is defined. We can set it to full screen.
    if (canDoFullScreen() && player) {
        if (player.playState == 3)
        {
            player.fullScreen = true;
        }
    } else {
        // everywhere else, we have to show the alternate message, telling the user to dblclick on the window. This works
        // in some player plugins
        //alert(alternateMessage);
    }
}

function showFooter(){
		var div = document.getElementById('footer_replay');
		div.style.display="block";
	}

/** Cookies */
function setCookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
//alert(name+"/"+value+"/"+exp_y+"/"+exp_m+"/"+exp_d+"/"+path+"/"+domain+"/"+secure);
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}

function getCookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}