// here we define global variable
var ajaxdestination="";

function getdata(what,where) { // get data from source (what)
 try {
   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }

 document.getElementById(where).innerHTML ="<table width=100%><tr style='height:100px;'><td></td></tr><tr><td width=100%><center><img src='/design/ajax-loader.gif'><br /><br />Henter data...</center></td></tr></table>";
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 ajaxdestination=where;
 xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
 xmlhttp.open("GET", what);
 xmlhttp.send(null);
  return false;
}


function postdata(what,where,datainput1,datainput2) { // get data from source (what)
 try {
   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }

 var datalink1 = document.getElementById(datainput1).value;
 var datalink2 = document.getElementById(datainput2).value;
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 ajaxdestination=where;
 xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
 xmlhttp.open("GET", what + '&pname=' + datalink1 + '&pdomain=' + datalink2);
 xmlhttp.send(null);
  return false;
}


function getsilent(what,where) { // get data from source (what)
 try {
   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }

// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 ajaxdestination=where;
 xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
 xmlhttp.open("GET", what);
 xmlhttp.send(null);
  return false;
}


function triggered() { // put data returned by requested URL to selected DIV
  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200) 
    document.getElementById(ajaxdestination).innerHTML = xmlhttp.responseText;
}


function ClearInput(value, id){ // This calls our function ClearInput, and the two variables we will need for it to function the original value and the id.
 var input = document.getElementById(id); // Gets the input field based on its id.

 if(value == input.value){ // If the default value is equal to the current value.
	input.value = ''; // Empty It.
 }else{ // Else the value is not equal to the current input field value.
	input.value = input.value; // Leave it the same.
 } // End Else.
} // Close Function.


function togglem(eId){
	var divn1 = document.getElementById(eId);
	if (divn1.style.display == "none") { divn1.style.display = "block"; }
	else { divn1.style.display = "none"; }
}

function showDiv(eId){
	var divn1 = document.getElementById(eId);
	if (divn1.style.display == "none") { divn1.style.display = "block"; }
}
