jQuery.fn.extend({
  switchClass: function(class1,class2) {
	this.removeClass(class1);
 	this.addClass(class2);
  },
  check: function() {
    return this.each(function() { this.checked = true; });
  },
  uncheck: function() {
    return this.each(function() { this.checked = false; });
  },
  isChecked: function() {
    return this.is(":checked");
  },
  disable: function() {
    return this.each(function() { this.disabled = true; });
  },
  enable: function() {
    return this.each(function() { this.disabled = false; });
  },
  simulateChBox:function(obj){
  	if($("#"+obj+":checked").size()==1)
  		$("#"+obj).uncheck();
  	else if($("#"+obj+":checked").size()==0)
  		$("#"+obj).check();
  },
  simulateRDbutton:function(name,total,me){
  	for(c=0;c<=total;c++){
		if(c!=me)
			$("#"+name+"_"+c).uncheck();
	}
	$("#"+name+"_"+me).check();
  },
 position:function(parent){
		if(parent=="stage"){
			int_top = ( jq_win.height() - this.height() ) / 2+jq_win.scrollTop();
			int_left = ( jq_win.width() - this.width() ) / 2+jq_win.scrollLeft();
			if(int_top<0){
				int_top = 18+jq_win.scrollTop();
			}
		}else{
			jq_p = $("#" + parent);
			int_top = jq_p.offset().top + jq_p.height() + 3;
			int_endX = (this.width() + jq_p.offset().left);
			if(int_endX<=jq_win.width()){
				int_left = jq_p.offset().left;
			}else{
				int_startX = jq_win.width() - (this.width()+20);
				if(int_startX>0){
					int_left = jq_win.width() - (this.width()+20);
				}else{
					int_left = 0;
				}
			}
		}
		return this.css({"position":"absolute","top":int_top + "px","left":int_left+"px"});
 },
  overlay:function(opacity){
  	//voeg loadingbackground toe op het einde van de body
	jq_bd.append("<div class='overlay'></div>");
	jq_loadBg = $(".overlay");
	//zet hoogte loadingbackground gelijk aan de totale hoogte,0.5 alpha
	jq_loadBg.height(jq_doc.height()).css('opacity',opacity);	
  }
});
