$(document).ready(function(){
 	
 	$("div.projektknapp").hover( function(){
 		var myID = $(this).attr("id");
 		$("#sub"+myID).css("display","block");
 		if(myID=="pknapp_projekt") {
 		//Projekt
 			$(this).css("background-position", "0px -22px");
 		} else if(myID=="pknapp_trailer") {
 		//trailer
 			$(this).css("background-position", "-89px -22px");
 		} else if(myID=="pknapp_galleri") {
 		//galleri
 			$(this).css("background-position", "-178px -22px");
 		} else if(myID=="pknapp_lankar") {
 		//länkar
 			$(this).css("background-position", "-267px -22px");
 		}
 	}, function() {
 		var myID = $(this).attr("id");
 		$("#sub"+myID).css("display","none");
 		if(myID=="pknapp_projekt") {
 		//Projekt
 			$(this).css("background-position", "0px 0px");
 		} else if(myID=="pknapp_trailer") {
 		//trailer
 			$(this).css("background-position", "-89px 0px");
 		} else if(myID=="pknapp_galleri") {
 		//galleri
 			$(this).css("background-position", "-178px 0px");
 		} else if(myID=="pknapp_lankar") {
 		//länkar
 			$(this).css("background-position", "-267px 0px");
 		}
 	});
 	
 	$(".submen_row").hover(function() {
 		$(this).css("background-color","#000");
 	}, function() {
 		$(this).css("background-color","#4f4d4d");
 	})
 	
 	
 	$(function($) {
      $('.jclock').jclock();
    });
    
    $('#slides')  
		.cycle({ 
    		fx:     'scrollHorz',
    		speed:  '300', 
    		timeout:'9500', 
    		prev:   '#slideprev',
    		next:   '#slidenext',
    		cleartypeNoBg: true
	});
	
	$('.oneslide').hover( function() {
		$('#slides').cycle('pause');
	}, function() {
		$('#slides').cycle('resume');
	})
	
		$("div.oneslide").click(function() {
			var GOTO = $(this).attr("rel");
			location.href = ''+GOTO+'';
		})
	
	$("#slideprev").hover(function() {
		$(this).css("background-position", "0px 0px")
	}, function() {
		$(this).css("background-position", "0px -33px")
	})
	
	$("#slidenext").hover(function() {
		$(this).css("background-position", "-33px 0px")
	}, function() {
		$(this).css("background-position", "-33px -33px")
	})
	
	$(".covernewsslide").hover( function() {
		$('#hold_news').cycle('pause');
		var subPage = $(this).attr("rel");
		$("#"+subPage).animate( { opacity: 'show' },200)
	}, function() {
		$('#hold_news').cycle('resume');
		var subPage = $(this).attr("rel");
		$("#"+subPage).animate( { opacity: 'hide' },200)
	}).click(function() {
		var skaffaId = $(this).attr("rel");
		location.href='?read='+skaffaId+'';
	})
	
	
//	$("div.readimg").hover(function() {
//		var subDiv = $(this).attr('id');
//		$("#sub"+subDiv).animate({ height: 'show' },100)
//	}, function() {
//		var subDiv = $(this).attr('id');
//		$("#sub"+subDiv).animate({ height: 'hide' },100)	
//	})
	
	//Video
	$("div.onclickvideo").click( function() {
		$("div.videosubwindow").css("display", "none");
		$("div#videooverlay").css("display","none");
		var videoId = $(this).attr("rel");
		$("div#videowindow"+videoId+"").css("display","block");
		$("div#videooverlay").css("display","block");
	})
	$("div#videooverlay").click(function(){
		$("div.videosubwindow").css("display", "none");
		$("div#videooverlay").css("display","none");
	})
	$("div.adminvideo").click(function() {
		$("div#addnewvideo").animate({ height: 'show' },200);
	})
	$("div.videorowwer").hover(function() {
		$(this).css("color","#000")
	}, function() {
		$(this).css("color","red")
	}).click(function(){
		$("input#videoiden").attr( "value", ""+$(this).attr("rel")+"" )
		var areuSure = confirm("Är du säker på att du vill ta bort denna?");
		if(areuSure) {
			document.forms['deletevideo'].submit();
		}
	})
	
	//admin grejjer
	$(".adminknapp").toggle( function() {
		var showDiv = $(this).attr("rel");
		$("#"+showDiv).animate({ height: 'show' },200);
	}, function() {
		var showDiv = $(this).attr("rel");
		$("#"+showDiv).animate({ height: 'hide' },200);
	});
		
});
function doAfterLoaded() {
		$('#hold_news')  
			.cycle({ 
    			speed:  '300', 
    			timeout:'5000',
    			pager: '#newspager' 
		});
}