jQuery.fn.center = function() 
{
  var w = $(window);
  //this.css("position","absolute");
  //this.css("top",(w.height()-this.height())/2+w.scrollTop() + "px");
  //this.css("left",(w.width()-this.width())/2+w.scrollLeft() + "px");
	this.css("top",(w.height()-this.height())/2 + "px");
  this.css("left",(w.width()-this.width())/2 + "px");
  return this;
}

var popup = null;
var popupContainer = null;
function switch_popup(id)
{
  if (!popup && !popupContainer){
    popupContainer = $('<div id="popup_full"><div id="popup_bg"></div></div>');
    popup = $('<div id="#popup_' + id + '"></div>');
    popupContainer.append(popup);
    $('body').append(popupContainer);
    popup.center();

  }else{
    $(popupContainer).remove();
    delete popupContainer;
    delete popup;

		//el.show();
  }
  /*
  
	el = $('#popup_'+id);


	if ( el.is(':visible') ) 
	{
		el.hide();
		//$('#popup_bg').remove();
		$('#popup_full').remove();
		$('#popup_bg').remove();

	}
	else
	{
		$('body').append('<div id="popup_full"><div id="popup_bg"></div></div>');
		el.center();
		el.show();
	}
	 */
	
	return false;
}


function init_fakecheck(){
	$(document).ready(function(){
		// check for what is/isn't already checked and match it on the fake ones
		$("input:checkbox").each( function() {
			(this.checked) ? $("#fake"+this.id).addClass('fakechecked') : $("#fake"+this.id).removeClass('fakechecked');
		});
		// function to 'check' the fake ones and their matching checkboxes
		$(".fakecheck").click(function(){
			($(this).hasClass('fakechecked')) ? $(this).removeClass('fakechecked') : $(this).addClass('fakechecked');
			$(this.hash).trigger("click");
			return false;
		});
	});
}

