﻿sfHover = function() {
	var sfEls = document.getElementById("navigation").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"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


var Vinter = {
	
	init: function()
	{
	    $('a[class=lightbox]').lightBox();
	    
	    $('a[class=projectlightbox]').lightBox();
	    
	    
	    
		 // 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);
		}
			
		if (typeof $().formHints == "function")
		{
			$("form").formHints({
				css_class: "preview-value",
				elements: ".text-hint"
			});
		}
		
		$("#searchForm .text").bind("focus", function() {
			 $(this).css({
				width: "180px"
			 });
		});
		
		$("#searchForm .text").bind("blur", function() {
			 $(this).css({
				width: "180px"
			 });
		});
		
		
		// Add >> to some links...
		$(".boxitem > a").append("<b>&nbsp;&rsaquo;&rsaquo;</b>");
		
		
		
		$('.movieplay').each(function() {
                     var $link = $(this);
                     var $dialog = $('<div></div>')
                        .load($link.attr('href') + ' #vrcontainer')
                        .dialog({
                            autoOpen: false,
                            title: $link.attr('title'),
                            width: 720,
                            modal: true,
					        buttons: {
						        "Stäng": function() { 
							        $(this).dialog("close"); 
						        }
						    }
                     });

                     $link.click(function() {
                        $dialog.dialog('open');

                        return false;
                     });
                });
		
	}
};
$(document).ready(Vinter.init);