/*var hider = function(element,openIndex)
{
	var elem = jQuery(element);
	var togglers = elem.children();
	jQuery.each(togglers, function(togglers)
	{
		var obj = jQuery(this);
		obj.children('.acc_handle').addClass("hand").children("h3").prepend('<img src="images/entry-more.png" alt="more button"/>');
		
		obj.children('.acc_content').hide();
		//setup event handle (toggle)
		obj.children('.acc_handle').click(function() {
		
				//Hide others
				jQuery.each(obj.siblings(),function()
				{
					if(jQuery(this).children('.acc_content').is(':visible'))
					{
						jQuery(this).children('.acc_content').hide('slow');
						jQuery(this).children('.acc_handle').children('h3').children('img').attr('src','images/entry-more.png');
					}
				});
		
				if(obj.children('.acc_content').is(':visible'))
				{
					obj.children('.acc_content').hide('slow');
					obj.children('.acc_handle').children('h3').children('img').attr('src','images/entry-more.png');
				}
				else
				{
					obj.children('.acc_content').show('slow');
					obj.children('.acc_handle').children('h3').children('img').attr('src','images/entry-less.png');
				}
			}
		);
		
		
		if(openIndex == jQuery("div.acc_toggler").index(this))
		{
			jQuery('html, body').animate({scrollTop: jQuery(this).offset().top}, 1000);
			jQuery(this).children('.acc_handle').click();
		}
		
	});
	
};
*/

//---- Cernam lightbox
var cssObj = {
	'background-color' : '#000',
	'display' : 'none',
	'height' : '100%',
	'left' : '0',
	'position' : 'fixed',
	'top' : '0',
	'width' : '100%',
	'z-index' : '100'
}

//---- Cernam lightbox
var dimTheLights = function(on)
{
	if(on)
	{
		if (jQuery("#light").length > 0) jQuery('#light').remove(); //any other ones?
		if (jQuery("#modal").length > 0) jQuery('#modal').hide(400);
		jQuery('body').prepend('<div id="light"></div>');
		jQuery('#light').css(cssObj);
		jQuery('#light').css('z-index','100');
		jQuery('#light').fadeTo(1000,0.75);
		jQuery('#light').click(function(){dimTheLights(false);});
	}
	else
	{
		jQuery('#modal').hide(400);
		jQuery('.slide-out-div').slideMe(true);//make sure the contact us box is away
		jQuery('#light').stop();
		jQuery('#light').fadeTo(250,0,function(){jQuery(this).remove();}); //turn off lights		
	}
	
}


jQuery.fn.center = function(init) {
		
	var object = this;
	var marginTop = (jQuery(window).height() / 2) - object.height() / 2;
	var marginLeft = jQuery(window).width() / 2 - object.width() / 2;
	if(!init) {
		object.css('display','block');
		object.css('margin-top', marginTop);
		object.css('margin-left', marginLeft);
		
		jQuery(window).resize(function() {
			object.center(!init);
		});
		
	} else {
		
	
		marginTop = (marginTop < 0) ? 0 : marginTop;
		marginLeft = (marginLeft < 0) ? 0 : marginLeft;

		object.stop();
		object.animate(
			{
				marginTop: marginTop, 
				marginLeft: marginLeft
			}, 
			150, 
			'linear'
		);
		
	}
}
