/* 
 * Fonctions javascripts lancement automatique accueil
 * 
 */

/*
 * Lancement general des animations et controle viewport
 *
 */



function anim_pub(){

 var flashvars = {
  page: "Accueil",
  name2: "world",
  name3: "foobar"
 };

 var params = {
  wmode: "transparent"
 };

 var attributes = {
  id: "myDynamicContent2",
  name: "myDynamicContent2"
 };

 var new_flash = new swfobject.embedSWF("http://www.carabosses.fr/animations/anim_accueil.swf", "anim_accueil", "320", "97", "9.0.0",
 "expressInstall.swf", flashvars, params, attributes);


//draw_overlay();
}


function draw_overlay(){
 var objBody = $$('body')[0];
 objBody.appendChild(Builder.node('div',{id:'overlay'}, [
            Builder.node('div',{id:'flash_header'}),
            Builder.node('div',{id:'flash_box'}),
            Builder.node('div',{id:'flash_footer'})
      ]));
      var arrayPageSize = getPageSize();
      var bas = arrayPageSize[1] - 600;
        
        $('flash_box').setStyle({ height: '150px', margin: bas + 'px 0 30px 0' });
        $('flash_box').innerHTML = "<div id='flash_content'></div>";
        $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });
        $('overlay').appear({ duration: 2, fps:25, from: 0.50, to: 0.90 });

anim_intro();

     }

function anim_intro(){
     var flashvars = {
  page: "Accueil",
  name2: "world",
  name3: "foobar"
 };

 var params = {
  wmode: "transparent"
 };

 var attributes = {
  id: "myDynamicContent2",
  name: "myDynamicContent2"
 };

 var new_flash2 = new swfobject.embedSWF("http://www.carabosses.fr/animations/anim_accueil.swf", "flash_content", "320", "97", "9.0.0",
 "expressInstall.swf", flashvars, params, attributes);

 $('flash_header').innerHTML = "<div id='close_intro' >Passer l'intro</div>";
 $('close_intro').observe('click', kill_ajax);

}

     function getPageSize() {

	     var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY) {
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;

		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth;
			} else {
				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) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}

		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		}

		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){
			pageWidth = xScroll;
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	}


function kill_ajax(event){

    var overlay = document.getElementById("overlay");
    var ancienfond = $$('body')[0].removeChild(overlay);



}



/*
 *
 * Ecouteur General on dom loaded
 */

document.observe('dom:loaded', anim_pub);
