function showHint(url , divid ){
    var xmlhttp=false;

    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }

    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
     
    xmlhttp.open("GET", url ,true);
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) {
            var box = document.getElementById( divid );
            var a = document.createElement('div');
			a.style.display = "none";
            box.appendChild(a);
            a.innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null)
} 
function setImgCookie(name, value){
    var imageStatusForm=document.imgStatusChgfrm;
    imageStatusForm.cookieName.value=name;
    imageStatusForm.cookieValue.value=value;
    imageStatusForm.submit();
}
function getImgStatus(cookieName, fieldName)
{
	var cookieValue=unescape(document.cookie);
    var cookieStartsAt=cookieValue.indexOf(cookieName + "=");

    if(cookieStartsAt == -1)
    {
         return 'N';
    }
    else
    {
        cookieStartsAt=cookieValue.indexOf("=", cookieStartsAt)+1;  //
        var cookieEndsAt=cookieValue.indexOf(";", cookieStartsAt);

        if(cookieEndsAt==-1)
        {
            cookieEndsAt=cookieValue.length;
        }
        cookieValue=unescape(cookieValue.substring(cookieStartsAt, cookieEndsAt));

        var fieldStartsAt=cookieValue.indexOf(fieldName+"=");
        if(fieldStartsAt!=-1)
        {
            fieldStartsAt=cookieValue.indexOf("=", fieldStartsAt);
            return cookieValue.charAt(fieldStartsAt+1);
        }
        else
        {
             return 'N';
        }
    }
}
function imgStatus()
{
	var img_Obj=document.getElementById("animatedImgStat");
	try {	
	    if(img_Obj)
		    img_Obj.style.display="";

	    if(getImgStatus("user_info", "isStaticImg")=="Y")
	    {
			img_Obj.href = "javascript:void(0);";
			img_Obj.className = "btn_imgref";
			img_Obj.title = "Á¤Áö ÇØÁ¦";
	        if (document.readyState == "complete") {
	            img_Obj.click();
	            animatedImgStatChg("stop");
            }
	    }
    } catch(e) {
    }	    
}
function animatedImgStatChg(stat)
{
	if (stat == "stop")
	{
		setImgCookie("isStaticImg", "Y");
		document.execCommand('Stop');
		var img_Obj=document.getElementById("animatedImgStat");
		img_Obj.href = "javascript:animatedImgStatChg('reload')";
		img_Obj.className = "btn_imgref";
		img_Obj.title = "Á¤Áö ÇØÁ¦";
		return;
	}
	else if (stat == "reload")
	{
		setImgCookie("isStaticImg", "N");
	}
}

function WindScroll() {
	imgStatus();
	if ( startFloatFlag == true )
	{
		var start_num = Math.floor(Math.random() * (total_cnt2));
		start_floate(start_num);
	}
}
function WindReset()
{
	imgStatus();
}
function msg_09_slide_up(){
	var sAgentName = getUserAgentName();
	var msgLayer = document.getElementById("msg_09_layer");
	if(sAgentName == "IE"){
		if (msgLayer.style.pixelBottom < 0) {
			msgLayer.style.display="inline";
			msgLayer.style.pixelBottom+=15; 
			setTimeout("msg_09_slide_up()",1);
		}else{
			msgLayer.style.pixelBottom=15; 
			setTimeout("msg_09_fadeout()",5000);
		}
	}else{
		msgLayer.style.bottom = "0px";
		msgLayer.style.display = "inline";
		setTimeout("msg_09_fadeout()",10000);
	}
}
var msg_09_Alpha = 100;
function msg_09_fadeout(){
	var sAgentName = getUserAgentName();
	var msgLayer = document.getElementById("msg_09_layer");
	if(sAgentName == "IE"){
		if (msg_09_Alpha != 0) {
			msg_09_Alpha -= 10;
			msgLayer.style.filter = "alpha(opacity="+msg_09_Alpha+")"; 
			setTimeout("msg_09_fadeout()",1);
		}else{
			msgLayer.style.display="none";
		}
	}else{
		msgLayer.style.display = "none";
	}
}
function msg_09_hide(){
	document.getElementById("msg_09_layer").style.display = "none";
}
function goToMessageBoxOpt(opt){
	var w = fixed_coupon_box_width;
	var h = fixed_coupon_box_height;
	var my_coupon_pop = window.open('http://www.gmarket.co.kr/challenge/neo_goods/my_coupon/my_coupon_renew.asp?m_id=2&goodscode=' + floatGoodsCode + '&msg_opt='+opt, 'showMyCoupon', 'top='+(screen.height-h)/3+',left='+(screen.width-w)/2+',toolbar=no, history=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width='+w+', height='+h);
	my_coupon_pop.focus();
}
var	floatingImgflag = false;
function new_mini_Layer_hidden() {
	var layer_contents = document.getElementById('total_mini_interest_layer');
	layer_contents.innerHTML = "";
	document.getElementById('total_mini_interest_layer_close').style.display = "none";
	document.getElementById('total_mini_interest_layer').style.display = "none";
}
function showMiniInterest()
{
	if (document.getElementById("PlusLayer")) {
		document.getElementById("PlusLayer").style.display = "none";	
	}
   if(floatingImgflag == false)
   {
	   showHint("/challenge/neo_include/floating/main_floating_select.asp?mtype=m2","total_mini_interest_layer");
	   document.getElementById('total_mini_interest_layer').style.display = "";	
	   document.getElementById('total_mini_interest_layer_close').style.display = ""; 
	   floatingImgflag = true;
   }else{
	   new_mini_Layer_hidden();
	   showHint("/challenge/neo_include/floating/main_floating_select.asp?mtype=m2","total_mini_interest_layer");
	   document.getElementById('total_mini_interest_layer').style.display = "";	
	   document.getElementById('total_mini_interest_layer_close').style.display = "";	
   }
   document.getElementById('FminiDivView').style.display = "none";
}

function showMiniBasket() {
	if (document.getElementById("PlusLayer")) {
		document.getElementById("PlusLayer").style.display = "none";	
	}
	
   if(floatingImgflag == false)
   {
	   showHint("/challenge/neo_include/floating/main_floating_select.asp","total_mini_interest_layer");
	   document.getElementById('total_mini_interest_layer').style.display = "";	
	   document.getElementById('total_mini_interest_layer_close').style.display = ""; 
	 floatingImgflag = true;
   }else{
	   new_mini_Layer_hidden()
	  showHint("/challenge/neo_include/floating/main_floating_select.asp","total_mini_interest_layer");
	   document.getElementById('total_mini_interest_layer').style.display = "";	
	   document.getElementById('total_mini_interest_layer_close').style.display = "";	
   }
   document.getElementById('FminiDivView').style.display = "none";
}
function showMyCouponPop(){
	var w = fixed_coupon_box_width;
	var h = fixed_coupon_box_height;
	var my_coupon_pop = window.open('http://www.gmarket.co.kr/challenge/neo_goods/my_coupon/my_coupon_renew.asp?goodscode=' + floatGoodsCode, 'showMyCoupon', 'top='+(screen.height-h)/3+',left='+(screen.width-w)/2+',toolbar=no, history=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width='+w+', height='+h);
	my_coupon_pop.focus();
}
function showMCouponLayer( fstr, mlayer )
{
	if ( document.getElementById(mlayer).style.display == "none" )
	{
		if ( document.getElementById(mlayer).innerHTML == "" )
		{
			showHint("/challenge/neo_include/floating/main_floating_mcoupon.asp?sFloatingDealerCoupon="+fstr,mlayer);
		}  
		document.getElementById(mlayer).style.display = "";	
	}
	else
		document.getElementById(mlayer).style.display = "none";
}
function setMsgCookie(name, value, expiredays)
{ 
	var todayDate = new Date(); 
	todayDate.setDate(todayDate.getDate() + expiredays); 
	document.cookie = name + "=" + escape(value) + "; domain=gmarket.co.kr; path=/; expires=" + todayDate.toGMTString() + ";" 
}
function getMsgCookie(name)
{ 
	var Found = false;
	var start, end; 
	var i = 0 ;

	while(i <= document.cookie.length)
	{ 
		start = i; 
		end = start + name.length;

		if(document.cookie.substring(start, end) == name)
		{ 
			Found = true;
			break;
		}
	
		i++
	} 
	if(Found==true)
	{ 
		start = end+1; 
		end = document.cookie.indexOf(";",start);
		
		if(end< start) 
			end = document.cookie.length; 
		
		return document.cookie.substring(start,end); 
	}
	return ""; 
} 
function goToMessageBox(){
	var w = fixed_coupon_box_width;
	var h = fixed_coupon_box_height;
	var my_coupon_pop = window.open('http://www.gmarket.co.kr/challenge/neo_goods/my_coupon/my_coupon_renew.asp?m_id=2&goodscode=' + floatGoodsCode, 'showMyCoupon', 'top='+(screen.height-h)/3+',left='+(screen.width-w)/2+',toolbar=no, history=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width='+w+', height='+h);
	my_coupon_pop.focus();
}
function fnDisplayOneCell(idx) {
	if(document.getElementById("_divGoodsTodayView_"+(v_goodsCntToday - idx - 1))) {
		document.getElementById("_divGoodsTodayView_"+(v_goodsCntToday - idx - 1)).innerHTML = v_goodsTableInfo[idx];
	}
}
function fnInitTodayView() {
	for(var i = v_goodsCntToday - 1 ; i > v_goodsCntToday - 4 ; i--) {
		if(i >= 0) {
			fnDisplayOneCell(i);	
		}
	}	
}
function fnTodayViewUp() {
	var StandardIndex = todayGoodsStartIdx - 1;
	if ( StandardIndex < 0) {
		StandardIndex = v_goodsCntToday - 1;	
	}
	todayGoodsStartIdx = StandardIndex;
	fnTodayViewReset();
}
function fnTodayViewDown() {
	var StandardIndex = todayGoodsStartIdx + 1;
	if ( StandardIndex > v_goodsCntToday - 1) {
		StandardIndex = 0;	
	}
	todayGoodsStartIdx = StandardIndex;
	fnTodayViewReset();
}
function fnTodayViewReset() {
	var startIdx = todayGoodsStartIdx;
	for(var i = 0 ; i < 3 ; i++) {
		if(startIdx < 0 ) {
			startIdx = v_goodsCntToday - 1;
		}
		document.getElementById("_divGoodsTodayView_"+i).innerHTML = v_goodsTableInfo[startIdx];	
		startIdx = startIdx - 1;
	}
}
function getPositionFloating(){
	var start, end, scale, term, speed, top_margin, top_margin2, tmp_top;
	var FloatingBn = document.getElementById('LayerFloatingBn');
	term = 5;
	end =  document.body.scrollTop || document.documentElement.scrollTop;
	if ( end  <= standardTop +1 )
	{
		start = parseInt (FloatingBn.style.top, 10);
		speed = 3;
	} else {
		start = parseInt (FloatingBn.style.top, 10) + standardTop;
		speed = 5;
	}
	if ( start != end ) {
		scale = Math.ceil( Math.abs( end - start ) / speed );
		if ( end < start )	scale = -scale;
		FloatingBn.style.top = parseInt (FloatingBn.style.top, 10)+ scale + "px";
		term = 1;
	}
	setTimeout ("getPositionFloating()", term);
}
function scrollFloating() {
	var scrollTop;

	scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
	document.getElementById('LayerFloatingBn').style.top = scrollTop + "px"; 
	getPositionFloating();
	return true;
}
