var currenty;

function ViewOtherPhoto(fname ){
		var div = document.createElement('div');
		div.className = 'photodetail';
		var img = document.createElement('img');
		img.setAttribute('src', 'http://trip.estimfriends.com/news/photos/big/'+fname+'.jpg');
		img.setAttribute('title', 'Cliquez pour fermer la photo.');
		img.setAttribute('onClick', 'javascript:Close();');
		div.appendChild(img);
		document.getElementById('specialdiv').appendChild(div);
		document.getElementById('specialdiv').style.display = 'block';
		currenty = window.scrollY ?  window.scrollY : document.documentElement.scrollTop;
		window.scrollTo(0,0);
} 

function Close(){
	window.scrollTo(0,currenty);
	document.getElementById('specialdiv').removeChild(document.getElementById('specialdiv').firstChild);
	document.getElementById('specialdiv').style.display = 'none';}



function send_email(str){
	var tmp = new send_email_newsletter(str);

}

function send_email_newsletter(str){
	this.send(str);
}

send_email_newsletter.prototype.send = function(str){
	var ajax = new AjaxEngine(this);
	ajax.url = 'add_newsletter_mail.php';
	ajax.AddVariable('mail', str);
	ajax.SendRequest();
}

send_email_newsletter.prototype.AnalyseResponse = function(str){
	if(str == 'ok'){
		alert('Votre email a bien été ajouté.');
		document.getElementById('mail').value;
	}else{
		alert('Votre email est invalide !');
	}
}

/************* Ajax Engine ***********/
function ValidRequest(ae){
	if(ae.http.readyState == 4){
		ae.parent.AnalyseResponse(ae.http.responseText);
	}
}
	
	
function AjaxEngine(par){
	this.parent = par;
	this.http = null;
	this.method = 'GET';
	this.variablesn = new Array;
	this.variablesv = new Array;
	this.countvar = 0;
}

AjaxEngine.prototype.InitRequest = function(){
		if (window.XMLHttpRequest){     
			this.http = new XMLHttpRequest();    
		}else if (window.ActiveXObject){   
			this.http = new ActiveXObject("Microsoft.XMLHTTP");    
		}
		var ae = this;
		this.http.onreadystatechange = function(){ValidRequest(ae);}
	}
	
AjaxEngine.prototype.SendRequest = function(){
		this.InitRequest();
		//document.write(this.MakeUrl());
//document.write(this.MakeUrl());
		this.http.open( this.method, this.MakeUrl(), true);
		//alert(this.MakeUrl());
		this.http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
		this.http.send(null); 
	}

AjaxEngine.prototype.ResetVariable = function(){
		this.variablesn = new Array;
		this.variablesv = new Array;
		this.countvar = 0;
	}
	
AjaxEngine.prototype.AddVariable = function(name, value){
		this.variablesn[this.countvar] = name;
		this.variablesv[this.countvar] = value;
		this.countvar ++;
	}

AjaxEngine.prototype.MakeUrl = function(){
		var tmp = this.url + '?';
		for(i=0;i<this.countvar;i++){
			tmp = tmp + this.variablesn[i] +'='+this.variablesv[i]+'&';
		}
		return tmp;
	}

