// Billtornade JS

// Contact
function focusedInput(obj,newclass){
	obj.className = newclass;
}
function bluredInput(obj,newclass){
	obj.className = newclass;
}

function hideDiv(divId) {
	if (document.getElementById(divId)){
		document.getElementById(divId).style.display = "none";
	}
}
function showDiv(divId) {
	if (document.getElementById(divId)){
		document.getElementById(divId).style.display = "block";
	}
}

// PopPlayer
function hideVisibility(divId){
	if (document.getElementById(divId)){
		document.getElementById(divId).style.visibility = 'hidden';
	}
}
function showVisibility(divId){
	if (document.getElementById(divId)){
		document.getElementById(divId).style.visibility = 'visible';
	}
}
function HideAndShow(divId1,divId2) {
    if (document.getElementById(divId1) != null) {
    	document.getElementById(divId1).style.display = 'none';
    }
    if (document.getElementById(divId2) != null) {
    	document.getElementById(divId2).style.display = 'block';
    }
}
// Ouverture PopUp
var newWin = null;
function closeWin(){
    if (newWin != null){
        if(!newWin.closed)
            newWin.close();
        }
}
function openPopPlayer(page) {
	closeWin();
	
	var largeur = "220";
	var hauteur = "20";
	var options = "menubar=no,scrollbars=no,statusbar=no,resizable=yes";
	//var top = (screen.height-hauteur)/6;
	//var left = (screen.width-hauteur)/6;
	var top=(screen.height-hauteur)/6;
	var left=(screen.width-largeur)/1.1;
	newWin = window.open(page,'newWin',"top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}
// Pour obliger la fermeture de la pop julebox quelle que soit la page
function closePopPlayer(page){
	openPopPlayer('closePop.php');
	//closeWin();
}
// Fonction auto-resize window (cf: http://www.quirksmode.org/js/doctypes.html et http://www.quirksmode.org/viewport/compatibility.html et http://www.devparadise.com/technoweb/code/jscript/a457.php)
function redimPopUp(){

	//var naV = navigator.appName;  
	// Detection Navigateur + Redimmensionnement
	if (navigator.appName == "Microsoft Internet Explorer") {
	
		var bodyLargeur = document.body.scrollWidth;
		var bodyHauteur = document.body.scrollHeight;	
		window.resizeTo((bodyLargeur+30), (bodyHauteur+100));
		
	} else if(navigator.appName == "Netscape") {
	
		var bodyLargeur = document.body.offsetWidth;
		var bodyHauteur = document.body.offsetHeight;	
		window.resizeTo(bodyLargeur, (bodyHauteur+70));
		
	} else if (navigator.appName == "Opera") {
	
		var bodyLargeur = document.body.offsetWidth;
		var bodyHauteur = document.body.offsetHeight;	
		window.resizeTo(bodyLargeur, (bodyHauteur+100));
	
	} else return; 
	//alert('bodyLargeur de la fenêtre = '+bodyLargeur+'\n'+'bodyHauteur de la fenêtre = '+bodyHauteur+'\n'+'Navigateur = '+naV);
}

// Fonction auto-resize relance
function redimPopUpTime() {
	setTimeout("redimPopUp()", 1000);
}
// Vérifie si cookie activé
function checkDivCookie(divId,nomCookie) {
	var valeurCookie = LireCookie(nomCookie);
	if (valeurCookie == null) {
		showDiv(divId);	// Affiche le lecteur interne
		HideAndShow('btnOn','btnOff');
	} else {
		hideDiv(divId);	// Cache le lecteur interne
		HideAndShow('btnOff','btnOn');
	}
}

// Affiche les photos au clic
function showPict (rootUrl, collectionDir, zoomDir, stdDir, index){
	
	if (document.getElementById('thumbPict_' + index)){
		var myPicture = document.getElementById("thumbPict_" + index).src;
		var	myUrlTab = myPicture.split("/");
			myPicture = myUrlTab.pop();			
			
		// Màj des photos
		if (document.getElementById('IMGPRODzoom')) {
			
			document.getElementById('IMGPRODzoom').src = rootUrl + collectionDir + zoomDir + myPicture;
			
			// Affiche la photo zoomée et remet à 0 les margin de la photo
			document.getElementById('IMGPRODdiv_zoom').style.display = "block";	
			document.getElementById('IMGPRODzoom').style.marginLeft = "0px";
			document.getElementById('IMGPRODzoom').style.marginTop = "0px";				
		}
			
		if (document.getElementById('IMGPRODapercu')) {
			document.getElementById('IMGPRODapercu').src = rootUrl + collectionDir + stdDir + myPicture;	
		}
		
		// Màj Titre + texte
		if (document.getElementById('textPict_' + index).childNodes[0].nodeValue != null){
			if (document.getElementById('textPictBox')) {
				
				document.getElementById('textPictBox').style.backgroundColor = "#FFF";	// Initialise	(bug Safari)
				
				var myPictText = document.getElementById('textPict_' + index).innerHTML;
				
				if (myPictText != '&nbsp;'){
					document.getElementById('textPictBox').style.backgroundColor = "#edecec";
				}
				document.getElementById('textPictBox').innerHTML = myPictText;	
			}
		}
		// Ajoute une bordure autours de la photo cliquée
	   var myGallery = document.getElementById('thumbsPictBox');
	   var myLinks = myGallery.getElementsByTagName('img');
	   for (k=0; k<myLinks.length; k++) {
			myLinks[k].className = 'off';	// initialise la bordure
		}
		document.getElementById('thumbPict_' + index).className = 'on';
	}	
}

// Affiche les photos au clic (scroller showroom)
function showPict2 (rootUrl, collectionDir, stdDir, index){
	
	if (document.getElementById('thumbPict_' + index)){
		var myPicture = document.getElementById("thumbPict_" + index).src;
		var	myUrlTab = myPicture.split("/");
			myPicture = myUrlTab.pop();			
			
		// Màj des photos
		if (document.getElementById('mainPicture2Img')) {		
			document.getElementById('mainPicture2Img').src = rootUrl + collectionDir + stdDir + myPicture;
		}
	}
}

// Affiche les photos au clic (scroller showroom) + dossier country
function showPict3 (rootUrl, collectionDir, stdDir, countryDir, index){
	
	if (document.getElementById('thumbPict_' + index)){
		var myPicture = document.getElementById("thumbPict_" + index).src;
		var	myUrlTab = myPicture.split("/");
			myPicture = myUrlTab.pop();			
			
		// Màj des photos
		if (document.getElementById('mainPicture2Img')) {		
			document.getElementById('mainPicture2Img').src = rootUrl + collectionDir + countryDir + stdDir + myPicture;
			//alert(rootUrl + collectionDir + countryDir + stdDir + myPicture);
		}
	}
	//return false;	// ne suit pas le lien href
}