/*global $ */
window.Alienware = window.Alienware || {};
Alienware.com = Alienware.com || {};
Alienware.com.microsite = Alienware.com.microsite || {};
Alienware.com.microsite.holiday_2009 = function(params) {
    /**
    * @param {String}       params.something      	any var received
    */

	//this.something = params.something || "default value";
	
    this.initialize();
	
}


Alienware.com.microsite.holiday_2009.prototype = {
    initialize: function() {
        
		$this = this;
		
		//$this.initEyeFlash();
		$this.initTabs();
		//$this.initTabExpansionWindows();
		$this.initLightBox();
		$this.initLinkBox();
        	
    },
	
	initTabs: function() {
		var currentActiveTab = $(".tabs a:first");
		var currentActiveRow = $(".productTabs .productRowGroup:first");

		function changeTab(tab,row) {
			if ($(currentActiveRow) != $(row)) {
				$(currentActiveRow).css("display","none");
				$("span",currentActiveTab).removeClass("active");
			}
			
			$(row).css("display","block");
			$("span",tab).addClass("active");
			
			currentActiveTab = tab;
			currentActiveRow = $(row);
		}
		
		function setupTabs(){
			// commented out tab expand arrows for the disable of dropdown function
			var $rowGroup = $('.productTabs .productRowGroup');
			
			$rowGroup.each(function(){
				//$('.productTabs a.tab_1 span').append("<span class='expand'></span>");
				$('.row:not(:first)',$(this)).css("display","none");											  
			});
						
			$('.productTabs .specsExpand a').css("display","block");
		}
		
		setupTabs();
		
		var $tabs = $('.tabs a');
		
		$tabs.each(function(intIndex){
			$(this).bind("click", function(e){
				e.preventDefault();	
				
				var $rowGroup = $(".productTabs .productRowGroup").eq(intIndex); 
				changeTab(this,$rowGroup);
			
				if ($("span.active",this).length > 0) {
					$(".row:not(:first)",$rowGroup).slideDown(); //changed from slideToggle and moved below changeTab to disable dropdown function
				}
			
			});
		});
						
	},
	
	initTabExpansionWindows: function() {
		function expandWindow(obj){
			$(".specsExpand",obj).click(function(e){
				e.preventDefault();	
				$(".specsWindow",obj).slideDown();
				$(".specsCollapse",obj).css("display", "block");
				$(".specsCollapse a",obj).css("display","block");
			});
			$(".specsCollapse a",obj).click(function(e){
				e.preventDefault();	
				$(".specsWindow",obj).slideUp();
				$(".specsCollapse",obj).css("display", "none");
				$(".specsCollapse a",obj).css("display","none");
			});	
		}
		
		$(".row li").each(function(){
			expandWindow(this);
		});

	},
	
	initEyeFlash: function() {	
		var flashvars 	= {};
		var params 		= { bgcolor: "#000000", base: 'http://image.alienware.com/images/microsite/holiday_2009/flash/', allowscriptaccess: "always", wmode: "transparent" };
		var attributes 	= { };
		
		swfobject.embedSWF( "http://image.alienware.com/images/microsite/holiday_2009/flash/flash_eye_holiday.swf", "eyeContainer", "1450", "700", "9.0.0","expressInstall.swf", flashvars, params, attributes );
		
		//position flash
		$('#eyeContainer').css({
			left: "-250px",
			top: "0px"
		});

    },
	
	initLightBox: function() {
		$('#Map area').lightBox();
		$('#Map2 area').lightBox();
		$('#perfChart').lightBox();
	},

	initLinkBox: function() {
		
	}

};


$(document).ready(function() {

	new Alienware.com.microsite.holiday_2009({});
	
});
