<!--
// location=yes/no : affiche ou non la barre d'adresse, 
// toolbar=yes/no : affiche ou non la barre de boutons, 
// directories=yes/no : affiche ou non la barre de boutons 'Nouveautes'..., 
// menubar=yes/no : affiche ou non la barre des menus (Fichier, Edition...), 
// resizable=yes/no : permet ou non le redimensionnement de la fenetre, 
// screenX= : placement de la fenetre en abcisse, 
// screenY= : placement de la fenetre en ordonnee, 
// scrollbars=yes/no : affiche ou non les ascenceurs, 
// status=yes/no : affiche ou non la barre d'etat, 
// width : donne la largeur de la fenetre en pixels, 
// height : donne la hauteur de la fenetre en pixels.


function pop_admin(adresse)
{
	window.open(adresse,'Administration','location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=yes,status=no,width=500,height=300,screenY=100,screenX=100');
}

function pop_user(adresse)
{
	if(confirm('Voulez vous vraiment modifier les droits d\'accès de cet utilisateur ?') )
	{
		window.open(adresse,'AdministrationUser','location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=yes,status=no,width=250,height=100,screenY=100,screenX=100');
	}
}

function pop2x_image(adresse,x,y)
{
	popupmodulo(adresse,'Image du Taulard',x+20,y+40,100,100);	
}

function pop_image(adresse, largeur, hauteur)
{
	var wh = hauteur+60;
	var wl = largeur+30;
	var txt = 'location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=no,status=no,width=' + wl + ',height=' + wh + ',screenY=100,screenX=100'
	window.open(adresse,'TaulardImage',txt);
}

function pop_vote(adresse)
{
	window.open(adresse,'Vote','location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=yes,status=no,width=300,height=100,screenY=100,screenX=100');
}

function pop_delete(adresse)
{
	if(confirm('Voulez vous vraiment supprimer cet élement ?') )
	{
		window.open(adresse,'AdministrationDelete','location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=yes,status=no,width=250,height=100,screenY=100,screenX=100');
	}
}

function pop_mail(nom,domaine)
{
	var txt = 'location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=no,status=no,width=10,height=10,screenY=100,screenX=100';
//	window.open('mailto:'+ nom + '@' + domaine,'Mail',txt);
	window.location	= 'mailto:'+ nom + '@' + domaine;
}

// fonction utilisable pour plusieurs fichiers dans la meme fenetre 'popup'
function popup(adresse){
	window.open(adresse,'nom_de_la_fenetre','location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=yes,status=no,width=200,height=150,screenY=100,screenX=100');
}

// fonction utilisable pour plusieurs fichiers dans des fenetres differentes, de tailles et positions differentes
function popupmodulo(adresse, name, x, y, top, left){
	window.open(adresse,name,'location=no,toolbar=no,directories=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,width='+x+',height='+y+'screenY='+top+',screenX='+left);
}

function mouse_switch(obj,aclass,stat)
{
	
	window.status = stat;
	obj.className = aclass;
}

function set_status(stat)
{
	window.status = stat;
}

function allerBlank(url)
{
	window.open(url);
}

function changeIcone()
{
	document.lsdt_form.ico.src = 'interface/common/' + document.lsdt_form.img_format.value;	
}


function pop_vote(section,element,obj,page)
{
	
	var vote = obj.options[obj.selectedIndex].value
	if(vote != '')
	{
		var adresse = page + '?s=' + section + '&e=' + element + '&vote=' + vote;
		window.open(adresse,'Vote'+section,'location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=yes,status=no,width=250,height=100,screenY=100,screenX=100');
	}
}

function pop_fake(section,element,fake,page)
{
	if(fake != '')
	{
		var adresse = page + '?s=' + section + '&e=' + element + '&fake=' + fake;
		window.open(adresse,'Vote'+section,'location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=yes,status=no,width=250,height=100,screenY=100,screenX=100');
	}
}

function pop_map(isCreate)
{
	
		var adresse = '/pop_checkmap.php';
		window.open(adresse,'Checkmap','location=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=yes,status=no,width=550,height=350,screenY=50,screenX=50');

}

 function allowedTag(fullString,i)
 {
  var str = fullString.substr(i,fullString.length-i);
  return (
          startsWith(str,'<object')
          || startsWith(str,'<param')
          || startsWith(str,'<embed')
          || startsWith(str,'</object')
          || startsWith(str,'</param')
          || startsWith(str,'</embed') );
 }
 
 function startsWith(str,pattern) 
 {
    return str.toLowerCase().indexOf(pattern) === 0;
 }

function stripNonEmbedHtml(str)
{
  // conserve uniquement les patterns suivants:
  // - <object ... >
  // - <param ...>
  // - <embed ...>
  
  var cleanStr = "";
  var cleanTag = false;
  
  for(var i = 0; i < str.length; i++) 
  {
        if(allowedTag(str,i) && !cleanTag)
        {
          cleanTag = true;
        }
   
        if(cleanTag) 
        {
          cleanStr += str.charAt(i);
        }
        
        if(str.charAt(i) == '>') 
        {
              cleanTag = false;
        }

   }

   return cleanStr;

}





/////////////////////////////////////////////////////////////////////////////////

function verif_email() 
{

// on passe la donnée saisie par le visiteur en variable pour plus de facilités
adresse = document.formulaire.user_email.value;
taille = document.formulaire.user_email.value.length;

// on créé 3 variables pour valider au fur et à mesure le login, le domaine et l'extension qui constituent l'adresse e-mail
validelog = false;
validedom = false;
valideext = false;

// on extrait le 'login' qui se situe avant l'arobace
arob = adresse.lastIndexOf("@");
login = adresse.substring(0,arob);

// on extrait l'extension qui se situe à partir du dernier point
pointfinal = adresse.lastIndexOf(".");
extension = adresse.substring(pointfinal,taille);

// on extrait le domaine qui se trouve entre l'arobace et le dernier point
domaine = adresse.substring(arob+1,pointfinal);


// un login a toujours plus de 2 caractères, on fait le test
if ( login.length > 2 ) {
validelog = true;
}
else {
alert('Ceci n\'est pas une adresse e-mail.\nUne adresse e-mail comporte un arobace precede d\'un login \'convenable\'.');
validelog = false;
}

// un domaine a toujours plus de 1 caractère, on fait le test
if ( domaine.length > 1 ) {
validedom = true;
}
else {
alert('Ceci n\'est pas une adresse e-mail.\nLe nom de domaine n\'existe pas.');
validelog = false;
}

// une extension a toujours 2 ou 3 caractères, on fait le test
if ( pointfinal > -1 && (extension.length == 3 || extension.length == 4) ) {
valideext = true;
}
else {
alert('Ceci n\'est pas une adresse e-mail valide.\nL\'extension n\'est pas bonne.');
valideext = false;
}

// On vérifie si les deux emails sont identiques
if( document.formulaire.user_email.value == document.formulaire.user_email2.value )
{
	validcopy = true;
}
else
{
	validcopy = false;
}


// on vérifie que nos trois variables sont vraies pour accepter la soumission du formulaire
if ( validelog == true && validedom == true && valideext == true && validcopy == true ) {
return true;
}
else {
return false;
}
}

function textevide() 
{
	
	
	if ( document.formulaire.username.value == '' ) 
	{
		window.alert('Veuillez rentrer un login');
		return false;
	}
	if ( document.formulaire.user_email.value == '' ) 
	{
		window.alert('Veuillez rentrer un email');
		return false;
	}
	
	if ( document.formulaire.user_gender.value == 0 )
	{
		window.alert('Veuillez indiquer votre sexe');
		return false;
	}
	
	if ( document.formulaire.password.value == '' ) 
	{
		window.alert('Veuillez rentrer un mot de passe');
		return false;
	}
	else
	{
		if ( document.formulaire.passwordconfirm.value == '' ) 
		{
			window.alert('Veuillez rentrer une deuxième fois votre mot de passe');
			return false;
		}
		else
		{
			if (document.formulaire.passwordconfirm.value == document.formulaire.password.value)
			{
				return true;
			}
			else
			{
				window.alert('Votre mot de passe est différent !');
				return false;
			}
		}
	}
	

	
}

function checkformulaire()
{
	if( (textevide()) && (verif_email()) )
		return true;
	else
		return false;
		
}






// Formulaire de chgt de mot de passe  ///////////////////////////////////////////////////////////////////////////////////
function modif_pass_form() 
{
	if( ( document.formulaire_pass.old_pass.value == '' )  || ( document.formulaire_pass.new_pass.value == '' ) || ( document.formulaire_pass.new_pass_confirm.value == '' ) )
	{
		window.alert('Veuillez remplir tous les champs');
		return false;
	}
	else
	{
		if (document.formulaire_pass.new_pass_confirm.value == document.formulaire_pass.new_pass.value)
		{
			return true;
		}
		else
		{
			window.alert('Votre mot de passe est différent !');
			return false;
		}
	}
}






function checkParentRefresh(nomFrame)
{
	if(window.frames[nomFrame].document.forms['RefreshForm'])
	{
		if(window.frames[nomFrame].document.forms['RefreshForm'].rafraichirParent.value == 'true')
		{
			window.alert('refresh');
		}
		
	}
	//window.setTimeout(checkParentRefresh(nomFrame),50000);	
}




function quoteComment(idCom,username)
{
	var comName = 'CommentaireQuoteSourceId_'+idCom;
	
	if(window.frames['commentaire_frame'].document.forms['lsdt_form'])
	{
		
		if(document.getElementById(comName))
		{
			
			window.frames['commentaire_frame'].document.forms['lsdt_form'].contenu.value += '[quote='+username+']'+document.getElementById(comName).innerHTML + '[/quote]';
		}
	}
}


function removeMsg(obj,msg)
{
	if(obj)
	{
		if(obj.value == msg)
		{
			obj.value = "";	
		}			
	}
}

function blockMsg(obj,msg)
{
	if(obj.contenu.value == msg || obj.contenu.value == '')
		return false;
	else
		return true;	
	
}

function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }

function verifPlugin(name)
{
	// Shockwave Director
	// SVG Viewer
	// Shockwave Flash
	// RealPlayer
	// Acrobat Reader
	
	var agt=navigator.userAgent.toLowerCase();
	
	
	
	var ie = (agt.indexOf("msie") != -1);
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
	var mac = (agt.indexOf("mac")!=-1);

	

	if (ie && win) {pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); }
	if (ns || !win) 
	{
		nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
		pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
	}	

pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1); 

	if (pluginlist.indexOf(name)!=-1)
	{
		return true;	
	}
	else
	{
		var i = agt.indexOf("firefox/");
	
		if(agt.substr(i+8,3)>=1.5)
			return true;
		else
			return false;
	}

}

// à utiliser avec :
// onKeyPress="return submitenter(this,event)"
function submitEnter(myfield,e)
{
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  else return true;
  
  if (keycode == 13)
  {
     return false;
  }
  else
     return true;
}

function noenter() 
{
  return !(window.event && window.event.keyCode == 13); 
}

function executeOnEnter(myfield,e,func)
{
  if(submitEnter(myfield,e))
  {
    return eval(func);
  }
}

function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1 && obj.constructor.toString().indexOf("array") == -1)
      return false;
   else
      return true;
}

//-->
