Cufon.set('fontFamily', 'VAG Rounded Std').replace('h1');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('h2');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.h2black');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.h3black');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.h4black');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.h3white');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('ul b');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('#dateline');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('#welcomeline');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('#intro');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.returns_text');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.markets_text');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.news_text');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.events_text');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.publications_text');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.contact_text');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel1_small');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel2_small');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel3_small');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel4_small');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel5_small');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel6_small');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel1_small_active');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel2_small_active');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel3_small_active');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel4_small_active');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel5_small_active');
Cufon.set('fontFamily', 'VAG Rounded Std').replace('.panel6_small_active');



$(document).ready(function() {
	if ($.browser.msie){
		// fade done by meta tag
	}
	else {
		$("#site_content").hide();
		$("#site_content").fadeIn("slow");
	}	
	$("div.clickable").click(function(){window.location = $(this).attr("url");});

	$('div.hsclickable').click(function() {
		document.getElementById($(this).attr("hs")).onclick();
	});
		
	// news ticker for home page only
	$("ul#ticker01").liScroll(); 
	
	// initialize scrollable  
	$("div.scrollable").scrollable({vertical:true,  size: 3 }).mousewheel();     	
	// initialize diary scrollable  
	$("div.diaryscrollable").scrollable({vertical:true,  size: 12 }).mousewheel();     	
	
	$("#ViewBookIntro").click(function () {
		$("#iframer").height(600)
		$("#iframer").width(955)
		$("#ViewBookIntro").hide();
		$("#fliphelp").show();
		$("#main_content").height(800)
		$("#main_content").css({'top' : '-40px'});
	});
	
	
});



// Array of day names
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
// Array of month Names
var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var now = new Date();
TodaysDate = (dayNames[now.getDay()] + ", " + monthNames[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear());



jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.07
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("newsticker")
				var stripWidth = 0;
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.find("li").each(function(i){
				stripWidth += jQuery(this, i).width();
				});
				$strip.width(stripWidth);			
				var defTiming = stripWidth/settings.travelocity;
				var totalTravel = stripWidth+containerWidth;								
				function scrollnews(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(function(){
				jQuery(this).stop();
				},
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime);
				});			
		});	
};

function updateChart(XML){
	if (XML != "blank"){
		var chartObj = getChartFromId("chartId");
		chartObj.setDataURL("/charts/"+XML); 
	}	
}

/////////////////////////////////////////////////////////////
// CMS functions
/////////////////////////////////////////////////////////////
Once=false
document.onkeyup = KeyCheck;
function KeyCheck(e){
	var KeyID = (window.event) ? event.keyCode : e.keyCode;
	if (KeyID==192 && Once){LoginEdit();}
	if (KeyID==192){Once=true; setTimeout("ClearOnce()",1000);}
	if (KeyID==45 && Once){LoginEdit();}
	if (KeyID==45){Once=true; setTimeout("ClearOnce()",1000);}
	if (KeyID==222 && Once){LoginEdit();}
	if (KeyID==222){Once=true; setTimeout("ClearOnce()",1000);}
}
function ClearOnce(){Once=false}
if (document.layers){document.captureEvents(Event.KEYPRESS)}

function LoginEdit(){
	showLayer("cmslogin");
	hideLayer("searchbox");
	document.forms['Editor'].elements['login'].focus() 
}
function GoEdit(){
	WriteToLayer("info","<b>Loading CMS...</b>");
	//location.href="http://"+location.hostname+"/admin.asp"+location.search
	return true;
}
function ByeEdit(){
	WriteToLayer("info","<b>Writing to database...</b>");
	return true;
}


/////////////////////////////////////////////////////////////
// Layer functions
/////////////////////////////////////////////////////////////
if (document.getElementById){var doc = 'document.', vis = '.style.visibility';}
else if (document.all) {var doc = 'document.all.', vis = '.style.visibility';}
else if (document.layers){var doc = 'document.document.', vis = '.visibility';}
function showLayer(object) {
	if (document.getElementById){eval(doc + "getElementById('"+object+"')" + vis + ' = "visible"');}
	else if (document.layers || document.all){eval(doc + object + vis + ' = "visible"');}
}
function hideLayer(object) {if (document.getElementById){eval(doc + "getElementById('"+object+"')" + vis + ' = "hidden"');}
	else if (document.layers || document.all){eval(doc + object + vis + ' = "hidden"');}
}
