	//var $j = jQuery.noConflict();
	$(document).ready(function(){
		if($(".fancy").length > 0){
			$(".fancy").colorbox({rel:'group'});
		}
		$("#voverlay").colorbox({iframe:true, innerWidth:480, innerHeight:340});
		$("#youtube").colorbox({inline:true});
		
		if($("#sendNewsletter").length > 0){
			$("#sendNewsletter").click(function(){
				var rItem = $(this).attr('alt');
				var rItemImage = $('#image_'+rItem).attr('alt')
				$.post("add-to-newsletter.php", $("#newsletterFrm").serialize(),function(r){
					if(r != ''){
						$('#errs').html(r);
						$('#news_name').val('Enter your name here..');
						$('#news_email').val('Enter your email ID here..');
						setTimeout("$('#inline_errors').trigger('click')", 200);
						
					}
				});	
				return false;
			});
		}
		
		if($("#inline_errors").length > 0){
			$("#inline_errors").colorbox({
				inline:true, 
				transition:'elastic',
				speed:600,
				initialWidth: 140,
				initialHeight: 50,
				width: 320,
				height: 140,
				scrolling: false
			});
		}
		if($("#controls li a").length > 0){
			$("#controls li a").click(function(){
					//Performed when a control is clicked
				shuffle();
				var rel = $(this).attr("rel");
				if ( $("#" + rel).hasClass("current") ){
					return false;
				}
				$("#" + rel).show();
				$(".current").fadeOut().removeClass("current");
				$("#" + rel).addClass("current");
				$(".active").removeClass("active");
				$(this).parents("li").addClass("active");
				set_new_interval(5000);
				return false;
			});
		}
	});

	function banner_switch(){
        //This function is called on to switch the banners out when the time limit is reached
        shuffle();
        var next =  $('.banner.current').next('.banner').length ? $('.banner.current').next('.banner') : $('#banners .banner:first');
        $(next).show();
	    $(".current").fadeOut().removeClass("current");
        $(next).addClass("current");
        var next_link = $(".active").next("li").length ? $('.active').next('li') : $('#controls li:first');
        $(".active").removeClass("active");
        $(next_link).addClass('active');
    }

    $(function() {
        //Initial timer setting
        slide = setInterval( "banner_switch()", 5000 );
    });

    function set_new_interval(interval){
        //Simply clears out the old timer interval and restarts it
        clearInterval(slide);
        slide = setInterval("banner_switch()", interval);
    }

    function shuffle(){
        //This function takes every .banner and changes the z-index to 1, hides them,
        // then takes the ".current" banner and brings it above and shows it
        $(".banner").css("z-index", 1).hide();
        $(".current").css("z-index", 2).show();
    }
	
function onYouTubePlayerReady(playerId) { 
	ytplayer = document.getElementById("video_overlay"); 
	ytplayer.setVolume(100); 
} 
