// Function for Launching SWF Object for the Flash BG video
/*
function toggle_flash(session_count, themovie) {

	var flashvars = {};
	flashvars.session_count = session_count;
	flashvars.themovie = themovie;
	var params = {};
	params.wmode = "opaque";
	params.bgcolor = "#000000"; 
	var attributes = {};
	attributes.id = "flash_engine";
	swfobject.embedSWF("./swf/fullscreen.swf", "source-image-strech", "100%", "100%", "10.0.0", false, flashvars, params, attributes);
	
}
*/



// This function is for resizing the video or image to crop properally on the HTML page
function resize_the_video(){
	
	// Variables to be used throughout this code
	 var current_w = $(window).width();
	 var current_h = $(window).height();
	 
	
	 		  // IF IE6, run this additional code
	  		  if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7) {
				  var ie_fix_for_layout = (current_w - 760)/2;
				  $("#abb_promotional_image").css({'left' : ie_fix_for_layout, 'position' : 'absolute', 'z-index' : '10' });
				  
			  } else {
				  $('#yellow_box').css({"height" : $(document).height() });
			  }
			 
	 
	 //For Main Page
		 if (current_h >= 900) {
		 	var main_metal_height = ((current_h /2) + 134) + "px";
		 	var main_promo_height = ((current_h /2) - 400) + "px";
		 	var main_feature_height = (current_h - 900)/2.5 + "px";
			
			$("#metal_table_main_page").css({'height' : main_metal_height});
		 	$("#abb_promotional_image").css({'padding-top' : main_promo_height});
			$("#sub_main_features").css({'margin-top' : main_feature_height});
			
			
		 } else {
			$("#metal_table_main_page").css({'height' : "580px"});
			 $("#abb_promotional_image").css({'padding-top' : "48px"}); 
		 }
		
	
	// For The Footer
		var footer_div_height = $("#footer").height() + 12;
		var footer_height = ($(document).height() - footer_div_height) + "px";
		
		$("#footer").css({"width" : (current_w - 12) + "px", "display" : "block" });
		
		if ($("#source-image-clip").length) { /* This one is in place just for the checkout pages and text pages */
			$("#footer").css({"top" : footer_height, "width" : (current_w - 12) + "px", "display" : "block", "float" : "none", "position" : "absolute", "left" : "0", "padding" : "2px 5px 5px 5px"});
			
			$(window).scroll(function () { 
			  var footer_div_height = $("#footer").height() + 12;
		      var footer_height = ($(document).height() - footer_div_height) + "px";
			  $("#footer").css({"top" : footer_height});
			  $(window).unbind('scroll');
			});
		
		} else if($(window).height() >= $(document).height()) {
			$("#footer").css({"top" : footer_height, "width" : (current_w - 12) + "px", "display" : "block", "float" : "none", "position" : "absolute", "left" : "0", "padding" : "2px 5px 5px 5px"});
		} else if ( (( $(window).height() + 20) >= $(document).height()) && $(window).height() >= 800 && jQuery.browser.msie && parseInt(jQuery.browser.version) <= 8 ) {
			$("#footer").css({"top" : footer_height, "width" : (current_w - 12) + "px", "display" : "block", "float" : "none", "position" : "absolute", "left" : "0", "padding" : "2px 5px 5px 5px"});
		}
	
	
	
	// Offset variables for Product Pages
	var metal_offset = 240;
	var product_offset = metal_offset - 541;
	
	
	

	// My Super Awesome Fluid Scalable Layout
	if (current_h < 790) {
		 
		  $("#source-image").css({'height' : '701px', 'width' : '935px', 'margin-left' : '2px'});
		  if (current_w > 1200) {  
		  	$("#metal_table").css({'width' : '67%', 'height' : '605px', 'margin-left' : '2px'});
		  } else {
			 $("#metal_table").css({'width' : '958px', 'height' : '605px', 'margin-left' : '2px'}); 
		  }
		  $("#product_container").css({'margin' : '62px 0 0 20px'});
		  $("#product_container_checkout").css({'margin' : '62px 0 0 20px'});
		  $("#product_container_larger").css({'margin' : '62px 0 0 20px'});
		  
		   $("#side_nav_smaller").css({'width' : '213px'});
		   
		    $("#source-image-noscale").css({'height' : 'auto', 'width' : 'auto'});
		  
	
	 } else if (current_w > 1400 && current_h > 1020) {
		 
		 $("#source-image").css({'height' : '750px', 'width' : '1000px', 'margin-left' : '4%'});
		    var new_metal_height =  metal_offset + (current_h/2) + "px";
			var new_product_height = product_offset + (current_h /2) + "px 0 0 20px";
			var new_product_height_checkout = (current_h /8) + "px 0 0 20px";
			
		 $("#metal_table").css({'width' : '1400px', 'height' : new_metal_height, 'margin-left' : '2px'});
		 $("#product_container").css({'margin' : new_product_height});
		  $("#product_container_checkout").css({'margin' : new_product_height_checkout});
		 $("#product_container_larger").css({'margin' : new_product_height});
		 
		 var new_smaller_nav_width = (current_w - 1050) + 213;
		 
		 if (new_smaller_nav_width > 213 && new_smaller_nav_width < 300) {
			 $("#side_nav_smaller").css({'width' : new_smaller_nav_width});
			 
		 } else {
		 
		 	$("#side_nav_smaller").css({'width' : '300px'});
		 
		 }
		 
		 $("#source-image-noscale").css({'height' : 'auto', 'width' : '1200px'});
		 
		 
	 } else if (current_w > 1400 && current_h <= 1020) {
		 
		 $("#source-image").css({'height' : '675px', 'width' : '900px', 'margin-left' : '4%'});
		 	var new_metal_height =  metal_offset + (current_h/2) + "px";
			var new_product_height = product_offset + (current_h /2) + "px 0 0 20px";
			var new_product_height_checkout = (current_h /8) + "px 0 0 20px";
			
		 $("#metal_table").css({'width' : '1400px', 'height' : new_metal_height, 'margin-left' : '2px'});
		 $("#product_container").css({'margin' : new_product_height});
		 $("#product_container_checkout").css({'margin' : new_product_height_checkout});
		 $("#product_container_larger").css({'margin' : new_product_height});
		 
		 var new_smaller_nav_width = (current_w - 1050) + 213;
		 
		 if (new_smaller_nav_width > 213 && new_smaller_nav_width < 300) {
			 $("#side_nav_smaller").css({'width' : new_smaller_nav_width});
			 
		 } else {
		 
		 	$("#side_nav_smaller").css({'width' : '300px'});
		 
		 }
		 
		  $("#source-image-noscale").css({'height' : 'auto', 'width' : 'auto'});
		 
	 } else if (current_w > 1050 && current_h > 900) {
		 
		 $("#source-image").css({'height' : 'auto', 'width' : '76%', 'margin-left' : '4%'});
		 	var new_metal_height =  metal_offset + (current_h/2) + "px";
			var new_product_height = product_offset + (current_h /2) + "px 0 0 20px";
			var new_product_height_checkout = (current_h /8) + "px 0 0 20px";
			
		 $("#metal_table").css({'width' : '98%', 'height' : new_metal_height, 'margin-left' : '2px'});
		 $("#product_container").css({'margin' : new_product_height});
		 $("#product_container_checkout").css({'margin' : new_product_height_checkout});
		 $("#product_container_larger").css({'margin' : new_product_height});
		 
		 var new_smaller_nav_width = (current_w - 1050) + 213;
		 
		 if (new_smaller_nav_width > 213 && new_smaller_nav_width < 300) {
			 $("#side_nav_smaller").css({'width' : new_smaller_nav_width});
			 
		 } else {
		 
		 	$("#side_nav_smaller").css({'width' : '300px'});
		 
		 }
		 
		  $("#source-image-noscale").css({'height' : 'auto', 'width' : 'auto'});
		 
	 } else if (current_w > 1050) { 
	 
		$("#source-image").css({'height' : '701px', 'width' : '935px', 'margin-left' : '6%'});
			var new_metal_height =  metal_offset + (current_h/2) + "px";
			var new_product_height = product_offset + (current_h /2) + "px 0 0 20px";
			var new_product_height_checkout = (current_h /8) + "px 0 0 20px";
			
		 $("#metal_table").css({'width' : '98%', 'height' : new_metal_height, 'margin-left' : '2px'});
		 $("#product_container").css({'margin' : new_product_height});
		 $("#product_container_checkout").css({'margin' : new_product_height_checkout});
		 $("#product_container_larger").css({'margin' : new_product_height});
		 
		 var new_smaller_nav_width = (current_w - 1050) + 213;
		 
		 if (new_smaller_nav_width > 213 && new_smaller_nav_width < 300) {
			 $("#side_nav_smaller").css({'width' : new_smaller_nav_width});
			 
		 } else {
		 
		 	$("#side_nav_smaller").css({'width' : '300px'});
		 
		 }
		
		 $("#source-image-noscale").css({'height' : 'auto', 'width' : 'auto'});
	 } else {
		  $("#source-image").css({'height' : '701px', 'width' : '935px', 'margin-left' : '2px'});
		  $("#metal_table").css({'width' : '98%', 'height' : '605px', 'margin-left' : '2px'});
		  $("#product_container").css({'margin' : '62px 0 0 20px'});
		  $("#product_container_checkout").css({'margin' : '62px 0 0 20px'});
		  $("#product_container_larger").css({'margin' : '62px 0 0 20px'});
		  $("#side_nav_smaller").css({'width' : '213px'});
		  $("#source-image-noscale").css({'height' : 'auto', 'width' : 'auto'});
	 }
	 
	 
// Min Width fixes for IE 
	if (current_h < 790 && current_w  > 1200) {
		  
		  $("#source-image").css({'height' : '701px', 'width' : '935px', 'margin-left' : '2px'});
		  $("#metal_table").css({'width' : '1100px'});
		  
		  $('#content_container').css({'width' : '100%'});
		  
		  var new_smaller_nav_width = (current_w - 1050) + 213;
		 
			 if (new_smaller_nav_width > 213 && new_smaller_nav_width < 300) {
				 $("#side_nav_smaller").css({'width' : new_smaller_nav_width});
				 
			 } else {
			 
				$("#side_nav_smaller").css({'width' : '300px'});
			 
			 }
		  
		  //$('#basic_layout_container').css({'width' : '958px'});
		  //$('#checkout_container').css({'width' : '958px'});
		  //$('#metal_table_main_page').css({'width' : '958px'});
		

	} else if (jQuery.browser.msie &&  parseInt(jQuery.browser.version) < 7 && current_w  < 980) {
	
		  $("#source-image").css({'height' : '701px', 'width' : '935px', 'margin-left' : '2px'});
		  $("#metal_table").css({'width' : '958px'});
		  $("#side_nav_smaller").css({'width' : '213px'});
		  
		  $('#content_container').css({'width' : '960px'});
		  $('#basic_layout_container').css({'width' : '958px'});
		  $('#checkout_container').css({'width' : '958px'});
		  $('#metal_table_main_page').css({'width' : '958px'});
	 
	 
	 } else  if (jQuery.browser.msie && current_w  < 962) {
	
		  $("#source-image").css({'height' : '701px', 'width' : '935px', 'margin-left' : '2px'});
		  $("#metal_table").css({'width' : '958px'});
		  $("#side_nav_smaller").css({'width' : '213px'});
		  
		  $('#content_container').css({'width' : '960px'});
		  $('#basic_layout_container').css({'width' : '958px'});
		  $('#checkout_container').css({'width' : '958px'});
		  $('#metal_table_main_page').css({'width' : '958px'});
		
	 } else {
		 $('#content_container').css({'width' : '100%'});
		 $('#basic_layout_container').css({'width' : '98%'});
		 $('#checkout_container').css({'width' : '98%'});
		 $('#metal_table_main_page').css({'width' : '98%'});
	 }
	 
	 
	 
	 //ADDITIONS FOR THE LIGHTBOX STUFF
	 		var top_height_one = $(window).height() / 2;
			var top_height_two = $("#lightbox-image").height() / 2;
			var new_top_height = top_height_one - top_height_two - 95 ;
			
			if(new_top_height < 35) {
				$('#lightbox-image-container').css({"top" : "35px"});
			} else {
				new_top_height = Math.round(new_top_height) + "px"
				$('#lightbox-image-container').css({"top" : new_top_height});
			}
}

	
// Functions launched on window resize	
$(window).resize(function() {
			
	resize_the_video();
 
});

function on_exp_menu(q_on_thing)
{
	//$(q_on_thing).removeAttr("href");
	$(q_on_thing).find("ul").slideToggle(100);		
}


// This is what launches once DOM is ready (the color changing BG and everything)
$(document).ready(function() {
					
	/* Launch the Site Resize code */				
	resize_the_video();
	
	// =========================================== 
	// MAIN NAVIGATION FOR THE SITE
	// =========================================== 
	
	$("#main_nav > li").hover(								 
		function() { 
			$('> a', this).css({'border-bottom' : '2px dotted #ffc425', 'margin-bottom' : '0px'});
			$('ul li', this).show();
			$('ul', this).slideDown(240, "easeOutExpo", function(){ $(this).css({'display' : 'block'}); }); 
		},								 
		function() { 
			$('> a', this).css({'border-bottom' : '0px', 'margin-bottom' : '2px'});
			$('ul li', this).fadeOut(200,"easeInOutSine"); 
			$('ul', this).slideUp(160, "easeInOutSine", function(){ $(this).css({'display' : 'none'}); }); 
		}								 		
	 );
	/* -- End of main navigation code -- */
	
	
});

