$(document).ready(function() {
  // navigation
	if(!navigator.userAgent.match(/Android/i) &&
	 !navigator.userAgent.match(/webOS/i) &&
	 !navigator.userAgent.match(/iPhone/i) &&
	 !navigator.userAgent.match(/iPod/i) &&
	 !navigator.userAgent.match(/BlackBerry/)
	 ){
		$('#navigation').kMenu({delay:200,boundDelay:true});
	}
  
  // Blog item expand
  $(".invisible").hide();
  
  $open = false;
  $(".navlink").click(function(){
	  $open = true;
  });
  
  
  $(".blogItem").click(function() {
	//get atribute
	//alert($("this.p").attr('rel'));
	/*if($("this.p").attr('rel') == 'open'){
	  
	  
	  $("this.p").attr('rel','closed');
	  alert($("this.p").attr('rel'));
	  } else {
		 
		  
		  $("this.p").attr('rel','open');
		  alert($("this.p").attr('rel'));
		  }*/
	if(!$open){
		if ($('p.invisible.fullText', this).css('display') == "none"){
			//alert($('p.invisible.fullText').css('display'));
		//$("p.invisible.fullText", this).show(600);
		
		$("p.introText", this).css('display','none');
		$("p.invisible.fullText", this).css('display','inline');
		//$("p.introText", this).slideUp("slow");
		//$("p.invisible.fullText", this).slideDown("slow");
		
		$("p.invisible.navlink", this).css('display','inline');
		//$("p.invisible.navlink", this).slideDown("slow");
		$("p.readMore a", this).html('Minder tekst');
		
		}else{
		//$('p.invisible.fullText').hide(600);
	
			$("p.introText", this).css('display','inline');
			$("p.invisible.fullText", this).css('display','none');
	
			//$("p.introText", this).slideDown("slow");
			//$("p.invisible.fullText", this).slideUp("slow");
		//$("p.invisible.navlink", this).slideUp("slow");
		$("p.invisible.navlink", this).css('display','none');
		$("p.readMore a", this).html('Meer tekst');
		}
		//$("p.invisible.fullText", this).show(600);
		
		//$("p.navlink", this).hide(600);
		//$("p.invisible.navlink", this).show(600);
	}
	$open = false;
  });
  
  // actionbox
  $("div.actionbox").hover(function() {
    $(this).addClass("roundedbox-dark1");
    $(this).css("cursor", "pointer");
    //window.status=$(this).find("p.navlink a").attr("href");
  }, function() {
    $(this).removeClass("roundedbox-dark1");
    //$(this).css("cursor", "default");
    //window.status="";
  });
  
  $("div.actionbox:not(.noClickAction)").click(function() {
    window.location=$(this).find("p.navlink a").attr("href"); return false;
  });
  
  // slides
  $("div.slides dl.slide dt").click(function () {
    var visible = !$(this).parent("dl").hasClass("active");			
    $(this).parents("div.slides").find("dl").each(
      function() {
        if ($(this).hasClass("active")) {
          $(this).removeClass("active");
          $(this).find("dd").slideUp("slow");
        }
      }
    );
    
    if (visible) {
      $(this).parent("dl").addClass("active");
      $(this).next("dd").slideDown("slow");
    }
  });
  
  // shadowbox
  $("a[rel='shadowbox']").click(function(){
    setTimeout(function() {
      if ($("#sb-nav-previous").css("display")=='none'){
        $("#sb-nav-first,#sb-nav-last").css("display","none");
      }
    }, 900);
  });
});

//Shadowbox.loadSkin('classic', 'scripts/shadowbox/skin'); // use the "classic" skin
//Shadowbox.loadLanguage('en', 'scripts/shadowbox/lang'); // use the English language
//Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], '/~siteDesign/site/~js/shadowbox/player');
Shadowbox.init({
  players: ['img', 'swf', 'flv', 'qt', 'wmp', 'iframe', 'html'],
  skipSetup: false,
  overlayColor: '#ffffff',
  overlayOpacity: 0.7,
  continuous: false,
  animSequence: 'sync',
  slideshowDelay: 3
});

// +++++++++++++++++++++ //

function first(){
  Shadowbox.change(0);
}

function last(){
  Shadowbox.change($records-1);
}
;
function resizeText(multiplier) {
  //if (document.getElementById('colMain').style.fontSize == "") {
  //document.getElementById('colMain').style.fontSize = "1.0em";
  //}
  document.getElementById('colMain').style.fontSize = multiplier+"em"; //parseFloat(document.getElementById('colMain').style.fontSize) + (multiplier * 0.2) + "em";
}

function showShadowBoxPopup(urlToShow, width, height) {
  //alert('bam');
  if (width == undefined){
    width = 350;
  }
  
  if (height == undefined){
    height = 350;
  }
  
  Shadowbox.open({
    content:urlToShow,
    player: "iframe",
    title:"",
    height: height,
    width:width,
    displayNav:false,
    displayCounter: false
  });
};
