/**
 * 
 */
var authYn = false;

$(function(){
	if('0:0:0:0:0:0:0:1' === IP){
		IP = '127.0.0.1';
	}
		
	checkConnection();
});

function checkConnection() {
	if(IPFLAG === "true"){
		passAuth();
		return;
	}
	
	let param = 'ip=' + IP +
			'&key=' + KEY;
		
		var option = {
			url: "main/getConnectionAuth.do",
			async: false,
			param: param,
			callback: checkConnectionCallback
		};
	
		callService(option);
}

function checkConnectionCallback(json) {
	authYn = json.data;

	if (authYn) {
		passAuth();
	} else {
		$('.wrapper').show();
		
        document.getElementById('idValue').innerHTML = 'IP : ' + IP;
	}
}

function passAuth(){
	setCookie('macChk', 'success', 1);
	
	if(IPFLAG === "true"){
		location.href = CONTEXTROOT;
	} else {
		location.href = CONTEXTROOT + '/?key=' + KEY;
	}
}