//////////////////////////////////////////////////////////////////////////////
/*
·Ðºô¸®Áö ÀÚ¹Ù ½ºÅ©¸³Æ®
	2008³â 12¿ù 23ÀÏ ÃÊ¾È Á¦ÀÛ
*/

//////////////////////////////////////////////////////////////////////////////

//Flash Script
function FlashObject(swf, width, height, bgcolor, id, flashvars)
{
    var strFlashTag = new String();
    
    if (navigator.appName.indexOf("Microsoft") != -1)
    {
        strFlashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        strFlashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=version=8,0,0,0" ';
        strFlashTag += 'id="' + id + '" width="' + width + '" height="' + height + '">';
        strFlashTag += '<param name="movie" value="' + swf + '"/>';
        
        if(flashvars != null) {strFlashTag += '<param name="flashvars" value="' + flashvars + '"/>'};
        strFlashTag += '<param name="quality" value="best"/>';
        strFlashTag += '<param name="bgcolor" value="' + bgcolor + '"/>';
        strFlashTag += '<param name="menu" value="false"/>';
        strFlashTag += '<param name="salign" value="LT"/>';
        strFlashTag += '<param name="scale" value="noscale"/>';
        strFlashTag += '<param name="wmode" value="transparent"/>';
        strFlashTag += '<param name="allowScriptAccess" value="always"/>';
        strFlashTag += '</object>';
    }
    else
    {
        strFlashTag += '<embed src="' + swf + '" ';
        strFlashTag += 'quality="best" ';
        strFlashTag += 'bgcolor="' + bgcolor + '" ';
        strFlashTag += 'width="' + width + '" ';
        strFlashTag += 'height="' + height + '" ';
        strFlashTag += 'menu="false" ';
        strFlashTag += 'scale="noscale" ';
        strFlashTag += 'id="' + id + '" ';
        strFlashTag += 'salign="LT" ';
        strFlashTag += 'wmode="transparent" ';
        strFlashTag += 'allowScriptAccess="always" ';
        if(flashvars != null) {strFlashTag += 'flashvars="' + flashvars + '" '};
        strFlashTag += 'type="application/x-shockwave-flash" ';
        strFlashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        strFlashTag += '</embed>';
    }

 document.write(strFlashTag);
}

function swfView(s, d, m, w, h){
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width="+w+" height="+h+" id="+d+">");
	document.write("<param name='allowScriptAccess' value='always' />");
	document.write("<param name=wmode value="+m+" />");
	document.write("<param name=movie value="+s+" />");
	document.write("<param name=quality value=high />");
	document.write("<param name=menu value=false />");
	document.write("<embed src="+s+" quality=high wmode="+m+" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash\" width="+w+" height="+h+" id="+d+">");
	document.write("</embed>");
	document.write("</object>");
}

//Flash Script End

//ÀÚ¹Ù½ºÅ©¸³Æ® Äõ¸®½ºÆ®¸µ(QueryString) °¡Á®¿À±â

function getParameter(name) {  

   var rtnval = '';  
   var nowAddress = unescape(location.href);  
   var parameters = (nowAddress.slice(nowAddress.indexOf('?') + 1, nowAddress.length)).split('&');  

   for (var i = 0; i < parameters.length; i++) {  
       var varName = parameters[i].split('=')[0];  
       if (varName.toUpperCase() == name.toUpperCase()) {  
           rtnval = parameters[i].split('=')[1];  
           break;  
       }  
   }  
   return rtnval;  
} 

//////////////////////////////////////////////////////////////////////////////
//Menu Open/Close
function clickshow(num){
	menu = document.getElementById("block"+num);
	if( menu != null && typeof menu != "undefined" )
		{
			if (menu.style.display=="block"){
			menu.style.display="none";//Close
		}
	else{
		menu.style.display="block";//Sub Menu Open
		}
	}
}
//Menu Open/Close End

function clickblock(num)
{
	for (i=1;i<=2;i++) {
		var menu=eval("block"+i+".style");
		
		if (num==i) {menu.display="block";}
		else { menu.display="none"; }
    }
}

//////////////////////////////////////////////////////////////////////////////
// Button script
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr;
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){
			d.MM_p[j]=new Image;
			d.MM_p[j++].src=a[i];
		}
	}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length){
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n);
	return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){
		document.MM_sr[j++]=x;
		if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

//////////////////////////////////////////////////////////////////////////////
// quick
var stmnLEFT = -20; // ¿ÞÂÊ ¿©¹é (¸Þ´º°¡ ¿ÞÂÊ¿¡¼­ 400ÇÈ¼¿ ¶³¾îÁø °÷¿¡ º¸¿©Áý´Ï´Ù) 
var stmnGAP1 = 150; // À§ÂÊ ¿©¹é (¸Þ´º°¡ À§¿¡¼­ 10ÇÈ¼¿ ¶³¾îÁø °÷¿¡ º¸¿©Áý´Ï´Ù) 
var stmnGAP2 = 150; // ½ºÅ©·Ñ½Ã ºê¶ó¿ìÀú À§ÂÊ°ú ¶³¾îÁö´Â °Å¸® 
var stmnBASE = 150; // ½ºÅ©·Ñ ½ÃÀÛÀ§Ä¡ 
var stmnActivateSpeed = 35; 
var stmnScrollSpeed = 20; 

var stmnTimer; 


function RefreshStaticMenu() { 
	var stmnStartPoint, stmnEndPoint; 
	
	stmnStartPoint = parseInt(document.getElementById('STATICMENU').style.top, 10); 
	stmnEndPoint = Math.max(document.documentElement.scrollTop, document.body.scrollTop) + stmnGAP2; 
	if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1; 
	
	if (stmnStartPoint != stmnEndPoint) { 
		stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 ); 
		document.getElementById('STATICMENU').style.top = parseInt(document.getElementById('STATICMENU').style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount ) + 'px'; 
		stmnRefreshTimer = stmnScrollSpeed; 
	}
	
	stmnTimer = setTimeout("RefreshStaticMenu();", stmnActivateSpeed); 
} 


function InitializeStaticMenu() {
	document.getElementById('STATICMENU').style.left = stmnLEFT + 'px'; 
	document.getElementById('STATICMENU').style.top = document.body.scrollTop + stmnBASE + 'px'; 
	RefreshStaticMenu();
}
// quick END

//////////////////////////////////////////////////////////////////////////////
// Layer Popup
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;
/*
function ddInit(e){
	topDog=isIE ? "BODY" : "HTML";
	whichDog=isIE ? document.all.divpop : document.getElementById("divpop");
	whichDog=isIE ? document.all.divpop2 : document.getElementById("divpop2");
	whichDog=isIE ? document.all.divpop3 : document.getElementById("divpop3");
	whichDog=isIE ? document.all.divpop4 : document.getElementById("divpop4");
	whichDog=isIE ? document.all.divpop5 : document.getElementById("divpop5");
	hotDog=isIE ? event.srcElement : e.target;
	while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
		hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
	}
	if (hotDog.id=="titleBar"){
	offsetx=isIE ? event.clientX : e.clientX;
	offsety=isIE ? event.clientY : e.clientY;
	nowX=parseInt(whichDog.style.left);
	nowY=parseInt(whichDog.style.top);
	ddEnabled=true;
	document.onmousemove=dd;
	}
}
*/
function dd(e){
	if (!ddEnabled) return;
	whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
	whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
	return false;
}

function ddN4(whatDog){
	if (!isN4) return;
	N4=eval(whatDog);
	N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
	N4.onmousedown=function(e){
		N4.captureEvents(Event.MOUSEMOVE);
		N4x=e.x;
		N4y=e.y;
	}
	N4.onmousemove=function(e){
		if (isHot){
		N4.moveBy(e.x-N4x,e.y-N4y);
		return false;
		}
	}
	N4.onmouseup=function(){
		N4.releaseEvents(Event.MOUSEMOVE);
	}
}

function hideMe(){
	if (isIE||isNN) whichDog.style.visibility="hidden";
	else if (isN4) document.divpop.visibility="hide";
}

function showMe(){
	if (isIE||isNN) whichDog.style.visibility="visible";
	else if (isN4) document.divpop.visibility="show";
}
function hideMe(){
	if (isIE||isNN) whichDog.style.visibility="hidden";
	else if (isN4) document.divpop2.visibility="hide";
}
function showMe(){
	if (isIE||isNN) whichDog.style.visibility="visible";
	else if (isN4) document.divpop2.visibility="show";
}
function hideMe(){
	if (isIE||isNN) whichDog.style.visibility="hidden";
	else if (isN4) document.divpop3.visibility="hide";
}
function showMe(){
	if (isIE||isNN) whichDog.style.visibility="visible";
	else if (isN4) document.divpop3.visibility="show";
}
function hideMe(){
	if (isIE||isNN) whichDog.style.visibility="hidden";
	else if (isN4) document.divpop4.visibility="hide";
}
function showMe(){
	if (isIE||isNN) whichDog.style.visibility="visible";
	else if (isN4) document.divpop4.visibility="show";
}

function hideMe(){
	if (isIE||isNN) whichDog.style.visibility="hidden";
	else if (isN4) document.divpop5.visibility="hide";
}
function showMe(){
	if (isIE||isNN) whichDog.style.visibility="visible";
	else if (isN4) document.divpop5.visibility="show";
}

//document.onmousedown=ddInit;
//document.onmouseup=Function("ddEnabled=false");

function InfoLayer(gubun){
    window.open("/Popup/PopupStockLoan.aspx?gubun=" + gubun, "StockLoanLearn", "scrollbars=no, resizable=no, width=820px, height=500px");
}
function SearchLayer(){
	document.getElementById("divpop2").style.display='inline'
}
function SearchLayer_iframe() {
    parent.document.getElementById("divpop2").style.display = 'inline'
}  
function goodsLayer01(){
	document.getElementById("divpop3").style.display='inline'
}
function goodsLayer02(){
	document.getElementById("divpop4").style.display='inline'
}
function goodsLayer03(){
	document.getElementById("divpop5").style.display='inline'
}
function close_Layer(){
	document.getElementById("divpop").style.display='none'
}
function close_Layer2(){
	document.getElementById("divpop2").style.display='none'
}
function close_Layer3(){
	document.getElementById("divpop3").style.display='none'
}
function close_Layer4(){
	document.getElementById("divpop4").style.display='none'
}
function close_Layer5(){
	document.getElementById("divpop5").style.display='none'
}
// Layer Popup

function Mid(str, start, len) {
    if (start < 0 || len < 0) return "";
    var iEnd, iLen = String(str).length;
    if (start + len > iLen)
        iEnd = iLen;
    else
        iEnd = start + len;
    return String(str).substring(start, iEnd);
}

function InStr(strSearch, charSearchFor) {
    for (i = 0; i < strSearch.length; i++) {
        if (charSearchFor == Mid(strSearch, i, 1)) {
            return i;
        }
    }
    return -1;
}


//

function fnOpenVodPopup(code) {
    var arrList;
    var list;
    
    window.open("http://www.etomato.com/tsearch/popup_vod_ex.asp?jcd=" + code, "", "scrollbars=yes, resizable=yes");
    
    list = getCookie("search_item_code_list");

    if (list != null && list != false) {

        arrList = list.split("/");
        if (getCookie("search_item_code_list").indexOf(code) == -1) {
            if (arrList.length < 7) {
                setCookie("search_item_code_list", getCookie("search_item_code_list") + "/" + code, 1);
            }
        }
    }
    else {

        setCookie("search_item_code_list", code, 1);
    }

}

function fnDelSearchItem(code) {
    
    var list;
    list = getCookie("search_item_code_list");

    if (list != null && list != false) {

        if (list.indexOf(code) != -1) {
            
            if (list.indexOf(code + "/") != -1) {
                setCookie("search_item_code_list", list.replace(code + "/", "").replace("//", "/"), 1);
            }
            else {
                setCookie("search_item_code_list", list.replace(code, "").replace("//", "/"), 1);
            }
        }
    }
    else {
    }

    fnSearchItemIntoHtml();
}

function setCookie(name, value, expiredays) {
    var todayDate = new Date();
    todayDate.setDate(todayDate.getDate() + expiredays);
    document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function getCookie(cookieName) {
    var search = cookieName + "=";
    var cookie = document.cookie;

    if (cookie.length > 0) {
        startIndex = cookie.indexOf(cookieName);

        if (startIndex != -1) {
            startIndex += cookieName.length;
            endIndex = cookie.indexOf(";", startIndex);

            if (endIndex == -1) endIndex = cookie.length;

            return unescape(cookie.substring(startIndex + 1, endIndex));
        }
        else {
            return false;
        }
    }
    else {
        return false;
    }
}

function fnNewsShow(gubun) {
    if (gubun == 0) {
        $("#recentNews_0").hide().fadeIn();
        $("#recentNews_1").hide();
        $("#recentNews_2").hide();
        $("#recentNews_3").hide();
        $("#recentNews_4").hide();

        $("#tab_smenu01").attr('src', '/Content/Images/ttab_ov01.gif');
        $("#tab_smenu02").attr('src', '/Content/Images/ttab_up02.gif');
        $("#tab_smenu03").attr('src', '/Content/Images/ttab_up03.gif');
        $("#tab_smenu04").attr('src', '/Content/Images/ttab_up04.gif');
        $("#tab_smenu05").attr('src', '/Content/Images/ttab_up05.gif');
    }
    else if (gubun == 1) {
        $("#recentNews_0").hide();
        $("#recentNews_1").hide().fadeIn();
        $("#recentNews_2").hide();
        $("#recentNews_3").hide();
        $("#recentNews_4").hide();

        $("#tab_smenu01").attr('src', '/Content/Images/ttab_up01.gif');
        $("#tab_smenu02").attr('src', '/Content/Images/ttab_ov02.gif');
        $("#tab_smenu03").attr('src', '/Content/Images/ttab_up03.gif');
        $("#tab_smenu04").attr('src', '/Content/Images/ttab_up04.gif');
        $("#tab_smenu05").attr('src', '/Content/Images/ttab_up05.gif');
    }
    else if (gubun == 2) {
        $("#recentNews_0").hide();
        $("#recentNews_1").hide();
        $("#recentNews_2").hide().fadeIn();
        $("#recentNews_3").hide();
        $("#recentNews_4").hide();

        $("#tab_smenu01").attr('src', '/Content/Images/ttab_up01.gif');
        $("#tab_smenu02").attr('src', '/Content/Images/ttab_up02.gif');
        $("#tab_smenu03").attr('src', '/Content/Images/ttab_ov03.gif');
        $("#tab_smenu04").attr('src', '/Content/Images/ttab_up04.gif');
        $("#tab_smenu05").attr('src', '/Content/Images/ttab_up05.gif');
    }
    else if (gubun == 3) {
        $("#recentNews_0").hide();
        $("#recentNews_1").hide();
        $("#recentNews_2").hide();
        $("#recentNews_3").hide().fadeIn();
        $("#recentNews_4").hide();

        $("#tab_smenu01").attr('src', '/Content/Images/ttab_up01.gif');
        $("#tab_smenu02").attr('src', '/Content/Images/ttab_up02.gif');
        $("#tab_smenu03").attr('src', '/Content/Images/ttab_up03.gif');
        $("#tab_smenu04").attr('src', '/Content/Images/ttab_ov04.gif');
        $("#tab_smenu05").attr('src', '/Content/Images/ttab_up05.gif');
    }
    else if (gubun == 4) {
        $("#recentNews_0").hide();
        $("#recentNews_1").hide();
        $("#recentNews_2").hide();
        $("#recentNews_3").hide();
        $("#recentNews_4").hide().fadeIn();

        $("#tab_smenu01").attr('src', '/Content/Images/ttab_up01.gif');
        $("#tab_smenu02").attr('src', '/Content/Images/ttab_up02.gif');
        $("#tab_smenu03").attr('src', '/Content/Images/ttab_up03.gif');
        $("#tab_smenu04").attr('src', '/Content/Images/ttab_up04.gif');
        $("#tab_smenu05").attr('src', '/Content/Images/ttab_ov05.gif');
    }
}

function fnOpenAccountRule(seq) {
    window.open("/Popup/PopupAccountManagementRule.aspx?seq=" + seq, "StockLoanAccountRule", "scrollbars=yes, resizable=no, width=750px, height=500px");
}