jQuery(document).ready(function() {
	if(jQuery(".content_image").length > 0){
		jQuery(".content_image").fancybox();
	}
	
	if(jQuery(".fancybox-image").length > 0){
		jQuery(".fancybox-image").fancybox();
	}
	
	if(jQuery(".gallery a").length > 0){
		jQuery(".gallery a").fancybox();
	}
	
	if(jQuery(".fancybox_gallery").length > 0){
		jQuery(".fancybox_gallery").fancybox();
	}
	
	if(jQuery("ul.sf-menu").length > 0){
		jQuery('ul.sf-menu').superfish({onHide:function() {Cufon.refresh();}});
	}
	
	if(jQuery(".portfolio_album").length > 0){
		jQuery('.portfolio_album').cycle({
		    fx: 'scrollHorz',
		    prev: '.previous_step',
		    next: '.next_step',
		    nowrap:  1,
		    easing: 'easeOutCirc',
		    after:   onAfter,
		    timeout: 0
		});
	}
	
	if(jQuery(".slider-homepage").length > 0){
		jQuery('.slider-homepage').cycle({
			fx: 'scrollHorz',
		    timeout:  4000,
		    random: true,
		    prev: '.prev',
		    next: '.next'
		});
	}
	
	if(jQuery(".portfolio-album").length > 0){
		jQuery('.portfolio-album').cycle({
			fx: 'scrollHorz',
		    timeout:  5000,
		    prev: '.portfolio-prev',
		    next: '.portfolio-next'
		});
	}
	
	if(jQuery("#contact_banner").length > 0){
		if (jQuery(window).width() < 1152) {
			jQuery('#contact_banner').hide();
		}
	}
	
	if(jQuery(".portfolio-album a").length > 0){
		jQuery('.portfolio-album a').mouseover(function (){ 
			jQuery('.portfolio-album .zoomin').css('background-position', '0 -558px');
		});
	}
	
	if(jQuery(".portfolio-album a").length > 0){
		jQuery('.portfolio-album a').mouseleave(function (){ 
			jQuery('.portfolio-album .zoomin').css('background-position', '-30px -558px');
		});
	}
	
	var pakket = jQuery.getUrlVar('pakket');
	jQuery('#' + pakket).attr("checked", true);
});



var isSafari3 = false;
 
if( window.devicePixelRatio &&  window.getMatchedCSSRules ){
	//you need 	put html {list-style-image:none;} in yout Safari 3 only stylesheet first
	//we detect whether if it's Safari 3 by checking if it read some Safari 3 only styles 
	isSafari3  =  !!window.getMatchedCSSRules(document.documentElement,'');
}

if (isSafari3) {
	var headID = document.getElementsByTagName("head")[0]; 
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = '/css/safari.css';
	cssNode.media = 'screen';
	headID.appendChild(cssNode);
}

if (jQuery.browser.opera) {
    var headID = document.getElementsByTagName("head")[0]; 
    var cssNode = document.createElement('link');
    cssNode.type = 'text/css';
    cssNode.rel = 'stylesheet';
    cssNode.href = '/css/safari.css';
    cssNode.media = 'screen';
    headID.appendChild(cssNode);
}

jQuery.extend({
	getUrlVars: function(){
		var vars = [], hash;
	    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	    for(var i = 0; i < hashes.length; i++) {
	    	hash = hashes[i].split('=');
	      	vars.push(hash[0]);
	      	vars[hash[0]] = hash[1];
	    }
	    return vars;
	},
  	getUrlVar: function(name){
    	return jQuery.getUrlVars()[name];
	},
	random: function(X) {
		return Math.floor(X * (Math.random() % 1));
  	},
  	randomBetween: function(MinV, MaxV) {
		return MinV + jQuery.random(MaxV - MinV + 1);
  	}
});

function fadeOut (case_id) {
	jQuery('#case_' + case_id + ' .black_opacity').fadeOut(300);
	jQuery('#case_' + case_id + ' .more_info').css('background-position', '-27px -532px');
	jQuery('#case_' + case_id + '').mouseleave(function (){ 
		jQuery('#case_' + case_id + ' .black_opacity').fadeIn(300); 
		jQuery('#case_' + case_id + ' .more_info').css('background-position', '0 -532px');
	});
}

function onAfter(curr, next, opts) {
	var index = opts.currSlide;
	jQuery('.previous_step')[index == 0 ? 'hide' : 'show']();
	jQuery('.next_step')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}




// Open External Links as Blank Targets via Unobtrusive JavaScript
// http://perishablepress.com/press/2007/11/20/open-external-links-as-blank-targets-via-unobtrusive-javascript/

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (
			anchor.getAttribute("href") && ( 
			anchor.getAttribute("rel") == "external" || 
			anchor.getAttribute("rel") == "external nofollow" || 
			anchor.getAttribute("rel") == "nofollow external" )
			)
		anchor.target = "_blank";
	}
}
window.onload = function() {
	externalLinks();
}



function ie_function() {
/*@cc_on @*/
/*@if (@_jscript_version < 5.7)
// JavaScript Document
/*

 

Correctly handle PNG transparency in Win IE 5.5 & 6.

http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.



Use in <HEAD> with DEFER keyword wrapped in conditional comments:

<!--[if lt IE 7]>

<script defer type="text/javascript" src="/js/pngfix.js"></script>

<![endif]-->



*/



var arVersion = navigator.appVersion.split("MSIE")

var version = parseFloat(arVersion[1])



if ((version >= 5.5) && (document.body.filters)) 

{

   for(var i=0; i<document.images.length; i++)

   {

      var img = document.images[i]

      var imgName = img.src.toUpperCase()

      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")

      {

         var imgID = (img.id) ? "id='" + img.id + "' " : ""

         var imgClass = (img.className) ? "class='" + img.className + "' " : ""

         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "

         var imgStyle = "display:inline-block;" + img.style.cssText

         if (img.align == "left") imgStyle = "float:left;" + imgStyle

         if (img.align == "right") imgStyle = "float:right;" + imgStyle

         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle

         var strNewHTML = "<span " + imgID + imgClass + imgTitle

         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"

         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"

         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 

         img.outerHTML = strNewHTML

         i = i-1

      }

   }

}
/*@end @*/
}



