// JavaScript Document

function getInternetExplorerVersion() {
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).

  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
	var ua = navigator.userAgent;
	var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	if (re.exec(ua) != null)
	  rv = parseFloat( RegExp.$1 );
  }
  return rv;
}


$(function () {
	$("#accordion").accordion({ fillSpace: true });		
			
	$('.vs_city').each(function() {
		//options for the effect
		var distance = 10;
		var time = 250; // .25 seconds
		var hideDelay = 325;
		
		//timer to leave the pop for a while after mouseout
		var hideDelayTimer = null;

		//trackers
		var beingShown = false;
		var visible = false;
		var top_value = null;
		var left_value = null;
		
		//trigger is the image (or element) that we're mouseing over 
		var $trigger = $('.trigger', this);
		//popup is the div (or element) that's appearing and disappearing
		var $popup = $('.popup', this);
		
		// set the mouseover and mouseout on both elements
		$([$trigger.get(0), $popup.get(0)]).mouseover(function() {
								
				$popup.css({'zIndex': 99});
				
				// stops the hide event if we move from the trigger to the popup element
				if ( hideDelayTimer ) clearTimeout(hideDelayTimer);
				
				if(beingShown || visible) {
					return;
				} else { 
					beingShown = true;
										
					$popup.css({
						display: 'block',
						top: -150,
						left: -155	
					}).animate({
						opacity: 1,
						top: '-=' + distance + 'px'
					}, '', function () {
						beingShown = false;
						visible = true;
					});
				}
		}).mouseout(function(){
				if ( hideDelayTimer ) clearTimeout(hideDelayTimer);
		
				hideDelayTimer = setTimeout(function () {
					$popup.animate({
						top: '-=' + distance + 'px',
						opacity: 0						
					}, '', function() {
							visible = false;
							$popup.css({display: 'none'});
					});
				}, hideDelay)
				
		});
	});
});