function addToFavorites() {
    
    switch(navigator.appName) {
        case "Netscape":
            window.sidebar.addPanel("Calculadora Carbono - CGD", "http://www.calculadoracarbono-cgd.com", "Calculadora Carbono - CGD");
            break;
            
        case "Microsoft Internet Explorer":
            window.external.AddFavorite("http://www.calculadoracarbono-cgd.com", "Calculadora Carbono - CGD");
            break;
            
        case "Opera":
            alert("Para adicionar o site aos bookmarks prima CTRL+D");
            break;
    }
}

function openContacts() {
    window.open('http://ws.cgd.pt/Espaco-Cliente/Contactos/Contactos.asp', '', 'width=777, height=519');   
}

var dimensions;

function getDimensions() {

  dimensions = {
  'width' : window.innerWidth ?
            window.innerWidth : //firefox
            ((document.documentElement.clientWidth == 0) ? // are we in quirks mode?
              document.body.clientWidth :  // yes we are, so this is width
              document.documentElement.clientWidth ), // no, so this is width

  'height': window.innerHeight ?
            window.innerHeight : //firefox
            ((document.documentElement.clientHeight == 0) ? // are we in quirks mode?
              document.body.clientHeight:  // yes we are, so this is width
              document.documentElement.clientHeight ), // no, so this is width

  'scrollTop' : window.pageYOffset ?
                window.pageYOffset : // ff
                (document.body.scrollTop != 0 ? //ie
                  document.body.scrollTop :  // quirks mode ie
                  (document.documentElement.scrollTop) ), // strict mode ie

  'scrollLeft': window.pageXOffset ?
                window.pageXOffset :
                (document.body.scrollLeft != 0 ? //ie
                          document.body.scrollLeft : // quirks mode ie
                          document.documentElement.scrollLeft ) // strict mode ie

  };

}



function checkBrowserHeight() {
    
    getDimensions();

    new_height = dimensions.height < 645 ? '645px' : '100%';
    
    if($('CalculadoraCarbono'))
        $('CalculadoraCarbono').height = new_height;
    else {
        if($$('embed').length)
            $$('embed')[0].height = new_height;       
    }
}

Event.observe(window, 'resize', checkBrowserHeight);
Event.observe(window, 'load', checkBrowserHeight);

