function showDiv(h) {
    for(i = 1; i < 10; i++) {
        if(i == h) { 
            document.getElementById('faq'+i).style.display = 'block';
        }
        else { 
            document.getElementById('faq'+i).style.display = 'none';
        }
    }
}

function addToFavorites() {
    switch(navigator.appName) {
        case "Netscape":
            window.sidebar.addPanel("Cart�o Carbono Zero - CGD", "http://cartaocarbonozero.cgd.pt","");
            break;
    
        case "Microsoft Internet Explorer":
            window.external.AddFavorite("http://cartaocarbonozero.cgd.pt", "Cart�o Carbono Zero - CGD");
            break;
    
        case "Opera":
            alert("Para adicionar o site aos bookmarks prima CTRL+D");
        break;
    }
}

function createForm(options) {
  form = document.createElement("form");
  if (options["id"])      form.setAttribute("id",     options["id"]);
  if (options["name"])    form.setAttribute("name",   options["name"]);
  if (options["method"])  form.setAttribute("method", options["method"]);
  if (options["action"])  form.setAttribute("action", options["action"]);
  return form;
}
function createHidden(options) {
  hidden=document.createElement("input");
  hidden.setAttribute("type", "hidden");
  if (options["name"])  hidden.setAttribute("name",   options["name"]);
  if (options["value"]) hidden.setAttribute("value",  options["value"]);
  if (options["id"])    hidden.setAttribute("id",     options["id"]);
  return hidden;
}


function submitSelect(idSelect) {
	var selectInput = document.getElementById(idSelect);
	var value = selectInput[selectInput.selectedIndex].value;
	submitDO(value);
}


function submitDO(DO) {
  sForm = document.getElementById("submitDOForm");
  if(!sForm) {
    sForm = createForm({id: "submitDOForm", name: "submitDOForm", action: "/sps/digitalOffer/anonymous.do", method: "get"});
    sForm.appendChild(createHidden({name:"SPS_PROMOTER", value:"cgd"}));
    sForm.appendChild(createHidden({name:"SPS_CAMPAIGN", value:"carbonozero"}));
    sForm.appendChild(createHidden({name:"DO1", value:"", id:"DO1"}));
    sForm.appendChild(createHidden({name:"Q1", value:"1"}));
    sForm.appendChild(createHidden({name:"DO2", value:"14b01b35f94a389017c28c5890d"}));
    sForm.appendChild(createHidden({name:"Q2", value:"1"}));
    document.getElementById("loja").appendChild(sForm);
  }
  sForm["DO1"].setAttribute("value", DO);
  sForm.submit();
}

