﻿/**
* Site specific namespace
*/
var Vinter = {
	
	activateMenu: function()
	{
		var m = /.+\/([^_-]+).*\.aspx/.exec(document.location.href);
		var f = m != null ? m[1].toLowerCase() : "default";
		$("#" + f + " > a").addClass("active");

		$("#subnav li a").each(function(i, o) {
			if (o.href && o.href.toLowerCase() == document.location.href.toLowerCase())
				$(o).addClass("active");
		});
	},
	
	externalLinks: function() 
	{
		$("a[rel=external]").each(function(i, item)	{
			$(item).click(function(e) {
				window.open(this.href, "external");
				return false;
			});
		});
	},
	
	initProductNavigation: function() 
	{	  	  	  
                
      $('#productNavigation ul').hide();
           
      // open active category
      $('#productNavigation li.active').parent().show();            
      
      $('#productNavigation li a').click(
        function() {
          var theElement = $(this).next();
          if((theElement.is('ul')) && (theElement.is(':visible'))) {
            return false;
            }
          if((theElement.is('ul')) && (!theElement.is(':visible'))) {
            $('#productNavigation ul:visible').slideUp('normal');
            theElement.slideDown('normal');
            return false;
            }
          }
        );                
    }
     
};

/**
* Onload inits
*/

$(document).ready(function() {
    
    // Append class to body if IE < 7
    // Do this so we don't need conditional comments
    if($.browser.msie === true && parseInt($.browser.version) <= 6)
    {
        $("body").addClass("png8");
        document.execCommand('BackgroundImageCache', false, true);
    }
   
	Vinter.activateMenu();
	Vinter.externalLinks();
	Vinter.initProductNavigation();
   
});