$(document).ready(function(){ 
    // Drop down menus
    //$("ul.sf-menu").supersubs({ minWidth: 12, maxWidth: 27, extraWidth: 1 }).superfish({speed: 'fast', autoArrows: false, animation: {height:'show'} }).find('ul').bgIframe({opacity:false}); 
    // Text over text boxes
//    $('label').labelOver('over-apply');

//    //default button setting
//    // do we need to increment .length manually?
//    $btn = $('.gelbtn34d'); $btn.add($('.gelbtn150d'));
//    var $form = $btn.parents('.form'); 
//    $form.keypress(function(e){ 
//        if (e.which == 13 && e.target.type != 'textarea') { 
//            if ($btn[0].type == 'submit') 
//                $btn[0].click(); 
//            else
//                eval($btn[0].href); 
//            return false; 
//        } 
//    }); 

//    if ($('#jcarousel01').length > 0){
//        $('#jcarousel01').html('');
//        $('#jcarousel01').jcarousel({ size: jcarousel01_itemList.length, itemLoadCallback: {onBeforeAnimation: jcarousel01_itemLoadCallback} });
//    }

//    $('#sc0105').localScroll({ target:'#sc0105', axis:'xy', queue:true, hash:false, duration:1000 });
//    $('#sc0104').localScroll({ target:'#sc0104', axis:'xy', queue:true, hash:false, duration:1000 });

//    $(".expandable ul").toggle();
//    $(".expandable").click(function(e) { if ($(e.target).children('ul').length > 0) { $(e.target).children('ul').toggle('fast'); } else { $(e.target).parent().children('ul').toggle('fast'); } });
    
    var options = {
        insert: '#main_image',
    	onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
			
			// fade in the image & caption
			if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
				image.css('display','none').fadeIn(1000);
			}
			caption.css('display','none').fadeIn(1000);
			
			// fetch the thumbnail container
			var _li = thumb.parents('li');
			
			// fade out inactive thumbnail
			_li.siblings().children('img.selected').fadeTo(500,0.3);
			
			// fade in active thumbnail
			thumb.fadeTo('fast',1).addClass('selected');
			
			// add a title for the clickable image
			image.attr('title','Next image >>');
		},
		onThumb : function(thumb) { // thumbnail effects goes here
			
			// fetch the thumbnail container
			var _li = thumb.parents('li');
			
			// if thumbnail is active, fade all the way.
			var _fadeTo = _li.is('.active') ? '1' : '0.3';
			
			// fade in the thumbnail when finnished loading
			thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
			
			// hover effects
			thumb.hover(
				function() { thumb.fadeTo('fast',1); },
				function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
			)
		}
    };
    jQuery(function($) { $('ul.gallery').galleria(options); });
   
});

//function jcarousel01_itemVisibleInCallback(carousel, item, i, state, evt) {
//    var idx = carousel.index(i, jcarousel01_itemList.length);
//    carousel.add(i, jcarousel01_getItemHTML(jcarousel01_itemList[idx - 1])); 
//};

//function jcarousel01_itemVisibleOutCallback(carousel, item, i, state, evt) {
//    carousel.remove(i); 
//};

//function jcarousel01_itemLoadCallback(carousel, state) {
//    for (var i = carousel.first; i <= carousel.last; i++) {
//        if (carousel.has(i)) { continue; }
//        if (i > jcarousel01_itemList.length) { break; }
//        var item = jQuery(jcarousel01_getItemHTML(jcarousel01_itemList[i-1])).get(0);
//        tb_init(item);
//        carousel.add(i, item);
//     }; 
//     $('a.toolTip').cluetip({splitTitle: '|', positionBy: 'fixed', leftOffset: -180, width: 255, showTitle: false, dropShadow: false, height:38 });
//};

//function jcarousel01_getItemHTML(item) {
//    var url_m = item.url.replace(/___Thumbnail./g, '___Selected.');
//    return '<a class="toolTip" href="' + url_m + '" title="|' + item.title + '"><img src="' + item.url + '" width="98" height="98" border="0" alt="' + item.title + '" /></a>'; 
//};

