
//Popup window
var profiles =
	{

		window800:
		{
			height:800,
			width:800,
			status:1
		},

		window200:
		{
			height:300,
			width:400,
			status:1,
			resizable:0
		},

		windowCenter:
		{
			height:600,
			width:500,
			center:1,
			resizable:0,
			createnew:0
		},

		windowNotNew:
		{
			height:300,
			width:400,
			center:1,
			createnew:0
		},

		windowCallUnload:
		{
			height:300,
			width:400,
			center:1,
			onUnload:unloadcallback
		},

	};

	function unloadcallback(){
		alert("unloaded");
	};


   	$(function()
	{
   		$(".popupwindow").popupwindow(profiles);
   	});


//Image hover effects		
$(document).ready(function(){									
	var thumbs = $("ul li img");		
	
	for (var i = 0, ii = thumbs.length; i < ii; i++){
		if (thumbs[i].title && thumbs[i].title.length > 0)
		{			
			var imgtitle = thumbs[i].title;		
			$(thumbs[i]).wrap('<div class="wrapper" />').				
			after('<div class=\'caption\'>' + imgtitle + '</div>').
			removeAttr('title');
										
		}					
	}
				
$('.wrapper').hover(
	function(){
		$(this).find('img').animate({opacity: ".6"}, 300);		
		$(this).find('.caption').animate({top:"-124px"}, 300);			
	}, 
	function(){
		$(this).find('img').animate({opacity: "1"}, 300);					
		$(this).find('.caption').animate({top:"50px"}, 1000);
	}		
	);			
});


// Main menu sub nav
jQuery(function(){
	jQuery('ul.sf-menu').superfish();
});


//Image NivoSlider script
	$(window).load(function() {
		$('#slider').nivoSlider({
		effect:'fold', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:7000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:false, // Only show on hover
        controlNav:true, // 1,2,3... navigation
        controlNavThumbs:true, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:true, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
		});
	});


//Image Easy slider 1.7 script	
		$(document).ready(function(){	
			$("#slider1").easySlider({
				auto: true,
				continuous: true
			});
			$("#slider2").easySlider({ 
				auto: true,
				continuous: true
			});
			$("#slider3").easySlider({ 
				auto: true,
				continuous: true
			});
		});	
	
// Input Placeholder for All Browsers
	$(document).ready(function(){
		$('[placeholder]').focus(function() {
			var input = $(this);
			if (input.val() == input.attr('placeholder')) {
				input.val('');
				input.removeClass('placeholder');
			}
			}).blur(function() {
				var input = $(this);
				if (input.val() == '' || input.val() == input.attr('placeholder')) {
					input.addClass('placeholder');
					input.val(input.attr('placeholder'));
				}
			}).blur().parents('form').submit(function() {
			$(this).find('[placeholder]').each(function() {
				var input = $(this);
					if (input.val() == input.attr('placeholder')) {
					input.val('');
				}
			})
		});
	});			
		
		
//Fancybox image script	
$(document).ready(function() {
			/*
			*   Examples - images
			*/

			$("a#example1").fancybox();

			$("a#example2").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

			$("a#example3").fancybox({
				'transitionIn'	: 'none',
				'transitionOut'	: 'none'	
			});

			$("a#example4").fancybox({
				'opacity'		: true,
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'none'
			});

			$("a#example5").fancybox();

			$("a#example6").fancybox({
				'titlePosition'		: 'outside',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.9
			});

			$("a#example7").fancybox({
				'titlePosition'	: 'inside'
			});

			$("a#example8").fancybox({
				'titlePosition'	: 'over'
			});

			$("a[rel=radnicki]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});

			/*
			*   Examples - various
			*/

			$("#various1").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});

			$("#various2").fancybox();

			$("#various3").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});

			$("#various4").fancybox({
				'padding'			: 0,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});
		});
		
		
//Zoom image	
$(function(){
	$(".zoom a").append("<span></span>");
	$(".zoom a").hover(function(){
		$(this).children("img").stop(true, true).animate({opacity:0.7},300);
		$(this).children("span").stop(true, true).fadeIn(300);
	},function(){
		$(this).children("img").stop(true, true).animate({opacity:1},250);
		$(this).children("span").stop(true, true).fadeOut(250);
	});
});		


//Preloading gallery images 
$(function () {
	//$('.preload').hide();//hide all the images on the page
	$('.play,.magnifier').css({opacity:0});
	$('.preload').css({opacity:0});
	$('.preload').addClass("animated");
	$('.play,.magnifier').addClass("animated_icon");
});


var i = 0;//initialize
var cint=0;//Internet Explorer Fix
$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
	var cint = setInterval("PreImage(i)",50);//500 is the fade in speed in milliseconds
});

function PreImage() {
	var images = $('.preload').length;//count the number of images on the page
	if (i >= images) {// Loop the images
		clearInterval(cint);//When it reaches the last image the loop ends
	}
	//$('.preload:hidden').eq(i).fadeIn(500);//fades in the hidden images one by one
	$('.animated_icon').eq(0).animate({opacity:1},{"duration": 500});
	$('.animated').eq(0).animate({opacity:1},{"duration": 300});
	$('.animated').eq(0).removeClass("animated");
	$('.animated_icon').eq(0).removeClass("animated_icon");
	i++;//add 1 to the count
}
