// menu
function dropdownMenu(menuID, toppos)
{
	document.getElementById('dropdown'+menuID).style.display = 'block';
	// wrapper1 is the id of the main Div; because the page is centered this is used to work out how far in the page is (+ 59px margin)
	maintableLeft = document.getElementById('wrapper1').offsetLeft + 59 ;
	document.getElementById('dropdown'+menuID).style.left = maintableLeft + document.getElementById('td'+menuID).offsetLeft + 'px';
//	document.getElementById('dropdown'+menuID).style.left = document.getElementById('td'+menuID).offsetLeft + 'px' ;
	document.getElementById('dropdown'+menuID).style.top = toppos + 'px';
}
function dropupMenu(menuID)
{
	document.getElementById('dropdown'+menuID).style.display = 'none';	
}
 function show( targetId )
    {
  	if (document.getElementById)
        {
  		target = document.getElementById( targetId );
        target.style.display = "";
  		}
    }


    function hide( targetId )
    {
  	if (document.getElementById)
        {
  		target = document.getElementById( targetId );
        target.style.display = "none";
  		}
    }
    

 function changeClass( targetId,targetClass )
    {
    
      if (document.getElementById)
        {
          target = document.getElementById( targetId );
          target.setAttribute("class", targetClass );
          }
    }
    


    
function SM_BR_dealer_popup(inputElement,innerInputElement,tyreID)
    {
        if(document.getElementById(inputElement).style.display=='block') 
        {
            document.getElementById(inputElement).style.display = 'none';
            document.getElementById('block_out').style.display = 'none';
        }
        else 
        {
            document.getElementById(inputElement).style.display = 'block';
            document.getElementById('block_out').style.display = 'block';
            document.getElementById(innerInputElement).src = '/selector.php?formaction=choose_dealer&tyreID='+tyreID;
        }
    }  

    
    
 function checkRadio( targetId)
    {
      if (document.getElementById)
        {
          target = document.getElementById( targetId );
          target.checked = true;
          }
    }
    
    

function displayBookings( container_id,selectedContainerClass,notSelectedContainerClass ) {
    var rows = document.getElementById(container_id).getElementsByTagName('td');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'radio' ) {
            unique_id = checkbox.name + checkbox.value;
            tdID = 'td_' + checkbox.id ;
            container = document.getElementById( tdID );
                if (checkbox.checked == true) 
                  {
                  container.setAttribute("class", 'booking_booked');
                  }
              else
                  {
                  container.setAttribute("class", 'booking_available');
                  }

        }
    }

    return true;
}
    
    
    
    
    
