var li_width2   	= 65;
var li_padding2 	= 4;
var visible_num2	= 4;

$(window).ready(function () {
	$('div.sliderGallery').each(function () {
		var ul = $('ul', this);

		var inner_width     = visible_num2 * (li_width2+li_padding2);
		var productWidth    = ($('.sliderGallery li').length * (li_width2+li_padding2)) - inner_width;

		var slider = $('.slider', this).slider({ 
			handle: '.handle',
			minValue: 0, 
			maxValue: productWidth, 
			slide: function (ev, ui) {
				pix = productWidth*(ui.value/100);
				ul.css('left', '-' + pix + 'px');
			}, 
			stop: function (ev, ui) {
				pix = productWidth*(ui.value/100);
				ul.animate({ 'left' : '-' + pix + 'px' }, 500, 'linear');
			}
		});
	});
});

var li_width    = 185;
var li_padding  = 10;
var visible_num = 4;

$(window).ready(function () {
	$('div.sliderGallery_properties').each(function () {
		var ul = $('ul', this);

		var inner_width     = visible_num * (li_width+li_padding);
		var productWidth    = ($('.sliderGallery_properties li').length * (li_width+li_padding)) - inner_width;

		var slider = $('.slider_properties', this).slider({ 
			handle: '.handle_properties',
			minValue: 0, 
			maxValue: productWidth, 
			slide: function (ev, ui) {
				pix = productWidth*(ui.value/100);
				ul.css('left', '-' + pix + 'px');
			}, 
			stop: function (ev, ui) {
				pix = productWidth*(ui.value/100);
				ul.animate({ 'left' : '-' + pix + 'px' }, 500, 'linear');
			}
		});
	});
});

// dropdown variables
var theParent = '';
var timeOut = '';

// dropdowns for the navigation
$(function(){

	$('.drop').hover(
		function(){
			clearTimeout(timeOut);
			$('ul ul').css('left', '-99999px');
			$(this).children('ul').css('left', '0');
		},
		function(){
			theParent = $(this);
			timeOut = setTimeout(removeSubNav, 1000);
		}
	);

});

function removeSubNav(){
	theParent.children('ul').css('left', '-99999px');
}

// properties scripts
$(function(){

	getFloorAndMap();

});

function getFloorAndMap()
{
	$('.get_floor, .get_map, .get_photo').unbind();

	$('.get_floor, .get_map, .get_photo').click(function(){

		var href = $(this).attr('href');

		$.ajax({
			type:		"GET",	
			dataType: 	"html",
			url:		href,
			success: 	function(data){
							$('.photo').html(data);
						},
			complete: 	function(){
							getFloorAndMap();
						}
		});

		return false;
	});
}

// HOME PAGE ANIMATION
$(function(){

	$('body#index-index #content h3').css('display', 'none');
	$('body#index-index #content img').css('display', 'none').fadeIn(2000, function(){
		$('body#index-index #content h3').slideDown("slow");
		startInterval	= setInterval("getImage()", 6000);
		startInterval2	= setInterval("getQuote()", 12000);
	});

});

var useKey = 0;

function getImage()
{
	if(useKey < (parseInt(home_images.length)-1))
	{
		useKey++;
	}
	else
	{
		useKey = 0;
	}

	$('body#index-index #content img').fadeOut(2000, function(){
		$('#rotate').css('display', 'none').html('<img src="' + home_images[useKey] + '" alt="Home" />').fadeIn(2000);
	});
}

var useKey2 = 0;

function getQuote()
{
	if(useKey2 < (parseInt(home_quotes.length)-1))
	{
		useKey2++;
	}
	else
	{
		useKey2 = 0;
	}

	$('body#index-index #content h3').slideUp('slow', function(){
		$('body#index-index #content h3').html(home_quotes[useKey2]).slideDown('slow');
	});
}

// TEXT POP UP

$(function(){
	$(".news_text").click(function(){
		window.open(
			$(this).attr('href'),
			"NewsEntry",
			"menubar=no,width=700,height=500,toolbar=no,scrollbars=yes"
		);
		return false;
	});
});