// FENDER MUSICAL INSTRUMENTS CORPORATION
// DESIGN/CODE: JEREMY W. SMITH (w/ extra help)


jQuery(function() {
	jQuery('a[name=modal]').click(function(e) {
		e.preventDefault();
		var id = jQuery(this).attr('href');
		var maskHeight = jQuery(document).height();
		var maskWidth = jQuery(window).width();
		jQuery('#mask').css({'width':maskWidth,'height':maskHeight});
		jQuery('#mask').fadeTo("fast",0.8);
		var winH = jQuery(window).height();
		var winW = jQuery(window).width();
		jQuery(id).css('top',  winH/2-jQuery(id).height()/2);
		jQuery(id).css('left', winW/2-jQuery(id).width()/2);
		jQuery(id).fadeIn(1000);
		if(jQuery(this).attr('id') == "loginModal") { jQuery('#login_focus').focus().select(); }
	});

	//if close button is clicked
	jQuery('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		jQuery('#mask').hide();
		jQuery('.window').hide();
	});

	//if mask is clicked
	jQuery('#mask').click(function () {
		jQuery(this).hide();
		jQuery('.window').hide();
	});
})

//GLOBAL SEARCH MODULE
jQuery(document).ready(function() {
			 jQuery(".search").click(function(e) {          
				e.preventDefault();
                jQuery("fieldset#search_menu").toggle();
				jQuery(".search").toggleClass("menu-open");
            });
			jQuery("fieldset#search_menu").mouseup(function() {
				return false
			});
			jQuery(document).mouseup(function(e) {
				if(jQuery(e.target).parent("a.search").length==0) {
					jQuery(".search").removeClass("menu-open");
					jQuery("fieldset#search_menu").hide();
				}
			});		
        });
  
  
// SOCIAL NETWORKING FADE MODULE
jQuery(function () {
    jQuery(".footer_social a").css("opacity", "1.0");
    jQuery(".footer_social a").hover(function () {
        jQuery(this).stop().animate({
            opacity: 0.5
        }, "medium");
    },
    function () {
        jQuery(this).stop().animate({
            opacity: 1.0
        }, "slow");
    });	
});


// GLOBAL CLEARN ALL FIELDS
function clearField(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
	}
	

// GLOBAL LANGUAGE SELECTOR MODULE
jQuery(document).ready(function() {
	jQuery("#lang_menu").hide();
	// Expand 
	jQuery("#open_lang").click(function(){
		jQuery("div#lang_menu").slideDown("fast");
	});	
	// Collapse 
	jQuery("#close_lang").click(function(){
		jQuery("div#lang_menu").slideUp("fast");	
	});		
	// Open / Close 
	jQuery("#lang_toggle a").click(function () {
		jQuery("#lang_toggle a").toggle();
	});		
});
	
	
//<!-- ADDTHIS BUTTON BEGIN -->
var addthis_config = {
         username: "fender",
         ui_cobrand: "Fender&reg;"
}

function navHover() {
	// JavaScript DocumentnavHover = function() {
		var lis = document.getElementById("navmenu-h").getElementsByTagName("LI");
        nav_overlay = document.getElementById("bg");
		for (var i=0; i<lis.length; i++) {
			lis[i].onmouseover=function() {
				this.className+=" iehover";
	                        nav_overlay.style.display = "block";
			}
			lis[i].onmouseout=function() {
	                        this.className=this.className.replace(new RegExp(" iehover\\b"), "");
	                        nav_overlay.style.display = "";
			}
		}
	}


/*
  Special navigation menu support for IE 6 only.
 */
var IE6 = (navigator.userAgent.indexOf("MSIE 6") > -1 ? 1 : 0);

if(IE6) {
	//if (window.attachEvent) window.attachEvent("onload", navHover);
	jQuery(document).ready(function(){
        over = function() { 
                jQuery("#bg").css({display:"block"});
                jQuery(this).addClass("iehover");
        }
        out = function() { 
                jQuery("#bg").css({display:""});
                jQuery(this).removeClass("iehover");
        }
        jQuery("#navmenu-h li").hover(over, out);//hover
        
		//Activate PNG fix
		jQuery(document).pngFix(); 
	        
	});
}

