/*---------------------------------------------------------------------

Template Name: 	Online Booking
Version:	 	1.0
Release Date: 	August 08, 2010

File:       	custom.js
Updated:    	2010-08-08

Copyright (c) 2010 Zoran Juric - http://themeforest.net/user/zoranjuric

-----------------------------------------------------------------------

WARNING! DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!

---------------------------------------------------------------------*/

// Preload images
imageObj = new Image();
imgs = ["img/loader.gif", "img/loading.gif"];
for (i = 0; i < imgs.length; i++) imageObj.src = imgs[i];

var infowindow;
var map;
var mapDrawn = false;

var hotels = [];
var markers = [];

// Site object setup
var Site = {};



// setup() - Site init and setup
Site.setup = function () {
    // Open an external link in a new window
    $('a[href^="http://"]').filter(function () {
        return this.hostname && this.hostname !== location.hostname;
    }).attr('target', '_blank');

    // scroll to top on request
    if ($("a#totop").length) Site.scrollToTop("a#totop");
	
	// setup content boxes (Search Filters)
	if ($(".content-box").length) {
		$(".content-box .header").css({
			"cursor": "s-resize"
		});
		// Give the header in content-box a different cursor	
		$(".content-box .header").click(
		function () {
			$(this).parent().find('.section').toggle(); // Toggle the content
			$(this).parent().toggleClass("content-box-closed"); // Toggle the class "content-box-closed" on the content
		});
	}
	

	
	// dropdown menu
	var $menu = $('#nav');		
	$menu.children('li').each(function(){
		var $this = $(this);

		var submenu = $this.find('.dropdown_submenu');
		if (submenu.length) {
			submenu.parents('ul, div').css('z-index', 2000); // z-index hack for IE7
			$this.bind('mouseenter',function(){
				submenu.slideDown().css('z-index', 1000); // z-index hack for IE7
			}).bind('mouseleave',function(){
				submenu.fadeOut('fast');
			});
		}		
	});
	
	// find closeable boxes and add a "close" action
	$('.closeable').each(function(index){
		$(this).prepend( 
			$('<a></a>')
				.attr({href: '#', title: 'Close'})
				.addClass('close')
				.text('x')
				.click(function() {
					$(this).parent().fadeOut();
					return false;
				})
		);
	});

}
