var xmas = true;

$(document).ready
(
	
	function()
	{
		$('a[href^="http://"]').attr("target", "_blank");
		$('a[href$=".pdf"]').attr("target", "_blank");//open pdfs in a new window
		menuSelector();
		$('p.button  a').hover(
			function()
			{
				$(this).css('background','url(/z_images/structure/book_now_on.gif) no-repeat bottom left');
			},
			function()
			{
				$(this).css('background','url(/z_images/structure/book_now.gif) no-repeat bottom left');
			}
		);
		$('.menu_select  a').click(
			function()
			{
				menuSelector(this);
				return false;
			}
		);
		
		if(xmas)
		{
			xmasDecorations();
		}
		
		$('div.abs div.special_offer a').each(
			function(index)
			{
			var link_obj = $(this);
			var a_link = link_obj.attr('href');
			//var a_title = $(this).attr('title');
			var arrow_str = '&nbsp;<a href="'+a_link+'"><img src="/z_images/structure/offer_arrow.jpg" /></a>';	
			link_obj.after(arrow_str);
			}//function
		);
		
		$(window).bind('resize', function() {
		
		if(xmas)
		{
			xmasDecorations();
		}
		
		});
		
		var testimonials_count = $('p.quote').length;
		if(testimonials_count > 0)
		{
			//alert(testimonials_count);
			var padding_left = 20;
			var margin_top = 5;
			$('p.quote').each(
			function(index)
			{
				//$(this).find('span').after(' <span class="jq_close">&nbsp;</span>');
				if($(this).find('span').length==0)
				{
					$(this).wrapInner('<span></span>');
				}
				$(this).find('span').after(' <span class="jq_close"><img src="/z_images/structure/close_quote.gif" style="display:inline;" /></span>');
				var p_left = $(this).position().left;
				var p_width = $(this).width();
				var el = $(this).find('span.jq_close');
				var height = el.height();
				var width=el.width();
				var pos = el.position();
				if(typeof(pos) != 'undefined')
				{
				var x = pos.left;
				
				var y = pos.top;
				
				if(x==padding_left)//then carriage return forced
				{
					x= p_width+5+width;
					y = y-height;
				}
				
				y = y + margin_top;
				
				el.css({'position' : 'absolute', 'left' : x,'top' : y});
				}
				
				//alert(' span x: '+pos.left,)
			}//function
			);//each
		}
		
	}
	
);


function xmasDecorations()
{
	var padding = 16;
	var x1 = $('div.outer_container').position().left;
	var w1 = $('div.trees_left').width();
	
	x1 = (x1-w1)+padding;
	var x2 = $('div.outer_container').position().left + $('div.outer_container').width();
	x2 = x2+padding;
	
	$('div.trees_left').css('left',x1);
	$('div.trees_right').css('left',x2);
	$('div.trees_left:hidden').show();
	$('div.trees_right:hidden').show();
}

function menuSelector()
{
	$('.menu_group:visible').hide();
	$('table.menu:visible caption').hide();
	$('.menu_select  a').removeClass('on');
	if(arguments.length == 1 && typeof arguments[0]=='object')
	{
		var obj = arguments[0];
		var thisID = $(obj).attr('href');
		 $(obj).addClass('on');
		$(thisID).show();
		
	}
	else
	{
		var showFirstID = $('.menu_select > li:first > a').attr('href');
		if(typeof showFirstID!='undefined')
		{
			$('.menu_select > li:first > a').addClass('on');
			$(showFirstID).show();	
		}
	}

	
}

if(!Array.indexOf){//index of breaks ie
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}

try {//ie6 image swap cache problem
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


function isset( variable )

{

	return( typeof( variable ) != 'undefined' );

}


function eml_snd(part2,part1)
{
	mail_str = 'mailto: '+part1+'@'+part2;
	return mail_str;
}
