var nopopuptoday = false;	// "하루동안 팝업 안보기" 기본 설정갑
var	cookieEnabled = true;

function popclose(divid) {
	document.getElementById(divid).style.display="none";
	document.getElementById("mainbannerposter").style.display = "none";
	document.getElementById("mainbannerflash").style.display = "block";
	document.getElementById("youtubeposter").style.display = "none";
	document.getElementById("youtubevideo").style.display = "block";
	document.getElementById("repop").style.display = "block";
}

function mainpopup(divid) {
	var theElement = document.getElementById(divid);
	var leftMargin = 0;
	var theWidth, theHeight, theTop;

	createCookie('test', 'test', 0);
	if (readCookie('test') == 'test') {   // Testing to see if the browser supports/enabled cookie
		eraseCookie('test');
		cookieEnabled = true;

		// Read cookies if found
		if (readCookie('nopopuptoday') != null) nopopuptoday = readCookie('nopopuptoday');
	} else {
		cookieEnabled = false;
		document.getElementById("footerBox").style.display = "none";
	}

	theWidth = $('#theContent').width();
	theElement.style.width = theWidth + 'px';
	//alert(theWidth);
	theHeight = $('#theContent').height();
	theElement.style.height = theHeight + 'px';
	//alert(theHeight);
	leftMargin = -theWidth / 2;
	theElement.style.marginLeft = leftMargin + 'px';
	theTop = (600 - theHeight) / 2;
	//alert(theTop);
	theElement.style.top = theTop + 'px';

	if (!nopopuptoday) {
		document.getElementById("mainbannerflash").style.display = "none";
		document.getElementById("mainbannerposter").style.display = "block";
		document.getElementById("youtubevideo").style.display = "none";
		document.getElementById("youtubeposter").style.display = "block";
		theElement.style.display = "block";
	} else {
		document.getElementById("repop").style.display = "block";
	}
}

function nopopshow(divid) {
	if (cookieEnabled) {
		if (document.getElementById("nopopcheck").checked == true) {
			createCookie('nopopuptoday', true, 1);
			nopopuptoday = readCookie('nopopuptoday');
			popclose(divid);
		} else {
			//createCookie('nopopuptoday', false, 1);
			eraseCookie('nopopuptoday');
			nopopuptoday = false;
		}
	}
}

function repop(divid) {
	if (nopopuptoday) {
		document.getElementById("nopopcheck").checked = true;
	}
	document.getElementById("mainbannerflash").style.display = "none";
	document.getElementById("mainbannerposter").style.display = "block";
	document.getElementById("youtubevideo").style.display = "none";
	document.getElementById("youtubeposter").style.display = "block";
	document.getElementById("repop").style.display = "none";
	document.getElementById(divid).style.display = "block";
}

function msienopopshow(divid) {
	if (browserType == "MSIE") {
		nopopshow(divid);
	}
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
	window.onload = function() {
		if (oldonload) {
			oldonload();
		}
		func();
	}
	}
}

function dynymtoggle() {
	var aaa = document.getElementById("mainbannerflash");
	var bbb = document.getElementById("dynym");

	if (aaa.style.display == "none") {
		aaa.style.display = "block";
		bbb.style.display = "none";
	} else {
		aaa.style.display = "none";
		bbb.style.display = "block";
	}
}
