
// comms with flash for mute button ----------------------------------------
var flashVolume = 1;
function setFlashVolume(newVolume)
{
	flashVolume = newVolume;
	SendDataToFlashMovie("setVolume", flashVolume); // triggers an event in flash to tell everything to mute/unmute
}

function getFlashVolume()
{
	SendDataToFlashMovie("getVolume", flashVolume);
}

function SendDataToFlashMovie(funcName, data)
{// calls 'sendTextToFlash' func in swf
	var flashMovie = swfobject.getObjectById("flashObj");
	//alert("SendDataToFlashMovie - flashMovie: " + flashMovie);
	//alert(funcName + ":" + data);
	flashMovie.sendTextToFlash(funcName, data);
}

// ---------------------------------------------------------------------------

$(document).ready(function() {
	
	// settings for the buy modal dialog
	var link = $("a#howto-buy")[0];
	if (link) {
		link.href = link.rel; 	// Change href's value to the one stored in rel
		$("a#howto-buy").fancybox({
			'overlayShow'	: false,
			'frameWidth'	: 694,
			'frameHeight'	: 475,
			'padding'		: 0,
			'hideOnContentClick': false
		});
	}
	
	$("a#requestsample-link").fancybox({
		'overlayShow'		: false,
		'frameWidth'		: 950,
		'frameHeight'		: 496,
		'padding'			: 0,
		'hideOnContentClick': false
	});
	
	var adflora = $("a.adflora")[0];
	if(adflora) {
		$("a.adflora").fancybox({
			'overlayShow'			: false,
			'padding'				: 0
		});
	}
});

//Flash functions place holder
function requestSample() { 
    $("#requestsample-flash").fancybox({'overlayShow':false,padding:0,frameWidth:950,frameHeight:496}).trigger('click');
}
function buy() { 
    $("#buy-flash").fancybox({'overlayShow':false,frameWidth:694,frameHeight:475,padding:0,hideOnContentClick:false}).trigger('click');
}
function campaign(slide) {
	$("#campaignFlash" + slide ).fancybox({'overlayShow': false,'zoomSpeedIn':0,'zoomSpeedOut':0,'padding':0}).trigger('click');
}

// Function for timeout
jQuery.fn.delay = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});
	return this;
};

$(document).ready(function() {
	var scrollPane, scrollTarget;
	$(this).delay(1000,function(){ // this timeout allows everything to load before applying the customized scrollbars on Flora's Collection page
		// settings for the scroll bar
		scrollPane =  $('div#altcontent div#scroll-area').jScrollPane({scrollbarWidth:15, dragMinHeight:217, dragMaxHeight:217, reinitialiseOnImageLoad: true, animateTo:true});
	});			
	// setup scrollTo links
	$('a.scollToLink').bind('click', function(event) {
		var href = $(this).attr('href').split("#");
		event.preventDefault();
		scrollTarget = $(this).attr('rel');
		scrollPane[0].scrollTo(scrollTarget);
		return false;
	});
});	
