function maskEmail(ename, edomain, ext, eclass){
	var linktext = ename + "@" + edomain + "." + ext;
	document.write("<a href=" + "mail" + "to:" + ename + "@" + edomain + "." + ext + " class='"+eclass+"'>" + linktext + "</a>");
}
function submitForm(theform){
		document.getElementById(theform).submit();
}

function getxmlhttp (){
	//Create a boolean variable to check for a valid Microsoft active x instance.
	var xmlhttp = false;
	//Check if we are using internet explorer.
	try {
	//If the javascript version is greater than 5.
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	//If not, then use the older active x object.
	try {
	//If we are using internet explorer.
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
	//Else we must be using a non-internet explorer browser.
	xmlhttp = false;
	}
	}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
	return xmlhttp;
}

function fillType(obj){
	xmlhttp = getxmlhttp();
	xmlhttp.open("GET", "ssi/incl/calculator_ajaxad64.asp?opt=1&amp;website=" + obj);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			var xmlResponse = xmlhttp.responseXML;
			xmlRoot = xmlResponse.documentElement;
			sname = xmlRoot.getElementsByTagName("sname");
			svalue = xmlRoot.getElementsByTagName("svalue");
			type = document.getElementById("type");
			type.options.length = 1;
			for (var i=0; i<sname.length; i++){
				option = document.createElement("OPTION");
				option.value = svalue.item(i).firstChild.data;
				option.text  = sname.item(i).firstChild.data;
				type.options.add(option);
			}	
		}
	}
	xmlhttp.send(null);
}
function rateCalc()
{
	selType =  (document.getElementById("type").value).split("#");
	cost = selType[0];
	rUnit = selType[1];
	
	noImpression = document.getElementById("no_impressions").value;	
	document.getElementById("total").innerHTML = "&euro; " + cost * noImpression / 1000;
}












function list_dados( valor )
{
  if (valor == null) {
  	valor = 0;
  }
  http.open("GET", "../js/result_cbo.php?id=" + valor, true);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
}

function handleHttpResponse() {
	destination = 0;
	campo_select = document.forms[0].destination;
	if (http.readyState == 4) {
	campo_select.options.length = 0;
	results = http.responseText.split(",");
	campo_select.options[0] = new Option( "Select Destination", "0" );
	for( i = 0; i < results.length - 1; i++ ) { 
		string = results[i].split( "|" );
		campo_select.options[i+1] = new Option( string[0], string[1] );
		if (string[1] == destination) { 
			campo_select.options[i+1].selected = true;
		} 
	}
}

}
function getHTTPObject() {
var req;

try {
 if (window.XMLHttpRequest) {
  req = new XMLHttpRequest();

  if (req.readyState == null) {
   req.readyState = 1;
   req.addEventListener("load", function () {
   req.readyState = 4;

   if (typeof req.onReadyStateChange == "function")
    req.onReadyStateChange();
   }, false);
  }

  return req;
 }

 if (window.ActiveXObject) {
  var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];

  for (var i = 0; i < prefixes.length; i++) {
   try {
    req = new ActiveXObject(prefixes[i] + ".XmlHttp");
    return req;
   } catch (ex) {};

  }
 }
} catch (ex) {}

alert("XmlHttp Objects not supported by client browser");
}
var http = getHTTPObject();
// Logo após fazer a verificação, é chamada a função e passada 
// o valor à variável global http.



	function ValidarCampos() {
		if (document.form_rates.departure.value == '0') 
		  {
			alert('Please, select a departure');
			document.form_rates.departure.focus();
			return false;
		  }
		if (document.form_rates.destination.value == '0') 
		  {
			alert('Please, select a destination');
			document.form_rates.destination.focus();
			return false;
		  }
		if (document.form_rates.carros.value == '0') 
		  {
			alert('Please, select a car');
			document.form_rates.carros.focus();
			return false;
		  }
	}
