// features.js

var features = ({
   init: function(){

   	var urls = ["/images/nav/subnav-cargo_on.png", "/images/nav/subnav-comfort_on.png","/images/nav/subnav-exterior_on.png","/images/nav/subnav-mobile-office_on.png","/images/nav/subnav-overview_on.png","/images/nav/subnav-performance_on.png","/images/nav/subnav-specs_on.png","/images/buttons/get-answers_on.png","/images/features/magnify.jpg"];
   	$.preload(urls);
      
      //Magnifying Glass for Thumbs
      $(".largeImg a").mouseover(function(){
      		$(this).append("<img class='mag' src='/images/features/magnify.jpg' />");
      });
      
      $(".largeImg a").mouseout(function(){
      		$(".mag", this).remove();
      });
      
      //Magnifying Glass for Hero
      $("#hero-img a").mouseover(function(){
      		$(this).append("<img class='mag' src='/images/features/magnify.jpg' />");
      });
      
      $("#hero-img a").mouseout(function(){
      		$(".mag", this).remove();
      });
      

      //Magnifying Glass for Thumbs
      $(".gallery .thumb a").mouseover(function(){

      			$(this).append("<img class='mag' src='/images/features/magnify.jpg' />");				
      
      });
      
      $(".gallery .thumb a").mouseout(function(){
      		$(".mag", this).remove();
      });
      
      var loc = $("title").text();
      
      features.callCrmEvent(loc);
      
   },
   setupFlash: function(){
      
      // set up flash if we're on v9
      var playerVersion = swfobject.getFlashPlayerVersion();
      
		if(playerVersion.major >= 9){

   		var params = {
   			menu: "false",
   			scale: "noScale",
   			allowScriptAccess: "always",
   			wMode: "transparent"
   		};

   		var flashvars = {
   		   imageLocation: "/images/features/threesixty/",
   		   swfLocation: "/includes/swf/threesixty/"
   		};
   		
   		var attributes = {
   			id:"features",
   			name:"features"
   		};

      	swfobject.embedSWF("/includes/swf/App360.swf", "feature-holder", "960", "430", "9.0.0","expressInstall.swf", flashvars, params, attributes);


      }else{

         $("#feature-holder").css({visibility: "visible"});         

      }
      
      
      
      
      
   },
   callCrmEvent: function(page){
      switch(page){
         case "Nissan NV Lineup Cargo Area":
            crmEvent4(true);
         break;
         case "Nissan NV Lineup Cabin Comfort":
            crmEvent5(true);
         break;
         case "Nissan NV Lineup Exterior":
            crmEvent6(true);
         break;
         case "Nissan NV Lineup Mobile Office":
            crmEvent3(true);
         break
         case "Nissan NV Lineup Performance":
            crmEvent2(true);
         break;
         case "Nissan NV Lineup Specifications":
            crmEvent8(true);
         break;
         default:
            // default to index
            crmEvent1(false,false,true,false);
         break;
      }
      
      
   }
});