
// Create a Cookie
function bakeCookie(n,v) {
    document.cookie=n+"="+v;
    window.location.href=window.location.href
}
// Create a Cookie
function bakeCookie_root(n,v) {
    document.cookie=n+"="+v+"; path=/";
    window.location.href=window.location.href
}
// Create a Cookie
function bakeCookie_root_latch(n,v,l) {
    document.cookie=n+"="+v+"; path=/";
    window.location.href=window.location.href+"#"+l;
}
// Delete additional travel guide
function delete_additional_tg (id,user) {
    string = "Are you sure you want to delete this listing?";
    if (window.confirm(string)) {
            idstring = "http://www.ottawavalley.travel/cface/publications/update.php?id="+id+"&mode=delete_tg&user="+user;
            window.location.href=idstring;
    }
}
// Drop down menu 
function show(id) {
  var d = document.getElementById(id);
      for (var i = 1; i<=10; i++) {
          if (document.getElementById('menu'+i)) {document.getElementById('menu'+i).style.display='none';}
      }
  if (d) {d.style.display='block';}
}

// Calendar Popups
function show_calpopup(id) {
  var d = document.getElementById(id);
      for (var i = 1; i<=31; i++) {
          if (document.getElementById('calpopup'+i)) {document.getElementById('calpopup'+i).style.display='none';}
      }
  if (d) {d.style.display='block';}
}

// Function to delete an item from the database
function delete_item(id,un) {
	string = "Are you sure you want to delete this item?";
	if (window.confirm(string)) {
		idstring = "http://www.ottawavalley.travel/control/membercontrol.php?id="+id+"&mode=delete&un="+un;
		window.location.href=idstring;
	}
}
// Function to delete an item from the database
function delete_item_members(id,un,url) {
	string = "Are you sure you want to delete this item?";
	if (window.confirm(string)) {
		idstring = "http://www.ottawavalley.travel/control/member_delete.php?id="+id+"&mode=delete&un="+un+"&url="+url;
		window.location.href=idstring;
	}
}
// Function to gather amenities
function get_amenities(category,subcategory,mode) {
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) { document.getElementById("amenities").innerHTML=xmlHttp.responseText; }
	}
	controlstr = "http://www.ottawavalley.travel/control/get_amenities_ajax.php?category="+category+"&subcategory="+subcategory+"&mode="+mode;
	xmlHttp.open("GET",controlstr,true);
	xmlHttp.send(null);
}
// Function to gather amenities
function get_amenities_publication(category,subcategory,mode,user) {
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) { document.getElementById("amenities").innerHTML=xmlHttp.responseText; }
	}
	controlstr = "http://www.ottawavalley.travel/cface/publications/update.php?category="+category+"&subcategory="+subcategory+"&mode="+mode+"&user="+user;
	xmlHttp.open("GET",controlstr,true);
	xmlHttp.send(null);
}
// Function to edit amenities
function edit_amenities(category,subcategory,organization,mode) {
	var xmlHttp = get_xmlHttp();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) { document.getElementById("amenities").innerHTML=xmlHttp.responseText; }
	}
	controlstr = "http://www.ottawavalley.travel/control/get_amenities_ajax.php?category="+category+"&subcategory="+subcategory+"&organization="+organization+"&mode="+mode;
	xmlHttp.open("GET",controlstr,true);
	xmlHttp.send(null);
}
// This function will return a XMLHttp connection
function get_xmlHttp() {
  var xmlHttp;
  try { // Firefox, Opera 8.0+, Safari   
		xmlHttp=new XMLHttpRequest(); }
  catch (e) { // Internet Explorer    
	try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) {
		try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
    catch (e) { 
		alert("Your browser does not support AJAX!");
		return false;  
	}}}
	return xmlHttp;
}
