//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
$(document).ready(function(){
	//	Main Menu
	$("#mainnav").menumaker({
		menu_speed:	50,
		constrain_to:	"center-x",
		offset_mode:	"override"
	});
	
	$('.toggler').toggle(function() {
		$(this).parent().addClass('active');
		$(this).next('.toggle-content').slideDown();
	}, function() {
		$(this).parent().removeClass('active');
		$(this).next('.toggle-content').slideUp();
	});
	
	//	In field labels
	$('.widget .textfield,.commentfield,#findtext').focus(function(e){
		$(this).siblings('label').hide();
	});

	$('.widget .textfield,.commentfield,#findtext').blur(function(e){
		var content = $(this).val();
		if (!content) {
			$(this).siblings('label').show();
		};
	});
});

Cufon.replace('h1', { fontFamily: 'effra' });
Cufon.replace('#content h2', { fontFamily: 'effra' });
Cufon.replace('.widget h2', { fontFamily: 'effra' });
Cufon.replace('#home-content', { fontFamily: 'effra' });
Cufon.replace('#features td h2', { fontFamily: 'effra' });

function openEmailPopup( id )
{
	sizeX = 500;
	sizeY = 500;
	
	//	Center the window
	leftpos	= (screen.width)  ? (screen.width-sizeX)/2 : 100;
	toppos	= (screen.height) ? (screen.height-sizeY)/2 : 100;

	//	Define the window size
	widthVar  = 'width=' + sizeX + ',';
	heightVar = 'height=' + sizeY + ',';
	
	//	Open the window
	contenturl				= '/blog/email.php/id/' + id;
	target					= 'email' + id;
	winobject				= window.open(contenturl,target,"menubar=0,statusbar=0,scrollbars=1,toolbar=0,location=0," + widthVar + heightVar + "left=" + leftpos + ",top=" + toppos + ",resizable=1" );
	winobject.focus();
}
