function WriteDiv(text, id) {
  x = document.all?document.all[id]:document.getElementById(id);
  x.innerHTML = text;
  return false;
}

function focus() {
  document.search.search.focus();
}

function isCheckedPaketti(checkbox) { 
  
  if ( checkbox.checked != true ) {
    return confirm('Oletko varma ettet halua pakettialennusta tilauksellesi?');
  }
  
  return true;
}

function toggleDivCheckbox(checkbox, id) {
  if ( checkbox.checked != true ) {
    hidediv(id);
  } else { 
    showdiv(id);
  }
  return true;
}

function toggle(id) {
  if ( document.getElementById(id).style.display == 'none' ) {
    showdiv(id);
  } else {
    hidediv(id);
  }
  
  return false;
}

function showhide(id1,id2) {
  hidediv(id2);
  showdiv(id1);
}

function hidediv(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	} else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		} else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	} else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		} else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function getSelectedOption(group) {
   if (group[0]) {
      for (var i=0; i<group.length; i++) {
         if (group[i].selected) {
            return i;
         }
      }
   } else {
      if (group.selected) { 
        return 0; 
      }
   }
   
   return -1;
}

function getSelectedOptionValue(group) {
   var i = getSelectedOption(group);
   if (i == -1) {
      return "";
   } else {
      if (group[i]) {
         return group[i].value;
      } else {
         return group.value;
      }
   }
}

function getTestAlert(group,div1,div2) {
  if ( getSelectedOptionValue(group) == 'LA' ) {
    showdiv(div1);
    showdiv(div2);
  } else {
    hidediv(div1);
    hidediv(div2);
  }
}

function checkPostType(group,div1,div2) {
  if ( getSelectedOptionValue(group) == 'ARRA' ) {
    showdiv(div1);
    showdiv(div2);
  } else {
    hidediv(div1);
    hidediv(div2);
  }
}

function popUpDim(URL,WID,HEI) {
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+WID+",height="+HEI+",left = 300,top = 220');");
}

function popUp(URL) {
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=500,left = 300,top = 220');");
}

function popUpSmall(URL) {
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=320,height=200,left = 300,top = 220');");
}

function varmistaTilausvahvistus() { 
  alert("Varmista, että laskun maksamisen jälkeen tulet sivulle jossa näet \ntilauksesi tiedot ja että saat tilausvahvistuksen sähköpostiisi.\n\nVirhetilanteessa ota yhteyttä asiakaspalveluumme asiakaspalvelu@booky.fi.");
} 

function kysyVarmistus(text) { 
  return confirm(text);
} 


