$(document).ready(function(){
	$('.btn').each(function(index,item){
		myid = $(this).attr('id');
		myid_split = myid.split('_');
		myid_new =myid_split[0] ;
		yid_new =myid_split[1] ;
		url = 'http://www.xoxideosc.com/notify_inventory_check.php?id='+myid_new+'&yid='+yid_new+'&callback=?';
		$.getJSON(url, function (data) {
			//console.log(data);
			if(data[0].cnt > 0){
				btn_active = btn_active.replace(/%s%/ig, data[0].yid);
				$('#'+data[0].divid+'_'+data[0].yid).html(btn_active);
			}else{
				//$('#'+data[0].divid).html('<a href="http://www.xoxideosc.com/notify_contact.php?id='+data[0].divid+'">'+btn_noti+'</a>');
				  $('#'+data[0].divid+'_'+data[0].yid).html('<a href="javascript:void(0);" onclick="npopup(\''+data[0].divid+'\',\''+data[0].yid+'\');">'+btn_noti+'</a>');
			}
		})
	})
});
function npopup(npid,yid){
	url = 'http://www.xoxideosc.com/notify_contact.php?id='+npid+'&yid='+yid;
	var iMyWidth;
	var iMyHeight;
	//half the screen width minus half the new window width (plus 5 pixel borders).
	iMyWidth = (window.screen.width/2) - (75 + 10);
	//half the screen height minus half the new window height (plus title and status bars).
	iMyHeight = (window.screen.height/2) - (100 + 50);
	//Open the window.
	var win2 = window.open(url,"Window2","status=no,height=200,width=350,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
	win2.focus();
}