
String.prototype.toInteger = function() {
	return this.replace(/[^0-9]/g, '') * 1;
}

function getPageSize(){
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	arrayPageSize = new Array(windowWidth,windowHeight) 
	return arrayPageSize;
}

function follow_banner(div_id,origin_top,limit_top,margin_top) {
	var d, t, s, g, target_height, windowHeight;	
	origin_top *= 1;
	limit_top *= 1;
	margin_top *= 1;
	windowHeight = getPageSize();
	
	
	if (window.pageYOffset){
		s = window.pageYOffset + ""
	}else if (document.documentElement && document.documentElement.scrollTop){
		s = document.documentElement.scrollTop + ""
	}else if (document.body){
		s = document.body.scrollTop + ""
	}
	
	d = document.getElementById(div_id);
	//alert(s + "||" + d.style.top);
	var limit = s;
	s = s - d.parentNode.offsetTop;
	
	target_height = s + margin_top -40;
	if(target_height < limit_top) {
		target_height = origin_top;
	}

	t = d.style.top.toInteger();
	d.style.clear = "both";
	if (/MSIE/.test(navigator.userAgent)) {
		var h = document.body.scrollHeight;
	} else {
		var s = document.body.appendChild(document.createElement('DIV'))
		s.style.clear = 'both';

		var h = s.offsetTop;
		s.parentNode.removeChild(s);
	}
	if (!d.style.top) d.style.top = "0";

	if(t != target_height) {
		g = Math.ceil((t - target_height) / 5);
		if(g > 50) {
			g = 50;
		} else if (g < -50) {
			g = -50;
		}
		var r = parseInt((d.offsetHeight * 2.3));
		if (h >= parseInt(d.style.top) + r) {
			d.style.top = (t - g) + "px";
		} else {
			d.style.top = (h - g - r - 1) + "px";
		}
	}
	
	//alert(h + "||" + parseInt(d.style.top) + 1300);
	
		setTimeout("follow_banner('" + div_id + "', " + origin_top + ", " + limit_top + ", " + margin_top + ");", 0.3);
}


//¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡
var iframeids=["boardFrame"] // iframe ¿¡ »ç¿ëÇÒ ID ¸¦ ÁöÁ¤ ÇØ ÁÖ¼¼¿ä

var iframehide="yes"

function resizeCaller() {
	var dyniframe=new Array()
	for (i=0; i<iframeids.length; i++){
		if (document.getElementById)
			resizeIframe(iframeids[i])
		if ((document.all || document.getElementById) && iframehide=="no"){
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
			tempobj.style.display="block"
		}
	}
}

function resizeIframe(frameid){
	var currentfr=document.getElementById(frameid)
	if (currentfr && !window.opera){
		currentfr.style.display="block"
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight + 30; 
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
			currentfr.height = currentfr.Document.body.scrollHeight + 30;
		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent)
			currentfr.attachEvent("onload", readjustIframe)
	}
}

function readjustIframe(loadevt) {
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
	if (iframeroot)
		resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
	if (document.getElementById)
		document.getElementById(iframeid).src=url
}

if (window.addEventListener)
	window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
	window.attachEvent("onload", resizeCaller)
else
	window.onload=resizeCaller
//¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡

function addEvent(object, event ,listener) { 
    if (object.addEventListener){ 
        object.addEventListener(event, listener, false); 
    } else if (object.attachEvent){ 
        object.attachEvent('on' + event, listener); 
    } 
}

function resizeIfr(obj, minHeight) {
	minHeight = minHeight || 10;

	try {
		var getHeightByElement = function(body) {
			var last = body.lastChild;
			try {
				while (last && last.nodeType != 1 || !last.offsetTop) last = last.previousSibling;
				return last.offsetTop+last.offsetHeight;
			} catch(e) {
				return 0;
			}
		}

		var doc = obj.contentDocument || obj.contentWindow.document;
		if (doc.location.href == 'about:blank') {
			obj.style.height = minHeight+'px';
			return;
		}

		if (/MSIE/.test(navigator.userAgent)) {
			var h = doc.body.scrollHeight;
		} else {
			var s = doc.body.appendChild(document.createElement('DIV'))
			s.style.clear = 'both';

			var h = s.offsetTop;
			s.parentNode.removeChild(s);
		}

		if (h < minHeight) h = minHeight;

		obj.style.height = h + 'px';
		if (typeof resizeIfr.check == 'undefined') resizeIfr.check = 0;
		if (typeof obj._check == 'undefined') obj._check = 0;

		setTimeout(function(){ resizeIfr(obj,minHeight) }, 200);

	} catch (e) {
	}

}
//¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡

function ChkNumber(aVal){
	var tmp = "1234567890" ; 
	var strLength = aVal.length ; 
	for (i=0; i<strLength ; i++){
		if (tmp.indexOf(aVal.substring(i, i+1)) < 0){
			return false ;
		}
	}
	if (aVal.length == 0)
		return false ;
	else
		return true ;
}

//¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡

function EroPop(purl, pname, psize){
	window.open(purl, pname, psize);
}

function ChkNull(aVal){
	for (i=0; i<aVal.length ; i++)
	{
		tmp = aVal.substring(i, i+1) ; 
		if ((tmp != ' ')&&(tmp != '\r')&&(tmp != '\n')&&(tmp != '\t')&&(tmp != '\b')&&(tmp != '\v')&&(tmp != '\f')) {
		  return false;
	   }
	}
	return true ; 
}

//¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡¦¡

function resizeImg(imgObj, max_width, max_height){
	var dst_width;
	var dst_height;
	var img_width;
	var img_height;

	img_width = parseInt(imgObj.width);
	img_height = parseInt(imgObj.height);

	if(img_width == 0 || img_height == 0){
		imgObj.style.display = '';
		return false;
	}
	// °¡·ÎºñÀ² ¿ì¼±À¸·Î ½ÃÀÛ
	if(img_width > max_width || img_height > max_height) {
		// °¡·Î±âÁØÀ¸·Î ¸®»çÀÌÁî
		dst_width = max_width;
		dst_height = Math.ceil((max_width / img_width) * img_height);

		// ¼¼·Î°¡ max_height ¸¦ ¹þ¾î³µÀ» ¶§
		if(dst_height > max_height) {
			dst_height = max_height;
			dst_width = Math.ceil((max_height / img_height) * img_width);
		}

		imgObj.width = dst_width;
		imgObj.height = dst_height;
	}
	// °¡·ÎºñÀ² ¿ì¼±À¸·Î ³¡

	imgObj.style.display = '';

	return true;
}

// Áñ°ÜÃ£±â
function addfav(){
	window.external.AddFavorite('http://www.1day.kr', '1ÀÏ°£ÀÇ ±âÀû! www.1day.kr')
}

//·Î±×ÀÎÆË
String.prototype.trim=function()
{
  var str=this.replace(/(\s+$)/g,"");
  return str.replace(/(^\s*)/g,"");
}
function getCookieVal(key1, key2) { 
	var totalCookie = unescape(document.cookie);
	var cookie1 = totalCookie.split(";");

	var subCookie = getChildValue(cookie1,key1);
	var cookie2 = subCookie.split("&");
	var val = getChildValue(cookie2, key2);

	return val;
}
function getChildValue(data,keyStr) {
	var returnVal = "";
	var nameStr = "";
	for( var idx=0; idx<data.length; idx++ ) {
		var dec =  data[idx].indexOf("=");
		nameStr = data[idx].substr( 0,dec);
		if (nameStr.trim()==keyStr ) {
			returnVal = data[idx].substring( dec+1, data[idx].length );
		}
	}

	return returnVal;
}
function chgMemInfo()
{
	if ((getCookieVal('OneDay', 'Uid')).trim() == "")
	{
		if (document.getElementById("popLoginZone"))
		{
			document.getElementById("popLoginZone").style.display = "";
			document.location.href="#";
		}
		else
		{
			var popZone = document.createElement("DIV");
			popZone.id = "popLoginZone";
			popZone.style.position="absolute";
			popZone.style.left="0px";
			popZone.style.top="0px"
			popZone.style.width="100%";
			popZone.style.height="100%";
			popZone.style.zIndex=999999;
			
			var tmpHTML = "";
			tmpHTML += "<table width=\"100%\" height=\"100%\">";
			tmpHTML += "<tr><td align=\"center\">";
			tmpHTML += "<table bgcolor=\"#FFFFFF\">";
			tmpHTML += "<tr><td align=\"right\" bgcolor=\"#EEEEEE\"><img src=\"http://img.sportsseoul.com/ss/special/2010/worldcup/btn_poll_close.gif\" border=\"0\" align=\"absmiddel\" style=\"cursor:pointer\" onclick=\"closeLoginPop()\"></td></tr>";
			tmpHTML += "<tr><td>";
			tmpHTML += "<iframe src=\"/member/login_pop.asp?OKurl=/member/mem_modify.asp\" width=\"450\" height=\"300\" scrolling=\"no\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" topmargin=\"0\" leftmargin=\"0\" style=\"border:4px #EEEEEE solid\"></iframe>";
			tmpHTML += "</td></tr>";
			tmpHTML += "</table>";
			tmpHTML += "</td></tr>";
			tmpHTML += "</table>";
			
			popZone.innerHTML = tmpHTML;
			
			document.body.appendChild(popZone);
			document.location.href="#";
		}
	}
	else document.location.href="http://www.1day.kr/member/mem_modify.asp";
}
function closeLoginPop()
{
	if (document.getElementById("popLoginZone"))
	{
		document.getElementById("popLoginZone").style.display = "none";
	}
}