function themenweltSortieren(obj){
	var objectValue = obj.value;
	if(objectValue > -1 && objectValue < 4){
		location.href="sortThemenwelt.htm?sort="+objectValue;
	}
}

function openBlk(link){
	var width = window.screen.availWidth-40;
	var height = window.screen.availHeight-40;
	window.open(link, "blkWindow", "height="+height+",width="+width+",left=20,top=20,resize=true");
}

// Cookie setzen
function setCookie(name, wert, expires){	
	if (document.cookie){
		var cookie = name + "="+unescape(wert)
		cookie += (expires) ? "; expires="+expires : ""
		document.cookie = cookie
	}
}

function showRechnungsAdresse(){
	  document.getElementById("lieferAdresseDiv").style.display="none";
	  document.getElementById("hermesAdresseDiv").style.display="none";
}

function showLieferAdresse(){
	  document.getElementById("lieferAdresseDiv").style.display="block";
	  document.getElementById("hermesAdresseDiv").style.display="none";
}

function showHermesAdresse(){
	  document.getElementById("lieferAdresseDiv").style.display="none";
	  document.getElementById("hermesAdresseDiv").style.display="block";
}

function changeSB(farbCode, groesseCode, farbElement, groesseElement){
	if(farbCode != ""){
		tmp = farbElement.replace('.', "\\.");
		$("#" + tmp + " option[value='" + farbCode + "']").attr("selected", "selected").change();
	}

	if(groesseCode != ""){
		tmp = groesseElement.replace('.', "\\.");
		$("#" + tmp + " option[value='" + groesseCode + "']").attr("selected", "selected").change();
	}
}

function showAusverkauftMatrix(zeile){
	var matrix = document.getElementById("ausverkauftMatrix" + zeile);
	matrix.style.visibility = "visible";
	matrix.style.display="block";
}

function startBMSlider(slides){

	  var currentPosition = 0;
	  var slideWidth = 105;
	  var numberOfSlides = slides.length;
	  
	  // Remove scrollbar in JS
	  $('#slidesContainer').css('overflow', 'hidden');

	  // Wrap all .slides with #slideInner div
	  slides
	  .wrapAll('<div id="slideInner"></div>')
	  // Float left to display horizontally, readjust .slides width
	  .css({
	    'float' : 'left',
	    'width' : slideWidth
	  });

	  // Set #slideInner width equal to total width of all slides
	  $('#slideInner').css('width', slideWidth * numberOfSlides);

	  if(numberOfSlides > 3){
		  // Insert left and right arrow controls in the DOM
		  $('#slidesContainer')
		    .prepend('<div class="control" id="leftControl">Move left</div>')
		    .append('<div class="control" id="rightControl">Move right</div>');
	  }
	  // Hide left arrow control on first load
	  manageControls(currentPosition);

	  // Create event listeners for .controls clicks
	  $('.control')
	    .bind('click', function(){
	    // Determine new position
	      currentPosition = ($(this).attr('id')=='rightControl')
	    ? currentPosition+1 : currentPosition-1;

	      // Hide / show controls
	      manageControls(currentPosition, numberOfSlides);
	      // Move slideInner using margin-left
	      $('#slideInner').animate({
	        'marginLeft' : slideWidth*(-currentPosition)
	      });
	    });
}

// manageControls: Hides and shows controls depending on currentPosition
function manageControls(position, numberOfSlides){
  // Hide left arrow if position is first slide
  if(position==0){ $('#leftControl').hide() }
  else{ $('#leftControl').show() }
  // Hide right arrow if position is last slide
  if(position==numberOfSlides-1){ $('#rightControl').hide() }
  else{ $('#rightControl').show() }
}

function showMediaGross(bild){
}


// Schliesst das Div dessen Name uebergeben wurde
function closeLayer(name){
	document.getElementById(name).style.visibility = "hidden";
}

function oeffneLeseprobe(url){
	windowProduktProbe = window.open(url, "Leseprobe", "menubar=no,status=no,toolbar=no,width=850,height=500,resizable=yes");
	windowProduktProbe.focus();
}

function oeffneHoerprobe(url){
	windowProduktProbe = window.open(url, "Hoerprobe", "menubar=no,status=no,toolbar=no,width=400,height=640,resizable=yes");
	windowProduktProbe.focus();
}

function getIdFromValue(value) {
	score = 1;
	indexOfUnderscore = value.indexOf('_');
	score = value.substring(indexOfUnderscore+1, value.length);
	return parseInt(score);
}

