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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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; x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
  return(false);
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function Imprime() {
  if (window.print)
     {
     window.print();
     }
}

function Checked() {
	// Tu testes si ca retourne TRUE ou FALSE
	if(document.form1.checkbox2.checked == true)
	{
		// Retourne coché = TRUE
		document.form1.submit();
	}
	else
	{
		// Retourne pas coché = FALSE
		alert('Vous devez accepter les conditions générales de vente pour pouvoir commander');
	}
}

function CheckedEcard() {
	// Tu testes si ca retourne TRUE ou FALSE
	if(document.form1.cgu.checked == true)
	{
		// Retourne coché = TRUE
		document.form1.submit();
	}
	else
	{
		// Retourne pas coché = FALSE
		alert('Vous devez accepter les conditions générales d utilisation pour envoyer une ecard');
	}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function get_javascript(url)
{
	new Ajax.Request(url, {
		method:'get', onComplete:function(transport) {
			eval(transport.responseText);
			}
		});
}

function get_synchro_javascript(url)
{
	new Ajax.Request(url, {
		method:'get', asynchronous: false, onComplete:function(transport) {
			eval(transport.responseText);
			}
		});
}

function get_javascript_anim(url, toanim) {
	var xhr_object = null;
	document.getElementById(toanim).src = '/img/anim.gif';
	if(window.XMLHttpRequest)
	{
		// Firefox 
		xhr_object = new XMLHttpRequest();
		xhr_object.open("GET", url);
		xhr_object.send(null);
		xhr_object.onreadystatechange = function anonymous() 
		{
			if(xhr_object.readyState == 4) 
			{
				eval(xhr_object.responseText);
			}
		}
	}
	else if(window.ActiveXObject)
	{
		// Internet Explorer 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		xhr_object.open("GET", url); 
		xhr_object.send(null); 
		xhr_object.onreadystatechange = function anonymous() 
		{
			if(xhr_object.readyState == 4) 
			{
				eval(xhr_object.responseText);
			}
		}
	}
	else 
	{ // XMLHttpRequest non supporté par le navigateur 
		var html_doc = document.getElementsByTagName('head').item(0);
		var js = document.createElement('script');
		js.setAttribute('language', 'javascript');
		js.setAttribute('type','text/javascript');
		js.setAttribute('src',url);
		html_doc.appendChild(js);
	}
}


function ajout_panier(id_image,id_album) {
	var url = '/javascripts/add_panier.php?id_image=' + id_image + '&id_album=' + id_album;
    // On ajoute un peu d'ajax pour faciliter le travail
	var xhr_object = null; 
	if(window.XMLHttpRequest)
	{
		// Firefox 
		xhr_object = new XMLHttpRequest();
		xhr_object.open("GET", url, false);
		xhr_object.send(null);
		if(xhr_object.readyState == 4)
		{
			eval(xhr_object.responseText);
		}
	}
	else if(window.ActiveXObject)
	{
		// Internet Explorer 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		xhr_object.open("GET", url, false); 
		xhr_object.send(null); 
		if(xhr_object.readyState == 4)
		{
			eval(xhr_object.responseText);
		}
	}
	else 
	{ // XMLHttpRequest non supporté par le navigateur 
    	var html_doc = document.getElementsByTagName('head').item(0);
    	var js = document.createElement('script');
    	js.setAttribute('language', 'javascript');
    	js.setAttribute('type','text/javascript');
    	js.setAttribute('src',url);
    	html_doc.appendChild(js);
		return false;
	}
}

function ajout_panier_detail(id_image,id_album) {
	var url = '/javascripts/add_panier.php?id_image=' + id_image + '&id_album=' + id_album + '&is_detail=1';
    // On ajoute un peu d'ajax pour faciliter le travail
	var xhr_object = null; 
	if(window.XMLHttpRequest)
	{
		// Firefox 
		xhr_object = new XMLHttpRequest();
		xhr_object.open("GET", url, false);
		xhr_object.send(null);
		if(xhr_object.readyState == 4)
		{
			eval(xhr_object.responseText);
		}
	}
	else if(window.ActiveXObject)
	{
		// Internet Explorer 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		xhr_object.open("GET", url, false); 
		xhr_object.send(null); 
		if(xhr_object.readyState == 4)
		{
			eval(xhr_object.responseText);
		}
	}
	else 
	{ // XMLHttpRequest non supporté par le navigateur     
        var html_doc = document.getElementsByTagName('head').item(0);
        var js = document.createElement('script');
        js.setAttribute('language', 'javascript');
        js.setAttribute('type','text/javascript');
        js.setAttribute('src',url);
        html_doc.appendChild(js);
		return false;
	}
}

function select_livraison(id_livraison) {
	var url = '/javascripts/select_livraison.php?id_livraison='+id_livraison;
    // On ajoute un peu d'ajax pour faciliter le travail
	var xhr_object = null; 
	if(window.XMLHttpRequest)
	{
		// Firefox 
		xhr_object = new XMLHttpRequest();
		xhr_object.open("GET", url, false);
		xhr_object.send(null);
		if(xhr_object.readyState == 4)
		{
			eval(xhr_object.responseText);
		}
	}
	else if(window.ActiveXObject)
	{
		// Internet Explorer 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		xhr_object.open("GET", url, false); 
		xhr_object.send(null); 
		if(xhr_object.readyState == 4)
		{
			eval(xhr_object.responseText);
		}
	}
	else 
	{ // XMLHttpRequest non supporté par le navigateur 
	    var html_doc = document.getElementsByTagName('head').item(0);
        var js = document.createElement('script');
        js.setAttribute('language', 'javascript');
        js.setAttribute('type','text/javascript');
        js.setAttribute('src',url);
        html_doc.appendChild(js);
		return false;
	}
}

function select_cheque(cheque) {
	var url = '/javascripts/select_cheque.php?cheque='+cheque;
	// On ajoute un peu d'ajax pour faciliter le travail
	var xhr_object = null; 
	if(window.XMLHttpRequest)
	{
		// Firefox 
		xhr_object = new XMLHttpRequest();
		xhr_object.open("GET", url, false);
		xhr_object.send(null);
		if(xhr_object.readyState == 4)
		{
			eval(xhr_object.responseText);
		}
	}
	else if(window.ActiveXObject)
	{
		// Internet Explorer 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		xhr_object.open("GET", url, false); 
		xhr_object.send(null); 
		if(xhr_object.readyState == 4)
		{
			eval(xhr_object.responseText);
		}
	}
	else 
	{ // XMLHttpRequest non supporté par le navigateur 
        var html_doc = document.getElementsByTagName('head').item(0);
        var js = document.createElement('script');
        js.setAttribute('language', 'javascript');
        js.setAttribute('type','text/javascript');
        js.setAttribute('src',url);
        html_doc.appendChild(js);
		return false;
	}
}

function select_cheque_perso(cheque) {
	var url = '/javascripts/select_cheque.php?cheque='+cheque+'&perso=1';
	// On ajoute un peu d'ajax pour faciliter le travail
	var xhr_object = null; 
	if(window.XMLHttpRequest)
	{
		// Firefox 
		xhr_object = new XMLHttpRequest();
		xhr_object.open("GET", url, false);
		xhr_object.send(null);
		if(xhr_object.readyState == 4)
		{
			eval(xhr_object.responseText);
		}
	}
	else if(window.ActiveXObject)
	{
		// Internet Explorer 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		xhr_object.open("GET", url, false); 
		xhr_object.send(null); 
		if(xhr_object.readyState == 4)
		{
			eval(xhr_object.responseText);
		}
	}
	else 
	{ // XMLHttpRequest non supporté par le navigateur 
        var html_doc = document.getElementsByTagName('head').item(0);
        var js = document.createElement('script');
        js.setAttribute('language', 'javascript');
        js.setAttribute('type','text/javascript');
        js.setAttribute('src',url);
        html_doc.appendChild(js);
		return false;
	}
}

function submit_paiement() {
	document.fin.id_livr.value = document.getElementById('id_livraison').value;
	myOption = -1;
	for (i=document.choix_paiement.paiement.length-1; i > -1; i--) {
		if (document.choix_paiement.paiement[i].checked) {
			myOption = i;
		}
	}
	if (myOption == -1) {
		alert("Vous devez selectionner un mode de paiement");
		return false;
	}
	document.fin.typePaiement.value = document.choix_paiement.paiement[myOption].value;
	document.fin.submit();
	return true;
}

function recalcule_tirage(id, prix, prixachat, prix_mini, is_mini)
{
	if(prix == '')
	{
		return true;
	}
	if(prix == 0 || prix == 'zero')
	{
		//document.getElementById('tirage_'+id+'_ht').innerHTML = 'Produit non proposé';
		if(document.getElementById('tirage_'+id+'_marge'))
		{
			document.getElementById('tirage_'+id+'_marge').innerHTML = 'Produit non proposé';
		}
	}
	else
	{
		document.getElementById('tirage_'+id).value=document.getElementById('tirage_'+id).value.replace(',','.'); 
		prix = prix.replace(',','.');
		prix = parseFloat(prix);
		prixachat = parseFloat(prixachat);
		prix_mini = parseFloat(prix_mini);
		marge = (Math.round((prix-(prixachat*1.196))*100))/100;
		if(is_mini != 1)
		{
			if(marge <= 0 || prix < prix_mini)
			{
				marge = '<span class="txt_std_bordx">Prix de vente non valide</span>';
				document.getElementById('tirage_'+id).className = 'textareaError';
				
			}
			else
			{
				document.getElementById('tirage_'+id).className = '';
			}
			document.getElementById('tirage_'+id+'_marge').innerHTML = marge+" &euro;ttc";
		}
		else
		{
			if(marge <= 0 && is_mini != 1)
			{
				marge = '<span class="txt_std_bordx">Prix de vente non valide</span>';
				document.getElementById('tirage_'+id).className = 'textareaError';
			}
			else
			{
				document.getElementById('tirage_'+id).className = '';
			}
			document.getElementById('tirage_'+id+'_marge').innerHTML = marge+" &euro;ttc";
		}
		//document.getElementById('tirage_'+id+'_ht').innerHTML = prixht;
	}
}

function recalcule_download(id, prix )
{
	if(prix == '')
	{
		return true;
	}
	if(prix == 0 || prix == 'zero')
	{
		document.getElementById('prix'+id+'_marge').innerHTML = 'Produit non proposé';
		document.getElementById('prix'+id).value=0;
	}
	else
	{
		document.getElementById('prix'+id).value=document.getElementById('prix'+id).value.replace(',','.'); 
		prix = prix.replace(',','.');
		marge = prix;
		document.getElementById('prix'+id+'_marge').innerHTML = marge+" &euro;ttc";
	}
}

function MM_jumpMenu(targ,selObj,restore)
{
	if(selObj.options[selObj.selectedIndex].value.match(/^popup:/))
	{
		var togo = selObj.options[selObj.selectedIndex].value.replace(/^popup:/,'');
		MM_openBrWindow(togo,'','status=yes,scrollbars=yes,resizable=yes,width=680,height=600');
		selObj.selectedIndex=0;
	}
	else
	{	
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		selObj.selectedIndex=0;
	}
}

function exit_Iframe()
{
	 if (window !=top ) {top.location=window.location;}
}


function process_keypress(e) 
{
	if(window.event)
	{
		if (window.event.type == "keypress" & window.event.keyCode == 13)
			return !(window.event.type == "keypress" & window.event.keyCode == 13);
	}
	if(e)
	{
		if (e.type == "keypress" & e.keyCode == 13)
		return !e;
	}
}

function envoi_imageuploader()
{
	document.getElementById('btntransfert').innerHTML='';
	document.getElementById('btnannuler').innerHTML='';
	getImageUploader("ImageUploader1").Send();
	return false;
}

function slideshow(url)
{
	string="document.location = '"+url+"';";
	a = setTimeout(string,2000);
}

function dis2() {
if(document.getElementById) document.getElementById("PanierPopup").style.visibility = "hidden";
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function scrollToID(id)
{
	var ele;
	if (!document.getElementById)
		return;
	ele = document.getElementById(id);
	var coors = findPos(ele);
	window.scrollTo( 0, coors[1]);
}

function lanceUpload()
{
	document.forms[0].submit();
	document.getElementById('contenu').innerHTML='<div class="NomPhotographe" id="NomPhotographe">Envoi en cours .';
	string="document.getElementById('NomPhotographe').innerHTML = '"+document.getElementById('NomPhotographe').innerHTML+" .';";
	a = setInterval(string,2000);
	document.body.onUnload="clearInterval(a)";
	return true;
	/*document.getElementById("PanierPopup").style.visibility = "visible";*/
	/*overlib('Chargement de votre image', FGCOLOR, '#999999', BGCOLOR, '#333333', BORDER, 4, CAPTIONFONT, 'Garamond', TEXTFONT, 'Courier', TEXTSIZE, 3, CENTERPOPUP);*/
	
}

function toggleLayer(whichLayer)
{
	var style2 = document.getElementById(whichLayer).style;
	if(style2.display == '')
	{
		document.getElementById(whichLayer).style.display = 'none';
	}
	else
	{
		document.getElementById(whichLayer).style.display = '';
	}
} 

function toggleLayerPicto(whichLayer, whichPicto, whichLayer2, whichPicto2)
{
	var style2 = document.getElementById(whichLayer).style;
	if(style2.display == '')
	{
		document.getElementById(whichLayer).style.display = 'none';
		if(document.getElementById(whichPicto))
		{
			document.getElementById(whichPicto).src = '/img/arrowbigV01.gif';
		}
		/*document.getElementById(whichLayer2).style.display = '';
		if(document.getElementById(whichPicto2))
		{
			document.getElementById(whichPicto2).src = '/img/arrowbigV02.gif';
		}*/
	}
	else
	{
		document.getElementById(whichLayer).style.display = '';
		if(document.getElementById(whichPicto))
		{
			document.getElementById(whichPicto).src = '/img/arrowbigV02.gif';
		}
		/*document.getElementById(whichLayer2).style.display = 'none';
		if(document.getElementById(whichPicto2))
		{
			document.getElementById(whichPicto2).src = '/img/arrowbigV01.gif';
		}*/
	}
} 

function toggleDownload(whichLayer)
{
	var x = new Array('prix2_3', 'prix4_5', 'prix6_10', 'prix11_20', 'prix21_50', 'prix51_100', 'prix101_250', 'prix251_500', 'prix501_750', 'prix751_1000', 'prix1001');
	var value1 = document.getElementById('prix1').value;
	for (var i = 0;i<x.length;i++)
	{
		var theName = whichLayer + x[i];
		// this is the way the standards work
		var style2 = document.getElementById(theName).style;
		if(style2.display == '')
		{
			document.getElementById(theName).style.display = 'none';
			document.getElementById(x[i]).value = '0';
		}
		else
		{
			document.getElementById(theName).style.display = '';
			document.getElementById(x[i]).value = value1;
			recalcule_download(x[i].substring(4), value1);
		}
	}
} 

function selectAll(nom)
{
	var checkboxs=document.getElementsByTagName("input");
	var regexstring = '^' + nom;
	var myregexp = new RegExp(regexstring);
	for (var i = 0;i<checkboxs.length;i++)
	{
		if(checkboxs[i].type == 'checkbox' && checkboxs[i].name.match(myregexp))
		{
			checkboxs[i].checked = true;
		}
	}
}

function deselectAll(nom)
{
	var checkboxs=document.getElementsByTagName("input");
	var regexstring = '^' + nom;
	var myregexp = new RegExp(regexstring);
	for (var i = 0;i<checkboxs.length;i++)
	{
		if(checkboxs[i].type == 'checkbox' && checkboxs[i].name.match(myregexp))
		{
			checkboxs[i].checked = false;
		}
	}
}

function flash(tag) {
document.write(tag);
}

function init_photoeditor(mypicture) {
	nd();
	ImageEditor.init(mypicture);
	window.scrollTo(0,0);
	//MM_showHideLayers('BckEditWin','','show');
	//MM_showHideLayers('BckEditWin2','','show');
}

function position_couleur()
{
	xOff = window.event.offsetX;
	yOff = window.event.offsetY;

	xi=66-xOff;
	yi=67-yOff;
	s=Math.round(Math.sqrt((xi*xi)+(yi*yi))/66*100);
	if (s>100) return;
	if (s==0) 
	{ 
	t=0; 
	} 
	else 
	{ 
	if(Math.abs(xi/66*100/s)>1)
	{ 
		ri=90;
	} 
	else
	{
		si=Math.asin(xi/66*100/s);
		ri=Math.round(90/157*si*100);
	}
	t=ri;
	if (xi>0) 
	{ 
		if (yi<0)t=180-ri;
	} 
	else 
	{ 
		t=180-ri;
		if (yi>4) 
		{
			t=360+ri;
		}
	}
	}
	if(isNaN(s) == true || isNaN(t) == true) return;
	document.colorform.hexvals.value=s;
	document.colorform.hexvalt.value=t;
	document.colorform.hexvalv.value=100; 

	a=(100-s)/100;
	v=100

	if (t<=60) 
	{
	r=255*v/100;
	f=t*r/60;
	g=f+(r-f)*a;
	b=r*a;
	} 
	else 
	{ 
	if (t<=120) 
	{ 
		g=255*v/100;
		f=(t-60)*g/60;
		r=g-f+(f*a);
		b=g*a;
	} 
	else 
	{ 
		if (t<=180) 
		{ 
			g=255*v/100;
			f=(t-120)*g/60;
			r=g*a;
			b=f+(g-f)*a;
		} 
		else 
		{ 
			if (t<=240) 
			{ 
				b=255*v/100;
				f=(t-180)*b/60;
				r=b*a;
				g=b-f+(f*a);
			} 
			else 
			{ 
				if (t<=300) 
				{ 
					b=255*v/100;
					f=(t-240)*b/60;
					g=b*a;
					r=f+(b-f)*a;
				} 
				else 
				{ 
					r=255*v/100;
					f=(t-300)*r/60;
					g=r*a;
					b=r-f+(f*a);
				}
			}
		}
	}
	}
	r = Math.round(r);
	g = Math.round(g);
	b = Math.round(b);
	document.getElementById('macouleur.btn').bgcolor = '#'+r+g+b;
}
function demarre_diaporama()
{
	/*var selectinterval = document.getElementById('interval_diapo');
	var interval = selectinterval.options[selectinterval.selectedIndex].value*1000;
	diaporama = setInterval(function(){
		num_photo = num_photo + 1;
		if(num_photo > tableau_images.length-1)
		{
			num_photo = 0;
		}
		affiche_photo_diaporama(num_photo);
		}, interval);*/
	affiche_photo_diaporama(num_photo);
}

function programme_photo_suivante()
{
	if(document.getElementById('maphoto2').complete)
	{
		clearInterval(diaporama);
		clearInterval();
		window.clearTimeout();
		window.clearTimeout(timeout);
		var selectinterval = document.getElementById('interval_diapo');
		var interval = selectinterval.options[selectinterval.selectedIndex].value*1000;
		timeout = setTimeout(function(){
			num_photo = num_photo + 1;
			if(num_photo > tableau_images.length-1)
			{
				num_photo = 0;
			}
			affiche_photo_diaporama(num_photo);
			}, interval);
	}
}

function stop_diaporama()
{
	clearInterval(diaporama);
	clearInterval();
	window.clearTimeout();
	window.clearTimeout(timeout);
	document.getElementById('diapoOnOff').innerHTML = '<a href="#" id="diaLienPause" onclick="restart_diaporama(); return false;" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'diaPause1\',\'\',\'/img/dia_play1b.gif\',1)"><img src="/img/dia_play1a.gif" id="diaPause1" name="diaPause1" width="180" height="28" border="0" id="diaPause" /></a>';
	rundiapo = 0;
}

function restart_diaporama()
{
	document.getElementById('diapoOnOff').innerHTML = '<a href="#" id="diaLienPause" onclick="stop_diaporama(); return false;" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'diaPause\',\'\',\'/img/dia_pause1b.gif\',1)"><img src="/img/dia_pause1a.gif" id="diaPause" name="diaPause" width="180" height="28" border="0" id="diaPause" /></a>';
	rundiapo = 1;
	demarre_diaporama();
}

function change_duree()
{
	stop_diaporama();
	restart_diaporama();
}

function dom_getElements(node, elt) {
    var list = node.getElementsByTagName(elt);
    return (list.length) ? list : node.getElementsByTagNameNS("*", elt); 
}

function affiche_photo_diaporama(numero)
{
/*	var preloadImage = new Image();
	preloadImage.src = tableau_images[numero].chemin;
	while(!preloadImage.complete)
	{
		;
	}*/
	clearInterval(diaporama);
	clearInterval();
	window.clearTimeout();
	window.clearTimeout(timeout);
	var max = (tableau_images[numero].page+1)*40;
	if(max > tableau_images.length)
	{
		max = tableau_images.length;
	}
	document.getElementById('maphoto2').src = tableau_images[numero].chemin;
	document.getElementById('navtexte').innerHTML = ((tableau_images[numero].page*40)+1) + ' a ' + max + ' sur ' + tableau_images.length;
	var j = tableau_images[numero].page*40;
	var fin = (tableau_images[numero].page+1)*40;
	var pages = Math.ceil(tableau_images.length/40);
	pages = pages - 1;
	var navtexte = '';
	if(tableau_images[numero].page != diapopage)
	{
		while(j < fin &&  j < tableau_images.length)
		{
			navtexte = navtexte + "\n";
			if(j == numero)
			{
				navtexte = navtexte + '<span id="spanaffich'+j+'"><img id="photoaffich'+ j +'" class="minidiaposelected" style="border: 1px solid white; margin: 5px;" src="'+tableau_images[j].cheminMiniature+'"/></span>';
			}
			else
			{
				navtexte = navtexte + '<span id="spanaffich'+j+'"><a href="#" onclick="num_photo='+j+';affiche_photo_diaporama('+j+'); return false;"><img id="photoaffich'+ j +'" class="minidiapounselected" style="border: 1px solid black; margin: 5px;" src="'+tableau_images[j].cheminMiniature+'"/></a></span>';
			}
			j++;
		}
		document.getElementById('navigationDiapo').innerHTML = navtexte;
	}
	else
	{ 
		var imgs;
		if (!(imgs=document.getElementsByTagName('img'))) 
		{
			imgs=dom_getElements('document', 'img');
		}
		for(i=0;i<imgs.length;i++)
 		{
		/*for(i in imgs)
		{*/
			if(/minidiaposelected/.test(imgs[i].className))
			{
				var tmpname = imgs[i].id;
				var reg=new RegExp("(photoaffich)", "g");
				var tmpnum = tmpname.replace(reg,"");
				document.getElementById('spanaffich'+tmpnum).innerHTML = '<a href="#" onclick="num_photo='+tmpnum+';affiche_photo_diaporama('+tmpnum+'); return false;"><img id="photoaffich'+ tmpnum +'" class="minidiapounselected" style="border: 1px solid black; margin: 5px;" src="'+tableau_images[tmpnum].cheminMiniature+'"/></a>';
			}
		}
		var tmpselect = document.getElementById('spanaffich'+numero);
		tmpselect.innerHTML = '<img id="photoaffich'+ numero +'" class="minidiaposelected" style="border: 1px solid white; margin: 5px;" src="'+tableau_images[numero].cheminMiniature+'"/>';
	}
	diapopage = tableau_images[numero].page;
	if(numero == 0)
	{
		document.getElementById('diapo_photo_suiv').innerHTML= '<a href="#" onclick="num_photo='+ (numero+1) +';affiche_photo_diaporama('+ (numero+1) +'); return false;" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'diaNxt1\',\'\',\'/img/dia_nxt-ovr.gif\',1)"><img src="/img/dia_nxt-out.gif" name="diaNxt1" width="25" height="28" border="0" id="diaNxt1" />';
		document.getElementById('diapo_photo_prec').innerHTML= '';
	}
	else
	{
		if(numero == tableau_images.length-1)
		{
			document.getElementById('diapo_photo_prec').innerHTML= '<a href="#" onclick="num_photo='+ (numero-1) +';affiche_photo_diaporama('+ (numero-1) +'); return false;" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'diaBck1\',\'\',\'/img/dia_bck-ovr.gif\',1)"><img src="/img/dia_bck-out.gif" name="diaBck1" width="25" height="28" border="0" id="diaBck1" /></a>';
			document.getElementById('diapo_photo_suiv').innerHTML= '';
		}
		else
		{
			document.getElementById('diapo_photo_prec').innerHTML= '<a href="#" onclick="num_photo='+ (numero-1) +';affiche_photo_diaporama('+ (numero-1) +'); return false;" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'diaBck1\',\'\',\'/img/dia_bck-ovr.gif\',1)"><img src="/img/dia_bck-out.gif" name="diaBck1" width="25" height="28" border="0" id="diaBck1" /></a>';
			document.getElementById('diapo_photo_suiv').innerHTML= '<a href="#" onclick="num_photo='+ (numero+1) +';affiche_photo_diaporama('+ (numero+1) +'); return false;" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'diaNxt1\',\'\',\'/img/dia_nxt-ovr.gif\',1)"><img src="/img/dia_nxt-out.gif" name="diaNxt1" width="25" height="28" border="0" id="diaNxt1" />';
		}
	}

	togo = (tableau_images[numero].page+1)*40;
	document.getElementById('diapo_page_suiv').innerHTML= '<a href="#" onclick="num_photo='+ togo +';affiche_photo_diaporama('+ togo +'); return false;" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'PgeNext\',\'\',\'/img/dia_pgeNext1b.gif\',1)"><img src="/img/dia_pgeNext1a.gif" name="PgeNext" width="35" height="31" border="0" id="PgeNext" /></a>';
	togo = (tableau_images[numero].page-1)*40;
	document.getElementById('diapo_page_prec').innerHTML= '<a href="#" onclick="num_photo='+ togo +';affiche_photo_diaporama('+ togo +'); return false;" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'PgeBack\',\'\',\'/img/dia_pgeBck1b.gif\',1)"><img src="/img/dia_pgeBck1a.gif" name="PgeBack" width="35" height="31" border="0" id="PgeBack" /></a>';
	if(tableau_images[numero].page == 0)
	{
		document.getElementById('diapo_page_prec').innerHTML= '';
	}
	if(tableau_images[numero].page == pages)
	{
		document.getElementById('diapo_page_suiv').innerHTML= '';
	}
	/**
	 * Ajouter gestion panier en javascript tableau_images[numero].is_on_panier
	 */
	if(tableau_images[numero].is_on_panier == 1)
	{
		document.getElementById('diapoActionPanier').innerHTML = '<a href="#" onclick="get_javascript(\'/javascripts/diaporama/set_panier.php?id_photo='+tableau_images[numero].id_photo+'\')" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'diaSelect1\',\'\',\'/img/dia_suppr1b.gif\',1)"><img src="/img/dia_suppr1a.gif" name="diaSelect1" width="228" height="31" border="0" id="diaSelect1" /></a>';
	}
	else
	{
		document.getElementById('diapoActionPanier').innerHTML = '<a href="#" onclick="get_javascript(\'/javascripts/diaporama/set_panier.php?id_photo='+tableau_images[numero].id_photo+'\')" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'diaSelect\',\'\',\'/img/dia_ajout1b.gif\',1)"><img src="/img/dia_ajout1a.gif" name="diaSelect" width="228" height="31" border="0" id="diaSelect" /></a>';
	}

	//get_javascript('/javascripts/diaporama/get_panier.php?id_photo='+tableau_images[numero].id_photo);
	if(numero+1<tableau_images.length)
	{
		var tmpImage = new Image();
		tmpImage.src = tableau_images[numero+1].chemin;
	}
	if(rundiapo == 1)
	{
		diaporama = setInterval("programme_photo_suivante()",200);
	}
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function getCheckedValue(radioObj) {
        if(!radioObj)
                return "";
        var radioLength = radioObj.length;
        if(radioLength == undefined)
                if(radioObj.checked)
                        return radioObj.value;
                else
                        return "";
        for(var i = 0; i < radioLength; i++) {
                if(radioObj[i].checked) {
                        return radioObj[i].value;
                }
        }
        return "";
}

function get_magasin_values() {
	var retrait_magasin = 0;
	var rdv_magasin = 0;
	for(var i = 0; i < document.form_retrait_magasin.retrait_magasin.length; i++)
	{
		if(document.form_retrait_magasin.retrait_magasin[i].checked)
		{
			retrait_magasin = document.form_retrait_magasin.retrait_magasin[i].value;
		}
	}
	for(var i = 0; i < document.form_retrait_magasin.rdv_magasin.length; i++)
	{
		if(document.form_retrait_magasin.rdv_magasin[i].checked)
		{
			rdv_magasin = document.form_retrait_magasin.rdv_magasin[i].value;
		}
	}
	
	var poststr = "?retrait_magasin=" + escape(encodeURI( retrait_magasin )) +
					"&nom_magasin=" + escape(encodeURI( document.getElementById("nom_magasin").value )) +
					"&adresse_magasin=" + escape(encodeURI( document.getElementById("adresse_magasin").value )) +
					"&tel_magasin=" + escape(encodeURI( document.getElementById("tel_magasin").value )) +
					"&texte_ouverture_magasin=" + escape(encodeURI( document.getElementById("texte_ouverture_magasin").value )) +
					"&rdv_magasin=" + escape(encodeURI( rdv_magasin )) +
					"&texte_rdv_magasin=" + escape(encodeURI( document.getElementById("texte_rdv_magasin").value ));
	get_javascript('/javascripts/prefs_photographe/set_magasin.php'+poststr);
}


function testeEtValideNomPostershop()
{
	if(document.form.nom_album.value == '' || document.form.nom_album.value == 'Saisissez un nom ici')
	{
		alert('Veuillez entrer un nouveau nom');
	}
	else
	{
		document.form.submit();
	}
}

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;// Flash Player Version Detection - Rev 1.6

/**
 * Enlève tous les select de la page
 */
function ShowLayer() {
    // hide all dropdowns on the page
    // looping through all forms on the page
    for (f = 0; f < document.forms.length; f++)
    {
        var elements = document.forms[f].elements;
        // looping through all elements on certain form
        for (e = 0; e < elements.length; e++)
        {
            if (elements[e].type == "select-one")
            {
                elements[e].style.display = 'none';
            }
        }
    }
    // show layer
    var layer = document.getElementById('layer');
    layer.style.display = 'block';
}

/**
 * Remet tous les select de la page
 */
function HideLayer() {
    // hide all dropdowns on the page
    for (f = 0; f < document.forms.length; f++)
    {
        var elements = document.forms[f].elements;
        for (e = 0; e < elements.length; e++)
        {
            if (elements[e].type == "select-one")
            {
                elements[e].style.display = 'block';
            }
        }
    }
    // hide layer
    var layer = document.getElementById('layer');
    layer.style.display = 'none';
}

function start_cropper(event)
{
	var x = xvalue;
	var y = yvalue;
	curcrop = new Cropper.Img( 'testImage', { 
					ratioDim: { x: x, y: y }, 
					minWidth: x, maxWidth: x,
					minHeight: y, maxHeight: y,
					displayOnInit: true, 
					onEndCrop: onEndCrop 
					} );
	if(document.getElementById('lien_valide_crop'))
	{
		document.getElementById('lien_valide_crop').style.display = '' ;
	}
}

/**
 * Pour le crop
 */
function onEndCrop( coords, dimensions ) {
	var ratio = myorigWidth/$('testImage').width;
	var x2 = coords.x1;
	var y2 = coords.y1;
	destx = Math.round(coords.x1*ratio);
	desty = Math.round(coords.y1*ratio);
	destwidth = Math.round(dimensions.width*ratio);
	destheight = Math.round(dimensions.height*ratio);
	switch(myangle)
	{
		case 90:
			ratio = myorigHeight/$('testImage').width;
			destx = Math.round(y2*ratio);
			desty = myorigHeight - Math.round(x2*ratio) - Math.round(dimensions.width*ratio);
			destwidth = Math.round(dimensions.height*ratio);
			destheight = Math.round(dimensions.width*ratio);
		break;
		case 180:
			destx = myorigWidth - Math.round(x2*ratio) - destwidth;
			desty = myorigHeight - Math.round(y2*ratio) - destheight;
		break;
		case 270:
			ratio = myorigHeight/$('testImage').width;
			destx = myorigWidth - Math.round(y2*ratio) - Math.round(dimensions.height*ratio);
			desty = Math.round(x2*ratio);
			
			destwidth = Math.round(dimensions.height*ratio);
			destheight = Math.round(dimensions.width*ratio);
		break;
	}
	if(destx <= 0)
	{
		destx = 0;
	}
	if(destx >= myorigWidth)
	{
		destx = myorigWidth;
	}
	
	if(desty <= 0)
	{
		desty = 0;
	}
	if(desty >= myorigHeight)
	{
		desty = myorigHeight;
	}
	
	if(destx+destwidth > myorigWidth)
	{
		destwidth = myorigWidth - destx;
	}

	if(desty+destheight > myorigHeight)
	{
		destheight = myorigHeight - desty;
	}
	//$( 'lignecde' ).value = "convert /opt/imagelibre/images/<?=$photo->chemin?> -crop "+ destwidth+"x"+destheight+"+"+destx+'+'+desty+' /tmp/test.jpg';
}

function valide_crop(id_photo, id_produit, page)
{
	show_selects();
	Event.stopObserving( 'testImage', 'load',	start_cropper);
	curcrop.remove();
	if(page == 'perso')
	{
		get_synchro_javascript('/javascripts/gestionpanier2.php?id_photo='+id_photo+'&id_produit='+id_produit+'&action=retaille&cmd=-crop '+ destwidth+'x'+destheight+'+'+destx+'+'+desty);
	}
	else
	{
		get_synchro_javascript('/javascripts/gestionpanier.php?id_photo='+id_photo+'&id_produit='+id_produit+'&action=retaille&cmd=-crop '+ destwidth+'x'+destheight+'+'+destx+'+'+desty);
	}
	nouveauDiv.style.display='none'; 
	nouveauDiv.innerHTML='';
}

function annule_crop(id_photo, id_produit, page)
{
	Event.stopObserving( 'testImage', 'load',	start_cropper);
	curcrop.remove();
	if(page == 'perso')
	{
		get_synchro_javascript('/javascripts/gestionpanier2.php?id_photo='+id_photo+'&id_produit='+id_produit+'&action=del_produit_element');
	}
	else
	{
		get_synchro_javascript('/javascripts/gestionpanier.php?id_photo='+id_photo+'&id_produit='+id_produit+'&action=del_produit_element');
	}
	show_selects();
	nouveauDiv.style.display='none'; 
	nouveauDiv.innerHTML='';
}

/**
 * Cache tous les select d'une page (pour les div)
 */
function hide_selects()
{
	oSelects = document.getElementsByTagName('SELECT');
	if (oSelects.length > 0) 
	{
		for (i = 0; i < oSelects.length; i++) 
		{
			oSelects[i].style.visibility = 'hidden';
		}
	}
}

/**
 * Re-affiche les selects
 */
function show_selects()
{
	oSelects = document.getElementsByTagName('SELECT');
	if (oSelects.length > 0) 
	{
		for (i = 0; i < oSelects.length; i++) 
		{
			oSelects[i].style.visibility = 'visible';
		}
	}
}

function struct_images(chemin, page, id_photo, is_on_panier) {
    this.chemin = chemin;
    this.page = page;
    var reg=new RegExp("(medium)", "g");
    this.cheminMiniature = chemin.replace(reg,"xsmall");
    this.id_photo = id_photo;
    this.is_on_panier = is_on_panier;
}

function reload_image(chemin)
{
	var preloadImage = new Image();
	var maintenant= new Date();
	preloadImage.src = chemin+'?'+maintenant.getTime();
}
