hs.graphicsDir = 'http://www.zerozero.pt/script/highslide/graphics/';

hs.showCredits = false;
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.fadeInOut = true;
hs.outlineType = 'rounded-black';
hs.wrapperClassName = 'dark';
hs.captionEval = 'this.a.title';
hs.dimmingOpacity = 0.8;
//hs.numberPosition = 'caption';
hs.useBox = true;
hs.width = 684;
hs.height = 662;
hs.numberOfImagesToPreload = 1;

hs.headingText = 'ad';

hs.headingOverlay = {
    className: 'highslide-banner',
    position: 'rightpanel',
    width: '310px'
}


hs.Expander.prototype.onAfterGetHeading = function(sender) {
    if (sender.heading) {
	sender.heading.innerHTML = '<iframe src="' + this.custom.url + '" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" id="frame"></iframe>';
    }
};

// Add the controlbar
hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		//className: 'text-controls',
		//offsetY: '-60',
		//relativeTo: 'viewport',
		position: 'bottom center',
		opacity: .75,
		hideOnMouseOut: true
	},
	thumbstrip: {
		position: 'above',
		mode: 'horizontal',
		relativeTo: 'expander'
	}
});

/*
// Make all images animate to the one visible thumbnail
var miniGalleryOptions1 = {
	thumbnailId: 'thumb1'
}
*/

function makeScrollable(w, s){
    // Get jQuery elements
    var wrapper = $(w);
    var scrollable = $(s);
    
    // Hide images until they are not loaded
    scrollable.hide();
    var teste = $('div.galeria_news');
    var testeWidth = teste.width();
    
    var loading = $('<div class="loading">a carregar fotos...</div>').appendTo(wrapper);
    
    // Set function that will check if all images are loaded
    var interval = setInterval(function(){
	var images = scrollable.find('img');
	var completed = 0;
	    
	// Counts number of images that are succesfully loaded
	images.each(function(){
		if (this.complete) completed++;	
	});
	if (completed == images.length){
	    clearInterval(interval);
	    // Timeout added to fix problem with Chrome
	    setTimeout(function(){
		loading.hide();
		teste.width(testeWidth);
		// Remove scrollbars	
		wrapper.css({overflow: 'hidden'});						
		scrollable.slideDown('slow', function(){
		    enable();	
		});					
	    }, 1000);	
	}
    }, 100);
    
    function enable(){
	
	//Get our elements for faster access and set overlay width
	var div = $('div.zz_strip'),
	ul = $('ul.zz_strip'),
	// unordered list's left margin
	ulPadding = 15;

	//Get menu width
	var divWidth = div.width();
	var ulWidth = ul.width();
	
	//Remove scrollbars
	div.css({overflow: 'hidden'});
    
	//Find last image container
	var lastLi = ul.find('li:last-child');
	
	//When user move mouse over menu			
	wrapper.mousemove(function(e){
	    var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
	    var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
	    if (left < 0){
		left = 0;
	    }	
	    div.scrollLeft(left);		
	});		
    }
}


