$(document).ready(function(){
	$('#nav li').hover(function(){
		$(this).stop().animate({
			marginTop: '-21px',
			height: '77px'
		},300)
		toggleLogo($(this).find('.navLogo'),'1.0');
		moveTxt($(this).find('span'),'26');
	},function(){
		toggleLogo($(this).find('.navLogo'),'0.0');
		$(this).find('span').stop().animate({
			marginTop: '0px'
		},300)
		$(this).stop().animate({
			marginTop: '0px',
			height: '57px'
		},300)
	})
	
	function moveTxt(elem,pos){
		elem.stop().animate({
			marginTop: pos+'px'
		},300)
	}
	
	function toggleLogo(elem,op){
		elem.stop().animate({
			opacity: op
		},400)
	}
	if($('#slider')){
		$('#slider').nivoSlider();
	}
	
	$('ul.pic_list li a').lightBox();

})
	//rot_elem: input element mit dem rotation value
	//img_elem: bild element
	//canvas_elem: canvas element
	//direction: string in welche richtung gedreht werden soll
	function rotateCool(rot_elem,direction){
		
		var c_rotation=Number(rot_elem.val());
		var angle=90;
		var image=document.getElementById('lightbox-image');
		var canvas=document.getElementById('canvas');
		if(canvas){
			var ctx=canvas.getContext('2d');
			image.style.display='none';
		}
		var img_w=image.width;
		var img_h=image.height;
		var img_x=0;
		var img_y=0;
		
		if(direction=="left"){
			if(c_rotation==0){
				c_rotation=360;
			}
			rot_elem.val(c_rotation-angle);
		}else{
			if(c_rotation<=180){
				rot_elem.val(c_rotation+angle);
			}else{
				rot_elem.val(0);
			}
		}
			
		if(rot_elem.val()==90 || rot_elem.val()==270){
			img_w=image.height;
			img_h=image.width;
		}
		
		switch(Number(rot_elem.val())){
			case 90:
				img_y=-image.height;
			break;
			case 180:
				img_x=-image.width;
				img_y=-image.height;
			break;
			case 270:
				img_x=-image.width;
			break;
		}
		if(ctx){
			canvas.setAttribute('width',img_w);
			canvas.setAttribute('height',img_h);
			ctx.rotate((rot_elem.val()*Math.PI/180)*1);
			ctx.drawImage(image,img_x,img_y);
		}else{
			switch(Number(rot_elem.val())){
				case 90:
					image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=1)';
				break;
				case 180:
					image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=2)';
				break;
				case 270:
					image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=3)';
				break;
				case 0:
					image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=0)';
				break;
			}
		}
		var dimensions = new Array(img_w,img_h);
		return dimensions;
	}
