/*<![CDATA[*/
/**
 * functions.js - Bibliothek mit uebergreifenden JavaScript Funktionen
 * 
 * Copyright (c) 2010 die.interaktiven GmbH u. Co. KG www.die-interaktiven.de
 * 
 * Alle Rechte vorbehalten. Unberechtigte Kopie und Weiter- verwendung nicht
 * gestattet.
 * 
 */
var DOCUMENT_ROOT = '/';
function doStart() {
	setStatus('LANG GmbH & Co. KG');
}
/** * We use the initCallback callback * to assign functionality to the controls */
function mycarousel_initCallback(carousel) {
	jQuery('.controls a').bind('click', function() {
		carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
		return false;
	});
	jQuery('.scroll select').bind(
			'change',
			function() {
				carousel.options.scroll = jQuery.jcarousel
						.intval(this.options[this.selectedIndex].value);
				return false;
			});
	jQuery('#next').bind('click', function() {
		carousel.next();
		return false;
	});
	jQuery('#prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};
jQuery(document).ready(function() {
	setCarouselControlNumbers();
    jQuery("#startbild-js ul.images").jcarousel({
        auto: 8, //Sekunden
    	visible: 1,
		scroll: 1,
		wrap: 'both',
		animation: 500, //Millisekunden
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null,
        itemVisibleInCallback:setCurrentElementActive,		//eingehendes Bild, Callback
        itemVisibleOutCallback:setCurrentElementInactive	//ausgehendes Bild, Callback
    });
	

	$(document).bind("contextmenu",function(e){
		return false;
	});

	
	$("a.fancy-image").fancybox();
	
	//Sprachvariante identifizieren
	sWord = "Searchterm";
	var lang = $('.choose li.active a').text();
	switch(lang) {
		case('English'): {
			sWord = "Ihr Suchbegriff";
			break;
		}
		case('Deutsch'): {
			sWord = "Searchterm";
			break;
		}
	}
	
	$('#qsearch-q').val(sWord);
	
	$('#qsearch-q').focus(function(){
		var newValue = $(this).val();
		if($(this).val() == sWord){
			$(this).attr('value','');
		} else {
			$(this).val(newValue);
		}
	});

	$('#qsearch-q').blur(function(){
		var newValue = $(this).val();
		if($(this).val() == ''){
			$(this).attr('value',sWord);
		} else {
			$(this).val(newValue);
		}
	});
});

function setCarouselControlNumbers() {
	var aImages = $('#startbild-js .images > li');
	sControls = '';
	aImages.each(function(index) {
		sControls += '<a href="javascript:void(0)" id="control_'+(index+1)+'" onclick="setActive('+(index+1)+')">'+(index + 1)+'</a>';
	});
	$('.controls').html(sControls);
}

function setActive(index) {
	//$('#control_'+index).addClass('active');	
}

function setCurrentElementActive(carousel, element, pos) {
	$('#control_'+pos).addClass('active');
}

function setCurrentElementInactive(carousel, element, pos) {
	$('#control_'+pos).removeClass('active');
}


//console.log(window.location.search);

/*
oCurrentLink = $('a[href*="'+window.location.search+'"]');
$(oCurrentLink).addClass('active');
console.log(oCurrentLink);
window.onload = doStart;
*/
/* ]]> */
