﻿$(document).ready(function() {
	$("img.input_submit").hover(function() {
		$(this).addClass("input_submit_hover");
	}, function() {
		$(this).removeClass("input_submit_hover");
	});
	$("input.input_submit").hover(function() {
		$(this).addClass("input_submit_hover");
	}, function() {
		$(this).removeClass("input_submit_hover");
	});	
	$(".main_menu ul li a img").hover(function() {
		$(this).attr("src", $(this).attr("src").replace(".gif", "_hover.gif"));
	}, function() {
		$(this).attr("src", $(this).attr("src").replace("_hover.gif", ".gif"));
	});
	$(".input_clear").focus(function() {
		if(this.value == this.defaultValue) {
			this.value = "";
		}
	}).blur(function() {
		if(!this.value.length) {
			this.value = this.defaultValue;
		}
	});
	$(".display_area .item_header a img").hover(function() {
		$(this).attr("src", $(this).attr("src").replace(".gif", "_hover.gif"));
	}, function() {
		$(this).attr("src", $(this).attr("src").replace("_hover.gif", ".gif"));
	});
	/*
	Must be language specific
	$(".submit_button").hover(function() {
		$(this).attr("src","/Style%20Library/images/lindab/button_order_hover.gif");
	}, function() {
		$(this).attr("src","/Style%20Library/images/lindab/button_order.gif");
	});
	*/
	$(".input_text").hover(function() {
		$(".input_submit").removeClass("input_submit_hover");
	}, function() {
		// VOID	(jQuery needs the callback to not throw an error)
	});
	/* NOt used
	$(".sub_navigation .lv1 a").hover(function() {
		$(this).parent().addClass("item_hover");
	}, function() {
		$(this).parent().removeClass("item_hover");
	});
	$(".sub_navigation .open a").hover(function() {
		$(this).parent().addClass("open_hover");
	}, function() {
		$(this).parent().removeClass("open_hover");
	});
	*/
	$(".dropdown_area .link_list li a").hover(function() {
		$(this).parent().addClass("link_list_hover");
	}, function() {
		$(this).parent().removeClass("link_list_hover");
	});
	$(".dropdown_area a").click(function() {
		$(this).attr("target","_blank");
	});
	$("#dropdown").click(function() {
		$(this).blur();
		showDropdown();
		return false;
	});
	showDropdown = function() {
		if($("#dropdown_area").is(".show")) {
			if($.browser.msie) {
				$("select").each(function() {
					$(".tab_row .tabs li").css("position","relative");
					$(".tab_row .tabs li").css("margin-top","0");
					$(".tab_row .tabs li").css("margin-bottom","0");
					var item_display = $(this).css("display");
					if(item_display == "none") {
						//$(this).show();
						//$(this).parents().find(".select_wrapper").removeClass("select_wrapper_active");
					}
				});
			}
			$("#dropdown").removeClass("dropdown_hover");
			$("#dropdown_area").removeClass("show");	
			$("#dropdown_area").css("display","none");		
		} else {
			if($.browser.msie) {
				$("select").each(function() {
					$(".tab_row .tabs li").css("position","static");
					$(".tab_row .tabs li").css("margin-top","1px");
					$(".tab_row .tabs li").css("margin-bottom","-1px");
					var item_display = $(this).css("display");
					if(item_display == "block") {
						//$(this).hide();
						//$(this).parents().find(".select_wrapper").addClass("select_wrapper_active");
					}
				});
			}
			$("#dropdown").addClass("dropdown_hover");
			$("#dropdown_area").addClass("show");
			$("#dropdown_area").css("display","block");
			var this_drop = document.getElementById("dropdown");
			var this_drop_left = this_drop.offsetLeft;
			var this_drop_height = this_drop.offsetHeight;
			$("#dropdown_area").css("left",this_drop_left-9);
			$("#dropdown_area").css("top",this_drop_height+12);
		}
	}
	var allSites = $("#dropdown");
	if(allSites.size() > 0) {
		$(document).bind("click",function(ev) {
			var target = ev.target;
			target = $(target);
			if($("#dropdown_area").is(".show")) {
				if(!target.is("#dropdown")) {
					if(!target.parents().is("#dropdown_area")) {
						showDropdown();
					}
				}
			}
		});
	}
});