var popupStatus = 0; 

function loadPopup(x, q){  
	if(popupStatus==0){  
		$("#backgroundPopup").css({  
			"opacity": "0.7"  
		}); 
		if(x == '1') $("#popupContent").load('/login.php');
		else $("#popupContent").load('/remind.php?pid=' + q);
			
		$("#backgroundPopup").fadeIn("slow");  
		$("#popupContact").fadeIn("slow");
		$("#popupContact").width('600px');
		$("#popupContact").height('300px');
		$("#popupContact").css('text-align', 'left');
				
		centerPopup();
		popupStatus = 1;  
	}  
}

function disablePopup(){   
	if(popupStatus==1){  
		$("#backgroundPopup").fadeOut("slow");  
		$("#popupContact").fadeOut("slow");  
		popupStatus = 0;  
	}
}

function centerPopup(){ 

	var w = $("#popupContact").width();
	var h = $("#popupContact").height();
	var posX = $('body').width()/2-(w/2);
	posY = $(window).height()/2-(h/2);
	$("#popupContact").css('position', 'fixed');
	$("#popupContact").css('top', posY + 'px');
	$("#popupContact").css('left', posX + 'px');

}

function wantit(id){
	
	$.ajax({
		url: '/wantit.php',
		data: 'pid='+id,
		type: 'post',
		dataType: 'json',
		success: function (d) {
			$('#wantit'+id).html(d['feedb']);
		}
	});
}

Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}
