$(function (){
	$.fn.lightbox.defaults.fileLoadingImage = APP_TPL_DIR+'js/jquery-lightbox/images/loading.gif';
	$.fn.lightbox.defaults.fileBottomNavCloseImage = APP_TPL_DIR+'js/jquery-lightbox/images/closelabel.gif';
	$.fn.lightbox.defaults.fitToScreen = true;
	
	$('.lightbox').lightbox();
	// menu hover
	$('#navigator a img')
		.each(function (){
			$(this).data('hover_data', {orig_src: this.src, hover_src: this.src+'h'});
			var prel_img = new Image();
			prel_img.src = this.src+'h';
		})
	$('#navigator a').hover(
		function (){
			$('img', this).each(function (){this.src = $(this).data('hover_data').hover_src;})
		},
		function (){
			$('img', this).each(function (){this.src = $(this).data('hover_data').orig_src;})
		}
	);
	
	// submenus
	$("#navigator ul li").hover(
		function(){
			$(this).children("ul").css("display","block");
		},
		function(){
			$(this).children("ul").fadeOut("fast");
		}
	);
	
	// slideshow
	$('.slideshow ul').each(function (){
		var $this = $(this), pb = $('.prev', $this.parents('.slideshow')), nb = $('.next', $this.parents('.slideshow'));
		$this.SlideShow({
			duration: 600,
			nextBtn: nb,
			prevBtn: pb
		});
	});
	
	// corners
	/* if ($.browser.msie){
		$('.rounded').corner({
			tl: { radius: 10 },
			tr: { radius: 10 },
			bl: { radius: 10 },
			br: { radius: 10 },
			antiAlias: true
		});
	} */
	/* if ($.browser.msie){
		curvyCorners({
			tl: { radius: 10 },
			tr: { radius: 10 },
			bl: { radius: 10 },
			br: { radius: 10 },
			antiAlias: true
		}, ".rounded");
	} */
	
	$("input[type=file]").filestyle({ 
		image: APP_TPL_DIR+'images/upload-button.gif',
		imageheight : 25,
		imagewidth : 116
	});
	
	// flv
	if ($('.flv-player').length){
		$('body').append('<div id="flv-player-container"></div>');
		$("#flv-player-container").dialog({
			bgiframe: true,
			width: 450,
			height: 350,
			modal: true,
			autoOpen: false,
			resizable: false,
			title: 'Player',
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			}
		});
		$('.flv-player').click(function (){
			$('#flv-player-container')
				.dialog('open')
				.load(this.href+'&layout=_inc')
			;
			return false;
		});
	}// end flv
	
	// 3 homepage boxes
	if ( $('div#boxes3').length ) {
		$('div#boxes3 ul li').hover(
			function(){
				$(this).css('background-position','bottom left');
				$(this).children('h1').css('color','#fff');
				$(this).children('div').children('h1').css('color','#fff');
				$(this).children('h1').children('a').css('color','#fff');
				$(this).children('p').children('a').css('color','#fff');
				$(this).children('div').children('p').children('a').css('color','#fff');
				$(this).children('div').children('p').css('color','#fff');
			},
			function(){
				$(this).css('background-position','top left');
				$(this).children('h1').css('color','#3F7D4C');
				$(this).children('div').children('h1').css('color','#3F7D4C');
				$(this).children('h1').children('a').css('color','#3F7D4C');
				$(this).children('p').children('a').css('color','#585858');
				$(this).children('div').children('p').children('a').css('color','#585858');
				$(this).children('div').children('p').css('color','#585858');
			}
		);
	}
});
