var gnb_over = 1;
String.prototype.trim = function() {
  return this.replace(/^\s+|\s+$/g, "");
}

function $(_str) {
	return document.getElementById(_str)?document.getElementById(_str):null;
}

function realOffset(_e) {
	var T = 0, L = 0;
	do { T += _e.offsetTop  || 0; L += _e.offsetLeft || 0; _e = _e.offsetParent; } while (_e);
	return [L, T];
}

function flashWrite( id, flashUri, vWidth, vHeight, winMode, ret, str) {
	var _obj_ = "";

	_obj_ = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle">';
	_obj_ += '<param name="movie" value="' + flashUri + '" />';
	_obj_ += '<param name=allowScriptAccess value=always />';
	_obj_ += '<param name="quality" value="high" />';
	_obj_ += '<param name="wmode" value="' + winMode + '" />    ';
	_obj_ += '<param name="bgcolor" value="#ffffff" />        ';
	_obj_ += '<param name="flashvars" value="' + str + '" />    ';
	_obj_ += '<embed src="' + flashUri + '" quality="high" wmode="' + winMode + '" bgcolor="#ffffff" width="' + vWidth +'" height="' + vHeight + '" id="' + id + '" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>    ';
	_obj_ += '</object>';

	if (ret) { return _obj_; } else { document.writeln( _obj_ ); }
}

function LogIn(f){
	f.mID.value = f.mID.value.trim();
	if (f.mID.value == '' || f.mID.value.length < 4) { alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä."); f.mID.focus(); return false; }
	else if (f.mPWD.value == ''  || f.mPWD.value.length < 4) { alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä."); f.mPWD.focus(); return false; }
	else { return true; }
} 
function CashCharge(obj){
	window.open('http://www.lottorich.co.kr/hirichToLogin.html?r_url=/cash/HirichFill.html&uid='+ obj, 'cash_popup', 'width=400, height=270');
}

function alert_anal (_nick) {
	alert (_nick + 'ÀÇ VIPÈ¸¿ø¸¸ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.'); 
	return false;
}

function viewTab (_id) {
	var arr = _id.split('_');
	var prefix = '';

	for (var i = 0; i < arr.length - 1;i++) { prefix += arr[i] + '_'; }

	for (i = 1;;i++) {
		if ($(prefix + '' + i) ) {
			$(prefix + '' + i).style.display = 'none';
		} else { break; }
	}
	$(_id).style.display = 'block'
}

function smsLayer (_obj) {
	if (!$('layer_top_sms')) {
		var div = document.createElement("DIV");

		div.id = 'layer_top_sms';
		div.style.position = 'absolute';
		div.style.left = realOffset(_obj)[0] + 'px';
		div.style.top = realOffset(_obj)[1] + 5 + 'px';
		div.style.width = 139 + 'px';
		div.style.height = 300 + 'px';
		div.onmouseover = function () {this.style.display = 'block';}
		div.onmouseout = function () {this.style.display = 'none';}

		div.innerHTML = '<img src="http://image.lsinfo.co.kr/hirich/TopLogin/smsLayer_new/bg01.gif">';
		div.innerHTML += '<iframe src="/inc/VipSmsCheck.ls?mode=VIP" width="100%" height="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="0" border="0" bgcolor="FFFFFF" name="VipSmsFrame"></iframe>';
		div.innerHTML += '<img src="http://image.lsinfo.co.kr/hirich/TopLogin/smsLayer_new/bg_footer.gif">';

		document.body.appendChild(div);
	} else {
		$('layer_top_sms').style.left = realOffset(_obj)[0] + 'px';
		$('layer_top_sms').style.top = realOffset(_obj)[1] + 5 + 'px';
		$('layer_top_sms').style.display = 'block';
	}
}

function smsLayerIlban (_obj) {
	if (!$('layer_top_sms')) {
		var div = document.createElement("DIV");

		div.id = 'layer_top_sms';
		div.style.position = 'absolute';
		div.style.left = realOffset(_obj)[0] + 'px';
		div.style.top = realOffset(_obj)[1] + 5 + 'px';
		div.style.width = 119 + 'px';
		div.style.height = 68 + 'px';
		div.onmouseover = function () {this.style.display = 'block';}
		div.onmouseout = function () {this.style.display = 'none';}

		div.innerHTML = '<table border=0 width=119 height=68 cellpadding=0 cellspacing=0 background="http://image.lsinfo.co.kr/hirich/main_new/top/BoxSmsSta.gif"><tr height="68" valign="bottom"><td align="center"><iframe src="http://global.hirich.co.kr/inc/VipSmsCheck.ls" width="95" height="20" marginheight="0" marginwidth="0" frameborder="0" scrolling="0" border="0" bgcolor="FFFFFF" name="VipSmsFrame" style="margin-bottom:10px;"></iframe></td></tr></table>';


		document.body.appendChild(div);
	} else {
		$('layer_top_sms').style.left = realOffset(_obj)[0] + 'px';
		$('layer_top_sms').style.top = realOffset(_obj)[1] + 5 + 'px';
		$('layer_top_sms').style.display = 'block';
	}
}

function getCookie( name ){ 
	var nameOfCookie = name + "="; var x = 0; 
	while(x <= document.cookie.length){ var y = (x+nameOfCookie.length); 
		if(document.cookie.substring(x, y) == nameOfCookie){ 
			if((endOfCookie=document.cookie.indexOf( ";", y )) == -1) endOfCookie = document.cookie.length; 
			return unescape(document.cookie.substring(y, endOfCookie)); 
		} x = document.cookie.indexOf(" ", x) + 1; if(x == 0) break; 
	} return ""; 
} 


function pop_news_data(_p_code, _p_uid, flag) {
	if (flag!="") {
		switch(flag) {
			case 1:
				var intWidth = screen.availWidth - 10;
				var intHeight = screen.availHeight - 15;
				var tempX = 0;
				var tempY = 0;

				news_data_window = window.open("", "news_data_window","left="+tempX+",top="+tempY+",width="+intWidth+",height="+intHeight+",scrollbars=yes, resizable=yes", "no");	


				news_data_window.location.href='/sise/kospi_sise.ls';

				news_data_window.focus();
				break;
			case 2:
				var intWidth = screen.availWidth - 10;
				var intHeight = screen.availHeight - 15;
				var tempX = 0;
				var tempY = 0;

				news_data_window = window.open("", "news_data_window","left="+tempX+",top="+tempY+",width="+intWidth+",height="+intHeight+",scrollbars=0, resizable=yes", "no");	


				if (_p_code && _p_uid) {
					try {
						news_data_window.readNews (_p_code, _p_uid);
					} catch(e) {
						news_data_window.location.href='/news/news_data/?p_code=' + _p_code + "&p_uid=" + _p_uid;
					}
				} else {
					news_data_window.location.href='/news/news_data/';
				}

				news_data_window.focus();
				break;
		}
	} else {
		var intWidth = screen.availWidth - 10;
		var intHeight = screen.availHeight - 15;
		var tempX = 0;
		var tempY = 0;

		news_data_window = window.open("", "news_data_window","left="+tempX+",top="+tempY+",width="+intWidth+",height="+intHeight+",scrollbars=0, resizable=yes", "no");	


		if (_p_code && _p_uid) {
			try {
				news_data_window.readNews (_p_code, _p_uid);
			} catch(e) {
				news_data_window.location.href='/news/news_data/?p_code=' + _p_code + "&p_uid=" + _p_uid;
			}
		} else {
			news_data_window.location.href='/news/news_data/';
		}

		news_data_window.focus();
	}
}

function gnbMenuOver (_num) {
	if (_num == gnb_over) {
		return;
	}
/*
	if (_num == 9) {
		img = img.replace("c.gif", "c.gif");
		$("gnb_icon_" + _num).src = img;
	}
*/
	if ($("gnb_icon_" + _num)) {
		var img = $("gnb_icon_" + _num).src.replace(".gif", "c.gif");
		img = img.replace("cc.gif", "c.gif");
		$("gnb_icon_" + _num).src = img;
	}

	if (gnb_over && gnb_over != 10) {
		$("gnb_icon_" + gnb_over).src = $("gnb_icon_" + gnb_over).src.replace("c.gif", ".gif");
	} else {
//		$("gnb_icon_2").src = $("gnb_icon_2").src.replace("c.gif", ".gif");
//		$("gnb_2").style.display = 'none';
	}

	$("gnb_" + gnb_over).style.display = 'none';
	$("gnb_" + _num).style.display = 'block';

	gnb_over = _num;

}
