
var loadTimer = null;
var resizeTimer = null;
	
function initGUI()
{     
 	loadTimer = setTimeout(addScrollbars, 100);
	
	$('input.error').focus(function(){
		$(this).removeClass('error');
	});
	
    if( $('input#input_file').size() > 0 ){
		SI.Files.htmlClass = 'SI-FILES-STYLIZED';
		SI.Files.wrapClass = 'file';
		SI.Files.fileClass = 'input_file';
		SI.Files.stylizeById('input_file');
	}
    
    /*
    slideshow
    */
    $('#slideshow').after('<div id="slideshownav">').cycle({ 
	    fx:    'fade', 
	    speed:  500,
	    timeout:  5000,
	    pager:  '#slideshownav'
 	});

    $('#slideshownav>a').mouseover(function(){
    	$('#slideshow').cycle('pause');
    	toggleDescription(false);
    }).click(function(){ 
    	$('#slideshow').cycle('pause');
   	}).mouseout(function(){ 
    	$('#slideshow').cycle('resume');
    	toggleDescription(true);
   	});
    
    /*
    teamslides
    */
    $('#teamslides').cycle({ 
	    fx:    'fade', 
	    speed:  1000,
	    timeout:  5000
 	});
	
	/*
	Google Maps
	*/
	if (GBrowserIsCompatible()) {
      var map = new GMap2(document.getElementById("map_canvas"));
      //var point = new GLatLng(48.13212, 11.53568);
      var point = new GLatLng(48.13205, 11.5358);
      map.addControl(new GSmallMapControl());
      map.setCenter(point, 17);
      var mapControl = new GMapTypeControl();
	  map.addControl(mapControl);
	  map.enableScrollWheelZoom();
	  
      var markerIcon = new GIcon(G_DEFAULT_ICON);
      markerIcon.image = "http://www.janmassberg.com/clmap/images/marker.png";
      markerIcon.shadow = "http://www.janmassberg.com/clmap/images/markerShadow.png";
      markerIcon.iconSize = new GSize(38, 46);
      markerIcon.shadowSize = new GSize(60, 46);
       
      // Set up our GMarkerOptions object
      markerOptions = { icon:markerIcon };
      var marker = new GMarker(point, markerOptions);
	  map.addOverlay(marker);

    }

}

function addScrollbars() 
{	
	if(loadTimer) clearTimeout(loadTimer);
	var div = $('div.scroll-content');
	if( div.size() > 0 )
	{
		var h = div.innerHeight();
		if( h > 380 )
		{
			var $scrollcontainer = $('<div></div>').attr({'className':'scroll-container'});
			var $scrollpane = $('<div></div>').attr({'className':'scroll-pane'}).attr({'id':'content-scrollpane'});
			div.wrap($scrollcontainer).wrap($scrollpane);
			$('#content-scrollpane').jScrollPane({scrollbarWidth:6, scrollbarMargin:0});
 		}
 	}
}

var descToggle = false;
var descVisible = true;
var descTimer = false;

function toggleDescription(s)
{
	if( !descToggle ) return;
	if( descTimer ) window.clearTimeout(descTimer);
	if( s ){
		if( !descVisible ){
			if( descTimer ) window.clearTimeout(descTimer);
			descTimer = window.setTimeout("fadeInDescription()", 500);
		}
	} else {
		if( descVisible ){
			descVisible = false;
			$('#column-1').fadeOut('slow');
		}
	}
}

function fadeInDescription()
{
	descVisible = true;
	descTimer = false;
	$('#column-1').fadeIn('slow');
}

$(document).ready( function(){
	initGUI();
});





