/* vim: set expandtab tabstop=3 shiftwidth=3: */
/**
*
* JS functionality for SCO002
*
* @author Dave <dave@neoco.com>
* @copyright Copyright (c) Neoco; www.neoco.com
* @version SVN: $Id: functionality.js 3974 2009-02-12 13:23:46Z dave $
*
*/

var testimonials;
var testimonial=0;

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$(document).ready(function(){

   /* GOOGLE MAP */
	var mapLocation = document.getElementById('googlemap');
	if (mapLocation && GBrowserIsCompatible()) {
		var map = new GMap2(mapLocation);
		map.setCenter(new GLatLng(51.51566,-0.13617), 16,G_NORMAL_MAP);
		map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl());
//		var gpObj = new GLatLng(51.516301, -0.143166);
//		var gpObj = new GLatLng(51.516328, -0.140741);

//&ll=,

		var gpObj = new GLatLng(51.51566,-0.13617);
		iconObj = new GIcon();
		iconObj.image = "http://sco002.neo51.com/images/mappin.png";
		iconObj.iconSize = new GSize(39,50);
		iconObj.iconAnchor = new GPoint(0,50);
		marker = new GMarker(gpObj, iconObj);
		map.addOverlay(marker);
	}
	
   //--------------------------------------------
   
   if ($("div.testimonial")) {
   	testimonial = 0;
   	setTimeout(next_testimonial, 10000);	
	}
	
	//--------------------------------------------
   
   $("a.back").click( function (event) { event.preventDefault(); history.go(-1); } );
   
   $('#tweet_box div.tweets p').css({'display':'none'})
   $('#tweet_box div.tweets').jTweetsAnywhere({
	    username: 'scorchlondon',
	    count: 1
	});
   
});

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function next_testimonial()
{	
	//Reset the counter if needed...
	if ( testimonial >= $("div#testimonials div").length ){
		testimonial = 0;
	}	
	
	//Gety the next testimonial...
	var next = $("div#testimonials div:eq("+testimonial+")");
	
	//If the index was valid...
	if ( next.length == 1 ){	
		
		var title = next.children("span.title").text();
		var quote = next.children("span.quote").text();
		var from = next.children("span.from").text();
		var url = next.children("span.url").text();
		
		url = jQuery.trim(url);
		
	   $("div.testimonial h5").html(title);
	   $("div.testimonial blockquote").html('<img src="/images/quotelrgside.gif" alt="quote large">'+quote);
	   
	   if ( url.length < 1 ){
			$("div.testimonial h6").html(from);	
	   } else {
			$("div.testimonial h6").html('<a target="_blank" href="'+url+'">'+from+'</a>');	
	   }
	   			
	} // - if ( next.length == 1 )
   
   testimonial++;
   
   setTimeout(next_testimonial, 10000);
} // end FUNC
