


var $j=jQuery.noConflict();





$slideshow = {
    context: false,
    tabs: false,
    timeout: 3000,      // time before next slide appears (in ms)
    slideSpeed: 1000,   // time it takes to slide in each slide (in ms)
    tabSpeed: 300,      // time it takes to slide in each slide (in ms) when clicking through tabs
    fx: 'scrollDown',   // the slide effect to use
    
    init: function() {
        // set the context to help speed up selectors/improve performance
        this.context = $j('#slideshow');
        
        // set tabs to current hard coded navigation items
        this.tabs = $j('ul.slides-nav li', this.context);
        
        // remove hard coded navigation items from DOM 
        // because they aren't hooked up to jQuery cycle
        this.tabs.remove();
        
        // prepare slideshow and jQuery cycle tabs
        this.prepareSlideshow();
    },
    
    prepareSlideshow: function() {
        // initialise the jquery cycle plugin -
        // for information on the options set below go to: 
        // http://malsup.com/jquery/cycle/options.html
        $j('div.slides > ul', $slideshow.context).cycle({
            fx: $slideshow.fx,
	
   
            timeout: $slideshow.timeout,
            speed: $slideshow.slideSpeed,
            fastOnEvent: $slideshow.tabSpeed,
            pager: $j('ul.slides-nav', $slideshow.context),
            pagerAnchorBuilder: $slideshow.prepareTabs,
            before: $slideshow.activateTab,
            pauseOnPagerHover: true,
            pause: true
        });            
    },
    
    prepareTabs: function(i, slide) {
        // return markup from hardcoded tabs for use as jQuery cycle tabs
        // (attaches necessary jQuery cycle events to tabs)
        return $slideshow.tabs.eq(i);
    },

    activateTab: function(currentSlide, nextSlide) {
        // get the active tab
        var activeTab = $j('a[href="#' + nextSlide.id + '"]', $slideshow.context);
        
        // if there is an active tab
        if(activeTab.length) {
            // remove active styling from all other tabs
            $slideshow.tabs.removeClass('on');
            
            // add active styling to active button
            activeTab.parent().addClass('on');
        }            
    }            
};


$j(function() {
    // add a 'js' class to the body
    $j('body').addClass('js');
    
    // initialise the slideshow when the DOM is ready
    $slideshow.init();
});  








$j(document).ready(function(){
 //Les éléments de contents en mode corner
//$("div#footer").corner("bottom 8px");
//$("div#infosContent").corner("5px");
//$("div#content").corner("top 5px");
$j("div#contenu").corner("top 5px");
$j("div#menu_droite").corner("top 5px");
$j("div.ruban, div#rubanSlide").corner("lr 5px");
$j("div.menu_droite_titre").corner("5px");
$j("div#ranges div.grid_6").corner("tr  Bevelfold 25px");
$j("div.menu_droite").corner("bottom 2px");

$j('#defile_forum').vTicker({ 
		speed: 1000,
		pause: 2000,
		animation: 'fade',
		mousePause: true,
		showItems: 3,
		 direction: 'down',
	});
	
	
	$j('#defile_breves').vTicker({ 
		speed: 800,
		pause: 3000,
		animation: 'fade',
		mousePause: true,
		showItems: 2,
		 direction: 'down',
	});
// information tweet


var tweet= {
	id: 'maisondomotique', 
	count: 5, 
	enableLinks: true, 
	ignoreReplies: true, 
	clearContents: true,
	newwindow:true,
	callback:move()
	};
getTwitters('tweet', tweet);


// mouvement

function move () {
 
var info = $j("div#tweet");
var coordL=info.css("marginLeft");

if(coordL=="670px")
	
	{
		info.animate({marginLeft:-4100}, 155000, 'linear', function (){
			
			$j(this).animate({opacity:0}, 1000, 'linear', function (){
			$j(this).css({marginLeft:670, opacity:1});
			move();
		});
		});
	
	
	}
}


 



/*Partenaire Web LMD
******************************************************************************************/
var btnDroite=$j("#slidePartenaireDroite");
var btnGauche=$j("#slidePartenaireGauche");
var ulPartenaire=$j("#partenaireContent ul");

var nombreElementLi=$j("#partenaireContent ul li").length;
var longueurElementLi=$j("#partenaireContent ul li").outerWidth(true);
var resultatElement= nombreElementLi*longueurElementLi;
ulPartenaire.css({"width":resultatElement});
var resultElement= Math.floor(resultatElement/(longueurElementLi*4));// permet de savoir le nombre de défilement
var max=resultElement;
var avance=0;
var longueur=longueurElementLi*4;
//var temps=resultElement;
var bool=true;
//
setInterval(mForward, 8000);


function mForward () {	
	
	if (bool) 
	{
		nextPartenaire();
		resultElement-=1;
		if(resultElement==0)
		{
		bool=false;
		}
		
	}else{
		previousPartenaire();
		resultElement+=1;		
		if(resultElement==max)
		{
		bool=true;
		}
	};
	

}


function nextPartenaire ()
{
	
	avance-=longueur;
	ulPartenaire.animate({marginLeft:avance},2000,'linear');
	

}


function previousPartenaire () {
	
		
	avance+=longueur;
	ulPartenaire.animate({marginLeft:avance},2000,'linear');
}




/* Gerer les boutons en places
*********************************************************************************************/


btnDroite.click(function(){
	
	if (resultElement!=0) {
	nextPartenaire();
	resultElement-=1;
	}else
	{
	bool=false;
	};
	
})

btnGauche.click(function(){
	if (resultElement!=max) {
	previousPartenaire();
	resultElement+=1;
	}else
	{
	bool=true;
	};
})


/*Effacer l'élément de base dans le "champs" Recherche.
********************************************************************************************************/

var search= document.getElementById("search");
search.onfocus= function ()
{
	
	if(this.defaultValue== this.value)
	{
	this.value=" ";
	}
}

var searchOut=$j("#recherche");

searchOut.bind("clickoutside", function(){

search.value="Rechercher...";
})





/*nautraliser le formulaire
*********************************************************************************************/

// déclarations des variables
var formu= $j("#formulaire");
var link=$j("#link");
var linkA=$j("#unique");
var domoStyleBlock= {
display:"block",
position:"absolute",
width:"170px",
height:"180px",
"background-color":"white",
"margin-top":"-2px",
"border-left":"1px dashed #999", 
"border-bottom":"1px dashed #999",
"border-right":"1px dashed #999",
"z-index":"999"
};

var domoStyleInline= 
{
	display:"none"
}




link.mouseover(function()
{
	formu.css(domoStyleBlock);
	link.css({background:"white"});
	linkA.css({color:"green"});
});


formu.bind("clickoutside", function(){

formu.css(domoStyleInline);
link.css({background:"none"});
linkA.css({color:"#EDECE9"});
})


});// end of script 



/* Les fonctions créees par maison domotique
*********************************************************/
function form_win(f,ima,w,h)
{
         var l=window.screen.width-w-8;
         ima += '?q=';
         ima += escape(document.forms[f].q.value);
         ima += '&interface=';

         for( var i=0;i<document.forms[f].elements['interface'].length;i++)
         {
                 if( document.forms[f].elements['interface'][i].checked==true)
                 {
                         ima += document.forms[f].elements['interface'][i].value;
                 }
         }
         ima += '&cible=';
        ima += document.forms[f].elements['cible'].value;
     
         mywin = window.open(ima,'','toolbar=1,location=0,directories=1,status=0,menubar=1,scrollbars=1,resizable=1,width='+w+',height='+h+',top=0,left='+l); 
         mywin.focus();
}

function mailto(id, sujet){
	var url="/mailto.php?id="+id;
	if (sujet != undefined) { var url = url + "&sujet="+sujet; }
	window.open(url, 'email', 'toolbar=no, location=no, menubar=no, scrollbars=yes, resizeable=yes, width=420, height=480, top=10, left=10');
}

function mailtopro(id, sujet) {
	var url="/mailtopro.php?id="+id;
	if (sujet != undefined) { var url = url + "&sujet="+sujet; }
	window.open(url, 'email', 'toolbar=no, location=no, menubar=no, scrollbars=no, resizeable=yes, width=420, height=480, top=10, left=10');
}





