/* MY AJAX CALLS**************************************************************************************************/
		  function updateRightWcitiesDiv(destinationid,agencyid,utp,passed_type,cpe_id,cid){
		 	document.body.style.cursor = 'wait';
			var url = 'wcities_ajax_reload.cfm';
			var output_container = 'right_wcities_container';
			var pars = 'destinationid=' + destinationid + '&bMulticity=1&agency_id=' + agencyid + '&UTP=' + utp + '&type=' + passed_type + '&cpe_id='+cpe_id + '&cid=' + cid;
			var myAjax = new Ajax.Updater(
					output_container, //the div container id
					url, // the url
					{
						method: 'post', // use post because gets are cached in IE, just a tip.
						parameters: pars, // my query string
						onSuccess: function(){document.body.style.cursor = 'default';}
					});
				
			}
			
			
		 function getContainer(id,cnt,agency_id,cpeid,did,cid,bHideDining){
		 	document.body.style.cursor = 'wait';
			var url = '/content/wcities/wcities_ajax.cfm';
			var output_container = 'content_container';
			var pars = 'action=ajax_get_container&city_id=' + id + '&container=' + cnt + '&agency_id=' + agency_id
						+ '&cpe_id=' + cpeid + '&dest_id=' + did + '&cid=' + cid + '&bHideDining=' + bHideDining;
			var myAjax = new Ajax.Updater(
					output_container, //the div container id
					url, // the url
					{
						method: 'post', // use post because gets are cached in IE, just a tip.
						parameters: pars, // my query string
						onSuccess: function(){document.body.style.cursor = 'default';}
					});
				
			}
			
		 function getHome(id,cnt,agency_id){
		 	document.body.style.cursor = 'wait';
			var url = '/content/wcities/wcities_ajax.cfm';
			var output_container = 'content_container';
			var pars = 'action=ajax_get_container&city_id=' + id + '&container=' + cnt + '&agency_id=' + agency_id;
			var myAjax = new Ajax.Updater(
					output_container, //the div container id
					url, // the url
					{
						method: 'post', // use post because gets are cached in IE, just a tip.
						parameters: pars, // my query string
						onSuccess: function(){document.body.style.cursor = 'default';}
					});
				
			}
			
		function getCityGuide(id,cnt,g,cpeid,did,cid,bHideDining){
		 	document.body.style.cursor = 'wait';
			var url = '/content/wcities/wcities_ajax.cfm';
			var output_container = 'content_container';
			var pars = 'action=ajax_get_container&city_id=' + id + '&container=' + cnt +'&g=' + g
						+ '&cpe_id=' + cpeid + '&dest_id=' + did + '&cid=' + cid + '&bHideDining=' + bHideDining;
			var myAjax = new Ajax.Updater(
					output_container, //the div container id
					url, // the url
					{
						method: 'post', // use post because gets are cached in IE, just a tip.
						parameters: pars, // my query string
						onSuccess: function(){document.body.style.cursor = 'default';}
					});
				
			}	
			
		function getCategories(id,cnt,cat_id,par,agency_id,cpeid,did,cid){
		 	document.body.style.cursor = 'wait';
			var url = '/content/wcities/wcities_ajax.cfm';
			var output_container = 'content_container';
			var pars = 'action=ajax_get_container&city_id=' + id + '&container=' + cnt +'&cat_id=' + cat_id +'&par_id=' + par + '&agency_id=' + agency_id
						+ '&cpe_id=' + cpeid + '&dest_id=' + did + '&cid=' + cid;
			var myAjax = new Ajax.Updater(
					output_container, //the div container id
					url, // the url
					{
						method: 'post', // use post because gets are cached in IE, just a tip.
						parameters: pars, // my query string
						onSuccess: function(){document.body.style.cursor = 'default';},
						evalScripts: true
					});
				
			}
		
		function getItemPage(id,cnt,cat_id,par,item_id,agency_id,cpeid,did,cid){
		 	document.body.style.cursor = 'wait';
			var url = '/content/wcities/wcities_ajax.cfm';
			var output_container = 'content_container';
			var pars = 'action=ajax_get_container&city_id=' + id + '&container=' + cnt +'&cat_id=' + cat_id +'&par_id=' + par +'&item_id=' 
					+ item_id  + '&agency_id=' + agency_id+ '&cpe_id=' + cpeid + '&dest_id=' + did + '&cid=' + cid;
			var myAjax = new Ajax.Updater(
					output_container, //the div container id
					url, // the url
					{
						method: 'post', // use post because gets are cached in IE, just a tip.
						parameters: pars, // my query string
						onSuccess: function(){document.body.style.cursor = 'default';},
						evalScripts: true
					});
				
			}		
		function getPage(id,cat_id,sec,startrow,endrow,agency_id){
		 	document.body.style.cursor = 'wait';
			var url = '/content/wcities/wcities_ajax.cfm';
			var output_container = 'pageable_categories';
			var pars = 'action=ajax_get_pageable&city_id=' + id + '&cat_id=' + cat_id +'&section=' + sec + '&startrow=' + startrow + '&endrow=' + endrow + '&agency_id=' + agency_id;
			var myAjax = new Ajax.Updater(
					output_container, //the div container id
					url, // the url
					{
						method: 'post', // use post because gets are cached in IE, just a tip.
						parameters: pars, // my query string
						onSuccess: function(){document.body.style.cursor = 'default';},
						evalScripts: true
					});
				
			}
			
		function getItemMap(lat,lon,name){
		 	document.body.style.cursor = 'wait';
			
			var url = '/content/wcities/wcities_ajax.cfm';
			var output_container = 'GmapsAPI';
			var pars = 'action=ajax_get_map&lat=' + lat + '&lon=' + lon +'&name=' + name;
			var myAjax = new Ajax.Updater(
					output_container, //the div container id
					url, // the url
					{
						method: 'post', // use post because gets are cached in IE, just a tip.
						parameters: pars, // my query string
						onSuccess: function(){document.body.style.cursor = 'default'; $('show').toggle(); $('hide').toggle();},
						evalScripts: true
					});
			
				
			//	$('GmapsAPI').setStyle({
  			//			 display:'none'
			//	});
			}		
		function hideItemMap(){
			document.body.style.cursor = 'wait';
			
			var url = '/content/wcities/wcities_ajax.cfm';
			var output_container = 'GmapsAPI';
			var pars = 'action=ajax_hide_map';
			var myAjax = new Ajax.Updater(
					output_container, //the div container id
					url, // the url
					{
						method: 'post', // use post because gets are cached in IE, just a tip.
						parameters: pars, // my query string
						onSuccess: function(){document.body.style.cursor = 'default';  $('show').toggle(); $('hide').toggle();},
						evalScripts: true
					});
				
			}	
		
	
/* NOT MY CODE *************************************************************************************/	
var Tooltip = Class.create();
Tooltip.prototype = {
  initialize: function(element, tool_tip) {
    var options = Object.extend({
      default_css: false,
      margin: "0px",
	    padding: "5px",
	    backgroundColor: "#d6d6fc",
	    min_distance_x: 5,
      min_distance_y: 5,
      delta_x: 0,
      delta_y: 0,
      zindex: 1000
    }, arguments[2] || {});

    this.element      = $(element);

    this.options      = options;
    
    // use the supplied tooltip element or create our own div
    if($(tool_tip)) {
      this.tool_tip = $(tool_tip);
    } else {
      this.tool_tip = $(document.createElement("div")); 
      document.body.appendChild(this.tool_tip);
      this.tool_tip.addClassName("tooltip");
      this.tool_tip.appendChild(document.createTextNode(tool_tip));
    }

    // hide the tool-tip by default
    this.tool_tip.hide();

    this.eventMouseOver = this.showTooltip.bindAsEventListener(this);
    this.eventMouseOut   = this.hideTooltip.bindAsEventListener(this);
    this.eventMouseMove  = this.moveTooltip.bindAsEventListener(this);

    this.registerEvents();
  },

  destroy: function() {
    Event.stopObserving(this.element, "mouseover", this.eventMouseOver);
    Event.stopObserving(this.element, "mouseout", this.eventMouseOut);
    Event.stopObserving(this.element, "mousemove", this.eventMouseMove);
  },

  registerEvents: function() {
    Event.observe(this.element, "mouseover", this.eventMouseOver);
    Event.observe(this.element, "mouseout", this.eventMouseOut);
    Event.observe(this.element, "mousemove", this.eventMouseMove);
  },

  moveTooltip: function(event){
	  Event.stop(event);
	  // get Mouse position
    var mouse_x = Event.pointerX(event);
	  var mouse_y = Event.pointerY(event);
	
	  // decide if wee need to switch sides for the tooltip
	  var dimensions = Element.getDimensions( this.tool_tip );
	  var element_width = dimensions.width;
	  var element_height = dimensions.height;
	
	  if ( (element_width + mouse_x) >= ( this.getWindowWidth() - this.options.min_distance_x) ){ // too big for X
		  mouse_x = mouse_x - element_width;
		  // apply min_distance to make sure that the mouse is not on the tool-tip
		  mouse_x = mouse_x - this.options.min_distance_x - 20;
	  } else {
		  mouse_x = mouse_x + this.options.min_distance_x - 20;
	  }
	
	  if ( (element_height + mouse_y) >= ( this.getWindowHeight() - this.options.min_distance_y) ){ // too big for Y
		  mouse_y = mouse_y - element_height;
	    // apply min_distance to make sure that the mouse is not on the tool-tip
		  mouse_y = mouse_y - this.options.min_distance_y - 60;
	  } else {
		  mouse_y = mouse_y + this.options.min_distance_y - 60;
	  } 
	
	  // now set the right styles
	  this.setStyles(mouse_x, mouse_y);
  },
	
		
  showTooltip: function(event) {
    Event.stop(event);
    this.moveTooltip(event);
	  new Element.show(this.tool_tip);
  },
  
  setStyles: function(x, y){
    // set the right styles to position the tool tip
	  Element.setStyle(this.tool_tip, { position:'absolute',
	 								    top:y + this.options.delta_y + "px",
	 								    left:x + this.options.delta_x + "px",
									    zindex:this.options.zindex
	 								  });
	
	  // apply default theme if wanted
	  if (this.options.default_css){
	  	  Element.setStyle(this.tool_tip, { margin:this.options.margin,
		 		  						                    padding:this.options.padding,
		                                      backgroundColor:this.options.backgroundColor,
										                      zindex:this.options.zindex
		 								    });	
	  }	
  },

  hideTooltip: function(event){
	  new Element.hide(this.tool_tip);
  },

  getWindowHeight: function(){
    var innerHeight;
	  if (navigator.appVersion.indexOf('MSIE')>0) {
		  innerHeight = document.body.clientHeight;
    } else {
		  innerHeight = window.innerHeight;
    }
    return innerHeight;	
  },
 
  getWindowWidth: function(){
    var innerWidth;
	  if (navigator.appVersion.indexOf('MSIE')>0) {
		  innerWidth = document.body.clientWidth;
    } else {
		  innerWidth = window.innerWidth;
    }
    return innerWidth;	
  }

}





