$(document).ready(function() {
	$('a.delete').click(function() {
		if (jQuery(this).attr('title').indexOf("el ") > -1) return confirm('\u00BFDesea borrar '+jQuery(this).attr('title')+' seleccionado?');
		else return confirm('\u00BFDesea borrar '+jQuery(this).attr('title')+' seleccionada?');
	}); 
	
	if ($.fn.fancybox) $('a.fancybox').fancybox({ 'overlayShow': true, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'titlePosition'  : 'inside' });
	
	$('a.external').live('click', function() {
		this.target = "_blank";
	});
	
	if ($('figure.specialty-detail ul.galeria li').length > 0) {
		$('figure.specialty-detail ul.galeria li a').click(function(e){
			link = $(this).attr('href');
			caption = $(this).attr('title');
			linkImagen = link.replace('/slide', '');
			$('a#main-image img').attr('src', $(this).attr('href'));
			$('a#main-image').attr('href', linkImagen);
			$('a#main-image').attr('title', caption);
			$('a#main-image span').html(caption);
			e.preventDefault();
		});
	}
	
	if ($('section.home figure figcaption div').length > 0) {
		$('section.home figure figcaption div').hide();
		$('section.home figure figcaption div.figure1').show();
		$('section.home figure .slider-menu a.target-figure1').addClass('active');			
			
		i = 1;
		path = new Array('1', '2', '3', '4', '3', '2');
		
		$(document).everyTime('5s',function() {
			incremental = path[i];
/* 			alert(incremental); */
			$('section.home figure figcaption div').slideUp('fast')
			$('section.home figure figcaption div.figure'+incremental).clearQueue().slideDown('slow');

			$('section.home figure .slider-menu a').removeClass('active');
			$('section.home figure .slider-menu a.target-figure'+incremental).addClass('active');			
			i++;
			if (i == path.length) {
				i = 0;
			}
		});

		
		$('section.home figure .slider-menu a').click(function(event) {
			$('section.home figure .slider-menu a').removeClass('active');
			aMostrar = $(this).attr('class');
			$(this).addClass('active');						
			aMostrar = aMostrar.replace('target-', '');

			$('section.home figure figcaption div').slideUp('fast')
			$('section.home figure figcaption div.'+aMostrar).clearQueue().slideDown('slow');
			$(document).stopTime();
			event.preventDefault();
		});
	}
	if ($('#map_canvas').length > 0) {
		initialize();
	}
});
function initialize() {
	var myLatlng = new google.maps.LatLng(38.411724,-0.564129);
	var myOptions = {
	  zoom: 9,
	  center: myLatlng,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	
	var contentString1 = '<div id="content">'+
	    '<div id="siteNotice">'+
	    '</div>'+
	    '<h3>Traumatología Vistahermosa</h3>'+
	    '<p>Clínica Vistahermosa<br />Tel: 965235108</p>'+
	    '</div>'+
	    '</div>';
	    
	var infowindow1 = new google.maps.InfoWindow({ content: contentString1 });
	
	var marker1 = new google.maps.Marker({
	    position: new google.maps.LatLng(38.362724,-0.464129),
	    map: map,
	    title: 'Traumatología Vistahermosa'
	});
	
	var contentString2 = '<div id="content">'+
	    '<div id="siteNotice">'+
	    '</div>'+
	    '<h3>Traumavist Alicante</h3>'+
	    '<p>Alfonso X El Sabio, 27 - 1º F<br />Tel: 965204136</p>'+
	    '</div>'+
	    '</div>';

	var infowindow2 = new google.maps.InfoWindow({ content: contentString2 });
	
	var marker2 = new google.maps.Marker({
	    position: new google.maps.LatLng(38.346745,-0.488288),
	    map: map,
	    title: 'Traumavist Alicante'
	});	

	var contentString4 = '<div id="content">'+
	    '<div id="siteNotice">'+
	    '</div>'+
	    '<h3>Traumavist Ibi</h3>'+
	    '<p>Comunidad Valenciana, 4<br />Tel: 965553779</p>'+
	    '</div>'+
	    '</div>';

	var infowindow4 = new google.maps.InfoWindow({ content: contentString4 });
	var marker4 = new google.maps.Marker({
	    position: new google.maps.LatLng(38.617218,-0.584909),
	    map: map,
	    title: 'Traumavist Ibi'
	});	
	
	google.maps.event.addListener(marker1, 'click', function() {
	  infowindow1.open(map,marker1);
	});
	google.maps.event.addListener(marker2, 'click', function() {
	  infowindow2.open(map,marker2);
	});
	google.maps.event.addListener(marker4, 'click', function() {
	  infowindow4.open(map,marker4);
	});

}
	

