var j = jQuery.noConflict();

var flashvars = {};

// -------------------[ each page initialize function is here
 
Pages = {
	
	homeswf: function() {
				
		/*j('#stage_home')
		    .prepend('<div id="flashcontent"></div>');*/
				
		var params = {
			quality: "high",
			scale: "noscale",
			wmode: "transparent",
			allowscriptaccess: "always",
			base: "/Speedstick/PE/X5/swf/"
		};
		
		var flashvars = {
			swfPath: "VideoCarousel.swf"
			};
		
		var attributes = {
			id: "flashcontent",
			name: "flashcontent"
		};
		
		if(swfobject.hasFlashPlayerVersion("10")){
			/*j('#SC-content #content #stage_home').css({'height':'376px'});*/
			swfobject.embedSWF("/Speedstick/PE/X5/swf/GenericLoader.swf", "flashcontent", "1020", "800", "10", "/Speedstick/PE/X5/swf/expressInstall.swf", flashvars, params, attributes);
		}else {
			j('#SC-content #content #stage_home').css({'height':'650px'});
		}
		
	}, 
	
	
	homejs:function(){
		j('#main-content').css('display', 'block');
		j('#stage_home')
		    .prepend('<div id="cnt_slider"><div id="slideshow"><div id="slidesContainer"><div class="slide" id="slide0"><a href="#" ><img src="img/img_slider/seco.png" width="980" height="419" /></a></div><div class="slide" id="slide1"><p><a href="#" ><img src="img/img_slider/no_irrita.png" width="980" height="419"/></a></p> </div><div class="slide" id="slide2"><p><a href="#"><img src="img/img_slider/sin_residuos.png" width="980" height="419"/></a></p></div><div class="slide" id="slide3"><a href="#" ><img src="img/img_slider/fresco.png" width="980" height="419" /><div class="slide" id="slide4"><a href="#" ><img src="img/img_slider/limpio.png" width="980" height="419" /></a></div></a></div></div>');
		    
	},
	
	detectDevice: function(){
		// android
		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf('iphone') > 0 || ua.indexOf('ipod') > 0 || ua.indexOf('android') > 0 || ua.indexOf('ipad') > 0){
			  Pages.menu_();
			  Pages.homejs();
		}else{
			Pages.menu();
			Pages.homeswf();
		}
	},

	menu_: function(){
		j(".top5").click(
		  function () {
		    j(".top5_top").fadeIn(0,
				  function () {
				    j(".top5_top").delay(3000).fadeOut(0);
				  }
		    	);
		  	}
		 );
		  
		j("#callouts_bottom .right").click(
		  function () {
		    j(".top5_down").fadeIn(0,
				  function () {
				    j(".top5_down").delay(3000).fadeOut(0);
				  }
		    	);
		  	}
		);

		j("#callouts_bottom_product .right").click(
		  function () {
		    j(".top5_down").fadeIn(0,
				  function () {
				    j(".top5_down").delay(3000).fadeOut(0);
				  }
		    	);
		  	}
		);
		
	},
	
	menu: function(){
		j(".top5").hover(
		  function () {
		    j(".top5_top").fadeIn(0);
		  },
		  function () {
		    j(".top5_top").fadeOut(0);
		  }
		  
		 );
		  
		j("#callouts_bottom .right").hover(
		  function () {
		    j(".top5_down").fadeIn(0);
		  },
		  function () {
		    j(".top5_down").fadeOut(0);
		  } 
		);
		
		j("#callouts_bottom_product .right").hover(
		  function () {
		    j(".top5_down").fadeIn(0);
		  },
		  function () {
		    j(".top5_down").fadeOut(0);
		  } 
		);
		
	}

};


//Run the fn method
function run(fn){
	if(typeof(fn) == 'function') {
		fn();
	}
}

//Trace
function trace(obj){
	if (window['console']) {
		console.log(obj)
	}
}

j(document).ready(function() {

	Pages.detectDevice();
	//return Pages[page] ? Pages[page]() : null;
	
});

j(function () {
			var ProductsTabs = j('div#tabs-products > div._product');
			ProductsTabs.hide().filter(':first').show();
			
			j('div#tabs-products ul.tabNav a').click(function () {
				ProductsTabs.hide();
				ProductsTabs.filter(this.hash).show();
				j('div#tabs-products ul.tabNav a').removeClass('selected');
				j(this).addClass('selected');
				return false;
			}).filter(':first').click();
		});



