curQuote=-1;
allQuotes=[];

$(document).ready(function(){
  	newQuote();
  	$(".datepicker").datepicker({
		numberOfMonths: 1,
		dateFormat: 'dd-mm-yy',
		buttons: true
	});

});

// Other Tenpin specific JS routines
newHeadline=function() {
  curHeadline=Math.floor(Math.random()*(headlines.length));
  $('#the-headline').attr("style","margin-left:0px");
  headline="<strong>"+headlines[curHeadline].headline1+" &#124 </strong>"+headlines[curHeadline].headline2;
  $('#news').html("<div id='news-window'><span id='the-headline'>"+headline+"</span></div>");
  if ($('#the-headline').width()<$('#news').width()) {
    setTimeout("newHeadline();",5000);
  } else {
    setTimeout("animateHeadline();",3000);
  }
  /* alert("the-headline.width="+$('#the-headline').width()+" and news.width="+$('#news').width()); */
}

function animateHeadline() {
  // How long is the current headline? (roughly 6px per char)
  pixelsToShift=(6*(headlines[curHeadline].headline1.length+headlines[curHeadline].headline2.length));
	$('#the-headline').animate({marginLeft: "-"+pixelsToShift+"px"},pixelsToShift*15,"linear",newHeadline);
}

newQuote=function() {
  curQuote=Math.floor(Math.random()*(allQuotes.length));
  $('#the-quote').attr("style","margin-left:0px");
  phrase=allQuotes[curQuote].phrase+" <span class='extra'>"+allQuotes[curQuote].name+"</span>";
  $('#quote-block').html("<div id='quote-window'><span id='the-quote'>"+phrase+"</span></div>");
  if ($('#the-quote').width()<$('#quote-block').width()) {
    setTimeout("newQuote();",6000);
  } else {
    setTimeout("animateQuote();",6000);
  }
}

function animateQuote() {
  // How long is the current phrase? (roughly 10px per char)
  pixelsToShift=(10*(allQuotes[curQuote].phrase.length+allQuotes[curQuote].name.length+allQuotes[curQuote].date.length));
	$('#the-quote').animate({marginLeft: "-"+pixelsToShift+"px"},pixelsToShift*15,"linear",newQuote);
}

var qWindow = '';
function qOpen(url) {
  /* Referrer and SiteRefferer parameters are now part of the url string passed in from PHP */
  /* url+='&SiteReferrer=' + escape(escape(unescape(<?php echo $_SESSION["HTTP_REFERER"]; ?>))); */
  if (!qWindow.closed && qWindow.location){
    qWindow.location=url;
  } else {
    qWindow = window.open(url, '_blank', "height=620, width=960, top=30, left=30, status=yes, toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=yes", true);
    if (!qWindow.opener) qWindow.opener = self;
  }
  qWindow.focus();
  return false;
}

function cl(goWhere) {
  document.location.href=goWhere;
}

var map;

function getGMap(){
	var center = new google.maps.LatLng(51.51714, -0.14602);
	var options = {scrollwheel: false, zoom: 15, center: center, mapTypeId: google.maps.MapTypeId.ROADMAP};
	map = new google.maps.Map(document.getElementById("map_canvas"), options);
	mapListener = google.maps.event.addListener(map, "zoom_changed", function(){
		if(map.getZoom() < 6){
			map.setZoom(6);
		}
	});	
	var shopLocation = new google.maps.LatLng(51.51714, -0.14602);
	var icon = new google.maps.MarkerImage("http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png",
		new google.maps.Size(32, 32));
		
	var infoText = '<div class="gmap-popup">Westlake Clinic<br />7 Harley Street<br />London<br />W1G9QD</div>';
	var infowindow = new google.maps.InfoWindow({ content: infoText});
	var marker = new google.maps.Marker({position: shopLocation, map: map, icon: icon});
	google.maps.event.addListener(marker, "click", function(){
		infowindow.open(map, marker);
	});	
								   
	
}

