function    toInt(x)
{
    return (parseInt(x) + 0);
}

(function ($) {
	$(document).ready(function () {		

		//$.preloadCssImages();
		
		//jQuery.easing.def = "easeInSine";

/*
		$('li:not(.current) a').each(function () {
			$(this).click(function () {
				$('#Main').fadeTo(500,0.7);
			})
		})
*/

		$('#Fader').each(function () {
			$(this).cycle({
				fx:     'fade', 
			    speed:   2800,
				easing: 'linear', 
			    timeout: 6000, 
			    next:   '#hdr'
/*			    pause:   0 
*/
			});
		})			
		
		$('#imgmap li').each(function () {
			$(this).css({opacity:"0"});
			$(this).hover(function () {
				$(this).stop().fadeTo(700,1);
			},function () {
				$(this).stop().fadeTo(1900,0);
			})
		})
		
		$('#Footer p').each( function () {
			$(this).css({opacity: 0.2}).hover(function () {
				$(this).stop().fadeTo(150,0.9);
			}, function () {
				$(this).stop().fadeTo(1900,0.2);
			})
		});

	if ($.browser.name != 'msie') {
		$('#Sidebar li:not(.current) a').each(function(){
			$(this).hover(function(){
				$(this).stop().animate({
					marginLeft: "-20px"
				}, 300);
			}, function(){
				$(this).stop().animate({
					marginLeft: "-15px"
				}, 300);
			})
		});
	}
	}) //end documentready
	
	$.fn.jax = function(url) {
		link=url+"ajax"+"&prev="+window.location.href.replace(/http:\//,"");
		/*
console.log("ajax call:"+link);
*/
		return this.queue("fx", function() {
			$(this).stop().load(link, function() {
				$(this).css({
					opacity : "0"
				}).fadeTo(1500, 1.0);
			});
		})
	}

})(jQuery);

/* IMAGES
 * ----------------------------------------
 */
(function ($) {
	$(document).ready(function () {
		
		$('#imageLeft').add('#imageWide').css({backgroundPosition:"1% top", opacity:0});
		$('#imageRight').css({backgroundPosition:"left 99%", opacity:0});
		
		var images = {
	        delay: 500,
	        actions:[],
	        run: function() {
                if (images.actions.length) {
                        images.actions.shift()();
                        setTimeout(images.run, images.delay);
                }
	        }
		};
		
		images.actions.push(function () {
			$('#imageLeft').fadeTo(950,1.0);
		})
		images.actions.push(function () {
			$('#imageRight').fadeTo(950,1.0);
		})
		images.actions.push(function () {
			$('#imageWide').fadeTo(1350,1.0);
		})
		
		setTimeout(images.run,500);
		
	})
})(jQuery);

/* TRIPLE PAGE stack
 * ----------------------------------------
 */
(function ($) {
	$(document).ready(function () {	
		$('.TriplePage #banners div').css({opacity:0});
		
		var triplePage = {
	        delay: 500,
	        actions:[],
	        run: function() {
                if (triplePage.actions.length) {
                        triplePage.actions.shift()();
                        setTimeout(triplePage.run, triplePage.delay);
                }
	        }
		};
		$('.TriplePage #banners div').each(function () {
			var that=this;
			triplePage.actions.push(function () {
				$(that).fadeTo(1150,1.0);	
			})
		})
		setTimeout(triplePage.run,700);
	})
})(jQuery);

/* SCROLLER - unused
 * ----------------------------------------
 */
(function ($) {
	$(document).ready(function () {		
		jQuery.easing.def = "easeInOutSine";
		var scroller = {
	        delay: 4500,
	        actions:[],
	        run: function() {
                if (scroller.actions.length) {
                        scroller.actions.shift()();
                        setTimeout(scroller.run, scroller.delay);
                }
	        }
		};

		scroller.actions.push(function () {
			$('#imageLeft').animate({backgroundPosition:"(99% top)"},9000);
		});
		scroller.actions.push(function () {
			$('#imageRight').animate({backgroundPosition:"(left 1%)"},12000);
		});
		scroller.actions.push(function () {
			$('#imageWide').animate({backgroundPosition:"(99% top)"},15000);
		});

		setTimeout(scroller.run,4000);
		
	})
})(jQuery);

/* MENU FADER
 * ----------------------------------------
 */
(function ($) {
	$(document).ready(function () {
	var fader = {
        delay: 250,
        actions:[],
        run: function() {
            if (fader.actions.length) {
                    fader.actions.shift()();
                    setTimeout(fader.run, fader.delay);
            }
        }
	};

	
	$('.HomePage #Sidebar ul li').each(function(){

		var that=this;
		$(that).css({opacity:0});
        fader.actions.push(function(){
            $(that).stop().animate({opacity:1},700);
        });
	});
	if ($.browser.name!='msie') {
		/*
console.log('enquing width animation');
*/
		$('#Menu2Holder .opaque').css({width:"0px"});
		fader.actions.push(function(){
	        $('#Menu2Holder .opaque').stop().animate({width:"576px"},{duration:1500, easing:"easeOutQuint"});
	    });
	} else {
		$('.hasMenu2 #Menu2Holder .opaque').css({width:"576px", height:"30px"});
	}

	$('.Menu2 li:not(.current) a').each(function () {
		$(this).css({opacity:0.5});
		$(this).hover(function () {					
			$(this).stop().fadeTo(500,1);					
		},function () {
			$(this).stop().fadeTo(1200,0.5);
		})
	})	

	fader.actions.push(function () {
		$("#PageContent .text").animate({opacity:1.0},{queue:false,duration:2500});
		
		/*
$("#PageContent .text").animate({opacity:1.0},900);
*/
	});
	
		$('.Menu2 li').each(function(){
        var that = this;
		
		$(that).css({opacity:0},900);	
        fader.actions.push(function(){
                $(that).animate({opacity:1.0},900);
        });
	});	
	
	$('#quotes li').each(function () {
		var p = $(this).find('p');
		$(this).hover(function () {
			p.stop().fadeTo(300,1);
		},function () {
			p.fadeTo(900,0.4);
		})
	})
	
	
	fader.run();
	})
})(jQuery);

(function ($) {
	$(document).ready(function () {
$('.bookButton').thickbox();

	})
})(jQuery);
/*

(function ($) {
	$(document).ready(function () {

		if (!$.browser.msie) {
			$('#Gallery').livequery(function () {
				var sidebar= $('#Sidebar');
				var l=sidebar.css('left');
				$(this).hover(function () {
					sidebar.stop().animate({opacity:0.3},950)
				},function () {
					sidebar.stop().animate({opacity:1},550)
				})
			})	
		}

		
		$('#tb-dim').livequery(function(){
			$(this).css({
				opacity: "0"
			});
			$(this).fadeTo({
				duration: 2100
			}, 0.75);
		})
	

		
		$('#Gallery li').livequery(function () {
			$(this).each(function() {
				var that=$(this);							
				var atag=$(this).find('a:first');
				
				var link=atag.attr('href');
				var title=atag.attr('title');				
				var url=atag.attr('rel');				
				//console.log(link+" u:" +url+" "+title);
				
				that.find('noscript').remove();
				$(function () {
			        var img = new Image();
			        $(img).load(function () {
			            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
			            $(this).hide();
			            that.removeClass('loading').css({opacity:"1"}).append(this);
			            $(this).wrap("<a class='thickbox' rel='gallery' href='"+link+"' title='"+title+"'></a>").fadeIn(1500);
			        }).error(function () {
			            //console.log("wtf");
			        }).attr('src', url);
			    });
			})
		})
		$('#Gallery a').livequery(function () {
			$(this).each(function () {
				$(this).thickbox();
			})
		})
		
	})
})(jQuery);

*/