$(document).ready(function() {
	
	//Yahoo
	if ($('body').is('.slug-location-directions')) {
		//alert(1)
		window.onload = startMap;
	}
	
	// toggle doesn't work if it is already hid
	/*
	$('p.hide a').toggle(
		function() {
			$('#care-info').slideUp();
			$(this).text('What information will VERGI need when you call?');
		},
		function() {
			$('#care-info').slideDown();
			$(this).text('Hide This');
		}
	);
	*/
	
	// add a wrapper for the background for the widget
	$('#text-337954711').wrapInner('<div id="bg-widget-top"></div>')
	
	$('p.hide a').click(function(){
		if ($(this).is('.open')) {
			//alert(1);
			$('#care-info').slideDown();
			$(this).text('Hide This').removeClass('open').addClass('close');
			return false;
		} else if ($(this).is('.close')) {
			//alert(2);
			$('#care-info').slideUp();
			$(this).text('What information will VERGI need when you call?').removeClass('close').addClass('open');
			return false;
		}
	});
	
	$('.get-care-info').click(function(){
		$('#care-info').slideDown();
		$('p.hide a').text('Hide This').removeClass('open').addClass('close');
	});
	
	// only show it unscrolled on the homepage
	$('body:not(.home) #care-info').hide();
	$('body:not(.home) p.hide a').text('What information will VERGI need when you call?').removeClass('close').addClass('open');
	$('body.home p.hide a').addClass('close');
	
	
	/* Tooltip */
	var positionTooltip = function(e) {
		var tPosX = e.pageX - 5;
		var tPosY = e.pageY + 12;
		$('.tooltip').css({top:tPosY,left:tPosX});
	};
	var showTooltip = function(e) {
		$('.tooltip').remove();
		if ($(this).attr('title')) {
			$(this).attr('tooltip',$(this).attr('title'));
			$(this).removeAttr('title');
		}
		var $thisTip = $(this).attr('tooltip');
		$('<div class="tooltip">' + $thisTip + '</div>').appendTo('body');
		positionTooltip(e);
		e.preventDefault();
		e.stopPropagation();
		return false;
	}
	var hideTooltip = function(e) {
		$('.tooltip').remove();	
	}
	$('ul.blogroll li a')
	.hover(showTooltip,hideTooltip)
	.mousemove(positionTooltip);
	
	$('ul.blogroll li a').mouseover(function(e){
		//alert('yo');
		e.preventDefault();
		e.stopPropagation();
		return false;
	});
	
});


	
	function startMap(){
		// Create a Map that will be placed in the "map" div.
		var map = new YMap(document.getElementById('map')); 
		// Create an array to contain the points of our polyline
		polylinePoints = [];
	
		// Add the ability to change between Sat, Hybrid, and Regular Maps
		map.addTypeControl(); 	
		// Add the zoom control. Long specifies a Slider versus a "+" and "-" zoom control
		map.addZoomLong();    		
		// Add the Pan control to have North, South, East and West directional control
		map.addPanControl();  
		// Specifying the Map starting location and zoom level
		map.drawZoomAndCenter("8921 Katy Freeway Houston, TX 77024", 3);
		
		//var point = new YGeoPoint(37.39975547955226,-122.03166961669922);
		
		var marker = new YMarker("8921 Katy Freeway Houston, TX 77024");
		marker.addAutoExpand("<b>VERGI 24/7</b>");
		map.addOverlay(marker);
		
		/*
		var new_image = new YImage();
			new_image.src = 'http://l.yimg.com/a/i/us/tr/fc/map/nightlife_bubble_w.png';
			marker.changeImage(new_image);
			*/
	}

