﻿/**
* 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;
			});
		});
	}
};

jQuery.fn.hasClass = function(c) {
 return this.is('.'+c)
};

/**
* 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();
 	 	
 	// set active image
    $(function() {
        
        // clear all
        
        $('.cross-link').click(function()
        {                            
            $('.cross-link').removeClass('current');   
        });
        
        // set active on click        
        
        $('#img1').bind('click', function() {
            if(! $('#img1').hasClass('current') )
            {
                $('#img1').addClass('current');
            }
        });
        
        $('#img2').bind('click', function() {
            if(! $('#img2').hasClass('current') )
            {
                $('#img2').addClass('current');
            }
        });
        
        $('#img3').bind('click', function() {
            if(! $('#img3').hasClass('current') )
            {
                $('#img3').addClass('current');
            }
        });
        
        $('#img4').bind('click', function() {
            if(! $('#img4').hasClass('current') )
            {
                $('#img4').addClass('current');
            }
        });                
          
    });
  
});
