$(document).ready(function(){

	//Ajax
	//Set ajax to not cache
	$.ajaxSetup ({
		cache: false,
		type: "POST"
	});

	var ajax_load = "<img src='http://174.137.136.68/images/ajax-loader.gif' alt='loading...' />";

	//Enter or Exit Warning
	//Set session cookie
	var userIsOk = $.cookie('has_seen_popup');
	
	if ($.cookie('has_seen_popup') == null) {
		
	// Select the overlay element - and "make it an overlay"
	$("#entrance_overlay").overlay({
		top: "0",
		expose: {
			color: '#000',
			loadSpeed:600,
			opacity: 0.9
		},
		closeOnEsc: false,
		closeOnClick: false,
	
		onClose: function(event) {
			$.cookie('has_seen_popup','hasseen' , { expires: 1, path: '/' });
			
		},

		api: true 
		}).load();
	};

	//Slideshow
	if ($("ul#latest_releases_slideshow").length) {
		$('ul#latest_releases_slideshow').cycle({
			fx: 'fade',
			random: 1 
		});
	};
	
	// Login
	$('.loginBox').css({ opacity: '0.0', display: 'none' });

	$('#madcap,.opensesame').click(function() {
		$("#loginBox").animate({marginTop: "0"}, 'fast' );
		$("input.mainLogin").focus();
		return false;
	});

	$("#closeLogin").click(function(){
		$("#loginBox").animate({marginTop: "-55px"}, 'fast');
		return false;
	});

	// Lazy Load
	$("body:not(#home,#movies,#israel_tour,#tour) img").lazyload({
		effect : "fadeIn"
	}); 

	//Searchbox: Display default text in search input 
	$("#search-input")
	.val('Search scenes, movies, models')
	.css("color", "#ccc")
	.focus(function(){
		$(this).css("color", "black");
		if ($(this).val() == 'Search scenes, movies, models') {
			$(this).val("");
		}
	})
	.blur(function(){
		$(this).css("color", "#ccc");
		if ($(this).val() == "") {
			$(this).val('Search scenes, movies, models');
		}
	});
	//Homepage Lists: Sliding Boxes
	$('.boxgrid.caption').hover(function(){
		$(".cover", this).stop().animate({top:'110px'},{queue:false,duration:360});
		
		}, function() {
		$(".cover", this).stop().animate({top:'190px'},{queue:false,duration:360});
	});

	//Show hide Scene Description
	$('#view_descrip').click(function () {
		$(this.hash).slideToggle(1000);
		return false;
	});
	
	//My Favorites Ajax Submit
	$("a.add-to-favorites").click(function() {
		$("div#favorite-added").html(ajax_load).load(this.href, null, function(responseText) {
		$("#favorite-added").html(responseText)})
		return false;
	});

	//jQuery scrollable
	$("div.scrollable").scrollable({
		size: 3
	}).navigator();
	$("a.newsletter-signup[rel]").overlay({ 

	   // some expose tweaks suitable for modal dialogs 
	   expose: { 
	       color: '#333', 
	       loadSpeed: 400, 
	       opacity: 0.9 
	   }, 

	   closeOnClick: false 
	});
	//Tooltip
	// initialize tooltip 
    $(".tour_pic img[title]").tooltip({ 

        // use single tooltip element for all tips 
        tip: '#tooltip',  

        // tweak the position 
        offset: [10, 2], 

        // use "slide" effect 
        effect: 'slide' 

    // add dynamic plugin  
    }).dynamic( {

        // customized configuration on bottom edge 
        bottom: { 

            // slide downwards 
            direction: 'down', 

            // bounce back when closed 
            bounce: true 
        } 
    });

});
//End Document Ready