/* 2004-2005 Kahiloa Solutions et Communication */
/* Universal Pictures Project */
/* SCRIPT GLOBAL DU SITE UNIVERSAL PICTURES */

/* Variables globales */
var MM_FlashCanPlay = false; //Variable pour savoir si le plugin flash est installé
var MM_contentVersion = 6; //Version du plugin flash
var vGetFlashFile = "/getflash.php";

//Test du navigator
var gCursor = null;
if(navigator.appName=='Microsoft Internet Explorer')	gCursor = 'hand';
else	gCursor = 'pointer';

// Navigator informations
var n = navigator;
var d = document;
var agent = n.userAgent.toLowerCase();
var name = n.appName.toLowerCase();
var opera = agent.indexOf("opera") != -1;

//Browser sniff hash obj
var sniff = {
	bw: {
	ie:agent.indexOf("msie") != -1 && !opera,
	ie4:agent.indexOf("msie 4.") != -1 && !opera,
	ie5:agent.indexOf("msie 5.") != -1 && !opera,
	ie6:agent.indexOf("msie 6.") != -1 && !opera,
	ns:name.indexOf("netscape") != -1 && agent.indexOf("gecko") == -1,
	ns6:agent.indexOf("netscape6") != -1
	},
	os: {
	win:n.userAgent.indexOf("Win") != -1,
	mac:n.userAgent.indexOf("Mac") != -1
	}
};

/* Fonction permettant de savoir si le plugin flash est installé */
function initFlashPlugin(){	
	//Test sur la présence du plugin flash du navigator
	MM_contentVersion = 6;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i) {
			if (isNaN(parseInt(words[i])))
			continue;
			var MM_PluginVersion = words[i]; 
	    }
		MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
	   && (navigator.appVersion.indexOf("Win") != -1)) {
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
		document.write('on error resume next \n');
		document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
		document.write('</SCR' + 'IPT\> \n');
	}
}

//Redirection vers la page de récupération du plugin flash	
initFlashPlugin();
if(!MM_FlashCanPlay){
	window.location = vGetFlashFile;
}

/* Affichage d'une animation flash avec focus direct (IE, Opera, Firefox) */
function InsertFlash(data, width, height, transparent){
    var swf = '<object'+
              ' type="application/x-shockwave-flash" data="'+data+
              '" width="'+width+
              '" height="'+height+
              '">\n';
        swf += '<param name="movie" value="'+data+'" />\n';
        if(transparent==true)
            swf += '<param name="wmode" value="transparent" />\n';
        swf += '<embed src="'+data+'" pluginspage="http://www.macromedia.com/go/getflashplayer'+
              '" width="'+width+
              '" height="'+height+
              '" type="application/x-shockwave-flash">'+
              '</embed>\n';
        swf += '</object>\n';
        document.write(swf);
        return;
}


/* Récupération de la hauteur d'un div */
function getHeightDivById(pId){
	var vDivHeight = 0;
	vDivHeight=(sniff.bw.ns)?d[pId].clip.height:sniff.bw.ie?d.all[pId].offsetHeight:d.getElementById(pId).offsetHeight;
	return vDivHeight;
}

/* Affectation de la hauteur d'un div */
function setHeightDivById(pId, pHeight){	
	var pMinHeight = 388;
	var vStyle=(sniff.bw.ns)?d[pId]:sniff.bw.ie?d.all[pId].style:d.getElementById(pId).style;
	if(pHeight<=pMinHeight) pHeight = pMinHeight;
	if(pHeight>0)	vStyle.height = pHeight+'px';
}

/* FONCTIONS POUR LE ROLL OVER DES IMAGES */
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* FONCTION INITIALISATION DES IMAGES DE LA NAV */
function __initImgAvantAffichage(){
	var vNumTerr = 1;
	var vImObj	= document.getElementById('img_nav_'+vNumTerr);
	//Gestionnaire d'evenements sur les images de la navigation
	while(vImObj!=null){
		if(vImObj.style.cursor!=null) vImObj.style.cursor = gCursor;
        //alert("img_nav_"+vNumTerr);
		vImObj.onmouseover = function(){
			if(typeof(MM_swapImage)!='undefined')	MM_swapImage(this.id,'',this.src.replace('off', 'on'),1);
		}
		vImObj.onmouseout = function(){
			if(typeof(MM_swapImgRestore)!='undefined')		MM_swapImgRestore();	
		}
		vNumTerr++;
		vImObj	= document.getElementById('img_nav_'+vNumTerr);
	}
}

/* Redimensionnement des div en fonction du contenu */
function resizeDivHeight(pId1, pId2, pId3){
	//Redimensionne les divs par rapport au plus grand
	var vHeightDiv1 = 0
	var vHeightDiv2 =0
	var vHeightDiv3 = 0;

	//Récupération de la hauteur des div
	if(pId1!=null) vHeightDiv1 = getHeightDivById(pId1);
	if(pId2!=null) vHeightDiv2 = getHeightDivById(pId2);
	if(pId3!=null) vHeightDiv3 = getHeightDivById(pId3)+78;
	var vTemp = Math.max(vHeightDiv1, vHeightDiv2);
	vTemp = Math.max(vTemp, vHeightDiv3);
	if(pId1!=null) setHeightDivById(pId1, vTemp);
	if(pId2!=null) setHeightDivById(pId2, vTemp);
	if(pId3!=null) setHeightDivById(pId3, vTemp);
}

//Ouverture des pop-up
function openWindow(pType, pUrl, pLargeur, pHauteur){
	var vFeatures = "";var vTitre = "";
	switch(pType){
		case "jaquette" : vFeatures="status=no,menubar=no,scrollbars=no,resizable=no,width=265,height=437"; vTitre="jaquette"; break;
		case "smallContent" : vFeatures="status=no,menubar=no,scrollbars=yes,resizable=no,width=600,height=480"; vTitre="smallContent"; break;
		case "bigContent" : vFeatures="status=no,menubar=no,scrollbars=no,resizable=no,width=760,height=441"; vTitre="bigContent"; break;
		case "rightMenu" : vFeatures="status=no,menubar=no,scrollbars=no,resizable=no,width=760,height=441"; vTitre="rightMenu"; break;
		case "trailers" : vFeatures="status=no,menubar=no,scrollbars=no,resizable=no,width=686,height=323"; vTitre="trailers"; break;
		case "minisite" : vFeatures="status=no,menubar=no,scrollbars=no,resizable=no,width="+pLargeur+",height="+pHauteur; vTitre="minisite"; break;
		default: vFeatures="status=no,menubar=no,scrollbars=yes,resizable=yes,width="+pLargeur+",height="+pHauteur; vTitre=pType; break;
	}
	if(pUrl!=null && pUrl!="")	window.open(pUrl,vTitre,vFeatures);
}


function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}
