﻿var isIE= navigator.appName == "Microsoft Internet Explorer" ; /* IE */ 
var isNS= navigator.appName == "Netscape" ; /* Netscape, Mozilla Firefox */ 
   
   
   

function redimIframe(){
    parent.document.getElementById("id_iframe").width=760;
    parent.document.getElementById("id_iframe").height=430;
/*

    if(navigator.appName=="Microsoft Internet Explorer" )
    {

    
        if(document.all) document.all.id_iframe.style.height = document.frames("id_iframe" ).document.body.scrollHeight;
       
        else document.getElementById("id_iframe" ).style.height = document.getElementById("id_iframe" ).contentDocument.body.scrollHeight;

        }
        else{

        document.getElementById("id_iframe" ).style.height = document.getElementById("id_iframe" ).contentDocument.body.offsetHeight+"px";

    }
*/
}


function displayFlash(swf, hauteur, largeur, couleur, nom) {
	document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\""+hauteur+"\" height=\""+largeur+"\" id=\""+nom+"\" align=\"middle\">\n");
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />\n");
	document.write("<param name=\"scale\" value=\"noscale\" />");
	document.write("<param name=\"movie\" value=\""+swf+"\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\""+couleur+"\" /><embed scale=\"noscale\" src=\""+swf+"\" quality=\"high\" bgcolor=\""+couleur+"\" width=\""+hauteur+"\" height=\""+largeur+"\" name=\""+nom+"\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />\n");
	document.write("</object>\n");
}

function displayFlashTransparent(swf, hauteur, largeur, couleur, nom) {
	document.write("<object style=\"position:relative;Z-Index:10;\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\""+hauteur+"\" height=\""+largeur+"\" id=\""+nom+"\" align=\"middle\">\n");
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />\n");
	document.write("<param name=\"scale\" value=\"noscale\" />");

	document.write("<param name=\"movie\" value=\""+swf+"\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\""+couleur+"\" /><embed wmode=\"transparent\" scale=\"noscale\" src=\""+swf+"\" quality=\"high\" bgcolor=\""+couleur+"\" width=\""+hauteur+"\" height=\""+largeur+"\" name=\""+nom+"\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />\n");
	document.write("<param name=\"wmode\" value=\"transparent\" />");
	document.write("</object>\n");
}

function afficheFlyer(image, evenementId)
{
	$("#flyer")[0].src = image;
	$.get("ajax_evenement.aspx", { id: evenementId }, function(data){ $("#desc").html(data); $('#fly').jScrollPane({reinitialiseOnImageLoad:true, maintainPosition:false}); } );
	return false;
}

//////////////////////////////////////////////////////

var evenementId;
var listePhotos;
var nbParPage = 20;
var nbParLigne = 4;
var urlStockage;
var formatMini, formatBig;
var numPage = 0;
var numPhoto = 0;
		
function changePage(increment)
{
	var nbPages = Math.ceil(listePhotos.length / nbParPage);
	if( listePhotos.length == 0 || (numPage + increment) > nbPages || (numPage + increment) == 0 ) return;
	
	numPage += increment;
	$("#numeroPage").html(numPage + "/" + nbPages);
	var debut = (numPage - 1) * nbParPage;
	var fin = debut + nbParPage;
	if(listePhotos.length < fin) fin = listePhotos.length;
	
	var strHTML = "<table cellspacing='0' cellpadding='0'>";
	for(i = debut; i < fin; i++)
	{
		if(i % nbParLigne == 0) strHTML += "<tr>";
		strHTML += "<td class='photo'>";
		strHTML += "<a onclick='affichePhoto(" + (i + 1) + ")' href='#a'><img " + (i + 1 == numPhoto ? "class='photo-sel'" : "") + " id='mini_" + (i + 1) + "' border='0' src='" + getUrlPhoto(listePhotos[i], formatMini) + "' /></a>";
		strHTML += "</td>";
		if(i + 1 == fin) strHTML += "</tr>";
		else if((i + 1) % nbParLigne == 0) strHTML += "</tr><tr><td height='2'></td></tr>";
		else strHTML += "<td width='2'></td>";
	}
	strHTML += "</table>";
	
	$("#liste").html(strHTML);
}

function getUrlPhoto(photoId, format)
{
	return urlStockage + format + "/photo_" + evenementId + "_" + photoId + ".jpg";
}

function changePhoto(increment)
{
	affichePhoto(numPhoto + increment);
}

function affichePhoto(num)
{
	if(numPhoto == num || num == 0 || num > listePhotos.length) return
	
	$("#mini_" + numPhoto).toggleClass("photo-sel", false);

	numPhoto = num;
	
	if(numPage != Math.ceil(numPhoto / nbParPage))
		changePage(numPage < Math.ceil(numPhoto / nbParPage) ? 1 : -1)
	else $("#mini_" + numPhoto).toggleClass("photo-sel", true);
	
	$("#photo").stop(true, true).fadeTo(0,0)
	$("#photo")[0].src = getUrlPhoto(listePhotos[num - 1], formatBig);
	$.get("ajax_evenement_photo_vu.aspx", { evenement_id: evenementId, photo_id: listePhotos[num - 1] } );
}
