/* scrolling internally */
$(function(){$.fn.scrollToTop=function(options){if(options.speed){var speed=options.speed;}else{var speed="slow";}if(options.ease){var ease=options.ease;}else{var ease="jswing";}if(options.start){var start=options.start;}else{var start="0";}var scrollDiv=$(this);$(this).hide().removeAttr("href");if($(window).scrollTop()>start){$(this).fadeIn("slow");}$(window).scroll(function(){if($(window).scrollTop()>start){$(scrollDiv).fadeIn("slow");}else{$(scrollDiv).fadeOut("slow");}});$(this).click(function(event){$("html, body").animate({scrollTop:"0px"},speed,ease);});}});


$(function()
{
	
	if ($('div#callbackform').length) 
	{
		$('a#requestacallback').click(function()
		{
			if($("div#callbackform").is(':visible'))
			{
				$("div#callbackform").slideUp('fast');
			}	
			else
			{
				$("div#callbackform").slideDown('fast');
			}
				
			return false;
		});
	}
	



	/* 
	=	LIZARD BOX 
	*/

	// some functions to resuse
	function slideboxin(){	$("div#lizardbox").animate({"marginTop": "+=50px", "opacity": "toggle"}, "slow");}
	function slideboxout(){	$("div#lizardbox").animate({"marginTop": "+=50px", "opacity": "toggle"}, "slow");}
	function fademaskout(){	$("div#lizardmask").fadeOut("fast")}

	// login button
	$('div#lizard').click(function()
	{
		$("div#lizardmask").fadeTo('fast', 0.5, slideboxin);
	});

	// click mask to dismiss
	$("div#lizardmask").click(function()
	{
		$("div#lizardbox").animate({"marginTop": "-=50px", "opacity": "toggle"}, "slow", fademaskout);
	});

	// or closeme button
	$("span#closeme").click(function()
	{
		$("div#lizardbox").animate({"marginTop": "-=50px", "opacity": "toggle"}, "slow", fademaskout);
	});



/*
=	back to the top!
*/

	$("#btt").scrollToTop({
		speed: "slow",
		//ease:  "easeOutBounce",
		start: 100
	});




/*
=	SCROLLING SIDEBAR QUOTES
*/

	$('ul#quotescroll').cycle({
		fx: 'fade',
		speed:  'slow',
		timeout: 10000,
		cleartype: !$.support.opacity
	});




	if ($('div#slideshow ul#slides').length != 0) 
	{
		$('ul#slides').cycle({
			fx: 'fade',
			speed:  'slow',
			timeout: 8000,
			cleartype: !$.support.opacity
		});

		$('ul#foliothumbs li a').click(function()
		{ 
			var ci = $(this).parent().index();
			//alert(ci);
			$('ul#slides').cycle(ci); 
			return false; 
		}); 
	}




	if ($('div#slideshowpager ul#slides').length != 0) 
	{
		$('ul#slides') .cycle({ 
			fx:     'fade', 
			speed:  'slow', 
			timeout: 5000, 
			pager:  '#slidepager'
		});

	}




});
