if (navigator.plugins) {
for (i=0; i < navigator.plugins.length; i++ ) {
if (navigator.plugins[i].name.indexOf
("QuickTime") >= 0)
{ haveqt = true; }
}
}

if ((navigator.appVersion.indexOf("Mac") > 0)
&& (navigator.appName.substring(0,9) == "Microsoft")
&& (parseInt(navigator.appVersion) < 5) )
{ haveqt = true; }
if (haveqt == false) alert("In order to fully enjoy this site's content you'll need to install a recent version of the Quicktim Plugin at www.quicktime.com")
var otliam = function(name,domain,tld){
	$('.mail_link').each(function(el){el.href = "mai"+"lto:"+name+"@"+domain+"."+tld})
}


// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};
/*
 * Jonathan Howard
 *
 * jQuery Pause
 * version 0.2
 *
 * pause() will hold everything in the queue for a given number of milliseconds,
 * or 1000 milliseconds if none is given.
 *
 * unpause() will clear the queue of everything of a given type, or 'fx' if no
 * type is given.
 */

$.fn.pause = function(milli,type) {
	milli = milli || 1000
	type = type || "fx"
	return this.queue(type,function(){
		var self = this
		setTimeout(function(){
			$.dequeue(self)
		},milli)
	});
};

$.fn.clearQueue = $.fn.unpause = function(type) {
	return this.each(function(){
		type = type || "fx"
		if(this.queue && this.queue[type]) {
			this.queue[type].length = 0
		}
	})
}
/*
 * JQuery Pause End
 */
/*
 * NKN_LOADING by David Esteves
 */
var loading = {
	status : "hidden",
	lock:false,
	elapsed : 0,
	poll:"",
	width:0,
	hide : function(){
		loading.status = "hidden"
		$("#loading").hide()
		clearInterval(loading.poll)
	},
	show : function(lock){
		if(!$("#loading").is(':visible')){
			var window_width = ($(".frame.front img").length > 0) ? $(".frame.front img").width() : $(window).width()-320
			// console.log("wid::"+window_width)
			var window_center = $(window).width()/2
			loading.status = "loading"
			$("#loading").show()
			loading.poll = setInterval(function(){
				loading.elapsed = (loading.width >= window_width) ? 0 : loading.elapsed
				loading.width = Math.floor((loading.elapsed*window_width)/1600)
				loading.new_width(loading.width,window_center)
				loading.elapsed += 20
			},20)
		}
	},
	timed : function(t){
		var window_width = $(window).width()
		var window_center = $(window).width()/2
		loading.status = "loading"
		$("#loading").show()
		loading.poll = setInterval(function(){
			if(loading.width >= window_width){
				loading.hide()
			}else{
				loading.width = Math.floor((loading.elapsed*window_width)/t)
				loading.new_width(loading.width,window_center)
				loading.elapsed += 20
			}
		},20)
	},
	new_width : function(loading_width,window_center){
		$("#loading div")[0].style.width = loading_width+"px"
		$("#loading div")[0].style.left = Math.floor(window_center - loading_width/2)+"px"
	}
}
/*
 * END NKN_LOADING
 */
/*
 * NKN_START by David Esteves
 */
var document_title = document.title;
if($("#intro_link")){
	$("#intro_link").click(function(ev){
		ev.preventDefault();
		show_copyright(this);
	})
}
var show_copyright = function(e){
	if($(e).is(".show_copyright")) {
		$("#intro_overlay").remove()
		loading.hide()
		return false
	}
	$("#intro_content").slideUp("slow").parent().css({'width':'100px','height':'80px'}).append("<div class='copyright'>"+$("#intro_link").html()+"</div>")
	$(e).addClass("show_copyright")
	loading.timed(4500)
	$("#intro_overlay").pause(4500).slideUp("slow")
}
loading.show()
function getUrlVars(url) {
	var vars = {};
	var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
		vars[key] = value;
	});
	return vars;
}
var site
var gets = getUrlVars(window.location.href)
$(function(){
	if (typeof(intro_url) != "undefined"){
		var flashvars = {
		  file: intro_url,
		  controlbar: "none",
		  screencolor: "000000",
		  skin: "js/beelden/beelden.xml",
		  autostart: "true",
		  repeat: "always"
		};
		var params = {
		  allowfullscreen: "true"
		};
		var attributes = {
		  id: "fl",
		  name: "fl"
		};

		swfobject.embedSWF("js/player.swf", 'intro_video', '720','405','9',"js/expressInstall.swf", flashvars, params, attributes);
	}
	$("#main_title").click(function(e){ 
		if(e.altKey){
			load_content("adm/login_form.php")
		} else {
			$.History.go("selected_work")
		}
	})
	$.getJSON("site.json",function(data){
		site = data
	});
	$.History.bind(function(state){
		// console.log("GETS_PAGE::"+gets.page)
		// console.log("GETS_STATE::"+state)
		if($("#fl_vid").length>0) swfobject.removeSWF("fl_vid");
		
		if ((!gets.page || (gets.page != state)) || (gets.page || (gets.page == state))){
			loading.show()
			load_content("pages/"+state+".php")
			// console.log("STATE::"+state)
			var sure_state = state.split("-")
			// var sure_state = (state.match(/-/))? state.replace(/([^ ]+)-([^ ]+)/i,"$1,$2").split(",") : [state]
			// console.log("SURE_STATE::"+sure_state)
			var menu_item = $("#nav a[href='#"+sure_state[0]+"']")
			var page_title = (!_.isElement(menu_item)) ? state : menu_item.html().replace(/\w+/g, function(a){
	    	    return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
	    	})
			if (gallery.items.length > 0){ 
				var sure_state_id = (sure_state[0] == "limited_acces") ? sure_state[2] : sure_state[1]
				// console.log("LEGEND_SURE_STATE::"+sure_state_id)
				// console.log("LEGEND_GET_ITEM::"+gallery.get_item(sure_state_id))
				var legend = (gallery.get_item(sure_state_id) != false ) ? gallery.get_item(sure_state_id)[0].desc :""
				if(legend.length > 80){
					legend = legend.substr(0, 80).split(" ")
					legend.remove((legend.length-1),-1)
					legend = legend.join(" ")+"..."
				}
			}
			page_title = (sure_state[0] != state) ? page_title+ ((gallery.items.length > 0) ? " - "+legend : "") : page_title
			document.title = document_title + ' | ' + page_title
		}
	});
	var hash = $.History.getHash()
	if((!hash || hash == "home" ) && !gets.page){
		$.History.go("selected_work")
	}
	if(gets.page != $.History.hash){
		
		$(document.body).addClass("text")
	}
	content_resize()
	loading.hide()
})
/*
 * END NKN_START
 */
/*
 * NKN_WINDOW_RESIZE by David Esteves
 */
$(window).resize(function(){content_resize()})

var content_resize = function (){
	var content_height = $(window).height() - $("#header").height() - 29 - parseInt($("#content").css('padding-top'))-parseInt($("#content").css('padding-bottom'))
	$("#content").css({'height':(content_height < 400) ? "400px" : (content_height > 1200) ? "1200px" : content_height+'px'}) 
	if($("#legend").length > 0) gallery.padder()
}
/*
 * END NKN_WINDOW_RESIZE
 */
/*
 * NKN_NAV by David Esteves
 */
var actual_content = "start"
var load_content = function(e){
	e = content_url(e)
	var tmp_content = (e.match(/^pages\//)) ? e.replace(/^pages\/([^ ]+)\.php$/,"$1") : "other"
	var tmp_content_split = tmp_content.split("-")
	tmp_content = (tmp_content_split.length >2) ? tmp_content_split[0]+"-"+tmp_content_split[1] : tmp_content
	// console.log("TMP_CONTENT_0::"+tmp_content)
	// console.log("TMP_CONTENT_LENGTH::"+tmp_content.split("-").length)
	if(tmp_content.match(/-/)){
		requested_content = tmp_content.split(/-/)
		var re = new RegExp(requested_content[0],"i")
		// console.log("ACTUAL_CONTENT_1::"+actual_content)
		if(actual_content.match(re) && requested_content[0] != "limited_access"){
			tmp_content = actual_content
			// console.log("TMP_CONTENT_1::"+tmp_content)
			if(document.body.className == "images") gallery.load(requested_content[1])
		}else{
			var req = e.split(/\-|\./)
			// console.log("R::"+r)
			
			// var req = e.replace(/^([^ ]+)-([^ ]+)\.([^ ]+)/,"$1,$2,$3").split(",")
			// console.log("REQ::"+req)
			if(req[0].match(/limited_access/)){
				// console.log("LIMITED")
				if(req.length > 3 && actual_content != "start"){
					// console.log("LIMITED_GALLERY_LOAD::"+req[2])
					gallery.load(req[2])
				}else if(req.length > 3 && actual_content == "start"){
					req_first_image = req[2]
					ajax_load(req[0]+"."+req[3]+"?limited_serie_id="+req[1])					
					gallery.unload()
				}else{
					ajax_load(req[0]+"."+req[2]+"?limited_serie_id="+req[1])
				}
			}else{
				// console.log("ELSE::"+req[0]+"."+req[2])
				req_first_image = req[1]
				ajax_load(req[0]+"."+req[2])
				tmp_content = tmp_content.replace(/^([^ ]+)\-([^ ]+)/,"$1")
				gallery.unload()
				// console.log("TMP_CONTENT_2::"+tmp_content)
				
			}
		}
	}else{
		if(actual_content != tmp_content) gallery.unload()
		ajax_load(e)
	}
	// console.log("ACTUAL_CONTENT_2::"+actual_content)
	// console.log("TMP_CONTENT_3::"+tmp_content)
	actual_content = tmp_content
	// console.log("ACTUAL_CONTENT_3::"+actual_content)
	
}
var content_url = function(e){
	return e
}
var ajax_load = function(e){
	console.log(e)
	$.ajax({
		type: "GET",
		url: e,
		cache: true,
		data: "partial=true",
		success: function(html){
			type = (html.match(/^\<ul\ class=\"gallery_items/)) ? "images" : "text"
			type = (e.match(/limited_access$/)) ? "limited" : type;
			var contentClass = (e.match(/limited_access$/)) ? "limited" : type;
			$(document.body).removeClass($(document.body).attr("class")).addClass(contentClass)
			if (e.match(/^pages\//)){
				var menu_el = $("#nav a[href='#"+actual_content+"']")
				$("#nav .active").each(function(){$(this).removeClass("active")})
				if(menu_el.parents("li")) menu_el.parents("li").each(function(){$(this).addClass("active")})
				menu_el.parent().addClass("active")
			}else{
				$("#nav .active").each(function(){$(this).removeClass("active")})
			}
			display[type](html)
			content_resize()
		}
	})
}
/*
 * END NKN_NAV
 */
/*
 * NKN_CONTENT_DISPLAY by David Esteves
 */
var display = {
	text : function(html){
			$("#content").html("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:100%;height:95%;\"><tr><td style=\"width:100%;height:100%;vertical-align:middle;text-align:center\">"+html+"</td></tr></table>")
		loading.hide()
	},
	images : function(html){
		if ( html.match(/^\<ul/)){
			$("#controls .items").empty().html(html)
			$("#content").empty().hide()
			gallery.start()
		}else{
			display.text(html)
		}
		// loading.hide()
	},
	slideshow : function(html){
		$("#content").html(html)
		loading.hide()
	},
	limited : function(html){
		$("#content").html(html)
		loading.hide()
	}
}
/*
 * END NKN_CONTENT_DISPLAY
 */
/*
 * NKN_PHOTO_GALLERY by David Esteves
 */
var req_first_image = false
var gallery = {
	items : [],
	count : 0,
	item : 0,
	keytemp : 1,
	keytempo : 1,
	key_activity : false,
	status : "stop",
	actual_image : new Image(),
	start : function(){
		gallery.prepare()
	},
	prepare :function(){
		$("#controls .gallery_items a").each(function(){
			var _p = (this.href.match(/\&r\=/)) ? this.href.replace(/([^ ]+)i\=([^ ]+)\&t\=([^ ]+)\&r\=([^ ]+)/,("$2,$3,$4")).split(",") : this.href.replace(/([^ ]+)i\=([^ ]+)\&t\=([^ ]+)/,("$2,$3")).split(",")
			gallery.items.push({
				el : $(this),
				href : ( this.href.match(/(&t=)(flv|mp4|m4v)$/) ? this.href.split("?i=")[0] : this.href.split("&t=")[0] ),
				id : _p[0],
				ratio : _p[2],
				desc : $(this).html(),
				type : ( _p[1].match(/(jpg|png|gif)/)) ? "img" : ( _p[1].match(/(mov|flv|mp4|m4v)/) ? _p[1] : ( _p[1].match(/(html|txt)/)) ? "txt" : false)
			})
			$(this).click(function(i,e){
				i.preventDefault()
				$.History.go(actual_content+"-"+_id)
			})
			gallery.count++
		})

		$("#controls .slide_show").live("click",function(){
			$("#header").addClass("slideshow")
			$(this).removeAttr("class").addClass("slide_hide")
			content_resize()
		})
		$("#controls .slide_hide").live("click",function(){
			$("#header").removeClass("slideshow")
			$(this).removeAttr("class").addClass("slide_show")
			content_resize()
		})
		$("#content").html("<div class=\"frame front\"></div><div class=\"frame back\"></div><div class=\"mask\"></div><div id=\"legend\" style=\"display:none\"></div>").find(".mask").css({cursor:"pointer"}).click(function(e){
			if(e.pageX > ($("#content").width()/2)){
				gallery.next()
			}else{
				gallery.prev()
			}
		}).mousemove(function(e){
			if(e.pageX > ($("#content").width()/2) && gallery.keytemp < gallery.count){
				if(!$(this).is(".next")){
					$(this).removeClass("prev").addClass("next")
					setTimeout(function(){$(".mask").removeClass("next")},3000);
				}
			}else if(gallery.keytemp > 1){
				if(!$(this).is(".prev")){
					$(this).removeClass("next").addClass("prev")
					setTimeout(function(){$(".mask").removeClass("prev")},3000);
				}
			}
		}).mouseout(function(e){
			$(this).removeClass("prev").removeClass("next")
		})
		gallery.controls()
		gallery.keyboard_control()
		$("#content .front").hide()
		// $("#legend").mouseenter(function(){
		// 	if($("#legend").html().length > 1) $(this).addClass("hover")
		// }).mouseleave(function(){
		// 	$(this).removeClass("hover")
		// })
		if(gallery.items[0]){
			var first_image = (req_first_image) ? req_first_image : gallery.items[0].id
			gallery.load(first_image)
			gallery_ids = []
			$.each(gallery.items, function(i,v){
				gallery_ids.push(v.id)
			})
			gallery.keytemp = $.inArray(first_image,gallery_ids)+1
		}else{
			$("#content").html("There's nothing to display for the moment, please come back later.")
		loading.hide()
		}
		$("#content").fadeIn(1800)

	},
	get_item : function(id){
		// console.log("GALLERY_GET_ITEM::"+id)
		// console.log("GALLERY_GET_ITEM_ITEMS::"+gallery.items)
		return jQuery.grep(gallery.items,function(item){
			return (item.id == id) ? item : false
		})
	},
	monitor : function(disp){
		$("#controls .monitor").html(disp)
		setTimeout(function(){
			$("#controls .monitor").empty()
		},1000)
	},
	load : function(i){
		// if(gallery.get_item(i) != false){
		if(gallery.status != "loading" && gallery.get_item(i).length > 0){
			gallery.status = "loading"
			$("#legend").fadeOut("fast",function(){
				$("#legend").html(gallery.get_item(i)[0].desc)
			})
			loading.show()
			// console.log("GALLERY_LOAD::"+gallery.get_item(i))
			var type = (gallery.get_item(i)[0].type.match(/(mov|flv|mp4|m4v)/)) ? "vid" : gallery.get_item(i)[0].type;
			gallery[type](i)
		}
		// }else{
		// 	alert("there's no image with this reference")
		// 	loading.hide()
		// }
	},
	show : function(i){
		gallery.buttons(i)
		loading.hide()
		$("#content .back").show(0)
		$("#content .front").fadeOut(1000,function(){
			$("#controls .gallery_items a.active").removeClass("active")
			gallery.get_item(i)[0].el.addClass("active")
			gallery.item = i
			$("#content .back").removeClass("back").addClass("front")
			if($("#fl_vid").length>0) swfobject.removeSWF("fl_vid");
			
			$(this).removeClass("front").addClass("back").empty()
			gallery.status = "stop"
			$("#legend").fadeIn("fast")
			content_resize()
		})
	},
	img: function(i){
		$(".video_control").hide()
		// var actual_height = ($("#content").height()-16) || false
		// var disp_width = $("body").width() || false
		// var size = 0		
		// if(actual_height){
		// 	size = actual_height;
		// }else{
		// 	size = site.image_sizes.p405[1];
		// }
		var img = new Image
		actual_image = img
		img.src = gallery.get_item(i)[0].href+"&s="+gallery.best_size(i)
		$("#content .back").append("<img src=\""+img.src+"\" alt=\"\" />")
		// console.log("LOAD_IMG_SRC::"+img.src)
		var loadInt = setInterval(function(){
			if(img.complete && $("#content .back img")[0].height > 0){
				clearInterval(loadInt)
				var img_ratio = img.width/img.height;
				var content_width = $("#content .frame").width()
				var content_height = $("#content").height()-16
				var content_ratio = content_width/content_height
				var img_size_attr = (img_ratio >= content_ratio) ? "width" : "height";
				$("#content .back img")[0].style[img_size_attr] = "100%"
				// $.fn.pause()
				gallery.show(i)
			}
		},50)
	},
	vid : function(i){
		$(".video_control").show();
		// console.log(gallery.get_item(i))
		if (gallery.get_item(i)[0].type.match(/vid|m4v|mov|mp4|flv/)){
				$("#content .back").empty().append("<div id=\"fl_vid\"></div>")
				var flashvars = {
				  file: gallery.get_item(i)[0].href,
				  controlbar: "none",
				  screencolor: "FFFFFF",
				  skin: "js/beelden/beelden.xml",
				  autostart: "true",
				  repeat: "always"
				};
				var params = {
				  allowfullscreen: "true"
				};
				var attributes = {
				  id: "fl",
				  name: "fl"
				};

				swfobject.embedSWF("js/player.swf", "fl_vid", '100%','100%','9',"js/expressInstall.swf", flashvars, params, attributes);
		}
		gallery.show(i)
	},
	vid_control:{
		stop:function(){
			if(document.getElementById("fl")){
				document.getElementById("fl").sendEvent("STOP")
				
			}else{
				document.qt.Stop();document.qt.Rewind();
			}
			if($(".playpause span:visible").is(".pause")){
				$(".pause").hide()
				$(".play").show()
			}
		},
		play:function(){
			if($(".playpause span:visible").is(".play")){
				$(".play").hide()
				$(".pause").show()
			}else if($(".playpause span:visible").is(".pause")){
				$(".pause").hide()
				$(".play").show()
			}
			if(document.getElementById("fl")){
				if($(".playpause span:visible").is(".pause")){
					document.getElementById("fl").sendEvent("PLAY","true")
				}else if($(".playpause span:visible").is(".play")){
					document.getElementById("fl").sendEvent("PLAY","false")
				}	
			}else{
				// console.log("qt")
				if($(".playpause span:visible").is(".pause")){
					document.qt.Play()
				}else if($(".playpause span:visible").is(".play")){
					document.qt.SetRate(0)
				}
			}
		}
	},
	txt : function(i){
		$(".video_control").hide()
		var item = i
		$.ajax({
			type: "GET",
			url: gallery.get_item(i)[0].href,
			cache: false,
			success: function(html){
				$("#content .back").html(html)
				gallery.show(item)
			}
		})
	},
	preload : function(){
		$("#controls .gallery_items a").each(function(){
			var img = new Image
			img.src = this.href
		})
	},
	buttons : function(i){
		if(gallery.items[0].id == gallery.get_item(i)[0].id){
			$("#controls .prev").css({"visibility":"hidden"})
		}else if(gallery.items[gallery.count-1].id == gallery.get_item(i)[0].id){
			$("#controls .next").css({"visibility":"hidden"})
		}else{
			$("#controls .prev, #controls .next").each(function(){
				if($(this).css("visibility") == "hidden") $(this).css({"visibility":"visible"})
			})
		}
	},
	next : function(){
		jQuery.grep(gallery.items,function(item,index){
			if (item.id == gallery.item && index != gallery.count-1){
				// console.log("NEXT_ACTUAL_CONTENT::"+actual_content)
				$.History.go(actual_content+"-"+gallery.items[index+1].id)
				gallery.monitor("next")
				gallery.keytemp ++
			}
		})
	},
	prev : function(){
		jQuery.grep(gallery.items,function(item,index){
			if (item.id == gallery.item && index != 0){
				// console.log("PREV_ACTUAL_CONTENT::"+actual_content)
				$.History.go(actual_content+"-"+gallery.items[index-1].id)
				gallery.monitor("previous")
				gallery.keytemp --
			}
		})
	},
	controls :  function(){
		$("#controls .prev").click(function(){ gallery.prev() })
		$("#controls .next").click(function(){ gallery.next() })
	},
	best_size : function(img){
		var ratio = gallery.get_item(img)[0].ratio
		var h = $("#content").height()-16
		var w = $("body").width()-320
		var window_ratio = w/h
		// console.log("RATIO::"+window_ratio+"//"+ratio)
		// console.log("DISP_H::"+h)
		if(window_ratio < ratio){
			h = w/ratio
		}else{
			
		}
		// console.log("BEST_H::"+h)
		size_test = 1080
		$.each(site.image_sizes,function(k,v){
			size_test_temp = Math.abs(v[1]-h)
			if(size_test_temp < size_test){
				size_test = size_test_temp
				best_size = v[1]
			}
			// console.log(v[1]+"//"+size_test_temp)
		})
		// console.log(img+"BEST_SIZE::"+best_size)
		return best_size
	},
	padder : function(){
		var h = $("#content").height()-16
		frame_width = $("#content").width()-320
		$("#content .frame").css({width:frame_width+"px"})
		img_node = $("#content .front img")
		if(img_node.size()){
			// console.log(img_node.height())
			// $(".mask").css({"background-position-y":(img_node.height()-20)+"px"})
			
			best_size = gallery.best_size(gallery.item)
			var loadInt = setInterval(function(){
				if(img_node.width()){
					content_ratio = $("#content .frame").width()/($("#content").height()-16)
					img_ratio = img_node.width()/img_node.height()
					var attr = img_node[0].attributes['width'] ? "width" : img_node[0].attributes['height'] ? "height" : false;
					// console.log(gallery.item+"RESIZE::"+actual_image.height+" != "+best_size)
					if((attr == "width" && img_ratio < content_ratio) || (attr == "height" && img_ratio > content_ratio) 
					|| actual_image.height != best_size
					){
						gallery.load(gallery.item)
					}
					clearInterval(loadInt)
					if($(".frame.front img").length > 0) $("#legend").css({"padding-right":parseInt(($("#content").width()-img_node.width())/2)+10+"px"})
				}
			},1000)
		}
		$("#content .frame").height(h)
		$("#content .mask").height(h)
		if($("#controls ul:first").size()){
			var absolute_center = ($(document.body).width()-$("#controls ul:first").width())/2
			var infos_offset_left = $("#infos").offset().left
			if( absolute_center > infos_offset_left){
				$("#controls ul:first").css({"padding-left":(absolute_center-infos_offset_left)+"px"})
				$("#controls ul.video_control").css({"padding-left":(absolute_center-infos_offset_left)+"px"})
			}else{
				$("#controls ul:first").css({"padding-left":"0px"})
				$("#controls ul.video_control").css({"padding-left":"0px"})
			}
		}
	},
	keyboard_control : function(){
		$(document).bind("keyup",gallery.keyboard_event)
	},
	keyboard_event: function(e){
		if((e.which > 36 && e.which < 41) || (e.which > 47 && e.which < 59)){
			switch (e.which) {
			    case 39:
					gallery.next() 
			    break
			    case 37:
					gallery.prev()
				break  
			   	case 38:
					$.History.go(actual_content+"-"+gallery.items[0].id)
					gallery.keytemp = 1
			    break
				case 40:
					$.History.go(actual_content+"-"+(gallery.items[gallery.count-1].id))
					gallery.keytemp = gallery.count
				break
				default:
					if(e.which > 47 || e.which < 59){
						var i = e.which - 48
						gallery.keytempo = (gallery.keytempo) ? gallery.keytempo +""+ i : i
						gallery.monitor(gallery.keytempo)
						if(!gallery.key_actvity){
							gallery.key_actvity = true
							setTimeout(function(){
								if(gallery.items[gallery.keytempo-1]){
									$.History.go(actual_content+"-"+(gallery.items[gallery.keytempo-1].id))
									gallery.keytemp = gallery.keytempo
									gallery.keytempo=0
									gallery.key_actvity = false
								}else{
									gallery.keytemp = gallery.keytempo
									gallery.keytempo=0
									gallery.key_actvity = false
								}
							},1000)
						}
					}
				break
			}
		}else{
			return false
		}
	},
	unload: function(){
		if($("#content .front").size()){
			$(document).unbind("keyup",gallery.keyboard_event)
		}
		$("#controls .items").empty()
		gallery.items = []
		gallery.count = 0
		gallery.item = 0
		gallery.keytemp = 1
		gallery.status = "stop"
	}
}
/*
 * END NKN_PHOTO_GALLERY
 */
