// JavaScript Document

document.write('<link href="css/javascript.css" rel="stylesheet" type="text/css" media="all" />');

var $j = jQuery.noConflict();

$j('#stay_details').live('submit',function() { pageTracker._linkByPost(this) });

function bookAddition() { 
	$j('body').prepend('<div class="container"><div id="quick-book">&nbsp;</div></div>');
}

var activeIndex = new Array();
var found = false;
var locat = location.href;
locat = locat.toLowerCase();

$j(document).ready(function() 
{
	$j('.book_btn').find('a').attr('href','javascript:;').attr('target','');
	$j('.book_btn').click(function()
	{
		//if($j("#quick-book").length > 0) {
			if($j("#quick-book").css('display') == "none") {
				$j("#quick-book").stop(true,true).animate({ height: 'show', opacity: 'show' }, 'slow', function() { $j(this).css('height','auto'); });	
				//$j("#next_page").css('display','block');
			}
			else {
				$j("#quick-book").stop(true,true).animate({ height: 'hide', opacity: 'hide' }, 'slow', function() { $j(this).css('height','auto'); });
			}
			if($j('#stay_details').attr('method')!='post')
				$j('#stay_details').attr('method','post');
		//}
	});
	
	$j('#mainmenu ul li').hover(function() { 
		$j(this).addClass('over');
	}, function() { $j(this).removeClass('over') });
	found = false;
	$j('#mainmenu ul li').each(activeCheck);
	found = false;
	$j('#mainmenu ul li ul li').each(activeCheck);
	$j('#mainmenu ul:eq(0)').hover(function() {
		$j('#mainmenu ul li').removeClass('active').find('li[rel="active"]').addClass('active');
	}, function() {
		found = false;
		$j('#mainmenu ul li[rel="active"]').addClass("active");
	});
	found = false;
	$j('.left_section li').each(activeCheck);
	$j(".menu").find("li").hover( function()
		{
			//$j(this).find("ul").stop(true,true).animate({ height: 'show', opacity: 'show' }, 'slow');
			//$j(this).find("ul li ul").stop(true,true).hide();
			$j(this).find("ul").css('display', 'block');
		}, function()
		{
			//$j(this).find("ul").stop(true,true).animate({ height: 'hide', opacity: 'hide' }, 'slow');
			//$j(this).find("ul li ul").stop(true,true).hide();
			$j(this).find("ul").css('display', 'none');
	})
	
	$j(".AddToCartTextBox").keydown( function() {
		var oldValue = this.value;
		oldValue = oldValue.replace(/[^0-9]/g,"");
		this.value = oldValue.substring(0,2);
	});
	$j(".AddToCartTextBox").keyup( function() {
		var oldValue = this.value;
		oldValue = oldValue.replace(/[^0-9]/g,"");
		this.value = oldValue.substring(0,2);
	});
	$j(".UnitsTextBox").keydown( function() {
			var oldValue = this.value;
			oldValue = oldValue.replace(/[^0-9]/g,"");
			this.value = oldValue.substring(0,2);
	});
	$j(".UnitsTextBox").keyup( function() {
		var oldValue = this.value;
		oldValue = oldValue.replace(/[^0-9]/g,"");
		this.value = oldValue.substring(0,2);
	});
	$j('.searchBox input').click( function() {
		$j(this).siblings('input').each(function() {
			if($j(this).attr('value') == 'Search') {
				$j(this).attr('value','');
			}
		});
	});
});

function activeCheck() {
	if(!found) {
		var oldHtml = $j(this).html();
		if($j(this).find('span').length < 0) {
			$j(this).html("<span>"+oldHtml+"</span>");
		}
		var itemList = $j(this).find('a');
		/*var slashes = locat.split('/');
		if(slashes.length > 3) {
			itemHref = itemHref.substring(0, itemHref.lastIndexOf('.'));
		}*/
		for(var i = 0; i < itemList.length;i++) {
			var itemHref = itemList[i].href;
			itemHref = itemHref.toLowerCase();
			if(locat.indexOf(itemHref) >= 0) {
				$j(this).addClass('active');
				$j(this).attr('rel', 'active');
				itemList[i].parentNode.className += ' active';
				found = true;
			}
		}
	}
}

function inputBoxContent(myInput)
{
    switch(myInput.value)
    {
        case "Enter Email Address":
            myInput.value = "";
            break;
    }
    myInput.style.color = '#000000';
}