
$(function() {
		$('body').append('<div id="jquery_mask" style="position:absolute; left:0; top:0; width:100%; height:100%; z-index:99; background-color:#000; display:none;" onClick="mask_off();"></div>');
});

function mask_on() {
	if (jQuery.browser.msie == true && jQuery.browser.version.indexOf("7.") == 0) {
		;
	}
	else {
		$('#jquery_mask').css({'height':$(document).height(),'width':$(window).width()});
		$('#jquery_mask').fadeTo("slow",0.8);
	}
};

function mask2_on() {
	$('body').append('<div id="jquery_mask2" style="position:absolute; left:0; top:0; width:100%; height:100%; z-index:99; background-color:#000; display:none;"></div>');
	if (jQuery.browser.msie == true && jQuery.browser.version.indexOf("7.") == 0) {
		;
	}
	else {
		$('#jquery_mask2').css({'height':$(document).height(),'width':$(window).width()});
		$('#jquery_mask2').fadeTo("slow",0.8);
	}
};

function mask2_off() {
		$('#jquery_mask2').hide();
		$('#jquery_mask2').remove();
};

function mask_off() {
		$('#jquery_mask').hide();
		$('.modal').hide();
};


function center_layer(layer_id) {
	$(layer_id).css('top', $(window).scrollTop() + $(window).height()/2-$(layer_id).height()/2);
	$(layer_id).css('left', $(window).width()/2-$(layer_id).width()/2);
}


function check_login() {
	if (document.cookie.indexOf('userSeq=')==-1) {
		error_layer(decodeURI("%E4%BC%9A%E5%93%A1%E5%B0%82%E7%94%A8%E3%83%A1%E3%83%8B%E3%83%A5%E3%83%BC"),decodeURI("%E5%85%88%E3%81%AB%E3%83%AD%E3%82%B0%E3%82%A4%E3%83%B3%E3%81%97%E3%81%A6%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84%E3%80%82"));
		return false;
	}
	return true;
}


function error_layer(title,mesg_body) {
    var mask_id = "mask" + parseInt(Math.random()*100);
    var layer_id = "err" + parseInt(Math.random()*100);

		var layer_html = '';
		layer_html += '<div id="'+layer_id+'" style="position:absolute; width:450px; z-index:10001;">';
		layer_html += '<div style="border:5px solid #363636;padding:15px;background:#ededed;position:relative;">';
		layer_html += '<h5 style="background:url(http://image.entercrews.com/0000_portal/common/ico_err.gif) 7px 7px no-repeat #1e1e1e;padding:14px 10px 10px 40px;color:#fff;font-weight:bold;font-size:12px;">'+ title +'</h4>';
		layer_html += '<p style="font-size:12px;color:#464646;margin:10px;line-height:1.6;">'+ mesg_body +'</p>';
		layer_html += '<button style="border:1px solid #969696;background:#f5f5f5;text-align:center;padding:5px 0 5px 0; width:100%;color:#5a5a5a;font-weight:bold;font-size:12px; cursor:Pointer;" onmouseover="this.style.color=\'#0056c3\';this.style.boderColor=\'#363636\';this.style.backgroundColor=\'#fff\';" onmouseout="this.style.color=\'#5a5a5a\';this.style.boderColor=\'#969696\';this.style.backgroundColor=\'#f5f5f5\';" onClick="$(\'#'+layer_id+'\').remove();$(\'#'+mask_id+'\').remove();">'+decodeURI("%E2%86%92%20%E7%A2%BA%E8%AA%8D%E3%81%99%E3%82%8B")+'</button>';
		layer_html += '</div>';
		layer_html += '</div>';

		$('body').append('<div id="'+mask_id+'" style="position:absolute; left:0; top:0; width:100%; height:100%; z-index:10000; background-color:#000; display:none;"></div>');
		$('#'+mask_id+'').css({'height':$(document).height(),'width':$(window).width()});
		$('#'+mask_id+'').fadeTo("fast",0.8);
		$('body').append(layer_html);

		$('#'+layer_id).css('top', $(window).scrollTop() + $(window).height()/2-$('#'+layer_id).height()/2);
		$('#'+layer_id).css('left', $(window).width()/2-$('#'+layer_id).width()/2);
}

function alert_then_go(title,mesg_body,url_to_go) {
    var mask_id = "mask" + parseInt(Math.random()*100);
    var layer_id = "err" + parseInt(Math.random()*100);

		var layer_html = '';
		layer_html += '<div id="'+layer_id+'" style="position:absolute; width:450px; z-index:10001;">';
		layer_html += '<div style="border:5px solid #363636;padding:15px;background:#ededed;position:relative;">';
		layer_html += '<h5 style="background:url(http://image.entercrews.com/0000_portal/common/ico_err.gif) 7px 7px no-repeat #1e1e1e;padding:14px 10px 10px 40px;color:#fff;font-weight:bold;font-size:12px;">'+ title +'</h4>';
		layer_html += '<p style="font-size:12px;color:#464646;margin:10px;line-height:1.6;">'+ mesg_body +'</p>';
		layer_html += '<button style="border:1px solid #969696;background:#f5f5f5;text-align:center;padding:5px 0 5px 0; width:100%;color:#5a5a5a;font-weight:bold;font-size:12px; cursor:Pointer;" onmouseover="this.style.color=\'#0056c3\';this.style.boderColor=\'#363636\';this.style.backgroundColor=\'#fff\';" onmouseout="this.style.color=\'#5a5a5a\';this.style.boderColor=\'#969696\';this.style.backgroundColor=\'#f5f5f5\';" onClick="$(\'#'+layer_id+'\').remove();$(\'#'+mask_id+'\').remove(); location.replace(\''+url_to_go+'\');">'+decodeURI("%E2%86%92%20%E7%A2%BA%E8%AA%8D%E3%81%99%E3%82%8B")+'</button>';
		layer_html += '</div>';
		layer_html += '</div>';

		$('body').append('<div id="'+mask_id+'" style="position:absolute; left:0; top:0; width:100%; height:100%; z-index:10000; background-color:#000; display:none;"></div>');
		$('#'+mask_id+'').css({'height':$(document).height(),'width':$(window).width()});
		$('#'+mask_id+'').fadeTo("fast",0.8);
		$('body').append(layer_html);

		$('#'+layer_id).css('top', $(window).height()/2-$('#'+layer_id).height()/2);
		$('#'+layer_id).css('left', $(window).width()/2-$('#'+layer_id).width()/2);
}
