/*POP UP*/
function popup(pop_url,pop_width,pop_height) {
	pop_left = (window.screen.availWidth / 2) - (pop_width / 2);
	pop_top = (window.screen.availHeight / 2) - (pop_height / 2);
	window.open(pop_url,"","left=" + pop_left + ",top=" + pop_top + ",width=" + pop_width + ",height=" + pop_height + ",scrollbars=yes,noresize");
}

/*FERME/OUVRE UN BLOC*/
function display_block(nom){
	if(document.getElementById(nom).style.display == 'none') document.getElementById(nom).style.display = 'block';
	else document.getElementById(nom).style.display = 'none';
}

/*FONCTION AJAX*/
function getXhr(){
	var xhr = null; 
	if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject){
		try{
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else{
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		xhr = false; 
	} 
	return xhr
}

/*AFFICHE AVEC AJAX*/
function ouvre_page(div,page,variable,type){
	var xhr = getXhr();
	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200){
			document.getElementById(div).innerHTML = xhr.responseText;
		}
	}
	xhr.open(type,page,true);
	if(type=="POST"){
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send(variable);
	}
	else xhr.send(null);
}

/*AFFICHE LES GRANDES PHOTOS REALISATIONS*/
function aff_photo(id){
	ouvre_page('bloc_gde_photo','realisation.php?aff_photo='+id,'','GET');
}

/*DIAPORAMA VISITE*/
var num_visite = 1;
function defil_visite(direction){
	if(direction=='last'){
		if(num_visite==1) num_visite = 12;
		else num_visite--;
	}
	else{
		if(num_visite==12) num_visite = 1;
		else num_visite++;
	}
	
	document.getElementById('photo_visite').src = 'imgs/visite/photo'+num_visite+'.jpg';
}

/*SCROLLBAR PHOTOS REALISATIONS
var Timer;
var Pas = 3;
function moveLayer(Sens) {
	Objet=document.getElementById("bloc_defil");
    if(parseInt(Objet.style.top) + (Pas*Sens)>0)  {
		clearTimeout(Timer);
	}
	else if(parseInt(Objet.style.top) + (Pas*Sens)<-(Objet.offsetHeight-document.getElementById("contenu_photo").offsetHeight)) {
		clearTimeout(Timer);
	}
    else {
        Objet.style.top = (parseInt(Objet.style.top) + (Pas*Sens)) + "px";
	}
	Timer = setTimeout("moveLayer(" + Sens + ");", 30);
}*/

/*BANDEAU HAUT ET DROITE*/
function fadeIn(id_img, opacity, direction) {
	if((direction=='plus' && opacity<100) || (direction=='moins' && opacity>0)) {
		if(direction=='plus') opacity = opacity+10;
		else opacity = opacity-10;
		
		document.getElementById(id_img).style.filter = "alpha(opacity:"+opacity+")";
		document.getElementById(id_img).style.KHTMLOpacity = opacity/100;
		document.getElementById(id_img).style.MozOpacity = opacity/100;
		document.getElementById(id_img).style.opacity = opacity/100;
		
		window.setTimeout( function() {
			fadeIn(id_img, opacity, direction);
		},100);
	}
}

function initImage(id_img, direction) {
	if(direction=='plus'){
		document.getElementById(id_img).style.display = 'block';
		fadeIn(id_img, 0, direction);
	}
	else{
		fadeIn(id_img, 100, direction);
		document.getElementById(id_img).style.display = 'none';
	}
}

function load_img(pos){
	initImage('bandeau_'+pos+'_'+compteur[pos], 'moins');
	if(compteur[pos]==4) compteur[pos] = 1;
	else compteur[pos]++;
	initImage('bandeau_'+pos+'_'+compteur[pos], 'plus');
	setTimeout("load_img('"+pos+"')",5000);
}

/*IMAGES PNG POUR IE < 7
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
if(version >= 5.5 && version < 7) {
	var listimg = document.getElementById('footer_liens')..getElementsByTagName('img');
	var newimg = "";
	for(i=0;i<listimg.length;i++){
		newimg = "<span style=\"width:" + img.width + "px;height:" + img.height + "px;display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "', sizingMethod='scale');\"></span>";
		listimg[i].outerHTML = newimg;
	}
}
*/

