/*
---
BEHAVIOURS.JS
---
(c)2009
indual GmbH, Brig
---
*/

var label_search = 'Suche...';

/* + Functions ----------------------------------------------------------------- */
function init_gallery (id, gallery_attributes) {
	// does the gallery exists?
	if ($('#gallery'+id).length) {
		$('#gallery'+id+' a').lightBox(gallery_attributes);
		return true;
	}
	return false;
}
function loadSearchButton() {
	btn = document.getElementById('searchfield');
	if (btn) {
		btn.onblur = function() { if (btn.value == '') btn.value = label_search; }
		btn.onfocus = function() { if (btn.value == label_search) btn.value = '';	}
	}
}
function setSearchLabel(newlabel) {
	label_search = newlabel;
}

/* + On load events ------------------------------------------------------------ */
$(document).ready(function() {
	
	// init
	var gallery_index = 1;
	var gallery_attributes = {
		overlayBgColor: '#999',
		overlayOpacity: 0.6,
		txtImage: '',
		txtOf: 'von',
		fixedNavigation: true,
		imageLoading: '/we/images/lightbox/lightbox-ico-loading.gif',
		imageBtnPrev: '/we/images/lightbox/lightbox-btn-prev.gif',
		imageBtnNext: '/we/images/lightbox/lightbox-btn-next.gif',
		imageBtnClose: '/we/images/lightbox/lightbox-btn-close.gif',
		imageBlank: '/we/images/lightbox/lightbox-blank.gif'
	};
	
	// Slide Shows
	if ($('#startimage').length) {
		$('#startimage').cycle({ 
			fx:'fade', 
			speed:1000,
			timeout:4000
		});
	}
	
	// quicksearch
	loadSearchButton();
	
	// init galleries
	while (true == init_gallery(gallery_index, gallery_attributes)) {
		// init next box
		gallery_index += 1;
	}
	
})