// Cybermuse - VERONESE common functions script
// Developer: Dan Copeland - BV02, Ottawa ON


jQuery.preloadImages = function(){
	for(var i = 0; i<arguments.length; i++){
		jQuery("<img>").attr("src", arguments[i]);
	}
};
function greyInitial() {
	var searchBox = $('#search #keyword');
	var ph;

	if($('body').hasClass('fr')){
		searchBox.val('Recherche Cybermuse');
		ph = 'Recherche Cybermuse';
	} else {
		searchBox.val('Search Cybermuse');
		ph = 'Search Cybermuse';
	}

	$('#search .overlabel').css('display','none');
	searchBox.css('fontSize','10px');

	searchBox.bind('focus', function(){
		if ($(this).val() == ph){
			$(this).val('');
		} else {
			$(this).val(ph);
		}
	});
	searchBox.bind('blur', function(){
		if ($(this).val() === ph || $(this).val() === ''){
			$(this).val(ph);
		}
	});
}
function resizeElement(heightValue) {
	var newHeight = heightValue + "px";
	$("#preparatory").css("height",newHeight);
}

function backToTop(anchor){
		$(window).scrollTo($(anchor), 800);
}


$(document).ready(function(){
	$('a.backToTop').bind('click', function(){
		backToTop('top',1200);
		return false;
	});
	/*var backToTop = function(anchor,dur){
		$(window).scrollTo($('#'+ anchor), dur);
		return false;
	};*/
	$('.imageContainer .imageControls').append('<a href="#" class="tooltipBtn">View info</a>');
	$('.imageContainer .imageControls div').css('display','none');
	$('.imageContainer a.tooltipBtn').tooltip({ 
		track: true, 
		delay: 0, 
		showURL: false,  
		fade: 450,
		bodyHandler: function() {
			if($(this).parent('.imageControls').children('div')){
				var tipDetail = $(this).parent('.imageControls').children('div').html();
				return $(tipDetail);
			} else {
			alert('matt, are you reading this?');}
		}
	});
	$('.imageContainer a.tooltipBtn').bind('click',function(){ return false; });
	greyInitial();
});

