
// Making an accordion.
$(document).ready(function(){
	
	// Sidebar menu toggles
	$('#categories li h3').click(function() {
		$(this).next().slideToggle('normal');
		$('span', this).html($('span', this).html() == '+' ? '-' : '+');
	});
	
	// Fancybox for products
	$("a.fancybox").fancybox({
		'titleShow'		: false
	});
	
	// Fancybox for gallery
	$(".gallery-icon a").fancybox({
		'titleShow'		: false
	});
	
	
	// Toggle Tell A Friend form
	$('#taf').css({'cursor':'pointer'});
	$('#taf').click(function() {
		$('#taf-form').slideToggle('normal');
		return false;
	});
	
	// Fadding dos menus
	$('#nav li.page_item').hover(function() {
		// Will be executed when the mouse roll over the element
	    $('ul', this).fadeIn('normal');
	},function() {
		// Will be executed when the mouse roll out the element
	    $('ul', this).fadeOut('normal');
	});
	
	
	// Fix for <input /> rendering bug on Firefox 3.6
	if($.browser.mozilla && $.browser.version == '1.9.2') {
		$('#s').addClass('ff-bugfix');
	}
	
	
	$("#fancyanchor").fancybox({
		width			: 800,
		height			: '95%',
        autoScale		: false,
        centerOnScroll	: true,
        scroll			: 'yes',
        
		type			: 'iframe'
	});
	
	/*
	//setTimeout("fancy('http://casadosrelojoeiros.com.br/api/lab/?type=bead&bead_number=0001000437575&');", 1000);
	setTimeout("fancy('http://casadosrelojoeiros.com.br/apps/');", 1000);
	
	var destiny = prompt('Enter a number (1 to view bead - 2 to search beads by name):');
	alert('You choised: ' + destiny);
	
	switch(destiny) {
		case 1:
			fancy('http://casadosrelojoeiros.com.br/apps/index.php/lab/bead');
			break;
			
		case 2:
			fancy('http://casadosrelojoeiros.com.br/apps/index.php/lab/bead/search/joel+wallis');
			break;
	}
	*/
});


/**
 * void fancy()
 * 
 * Fire a Fancybox window from a JavaScript code call.
 * 
 * @author Joel Wallis <joelwallis@gmail.com>
 * @since Feb 12, 2010
 * @param url
 */
function fancy(url) {
	
	var fancy;
	
	fancy		= document.getElementById('fancyanchor');
	fancy.href	= url;
	
	$('#fancyanchor').trigger('click');
}


/**
 * fullscreen() JavaScript helper
 * 
 * @author Joel Wallis <joelwallis@gmail.com>
 * @since Jan 29, 2010
 * @version 0.1
 */
function fullscreen(url) {
	
	var w = screen.availWidth, h = screen.availHeight, t = 0, l = 0, s = 0, win;
	
	win = window.open(url, 'laboratory', 'height=' + h + ',width=' + w + ',top=' + t + ',left=' + l + 'scrollbars=0,location=0,menubar=0,resizable=0,status=0,toolbar=0');
	
	if(parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}
