﻿/**
* 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");

       
		$("#mainnav li a").each(function(i, o) {
			if (o.href && o.href.toLowerCase() == document.location.href.toLowerCase())
			{
				$(o).addClass("active");
			}
		});
		
		
		$("#menu li a").each(function(i, o) {
			if (o.href && o.href.toLowerCase() == document.location.href.toLowerCase())
			{
				$(o).addClass("active");
			}
		});
		
		
	},
	
	sfHover: function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
},
	
	externalLinks: function() 
	{
		$("a[rel=external]").each(function(i, item)	{
			$(item).click(function(e) {
				window.open(this.href, "external");
				return false;
			});
		});
	},
	
	activateLightbox: function() 
	{
	    $(function() {
	        $('a[@rel*=1]').lightBox({fixedNavigation:true});
	        $('a[@rel*=2]').lightBox({fixedNavigation:true});
	        $('a[@rel*=3]').lightBox({fixedNavigation:true});
        });
    }
};

/**
* 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();
	//Vinter.activateLightbox();
   
});
