function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// Tout autres qu'Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // Tous sauf Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...marchera également avec Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// tous excepté Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // autres qu'Explorer
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){ hideLightbox(); }
}

// listenKey()

function listenKey () {	document.onkeypress = getKey; }

function hideLightbox()
{
	// get objects
	objOverlay = document.getElementById('overlay');
	objBox = document.getElementById('box');

	
	objOverlay.style.display = 'none';
	objBox.style.display = 'none';
	
	document.onkeypress = '';
}

function fiche(id) {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var closeButton = 'http://www.lascive.fr/images/close.gif';

	var anchorss = document.getElementsByTagName("img");

	for (var i=0; i<anchorss.length; i++){
		var anchor = anchorss[i];
		if (anchor.getAttribute("src")=='http://www.lascive.fr/thumb/'+id+".jpg"){
			mytitle = anchor.getAttribute("alt");
		}
	}


	//if (!document.getElementsByTagName){ return; }

	var objBody = document.getElementsByTagName("body").item(0);

		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		//objOverlay.onclick = function () {hideLightbox(); return false;}
		//objOverlay.style.display = 'block';
        objOverlay.style.left="0px";
        objOverlay.style.top="0px";
		objOverlay.style.position = 'absolute';
        objOverlay.style.width="100%";
		objOverlay.style.height=((arrayPageSize[1]+20) + 'px');
		objOverlay.style.zIndex="90";
		objBody.insertBefore(objOverlay, objBody.firstChild);
		//objBody.appendChild(objOverlay);


	var boxTop = arrayPageScroll[1] + (arrayPageSize[3] - 450);
	var boxLeft = (arrayPageSize[0] - 840);

	var objBox = document.createElement("div");
	objBox.setAttribute('id','box');
	objBox.style.top = boxTop + "px";
	objBox.style.left = boxLeft + "px";
	//objBox.style.display = 'block';
	objBox.style.position = 'absolute';
	objBox.style.zIndex = '100';
	objBox.style.padding="0px";
	objBox.style.width="624px";
	objBox.style.height="305px";
	objBox.style.background="transparent url(http://www.lascive.fr/images/box.gif) top center no-repeat";
	objBox.innerHTML = 'Inscription gratuite pour rencontrer '+mytitle;

	//objBody.appendChild(objBox);
	//objBody.insertBefore(objBox, objOverlay.nextSibling);
	objBody.insertBefore(objBox, objBody.firstChild);


	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	objLink.setAttribute('title','Cliquez pour fermez');
	objLink.onclick = function () {hideLightbox(); window.clearInterval(force); return false;}
	objBox.appendChild(objLink);

var imgPreloadCloseButton = new Image();
	imgPreloadCloseButton.onload=function(){

		var objCloseButton = document.createElement("img");
		objCloseButton.src = closeButton;
		objCloseButton.setAttribute('id','closeButton');
		objCloseButton.style.border = '0px';
		objCloseButton.style.zIndex = '200';
		objLink.appendChild(objCloseButton);

		return false;
	}

	imgPreloadCloseButton.src = closeButton;




var objIframe = document.createElement("iframe");
	objIframe.setAttribute('src','http://www.lascive.fr/box-inscription-'+id+'.htm');
	objIframe.setAttribute('id','myiframe');
	objIframe.style.width = '620px';
	objIframe.style.height = '265px';
	objIframe.style.margin = '10px 1px 0px 1px';



	objBox.appendChild(objIframe);
	//objBody.appendChild(objBox);
 force=window.setInterval("window.scrollTo(0,"+(boxTop-60)+")", 1);
}
