function changeType(typeID, typeLabel){
  var link = "./types.php?typeID=" + typeID + "&typeLabel=" + typeLabel;
  window.location = link;
}

function changePage(link){
  window.location = link;
}

function goToProfile(name){
  urlName = replaceChars(name);	
  var link = "http://myarea.ca/" + urlName;
  window.location = link;
}

function changeRegistrationForm(userType){
  var link = "./calendar?userType=" + userType;
  window.location = link;
}


function buildingListing(buildingID){
  var link = "./listing.php?buildingID=" + buildingID;
  window.location = link;
}

function areaListing(areaID){
  var link = "./listing.php?areaID=" + areaID;
  window.location = link;
}



function ajaxFunction(type, arg1, arg2, arg3){

	var ajaxRequest = null;  // The variable that makes Ajax possible!

   try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
   } catch (e) {

   try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("This feature was disabled by your browser.");
				return false;
			}
		}
	}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState==4 || ajaxRequest.readyState=="complete"){
          if (type == 'emailTest'){		
		    alert(ajaxRequest.responseText);
		  }
          if (type == 'contactFriend'){		
//		    alert(ajaxRequest.responseText);
		  }		  
      }
	}

    if (type == 'emailTest'){
      var emailSubject = document.getElementById('emailSubject').value;	
      var emailBody = document.getElementById('emailBody').innerHTML;	  

      var queryString = "?action=" + type + "&emailSubject=" + emailSubject + "&emailBody=" + emailBody; 	
      ajaxRequest.open("GET", "../../includes/ajaxFormmail.php" + queryString, true);
	  ajaxRequest.send(null); 	  
	}
}

function addToAtrributeList(numItems) {

var eventsList = " ";
var box;
var i = 0;
var totalCost;
var estCost;
//alert(numItems);
for (var j = 22; j <= numItems; j++) {
  box = eval("document.usersForm.checkbox" + j); 	  
  if ((box)&&(box.checked == true))
  {
      eventsList += " "  + j + ",";
  }  
}
//alert("Hi"+eventsList);
inputEventsList = eval("document.usersForm.eventsList");    
inputEventsList.value = eventsList;
}

function replaceChars(entry) {
out = " "; // replace this
add = "_"; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
return temp;
}

function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}