/*** BIKE TYPE CHOOSER ***/
var currentMenu = null;
var active = null;
if (!document.getElementById) document.getElementById = function() { return null; }

function initMenu(menuid, menuaktivator)
{
	var menu = document.getElementById(menuid);
	var activator = document.getElementById(menuaktivator);
		
	if (menu == null || activator == null) return;

    activator.onmouseover = function() {    		
    	if (currentMenu == null) {
            this.showMenu();
        }
    	if (currentMenu) {
            currentMenu.style.visibility = "hidden";
            this.showMenu(); 
        }
        window.clearTimeout(active);
    }
    
    activator.onmouseout = function() {
    	active = window.setTimeout("closeMenu()", 250);
    }
    
    menu.onmouseout = function() {
    	active = window.setTimeout("closeMenu()", 250);
    }
    
    menu.onmouseover = function() { 	
    	window.clearTimeout(active);
    }
    
    menu.onclick = function() {
    	if (currentMenu) {
         closeMenu();
      	}
    }
	
	activator.showMenu = function(){
		menu.style.visibility = "visible";
		currentMenu = menu;
		
	}
	closeMenu = function(){
		if(currentMenu){
			currentMenu.style.visibility = "hidden";
			currentMenu = null;
		}
	}
}
/*** BIKE TYPE CHOOSER END ***/

/******************************************/
/********** ENHANCED CHECKBOXES  **********/
/******************************************/
function enhanceCheckboxes() {
  var ar=document.getElementsByTagName("input");
  for(var i=0; i < ar.length; i++) {
    if (ar[i].type=='checkbox') {
      ar[i].style.display='none';     
      var img = document.createElement("img");    
	  img.align = "middle";      
      if (ar[i].checked) {
        img.src="data/media/_shared/forms/checkbox_active.gif";
        img.title="Checked";
      }else{
        img.src="data/media/_shared/forms/checkbox.gif";
        img.title="Unchecked";
      } 
      img.onclick = toggleCheckbox;
      ar[i].parentNode.insertBefore(img, ar[i]);    
    }  
  }
}

function toggleCheckbox() {
  if (this.title == "Checked") {  
    this.src="data/media/_shared/forms/checkbox.gif";
    this.title="Unchecked";
    this.nextSibling.checked=false;
  }else{
    this.src="data/media/_shared/forms/checkbox_active.gif";
    this.title="Checked";
    this.nextSibling.checked=true;
  }
  /** 
  * if for shopfinderContent:
  * * * * * * * * *
  * to send the fomular fields
  * needed because onclick on the
  * x-checkbox is overwritten by this function
  */
  if(document.getElementById('countrychooser')){
	  document.getElementById('countrychooser').submit();
  }
}
/********** ENHANCED CHECKBOXES end **********/
