﻿/**
* 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;
			});
		});
	}
};

var Naiden = {
	
	initAccordion: function() 
	{                
      $('.accordion ul').hide();
           
      // open active category
      $('.accordion li.current').parent().show();
      
      $('.accordion li a').click(
        function() {
          var theElement = $(this).next();
          if((theElement.is('ul')) && (theElement.is(':visible'))) {
            return false;
            }
          if((theElement.is('ul')) && (!theElement.is(':visible'))) {
            $('.accordion 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)
    {
        // Add png8 to body... 
        $("body").addClass("png8");
        document.execCommand('BackgroundImageCache', false, true);
    }
   
	Vinter.activateMenu();
	Naiden.initAccordion();
   
});
