// Windflower Core JavaScript by Aakash Bhatia

$(document).ready(function(){
    // Home Page marquee
	if($('#home-list-container').length != 0) {
		$('marquee').marquee('pointer').mouseover(function () {	
			$(this).trigger('stop');
		}).mouseout(function () {
			$(this).trigger('start');
		}).mousemove(function (event) {
			if ($(this).data('drag') == true) {
				this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
			}
		}).mousedown(function (event) {
			$(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
		}).mouseup(function () {
			$(this).data('drag', false);
		});
	}
	
	//  Initialize Backgound Stretcher
	var background = $('body').css('background-image').replace('url("', '').replace('")', '').replace('url(', '').replace(')', '');
	$(document).bgStretcher({
		images: [background], imageWidth: 900, imageHeight: 637,
		resizeProportionally: false
	});
	
	// To control slide down on click
	$('.unhider').click(function() {
		var id = $(this).attr('rel');
		
		if($('#' + id).css('display') == 'none')
			$('#' + id).slideDown(function(){
				$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
			});
		else
			$('#' + id).slideUp(function(){
				$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
			});
		
		return false;
	});
	
	// To control slidedown on click on dining page
	$('.unhider2').click(function(){
		var id2 = $(this).attr('rel');
		
		$('.hidden-content').slideUp();
		if($('#' + id2).css('display') == 'none')
			$('#' + id2).slideDown(function(){
				$('html,body').animate({scrollTop: $("#"+id2).offset().top},'slow');
			});
		else			
			$('#' + id2).slideUp(function(){
				$('html,body').animate({scrollTop: $("#"+id2).offset().top},'slow');
			});

		return false;
	});
	
	
	// Reading Weather Forecast 
	/*$(function() {
	$.simpleWeather({
		location: 'mysore, india',
		unit: 'c',
		success: function(weather) {
		  $("#header-text-right").html('Local Time: 18:00 Weather:'  + weather.temp + '&deg; ' + weather.units.temp + '/' + weather.currently);
		},
		error: function(error) {
		  $("#header-text-right").html('<p>'+error+'</p>');
		}
		});
	});*/
	
	//Displaying image title for the marqueeing images on the home page
	$('#home-list-container ul li img').mouseenter(function(){
		$('#image-title').html('<p>' + $(this).attr('rel') + '</p>');
		$('#image-title p').css('margin-left', $(this).offset().left + 'px');
	});

	$('#home-list-container ul li img').mouseleave(function(){
		$('#image-title').html('');
	});
	
			$('.bookshow').click(function(){
			$('#bookholder').css('display','block');
	});

});
