var ie, badBrowser;

$(document).ready(function(){
	$('head').append('<style>#jsPrompt p{font-family:arial;font-style:normal;padding:0px;margin:0px;}#jsPrompt{position:fixed;left:0px;bottom:0px;}#jsPrompt:hover{overflow:auto;width:auto;}</style>');
	$('body').append('<div id="jsPrompt"></div>');
	
	badBrowser = jQuery.browser.msie && jQuery.browser.version<7 ;
	ie = jQuery.browser.msie;
	

	$('.mainNavi li ul').css({display:'none'});
	$('.mainNavi li').bind('mouseenter',function(){
		$(this).find('ul').fadeIn(200);
	});
	$('.mainNavi li').bind('mouseleave',function(){
		$(this).find('ul').fadeOut(200);
	});
	
	$('.imageThumbnail').bind('click',function(event){
		event.preventDefault();
	});
	var controlsOpacity=0.4;
	$('div.gallery').append('<a href="javascript:void(0);" class="prev" style="display:none;"></a><a href="javascript:void(0);" class="next" style="display:none;"></a>');
	$('div.gallery a:last-child').delay(1800).fadeIn(600).animate({'opacity':controlsOpacity},1000);
	$('div.gallery div').delay(1000).animate({'margin-left':-70},600,'easeOutQuart').animate({'margin-left':0},300,'easeOutQuart');
	$('div.gallery a').bind('click',function(){
		var next=$(this).hasClass('next');
		var mover=$(this).parent().children('div');
		var box=$(this).parent();
		var length=mover.children('img').length;
		var step=mover.children('img:first-child').width();
		var end = step*(length-1);
		var position = Math.round(parseInt(mover.css('margin-left'))/step)*step;
		var distance = (step)*(next?-1:1);
		if(position+distance<-end) distance = end;
		else if(position+distance>0) distance = -end;
		
		mover.animate({'margin-left':position+distance},500,'easeInOutQuart',function(){
			if(box.children('a').css('display')=='none') box.children('a').fadeIn(200).animate({'opacity':controlsOpacity},1000);
		});
	});
	$('div.gallery a').bind('mouseover',function(){
		$(this).animate({'opacity':1},100);
	});
	$('div.gallery a').bind('mouseout',function(){
		$(this).animate({'opacity':controlsOpacity},200);
	});
	
});
/**************************** HELP *********************************************/

function decrypt (string){
	key="werhatangstvor";
	array_alphabet=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","%",".","-","&");
	var result="";

	for(i=0;i<string.length;i++){
		var j=0;
		while(j<array_alphabet.length&&string.charAt(i)!=array_alphabet[j])j++;
			position_char=j;
			j=0;
			//alert(string.charAt(i));
		while(j<array_alphabet.length&&key.charAt(i%key.length)!=array_alphabet[j])j++;
			position_key=j;
			position=(position_char-position_key)%array_alphabet.length;
			if(position<0)position+=array_alphabet.length;

			//alert(key.charAt(i%key.length));

			result+=array_alphabet[position];
			//alert(array_alphabet[position]);

	}
	//alert(decodeURIComponent(result));
	
	var link=decodeURIComponent(result);
	
	link=link.replace('&amp;', '&');
	document.location.href=link;}

/**************************** DEBUGGING *********************************************/

var jsPromptPre = "";

function jp(promptTXT){
	promptTXT +=' ';
	if(document.getElementById('jsPrompt')){
		lines=promptTXT.split("\n");
		for (i=0;i<lines.length;i++){
			var newP = document.createElement("p");
			var newTXT = document.createTextNode(lines[i]);
			newP.appendChild(newTXT);
			document.getElementById('jsPrompt').appendChild(newP);
		}
	} else jsPromptPre+="\n"+promptTXT;
}
function jd(obj){
	var text ='';
	if (typeof(obj)=='object'){
		for(var key in obj) {
			if (key!='channel'){
				if (obj[key]) 
					var string=""+obj[key];
					if(typeof(obj[key])!='function') text+=key+" => "+string+"\n";
					else text+=key+" => "+string.substring(0,string.indexOf('{'))+"\n";
			}
//			if (obj[key]) text+=key+" => "+obj[key]+"\n";
		}
		jp(text);
	}
}
function jc(){
	if(document.getElementById('jsPrompt')){
		document.getElementById('jsPrompt').innerHTML='';
	} else jsPromptPre="";
	
}


