// JavaScript Document

/*********************************************************************
* FONCTION QUI CHANGE UNE IMAGE LORSQUE LA SOURIS PASSE DESSUS
*********************************************************************/
function ChangeImage(unBouton, uneImage) {
	unBouton.src = uneImage;
}

function popupcentree (page, largeur, hauteur, options) {
	var top = (screen.height-hauteur) / 2;
	var left = (screen.width-largeur) / 2;
	pop = window.open (page, "pop", "top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

var message="© Copyright 2010, michele-richard.com. Tous droits réservés."; // Message for the alert box

isIE = document.all;
isNN =! document.all&&document.getElementById;
isN4 = document.layers;

if (isIE||isNN) {
	document.oncontextmenu = block;
} else {
	document.captureEvents (Event.MOUSEDOWN || Event.MOUSEUP);
	document.onmousedown = block;
}

function block(e) {
	if (isN4) {
		if (e.which==2||e.which==3) {
			alert(message);
		return false;
		}
	} else {
		alert(message);
		return false;
	}
}

function blockError() {
	return true;
}

window.onerror = blockError;

function OuvrirSite() {
	var site;
	site = window.open("site.php", "Main", "height=425,width=760,menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	site.focus();
}

function OuvrirSiteExterne(URL) {
	var siteExterne;
	siteExterne = window.open("" + URL + "", "_externe", "height=425,width=760,menubar=no,scrollbars=yes,resizable=yes,status=yes,screenX=20,screenY=20");
	siteExterne.focus();
}

function OuvrirPhoto(cat, id) {
	var photo;
	photo = window.open("multimedia/photos_view.php?cat=" + cat + "&id=" + id + "", "Photo", "height=600,width=500,menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	photo.focus();
}

function OuvrirPhotoPaysage(cat, id) {
	var photo;
	photo = window.open("multimedia/photos_view.php?cat=" + cat + "&id=" + id + "", "Photo", "height=500,width=600,menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	photo.focus();
}

function OuvrirPhotoBD(id, orientation) {
	var photo;
	
	if (orientation == 1) { // Photo paysage...
		photo = window.open("multimedia/photos_view_bd.php?id=" + id + "", "Photo", "height=500,width=680,menubar=no,scrollbars=yes,alwaysRaised=yes,dependent=yes,resizable=yes,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");		
	} else { // Photo portrait
		photo = window.open("multimedia/photos_view_bd.php?id=" + id + "", "Photo", "height=600,width=500,menubar=no,scrollbars=yes,alwaysRaised=yes,dependent=yes,resizable=yes,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");		
	}
	
	photo.focus();
}

function OuvrirParoles(id) {
	var paroles;
	paroles = window.open("discographie/paroles.php?id=" + id + "", "Paroles", "height=600,width=500,menubar=no,scrollbars=yes,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	paroles.focus();
}

function OuvrirPresentationAlbum(album) {
	var paroles;
	paroles = window.open("discographie/" + album + "", "Présentation", "height=600,width=500,menubar=no,scrollbars=yes,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	paroles.focus();
}

/* =============================================================================================================== */
/* = Ouvrir les extraits VIDEOS
/* =============================================================================================================== */
function OuvrirExtraitVideo(type, id, width, height, titre) {
	var video;
	if (type == "mp3") {
		video = window.open("multimedia/extraits_musicaux.php?titre=" + titre + "&filename=" + id + "", "ExtraitsMusicaux", "height=265,width=620,menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");				
	} else {
		video = window.open("multimedia/extraits_video_view.php?height=" + height + "&width=" + width + "&type=" + type + "&id=" + id + "", "Video", "height=580,width=620,menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");		
	}	
	video.focus();
}

function OuvrirExtraitVideoMetro () {
	video = window.open("multimedia/extraits_video_view_metro.php", "Video", "height=580,width=620,menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");		
	video.focus();
}

function OuvrirExtraitVideoBandeAnnonce () {
	video = window.open("multimedia/extraits_video_view_bande_annonce.php", "Video", "height=580,width=620,menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");		
	video.focus();
}
/* =============================================================================================================== */
/* = FIN - Ouvrir les extraits VIDEOS
/* =============================================================================================================== */


var hcolor = 255;
function Fade(direction) {
	obj = document.getElementById("head1");
   	hcolor += direction;
   	if (hcolor >= 0 && hcolor < 256) {
    	hex=hcolor.toString(16);
      	if (hex.length==1) hex="0" + hex;
      	obj.style.color="#" + hex + hex + hex;
      	window.setTimeout("Fade(" + direction + ");",1);
	}
}

/*************************************************************************
  This code is from Dynamic Web Coding at www.dyn-web.com
  Copyright 2001-4 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function initScrollLayer() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo = new dw_scrollObj('wn', 'lyr1');
  
  // bSizeDragBar set true by default (explained at www.dyn-web.com/dhtml/scroll/ )
  // wndo.bSizeDragBar = false;
  
  // arguments: dragBar id, track id, axis ("v" or "h"), x offset, y offset
  // (x/y offsets of dragBar in track)
  wndo.setUpScrollbar("dragBar", "track", "v", 1, 1);
  
  // pass id('s) of scroll area(s) if inside table(s)
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn'); 
}

function initScrollLayerAccueil() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo = new dw_scrollObj('wn_accueil', 'lyr1');
  
  // bSizeDragBar set true by default (explained at www.dyn-web.com/dhtml/scroll/ )
  // wndo.bSizeDragBar = false;
  
  // arguments: dragBar id, track id, axis ("v" or "h"), x offset, y offset
  // (x/y offsets of dragBar in track)
  wndo.setUpScrollbar("dragBar", "track", "v", 1, 1);
  
  // pass id('s) of scroll area(s) if inside table(s)
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn_accueil'); 
}




function ChangeImage (unBouton, uneImage) {
	document[unBouton].src = uneImage;
}

function fermerFenetre () {
	window.opener.location.href = "pages.php";
	this.close();
}

function ajouterMenu () {
	var ajouterMenu;
	ajouterMenu = window.open ("ajouter_menu.php", "PopUp", "height=300,width=550,menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	ajouterMenu.focus();	
}

function ajouterRubrique () {
	var ajouterRubrique;
	ajouterRubrique = window.open ("ajouter_rubrique.php", "PopUp", "height=300,width=550,menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	ajouterRubrique.focus();	
}

function ajouterSection () {
	var ajouterSection;
	ajouterSection = window.open ("ajouter_section.php", "PopUp", "height=350,width=550,menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	ajouterSection.focus();	
}

function ajouterTeaser () {
	var ajouterTeaser;
	ajouterTeaser = window.open ("ajouter_teaser.php", "PopUp", "height=350,width=550,menubar=no,scrollbars=yes,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	ajouterTeaser.focus();	
}

function ajouterPage () {
	var ajouterPage;
	ajouterPage = window.open ("ajouter_page.php", "PopUp", "height=350,width=550,menubar=no,scrollbars=yes,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	ajouterPage.focus();	
}

function ajouterVariable () {
	var ajouterVariable;
	ajouterVariable = window.open ("ajouter_variable.php", "PopUpVariable", "height=350,width=550,menubar=no,scrollbars=yes,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	ajouterVariable.focus();	
}

function contenuTeaser (id, language) {
	var largeurEcran = screen.availWidth;
	var hauteurEcran = screen.availHeight;
	var ajouterTeaser;
	ajouterTeaser = window.open ("teaser_contenu.php?IDTeaser=" + id +"&language=" + language +"", "PopUp", "height=500,width=700,menubar=no,scrollbars=yes,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=10,screenY=10,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	ajouterTeaser.focus();	
}

function contenuPage (id, language) {
	var largeurEcran = screen.availWidth;
	var hauteurEcran = screen.availHeight;
	var ajouterPage;
	ajouterPage = window.open ("pages_contenu.php?IDPage=" + id +"&language=" + language +"", "PopUp", "height=500,width=700,menubar=no,scrollbars=yes,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=10,screenY=10,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	ajouterPage.focus();	
}

function ChangerRubriques () {
	xmlhttp.open ('POST', "changer_rubriques.php", false);
	var IDSection = document.forms["AjouterPage"].IDSection.value;
   	xmlhttp.setRequestHeader ('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send("IDSection= " + IDSection + "");
	document.getElementById('DIVRubriques').innerHTML = xmlhttp.responseText;
}

function getSection () {

	var IDRubrique = document.AjouterPage.IDRubrique.options[document.AjouterPage.IDRubrique.selectedIndex].value;
	xmlhttp.open ('GET', "get_section_by_rubrique.php?IDRubrique=" + IDRubrique + "", true);
   	xmlhttp.setRequestHeader ('Content-Type','application/x-www-form-urlencoded');

	if (xmlhttp) {				
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) { /* 4 : état "complete" */		
				if (xmlhttp.status == 200) { /* 200 : code HTTP pour OK */							 
					document.getElementById ('getSectionByRubrique').innerHTML = xmlhttp.responseText;
				}
			}
		}
	} 

	xmlhttp.send (null);	
}

function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

function ouvrirPopup (url, width) {
	var popup;
	popup = window.open(url, "popup", "height=800,width=" + width + ",menubar=no,scrollbars=no,alwaysRaised=yes,dependent=yes,resizable=no,status=no,screenX=20,screenY=20,innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0");
	popup.focus();		
}

var xmlhttp = false;

/* Compilation conditionnelle d'IE */
/*@cc_on
@if (@_jscript_version >= 5)
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	}
 	catch (e) {
		try {
	   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E) {
	   		xmlhttp = false;
		}
 	}
@else
	xmlhttp = false;
@end @*/

/* on essaie de créer l'objet si ce n'est pas déjà fait */
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
 	}
 	catch (e) {
		xmlhttp = false;
 	}
}

function getNextPosition () {

	var IDRubrique = document.AjouterRubrique.IDRubrique.options[document.AjouterRubrique.IDRubrique.selectedIndex].value;
	xmlhttp.open ('GET', "get_next_position.php?IDRubrique=" + IDRubrique + "", false);
   	xmlhttp.setRequestHeader ('Content-Type','application/x-www-form-urlencoded');
	
	if (xmlhttp) {		
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) { /* 4 : état "complete" */		
				if (xmlhttp.status == 200) { /* 200 : code HTTP pour OK */		 
					document.getElementById ('SPANNextPosition').innerHTML = xmlhttp.responseText;
				}
			}
		}
	} 

	xmlhttp.send (null);
	
}