function toggleDisplay(elementId) {
	div = document.getElementById(elementId);
	if (div.style.display == 'none') {
		div.style.display = 'block';
	} else {
		div.style.display = 'none';
	}
}	
function displaySelectedNodeOnly(selectedNodeIndex, prefixId, allNodesNbr) {
	for(x = 0; x < allNodesNbr; x++ ) {
		child = document.getElementById(prefixId + x);
		if (x == selectedNodeIndex) {
			child.style.display = 'block';
		} else {
			child.style.display = 'none';
		}
	}
}

$(function() {
    $('.screenshots a').lightBox();

/*
    $('input[type=submit]').hide().each(function(index, item){
    	that =  $(item);
    	that.before(
    			$("<a class='button' href='#'></a>").html(that.attr("value")).click(function(){
    				$(item).click();
    			}));
    });
*/
    if(cart_items > 0){
    	//$("#menu >  li > a").width("60px");
    	$("#menu .cart").append(" (" + cart_items +")  ").parent().show();
    	
    }
   // Bundles
   $("#bundles .price").filter(function(){
	   var that = $(this), price;
	   var classList = that.attr('class').split(' ');
	   $.each(classList, function(index, item){
		   var pos = item.indexOf("price-");
		   if(pos === 0){
			  price = item.substr(6, 3)*1.0;
		   }
	   });
	  return that.text() < price;
   }).after(" &euro; <span class='cohmpletion'>Cohmpletion !</span>");
});


/// Menu	
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function(){  
   $('#menu > li').bind('mouseover', jsddm_open);
   $('#menu > li').bind('mouseout',  jsddm_timer);
   
   $('input').each(function() {
   		$(this).focus(function() {
			$('label[for='+$(this).attr('id')+']').html('');
			//	$(this).addClass('focused');
		});
		
		$(this).blur(function() {
			if($(this).val() === '') {
				$('label[for='+$(this).attr('id')+']').html($('label[for='+$(this).attr('id')+']').attr('title'));
				//.removeClass('focused');
			}
		});
	});
   
  }
);



document.onclick = jsddm_close;