// JavaScript Document

function ValideLogin(Form_){
	var Error = 0;
	if(Form_){
		if(trim(Form_.MembreUsername.value) != ""){
			document.getElementById("labelusername").className = "LblBoxLogin";
		}else{
			Error = 1;
			document.getElementById("labelusername").className = "LblBoxLoginErreur";
		}
		
		if(trim(Form_.MembrePassword.value) != ""){
			document.getElementById("labelmotdepasse").className = "LblBoxLogin";
		}else{
			Error = 1;
			document.getElementById("labelmotdepasse").className = "LblBoxLoginErreur";
		}
		
		
		if(Error != 0){
			return false;
		}else{
			return true;
		}
	}else{
		alert("Pas de formulaire");
		return false;
	}
}


function ValideLoginHeader(Form_){
	var Error = 0;
	if(Form_){
		if(trim(Form_.MembreUsername.value) != ""){
			document.getElementById("labelusernameheader").className = "LblBoxLoginHeader";
		}else{
			Error = 1;
			document.getElementById("labelusernameheader").className = "LblErreurLoginHeader";
		}
		
		if(trim(Form_.MembrePassword.value) != ""){
			document.getElementById("labelpasswordheader").className = "LblBoxLoginHeader";
		}else{
			Error = 1;
			document.getElementById("labelpasswordheader").className = "LblErreurLoginHeader";
		}
		
		
		if(Error != 0){
			return false;
		}else{
			return true;
		}
	}else{
		alert("Pas de formulaire");
		return false;
	}
}



function ValideSendMsg(Form_){
	var Error = 0;
	if(Form_){
		if(trim(Form_.MsgSujet.value) != ""){
			document.getElementById("labelmsgsujet").className = "TDSendMsgChamps";
		}else{
			Error = 1;
			document.getElementById("labelmsgsujet").className = "TDSendMsgChampsErr";
		}
		
		if(trim(Form_.Message.value) != ""){
			document.getElementById("labelmessage").className = "TDSendMsgChamps";
		}else{
			Error = 1;
			document.getElementById("labelmessage").className = "TDSendMsgChampsErr";
		}
		
		
		if(Error != 0){
			return false;
		}else{
			return true;
		}
	}else{
		alert("Pas de formulaire");
		return false;
	}
}

function ValideSendReponse(Form_){
	var Error = 0;
	if(Form_){
		if(trim(Form_.Message.value) != ""){
			document.getElementById("labelmessage").className = "TDSendMsgChamps";
		}else{
			Error = 1;
			document.getElementById("labelmessage").className = "TDSendMsgChampsErr";
		}
		
		
		if(Error != 0){
			return false;
		}else{
			return true;
		}
	}else{
		alert("Pas de formulaire");
		return false;
	}
}



function closeBox(WhichBox_){
	if(document.getElementById(WhichBox_)){
		document.getElementById(WhichBox_).style.display = "none";
		if(WhichBox_ == "DivListeVille"){
			if(document.getElementById("TypeMembre")){
				document.getElementById("TypeMembre").style.visibility = "visible";
			}
		}
		if(document.getElementById("CurrentPhoto")){
			document.getElementById("CurrentPhoto").src = "images/spacer.gif";
			document.getElementById("CurrentPhoto").width = 1;
			document.getElementById("CurrentPhoto").height = 1;
		}
	}
}

function showImage(Src_,Width_,Height_){
	var details = navigator.userAgent;
	if(document.getElementById("DivShowPhoto")){
		if(details.indexOf("MSIE") >= 0){
			document.getElementById("DivShowPhoto").className = "ShowPhotoIE";
		}
		if(document.getElementById("CurrentPhoto")){
			document.getElementById("CurrentPhoto").src = Src_;
			document.getElementById("CurrentPhoto").width = Width_;
			document.getElementById("CurrentPhoto").height = Height_;
		}
		LeftPosition = (window.innerWidth) ? (window.innerWidth - Width_)/2 : (screen.width) ? (screen.width - Width_) / 2 : 0;
		document.getElementById("DivShowPhoto").style.display = "block";
		document.getElementById("DivShowPhoto").style.left = LeftPosition + "px";
	}
}

function selectVille(){
	var details = navigator.userAgent;
	if(document.getElementById("DivListeVille") && document.getElementById("TypeMembre")){
		document.getElementById("TypeMembre").style.visibility = "hidden";
		if(details.indexOf("MSIE") >= 0){
			document.getElementById("DivListeVille").className = "ListeVillesIE";
		}
		LeftPosition = (window.innerWidth) ? (window.innerWidth - 700)/2 : (screen.width) ? (screen.width - 700) / 2 : 0;
		document.getElementById("DivListeVille").style.display = "block";
		document.getElementById("DivListeVille").style.left = LeftPosition + "px";
	}
	return false;
}

function setVille(ID,Name){
	if(document.getElementById("Ville") && document.getElementById("DescVille") && document.getElementById("DivListeVille") && document.getElementById("TypeMembre")){
		document.getElementById("Ville").value = ID;
		document.getElementById("DescVille").innerHTML = Name;
		document.getElementById("DivListeVille").style.display = "";
		document.getElementById("TypeMembre").style.visibility = "visible";
	}
}

function trim(str){
   return str.replace(/^\s*|\s*$/g,"");
}


function changeClasse(WhichTDDebut_,WhichTDMilieu_,WhichTDFin_,ClassNameDebut_,ClassNameMilieu_,ClassNameFin_){
	if(document.getElementById(WhichTDDebut_) && document.getElementById(WhichTDMilieu_) && document.getElementById(WhichTDFin_)){
		document.getElementById(WhichTDDebut_).className = ClassNameDebut_;
		document.getElementById(WhichTDMilieu_).className = ClassNameMilieu_;
		document.getElementById(WhichTDFin_).className = ClassNameFin_;
	}
}


function changeLocation(Src_){
	document.location.href = Src_;
}

function validKeyDown(){
	// Check if the control key is pressed.
	// If the Netscape way won't work (event.modifiers is undefined),
	// try the IE way (event.ctrlKey)
	var ctrl = typeof event.modifiers == 'undefined' ? event.ctrlKey : event.modifiers & Event.CONTROL_MASK;
	
	// Check if the 'V' key is pressed.
	// If the Netscape way won't work (event.which is undefined),
	// try the IE way (event.keyCode)
	var v = typeof event.which == 'undefined' ? event.keyCode == 86 : event.which == 86;
	
	// If the control and 'V' keys are pressed at the same time
	if ( ctrl && v ) {
	// ... discard the keystroke and clear the text box
		return false;
	}
}


function changeClasse(WhichTDDebut_,WhichTDMilieu_,WhichTDFin_,ClassNameDebut_,ClassNameMilieu_,ClassNameFin_){
	if(document.getElementById(WhichTDDebut_) && document.getElementById(WhichTDMilieu_) && document.getElementById(WhichTDFin_)){
		document.getElementById(WhichTDDebut_).className = ClassNameDebut_;
		document.getElementById(WhichTDMilieu_).className = ClassNameMilieu_;
		document.getElementById(WhichTDFin_).className = ClassNameFin_;
	}
}




function longueurOK(Textarea_){
	var MaxLongueur = Textarea_.getAttribute? parseInt(Textarea_.getAttribute("maxlength")) : ""
	
	if(Textarea_.getAttribute && Textarea_.value.length > MaxLongueur){
		Textarea_.value = Textarea_.value.substring(0, MaxLongueur)
	}
}



