//
var btn_dev_over = new Image();
btn_dev_over.src = "img/" + lang + "/btn_devBg_over.jpg";
var btn_prod_over = new Image();
btn_prod_over.src = "img/" + lang + "/btn_produitBg_over.jpg";
var btn_kit_over = new Image();
btn_kit_over.src = "img/" + lang + "/btn_kitdevBg_over.jpg";
var btn_maison_over = new Image();
btn_maison_over.src = "img/" + lang + "/btn_maisonBg_over.jpg";



function addArrow(el) {
	$$(el + ' a[class=roll]').addEvents({
				'mouseover' : function() {
					parentNode = this.getParent('div');
					//alert(parentNode);
					//parentNode.setStyle('background-color', '#FFFFFF');
					
					parentNode.setStyle('background', 'url("img/btn_overMain.jpg") no-repeat');
					
					//rollOver(this, over);
				},
				'mouseout' : function() {
					parentNode.setStyle('background', 'none');
				}
			});
}


function addArrowSub(el, over) {
	$$(el + ' a[class=roll2]').addEvents({
				'mouseover' : function() {
					parentNode = this.getParent('div');
					//alert(parentNode);
					//parentNode.setStyle('background-color', '#FFFFFF');
					
					parentNode.setStyle('background', 'url("img/btn_subOver.jpg") no-repeat');
					
					//rollOver(this, over);
				},
				'mouseout' : function() {
					parentNode.setStyle('background', 'none');
				}
			});
}



function addRollOver(el, over) {
	$$(el + ' img[class=rollBtn]').addEvents({
				'mouseover' : function() {
					rollOver(this, over);
				},
				'mouseout' : function() {
					rollOver(this, over);
				}
			});
}

function rollOver(obj, over) {
	var path = obj.getProperty('src').split('/');
	var ind = path.length - 1;
	var file = path.getLast();

	file = file.split('.');

	if (file[0].indexOf(over) > -1) {
		path[ind] = file[0].replace(over, '') + '.' + file[1];
	} else {
		path[ind] = file[0] + over + '.' + file[1];
	}
	path = path.join('/');
	obj.setProperty('src', path);

}



 function changeMaison(id){
    		//alert(id);	

	 		var req = new Request.HTML({
				url : 'include/stripMaison.php?id=' + id,
				method : 'get',
				onComplete : function(tree, e, html, js) {
					$('stripMaison').set('html', html);
				}

			}).send();
			
			var req = new Request.HTML({
				url : 'include/linkMaison.php?idChangeMaison=' + id,
				method : 'get',
				onComplete : function(tree, e, html, js) {
					$('linkChangeMaison').set('html', html);
				}

			}).send();	
 }
  function changeRealisationThumb(id){
    		//alert(id);	

	 		var req = new Request.HTML({
				url : 'include/stripRealisation.php?id=' + id,
				method : 'get',
				onComplete : function(tree, e, html, js) {
					$('stripMaison').set('html', html);
				}

			}).send();
			
			var req = new Request.HTML({
				url : 'include/linkRealisation.php?idChangeMaison=' + id,
				method : 'get',
				onComplete : function(tree, e, html, js) {
					$('linkChangeMaison').set('html', html);
				}

			}).send();
	
 }
 
 function changeModele(id){
    		//alert(id);	

	 		var req = new Request.HTML({
				url : 'modele/modele'+id+'.html?'+Math.floor(Math.random()*11),
				method : 'get',
				onComplete : function(tree, e, html, js) {
					$('modeleMaison').set('html', html);
					//alert(html);
					milkbox.reloadGalleries();
				}

			}).send();
			return false;
	
 }
 
 


 function changeRealisation(id){
    		//alert(id);	
	 		var req = new Request.HTML({
				url : 'realisations/realisation'+id+'.html',
				method : 'get',
				onComplete : function(tree, e, html, js) {
					$('modeleMaison').set('html', html);
				}

			}).send();
	
 }

 
function flashHome(){
	swfobject.embedSWF("img/main_player.swf", "flashContainer", "695", "340", "9.0.0","",{},{menu:false,wmode:"transparent"},{});	
	//document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="695" height="325" id="main_player" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="main_player.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />	<embed src="main_player.swf" quality="high" bgcolor="#ffffff" width="695" height="325" name="main_player" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

function countdown(){
	swfobject.embedSWF("img/countdown.swf", "countdown", "300", "100", "9.0.0");		
}

function boutonVisiteImmersive(){
	swfobject.embedSWF("img/fr/btn_visiteimmersive.swf", "btnVisite", "208", "106", "9.0.0", "expressInstall.swf", {lienUrl:"particuliers/visites-virtuelles/"},{menu:false,wmode:"transparent"},{});	
}
function boutonVisiteImmersive2(){
	swfobject.embedSWF("img/fr/video-preview2.swf", "btnVisite2", "208", "150", "9.0.0", "expressInstall.swf", {lienUrl:"particuliers/visite-immersive2/"},{menu:false,wmode:"transparent"},{});	
}

function expertisePopupVideo(){
	swfobject.embedSWF("img/popup_player.swf", "expertiseVideo", "320", "240", "9.0.0");
}

/*var slideShow = function(){

	//stop the current animation if it is running.
    if($("slide1").fx){$("slide1").fx.cancel();}
    if($("slide2").fx){$("slide2").fx.cancel();}

    //Decide which div to hide and which to show.
    if(this.visibleDiv == $("slide1")){
        //fade the visible out and the hidden in.
        $("slide1").fx = new Fx.Tween($("slide1"), {property:'opacity', duration: 1000}).start(1, 0);
        $("slide2").fx = new Fx.Tween($("slide2"), {property:'opacity', duration: 1000}).start(0, 1);
        //Set which div is visible.
        this.visibleDiv = $("slide2");
    }else{
        //fade the visible out and the hidden in.
        $("slide1").fx = new Fx.Tween($("slide1"), {property:'opacity', duration: 1000}).start(0, 1);
        $("slide2").fx = new Fx.Tween($("slide2"), {property:'opacity', duration: 1000}).start(1, 0);
        //Set which div is visible
        this.visibleDiv = $("slide1");
    } 
}*/

window.addEvent('domready', function() {  
 	
 	addArrow('#menu');
 	addArrowSub('#menu');
 	
 	addRollOver('#tableHomeParticuliers', '_over');
 	
 	if ($('flashContainer')) {
		flashHome();
	}
 	if ($('btnVisite')) {
		boutonVisiteImmersive();
	}
	if ($('btnVisite2')) {
		boutonVisiteImmersive2();
	}
 	if ($('expertiseVideo')) {
		expertisePopupVideo();
	}
	
	if($('countdown')){
		countdown();
	}

	var visibleDiv = new Hash({visibleDiv: $("slide1")});
	//var slideShowEcologie = slideShow.periodical(4000, visibleDiv); 


});


