﻿/**
* 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;
			});
		});
	},

	gallery: function()
	{
	
		if ("#slides")
		{
	
			$("#slides").cycle({
				fx: "scrollLeft"
			});

			$("#gallery-playpause").toggle(function(e) {

				$("#leftcol").css("display", "none");
				
				$(this).css({
					backgroundPosition: "0 -20px"
				}).blur();
				
				$("#rightcol")
					.animate({
						width: "787px"
					}, 300, function() {
					
						$("#slides").css("display", "block")
						$("#slides").cycle("resume");
						
						
					});
								
			//soundManager.play("loop");
					
			},
			function(e) {
				
				
				//soundManager.pause("loop");
			
				$(this).css({
					backgroundPosition: "0 0"
				}).blur();
				
				$("#rightcol")
					.animate({
						width: "190px"
					}, 300, function() {
						$("#leftcol").fadeIn();
					});
					
				$("#slides").cycle("pause");
				
			});
			
		
		}
	}

};

/**
* 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.gallery();
    Vinter.activateMenu();
    
    // Fix target="_blank"
    $(".popup").click(function(e) {
		window.open(this.href, "mywin" + Math.random());
		return false;
    });
});
