/*********************************************************************************************************/
// Fonction pour la confirmation d'action
// NB : pensez à addslashes les quotes \' dans le texte du message
// exemple d'uilisation : <a href="javascript:securit('Etes vous sur de vouloir supprimer le thème <?php echo addslashes($theme_nom); ?> ?','theme1.php?theme_id=<?php echo "$theme_id"; ?>&action=supprimer');">
function securit(message,action)
{

	if(confirm(message))
		window.location = action;
		

}
/*********************************************************************************************************/


/*********************************************************************************************************/
// fonction des vérification du nom de fichier dans un formulaire
// Utilisation : <form method="post" action="fileaction.php" enctype="multipart/form-data" onSubmit="return testnomfile(this.nomchampsfile)" >
function testnomfile(fichier) {
	
	
	//if(fichier.value=="") { alert('Le fichier est vide !');fichier.focus();return false }
	

	if (navigator.appVersion.indexOf("Mac",0)>0)
	{
			//alert("C'est un MAC");
			
			// TEST du nom de fichier pour MAC
			var chaine = fichier.value;
			
			var tableau=chaine.split("/");
		
			var num = tableau.length-1;
			
			for(i = 0; i < tableau[num].length; i++) 
			{
				if ((tableau[num].substr(i,1) != "a") && (tableau[num].substr(i,1) != "b") && (tableau[num].substr(i,1) != "c") && 
					(tableau[num].substr(i,1) != "d") && (tableau[num].substr(i,1) != "e") && (tableau[num].substr(i,1) != "f") &&
					(tableau[num].substr(i,1) != "g") && (tableau[num].substr(i,1) != "h") && (tableau[num].substr(i,1) != "i") &&
					(tableau[num].substr(i,1) != "j") && (tableau[num].substr(i,1) != "k") && (tableau[num].substr(i,1) != "l") &&
					(tableau[num].substr(i,1) != "m") && (tableau[num].substr(i,1) != "n") && (tableau[num].substr(i,1) != "o") &&
					(tableau[num].substr(i,1) != "p") && (tableau[num].substr(i,1) != "q") && (tableau[num].substr(i,1) != "r") &&
					(tableau[num].substr(i,1) != "s") && (tableau[num].substr(i,1) != "t") && (tableau[num].substr(i,1) != "u") &&
					(tableau[num].substr(i,1) != "v") && (tableau[num].substr(i,1) != "w") && (tableau[num].substr(i,1) != "x") &&
					(tableau[num].substr(i,1) != "y") && (tableau[num].substr(i,1) != "z") && (tableau[num].substr(i,1) != "A") &&
					(tableau[num].substr(i,1) != "B") && (tableau[num].substr(i,1) != "C") && (tableau[num].substr(i,1) != "D") &&
					(tableau[num].substr(i,1) != "E") && (tableau[num].substr(i,1) != "F") && (tableau[num].substr(i,1) != "G") &&
					(tableau[num].substr(i,1) != "H") && (tableau[num].substr(i,1) != "I") && (tableau[num].substr(i,1) != "J") &&
					(tableau[num].substr(i,1) != "K") && (tableau[num].substr(i,1) != "L") && (tableau[num].substr(i,1) != "M") && 
					(tableau[num].substr(i,1) != "N") && (tableau[num].substr(i,1) != "O") && (tableau[num].substr(i,1) != "P") &&
					(tableau[num].substr(i,1) != "Q") && (tableau[num].substr(i,1) != "R") && (tableau[num].substr(i,1) != "S") &&
					(tableau[num].substr(i,1) != "T") && (tableau[num].substr(i,1) != "U") && (tableau[num].substr(i,1) != "V") &&
					(tableau[num].substr(i,1) != "W") && (tableau[num].substr(i,1) != "X") && (tableau[num].substr(i,1) != "Y") &&
					(tableau[num].substr(i,1) != "Z") && (tableau[num].substr(i,1) != "0") && (tableau[num].substr(i,1) != "1") &&
					(tableau[num].substr(i,1) != "2") && (tableau[num].substr(i,1) != "3") && (tableau[num].substr(i,1) != "4") &&
					(tableau[num].substr(i,1) != "5") && (tableau[num].substr(i,1) != "6") && (tableau[num].substr(i,1) != "7") &&
					(tableau[num].substr(i,1) != "8") && (tableau[num].substr(i,1) != "9") && (tableau[num].substr(i,1) != "-") &&
					(tableau[num].substr(i,1) != "_") && (tableau[num].substr(i,1) != ".") && (tableau[num].substr(i,1) != " ") &&
					(tableau[num].substr(i,1) != "\\") && (tableau[num].substr(i,1) != ":") && (tableau[num].substr(i,1) != "/")
					)
				{
					alert('Le nom du fichier est incorrect !');fichier.focus();return false
				}
				
			}//fin du for test nom de fichier

	}//fin de test si mac
	else
	{
		//alert("Ce n'est pas un MAC");
	
		// TEST du nom di fichier pour window
		var chaine = fichier.value;
		
		var tableau=chaine.split("\\");
	
		var num = tableau.length-1;
		
		for(i = 0; i < tableau[num].length; i++) 
		{
			if ((tableau[num].substr(i,1) != "a") && (tableau[num].substr(i,1) != "b") && (tableau[num].substr(i,1) != "c") && 
				(tableau[num].substr(i,1) != "d") && (tableau[num].substr(i,1) != "e") && (tableau[num].substr(i,1) != "f") &&
				(tableau[num].substr(i,1) != "g") && (tableau[num].substr(i,1) != "h") && (tableau[num].substr(i,1) != "i") &&
				(tableau[num].substr(i,1) != "j") && (tableau[num].substr(i,1) != "k") && (tableau[num].substr(i,1) != "l") &&
				(tableau[num].substr(i,1) != "m") && (tableau[num].substr(i,1) != "n") && (tableau[num].substr(i,1) != "o") &&
				(tableau[num].substr(i,1) != "p") && (tableau[num].substr(i,1) != "q") && (tableau[num].substr(i,1) != "r") &&
				(tableau[num].substr(i,1) != "s") && (tableau[num].substr(i,1) != "t") && (tableau[num].substr(i,1) != "u") &&
				(tableau[num].substr(i,1) != "v") && (tableau[num].substr(i,1) != "w") && (tableau[num].substr(i,1) != "x") &&
				(tableau[num].substr(i,1) != "y") && (tableau[num].substr(i,1) != "z") && (tableau[num].substr(i,1) != "A") &&
				(tableau[num].substr(i,1) != "B") && (tableau[num].substr(i,1) != "C") && (tableau[num].substr(i,1) != "D") &&
				(tableau[num].substr(i,1) != "E") && (tableau[num].substr(i,1) != "F") && (tableau[num].substr(i,1) != "G") &&
				(tableau[num].substr(i,1) != "H") && (tableau[num].substr(i,1) != "I") && (tableau[num].substr(i,1) != "J") &&
				(tableau[num].substr(i,1) != "K") && (tableau[num].substr(i,1) != "L") && (tableau[num].substr(i,1) != "M") && 
				(tableau[num].substr(i,1) != "N") && (tableau[num].substr(i,1) != "O") && (tableau[num].substr(i,1) != "P") &&
				(tableau[num].substr(i,1) != "Q") && (tableau[num].substr(i,1) != "R") && (tableau[num].substr(i,1) != "S") &&
				(tableau[num].substr(i,1) != "T") && (tableau[num].substr(i,1) != "U") && (tableau[num].substr(i,1) != "V") &&
				(tableau[num].substr(i,1) != "W") && (tableau[num].substr(i,1) != "X") && (tableau[num].substr(i,1) != "Y") &&
				(tableau[num].substr(i,1) != "Z") && (tableau[num].substr(i,1) != "0") && (tableau[num].substr(i,1) != "1") &&
				(tableau[num].substr(i,1) != "2") && (tableau[num].substr(i,1) != "3") && (tableau[num].substr(i,1) != "4") &&
				(tableau[num].substr(i,1) != "5") && (tableau[num].substr(i,1) != "6") && (tableau[num].substr(i,1) != "7") &&
				(tableau[num].substr(i,1) != "8") && (tableau[num].substr(i,1) != "9") && (tableau[num].substr(i,1) != "-") &&
				(tableau[num].substr(i,1) != "_") && (tableau[num].substr(i,1) != ".") && (tableau[num].substr(i,1) != " ") &&
				(tableau[num].substr(i,1) != "\\") && (tableau[num].substr(i,1) != ":") && (tableau[num].substr(i,1) != "/")
				)
			{
				alert('Le nom du fichier est incorrect !');fichier.focus();return false
			}
			
		}//fin du for test nom de fichier

	}//fin du else test

	return true;
}
/*********************************************************************************************************/



/*********************************************************************************************************/
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_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];
		}
}
/*********************************************************************************************************/


/*********************************************************************************************************/
function openWin(theURL,winName,features)
{
    newWin = window.open('',winName,features);;
    newWin.document.write("<p align=center>");
    newWin.document.write(theURL);
    newWin.document.write("</p>");
    newWin.document.write("<p align=center>");
    newWin.document.write("<a href=\"JavaScript:window.close()\">Fermer la fenêtre</a>");
    newWin.document.write("</p>");
}
			
/*********************************************************************************************************/

/*********************************************************************************************************/
function MM_swapClassRestore() { //v3.0
	var i,x,a=document.MM_cl;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oClass;i++)
		x.className=x.oClass;
}
/*********************************************************************************************************/

/*********************************************************************************************************/
function MM_swapClass() { //v3.0
	var i,j=0,x,a=MM_swapClass.arguments;
	document.MM_cl=new Array;
	for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){
			document.MM_cl[j++]=x;
			if(!x.oClass)
				x.oClass=x.className;
			x.className=a[i+2];
		}
}
/*********************************************************************************************************/




/*********************************************************************************************************/
// JavaScript Document
// This script is (c) copyright 2006 Jim Tucek under the
// GNU General Public License (http://www.gnu.org/licenses/gpl.html)
// For more information, visit www.jracademy.com/~jtucek/email/ 
// Leave the above comments alone!

var decryption_cache = new Array();

function decrypt_string(crypted_string,n,decryption_key,just_email_address) {
	var cache_index = "'"+crypted_string+","+just_email_address+"'";

	if(decryption_cache[cache_index])					// If this string has already been decrypted, just
		return decryption_cache[cache_index];				// return the cached version.

	if(addresses[crypted_string])						// Is crypted_string an index into the addresses array
		var crypted_string = addresses[crypted_string];			// or an actual string of numbers?

	if(!crypted_string.length)						// Make sure the string is actually a string
		return "Error, not a valid index.";

	if(n == 0 || decryption_key == 0) {					// If the decryption key and n are not passed to the
		var numbers = crypted_string.split(' ');			// function, assume they are stored as the first two
		n = numbers[0];	decryption_key = numbers[1];			// numbers in crypted string.
		numbers[0] = ""; numbers[1] = "";				// Remove them from the crypted string and continue
		crypted_string = numbers.join(" ").substr(2);
	}

	var decrypted_string = '';
	var crypted_characters = crypted_string.split(' ');

	for(var i in crypted_characters) {
		var current_character = crypted_characters[i];
		var decrypted_character = exponentialModulo(current_character,n,decryption_key);
		if(just_email_address && i < 7)				// Skip 'mailto:' part
			continue;
		if(just_email_address && decrypted_character == 63)	// Stop at '?subject=....'
			break;
		decrypted_string += String.fromCharCode(decrypted_character);
	}
	
	decryption_cache[cache_index] = decrypted_string;			// Cache this string for any future calls

	return decrypted_string;
}
/*********************************************************************************************************/

/*********************************************************************************************************/
function decrypt_and_email(crypted_string,n,decryption_key) {
	if(!n || !decryption_key) { n = 0; decryption_key = 0; }
	if(!crypted_string) crypted_string = 0;

	var decrypted_string = decrypt_string(crypted_string,n,decryption_key,false);
	parent.location = decrypted_string;
}
/*********************************************************************************************************/

/*********************************************************************************************************/
function decrypt_and_echo(crypted_string,n,decryption_key) {
	if(!n || !decryption_key) { n = 0; decryption_key = 0; }
	if(!crypted_string) crypted_string = 0;

	var decrypted_string = decrypt_string(crypted_string,n,decryption_key,true);
	document.write(decrypted_string);
	return true;
}
/*********************************************************************************************************/

/*********************************************************************************************************/
// Finds base^exponent % y for large values of (base^exponent)
function exponentialModulo(base,exponent,y) {
	if (y % 2 == 0) {
		answer = 1;
		for(var i = 1; i <= y/2; i++) {
			temp = (base*base) % exponent;
			answer = (temp*answer) % exponent;
		}
	} else {
		answer = base;
		for(var i = 1; i <= y/2; i++) {
			temp = (base*base) % exponent;
			answer = (temp*answer) % exponent;
		}
	}
	return answer;
}
/*********************************************************************************************************/

// AC_ActiveX

//v1.1
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AX_RunContent(){
  var ret = AC_AX_GetArgs(arguments);
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_AX_GetArgs(args){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "pluginspage":
      case "type":
      case "src":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "data":
      case "codebase":
      case "classid":
      case "id":
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  return ret;
}
/*********************************************************************************************************/

// AC_RunActiveContent

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
/*********************************************************************************************************/

