// JavaScript Document

var showScroll1 = true;
var showScroll2 = false;
var showScroll3 = false;
var showScroll4 = false;
var showRightScroll = false;
var mobileSafari = false;
var agent = navigator.userAgent.toLowerCase();
var version = navigator.appVersion.toLowerCase();
var isReady = false;
var heightCorrection = 0;

/*
alert( "navigator.userAgent: " + navigator.userAgent +
	   "\nnavigator.appVersion: " + navigator.appVersion + 
	   "\nnavigator.appMinorVersion: " + navigator.appMinorVersion );
*/
if( ( agent.indexOf('iphone') !=-1 ) || ( agent.indexOf('ipad') !=-1 ) ||
	( version.indexOf('iphone') !=-1 ) || ( version.indexOf('ipad') !=-1 ) )
{
	mobileSafari = true;
	//alert("Mobile Safari!");
}

function startup()
{
	//location.hash = 'currentPage';
}

function ie_reload()
{
	//alert("reload for IE");
	if( init )
	{
		//location.reload(true);
		//window.history.go(0);
		//window.location.replace(window.location.href); 
		init = false;
	}
}


var j = jQuery.noConflict();

function teaserFadeIn()
{
	j('#teaserImg').stop();
	j('#teaserImg').fadeTo( 2000, 1 );
	// set filter to 'none' when done
	setTimeout( "changeInfo();", 1000 );
}

function teaserFadeOut()
{	
    // reset the filter incase it was set to 'none' before
	j('#teaserImg').css( "filter", " " );
	
	j('#teaserImg').stop();
	j('#teaserImg').fadeTo( 4000, 0 );
	j('#teaserImg').css( "cursor", "wait" );
	
}

function changeInfo()
{
	j('#teaserImg').css( "filter", "none" );
	j('#teaserImg').css( "cursor", "pointer" );
}

function setHeights()
{
 var contentHeight = 200;
 var contentHeight2 = 380;
 var windowHeight = 0;
 var topImgHeight = 180;
 
	if( isReady )
	{
		if( typeof( window.innerHeight ) == 'number' )
		{
			windowHeight = window.innerHeight;
		}
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		{
			windowHeight = document.documentElement.clientHeight;
		}
		if( windowHeight > 0 )
		{
			contentHeight = (windowHeight - heightCorrection) - 405;
		}
		contentHeight2 = contentHeight + topImgHeight;
		//alert( "Window height: " + windowHeight );
		//j('#scroll1').css({height: contentHeight + "px"});
		
	   j(function()
		{
		   // this initialises the scollpanes on the page.
		   if( showScroll1 )
		   {
			   j('#scroll1').css({height: contentHeight + "px"});
			   if( mobileSafari )
			   {
				   j('#scroll1').jScrollTouch();
			   }
			   else
			   {
				   j('#scroll1').jScrollPane({ scrollbarOnLeft:false, 
											   showArrows:true, 
											   scrollbarWidth: 14, 
											   arrowSize: 0,
											   verticalGutter: 10, 
											   reinitialiseOnImageLoad: true, 
											   arrowScrollOnHover: true});
			   }
		   }
		   if( showScroll2 )
		   {
			   j('#scroll2').css({height: contentHeight2 + "px"});
			   if( mobileSafari ) 
			   {
				   j('#scroll2').jScrollTouch();
			   }
			   else
			   {
				   j('#scroll2').jScrollPane({ scrollbarOnLeft:false, 
											   showArrows:true, 
											   scrollbarWidth: 14, 
											   arrowSize: 0,
											   verticalGutter: 10, 
											   reinitialiseOnImageLoad: true, 
											   arrowScrollOnHover: true});
			   }
		   }
		   
		   if( showScroll3 )
		   {
			   j('#scroll3').css({height: contentHeight2 + "px"});
			   if( mobileSafari )
			   {
				   j('#scroll3').jScrollTouch();
			   }
			   else
			   {
				   j('#scroll3').jScrollPane({ scrollbarOnLeft:false, 
											   showArrows:true, 
											   scrollbarWidth: 14, 
											   arrowSize: 0,
											   verticalGutter: 10, 
											   reinitialiseOnImageLoad: true, 
											   arrowScrollOnHover: true});
			   }
		   }
		   if( showScroll4 )
		   {
			   j('#scroll4').css({height: contentHeight2 + "px"});
			   if( mobileSafari )
			   {
				   j('#scroll4').jScrollTouch();
			   }
			   else
			   {
				   j('#scroll4').jScrollPane({ scrollbarOnLeft:false, 
											   showArrows:true, 
											   scrollbarWidth: 14, 
											   arrowSize: 0,
											   verticalGutter: 10, 
											   reinitialiseOnImageLoad: true, 
											   arrowScrollOnHover: true});
			   }
		   }
		   
		});	
	}
}

j(document).ready(function() 
 {
	 isReady = true;
	 
   setHeights();
   if( mobileSafari )
   {
	   j('#teaserImg').css( "display", "block" );
   }
   else
   {
	   j('#teaserImg').fadeIn( 2000, function() 
		  {
			// Animation complete
		  });
	   
   }
   
   //jQuery(".bdLightbox").colorbox({transition:"fade"});
 });

