/*

--------------------------------------------------------->8---

AUTHOR		g madison / ohsoso.com
CLIENT		niklas johansson
VERSION		1.5 no hover, final rel
DATE		110210

--------------------------------------------------------------

*/

$(document).ready(function(){
						   
	// HIDE INITIALLY
	
	$('img').hide();
	$('img').one('load', function(){
			$(this).fadeTo(400, 1);
	})
	.each(function(){
			if(this.complete) $(this).trigger('load');
	});
	
	// LOADING MESSAGE

	$(window).load(function(){ 
			$("#load").fadeOut(400);
	});
	
	// SHOW IMAGE TITLE

	$('#imginc img, #txtinc img, #imgview img').hover(function(){
			$('#movinfo').html(this.title);
	}, function(){
			$('#movinfo').html('');
	});

	// SHOW CATEGORY MENU

	$('#imginc img').addClass('nofade');
	
	$('#imginc li').hover(function() {
			$('img',this).not('.nofade').fadeTo(200, 1);
//			var showcat = $(this).attr('class').split(" ")[1];
//			$('#' + showcat).addClass('active');
    }, function() {
			$('img',this).not('.nofade').fadeTo(400, 0);
// 			var showcat2 = $(this).attr('class').split(" ")[1];
//			$('#' + showcat2).removeClass('active');
   });

	// SHOW CATEGORY IMAGES
	
	var cat = ['all','commercials','music_videos','features_and_shorts'];

	$.each(cat, function(index, item) {
//			$('#' + item).hover(function() {
//					$('#imginc img').not('.' + item + ' img').fadeTo(400, 0);
 //   		}, function() {
//					$('#imginc img').fadeTo(400, 1);
//			});
	
	// KEEP ON CLICK
	
			$('#' + item).click(function() {
					$('#imginc img').not('li.' + item + ' img').fadeTo(400, 0).removeClass('nofade');
					var getid = $(this).attr('id');
					$('li.' + getid + ' img').fadeTo(200, 1).addClass('nofade');
					$(this).addClass('active').siblings().removeClass('active');
					
			});
	});

	// SLIDESHOW
	
	$(function(){
			var fadein = $('#slideshow');
			fadein.children().slice(1).hide();	
			setInterval(function(){
					fadein.children().eq(0).fadeOut().next().fadeIn().end().appendTo(fadein);
			}, 3000);
	});
    
/*	$('#commercials').hover(function() {
			$('#imginc img').fadeTo(0, 0);
			$('.commercials img').fadeTo(100, 1);
			$('#menu li').removeClass('active');
	});

	$('#features_\\&\\_shorts').hover(function() {
			$('#imginc img').fadeTo(0, 0);
			$('.features_\\&\\_shorts img').fadeTo(100, 1);	
			$('#menu li').removeClass('active');
	}, function() {
			$('.features_\\&\\_shorts img').fadeTo(400, 0);
	});

	$('#music_videos').hover(function() {
			$('#imginc img').fadeTo(0, 0);
			$('.music_videos img').fadeTo(100, 1); 
			$('#menu li').removeClass('active');
	}, function() {
			$('.music_videos img').fadeTo(400, 0);
	});
 */
	// AFMIN NEW CATEGORY

	$('#txtcat').change(function(){
			if ($(this).val() == 'new') {
					$('#newcat').show();
			}
			else {
					$('#newcat').hide();
			}
	});

	// ADMIN SECTIONS

	$('#uploadimg, #editimg, #editinfo').hide();

	$('input[name=showleft]:eq(0)').click(function(){
//			$('#editimg').show();
			$('#editinfo').hide();
			$('#editmov').hide();
	});

	$('input[name=showleft]:eq(1)').click(function(){
	//		$('#editimg').hide();
			$('#editinfo').show();
			$('#editmov').hide();
	});

	$('input[name=showleft]:eq(2)').click(function(){
	//		$('#editimg').hide();
			$('#editinfo').hide();
			$('#editmov').show();
	});

	$('input[name=showright]:eq(0)').click(function(){
			$('#uploadmov').hide();
//			$('#uploadimg').show();
	});

	$('input[name=showright]:eq(1)').click(function(){
		$('#uploadmov').show();
//		$('#uploadimg').hide();
	});

	return false;

});
