function showDancer()
{
	$('#dancer1').fadeIn('slow',function(){
		$('#dancer2').fadeIn('slow',function(){
			$('#dancer3').fadeIn('slow',function(){
				$('#dancer4').fadeIn('slow',function(){
					$('#dancer5').fadeIn('slow');
				});
			});
		});
	});
}
function show(id)
{
	$('#'+id).toggle('slow');
}
function music()
{
//	if (window.location.pathname.length > 1) return;
//	window.open('\music','music','width=100,height=10,location=0,menubar=0,status=0');	
//	window.active();
}
function basketQuestion(element,text)
{
	if (window.detailsWith && !window.clicked2) alert(text);
	else element.parentNode.parentNode.submit();
}
function clearText()
{
	var text = $('.longdesc').html();
	while (text.search(/&lt;br&gt;/) != -1) text = text.replace(/&lt;br&gt;/,'<br>');
	$('.longdesc').html(text);
}
function productDetails(details)
{
	window.clicked = false;
	window.clicked2 = false;
	window.detailsWith = false;
	if (!details) return;
			
	$('#sizeLabel').after('<div id="productColors"></div><div id="productSizes"></div>');
	var colors = new Object();
	var sizes = new Object();
	
	details = details.split(';');
	for (var i=0; i<details.length; i++){
		
		var value = details[i].split(' x ');
		var amount = value[0];
		if (!isBig(value[1])) create(value[1],value[2]); // first color
		else create(value[1],value[2]);			
	};
}
function productRefresh(details)
{
	$('#productColors').remove();
	$('#productSizes').remove();
	delete window.clicked;
	delete window.clicked2;
	productDetails(details);
}
function create(color,size)
{
	detailsWith = true;
	if (!color || !size) window.clicked = 1; // simulate a click
	
	if (color) var colorId = color.substr(0,2);
	if (size) var sizeId = size.substr(0,2);
		
	if (color && !$('#'+colorId)[0]) createBox($('#productColors')[0],colorId,color);
	if (size && !$('#'+sizeId)[0]) createBox($('#productSizes')[0],sizeId,size);
	
	// border solid
	$('#'+colorId+', #'+sizeId).mouseover(function(){
		$('#'+colorId).css('border-style','solid');
		$('#'+sizeId).css('border-style','solid');
		window.wrong = false;
	});
	
	// border dotted
	$('#'+colorId+', #'+sizeId).mouseout(function(){
		if (!$('#'+colorId).css('background')) $('#'+colorId).css('border-style','dotted');
		if (!$('#'+sizeId).css('background')) $('#'+sizeId).css('border-style','dotted');	
	});
	
	// select -> change background
	$('#'+colorId+', #'+sizeId).click(function(){
		
		if (window.clicked2) return;
		if (window.clicked){
			
			// wrong click
			if (clicked != 1 && !$(this).css('background')){ 
				if (window.wrong) alert('Der Artikel ist in dieser Kombination leider nicht vorhanden.'); 
				window.wrong = true; // other it alerts twice
				return; 
			} 
			// second click
			else if (window.clicked != this){ 
				$(this).css('background','#E9E6D5'); 
				window.clicked2 = this;		
				var detail = $('#test_product_name').html()+' ('+$('#test_product_artnum').html()+'): ';
				if (clicked.innerHTML) detail += clicked.innerHTML+' x ';
				detail += clicked2.innerHTML;
				ajax('detail',detail);
				alert(detailNote+'\n\n'+detail);
				return; 
			} 
		} 
		
		$('#'+colorId).css('background','#FBFAF6');
		$('#'+sizeId).css('background','#FBFAF6');
		$(this).css('background','#E9E6D5');
		$(this).attr('name','clicked');
		window.clicked = this;	
	});
}
function createBox(cont,id,text)
{
	var element = document.createElement('SPAN');
	element.innerHTML = text;
	element.id = id;
	element.className = 'productBox';
	cont.appendChild(element);		
	return element;
}
function isBig(text)
{
	if (text.match(/[A-Z]/)) return true;
}
function ajax(key1,value1,key2,value2,key3,value3,key4,value4,key5,value5)
{
	var param = key1+'='+value1;
	if (key2) param += '&'+key2+'='+value2;
	if (key3) param += '&'+key3+'='+value3;
	if (key4) param += '&'+key4+'='+value4;
	if (key5) param += '&'+key5+'='+value5;

	$.ajax({
	  type: 'POST',
	  url: 'scripts/ajax.php',
	  dataType: 'json',
	  data: param,
	  success: function (answer){ ajaxAnswer(answer); }
	});
}
function ajaxAnswer(answer)
{
	
}
function object(key1,value1,key2,value2,key3,value3,key4,value4,key5,value5)
{
	var object = new Object();
	object[key1] = value1;
	if (key2) object[key2] = value2;
	if (key3) object[key3] = value3;
	if (key4) object[key4] = value4;
	if (key5) object[key5] = value5;
	return object;
}
