﻿// menuOver
function imageOver(obj) {
	obj.src = obj.src.replace("off.gif", "on.gif");
}
function imageOut(obj) {
	obj.src = obj.src.replace("on.gif", "off.gif");
}
function imageChg(obj) {
	if(obj.src.indexOf("off.gif") != -1) obj.src = obj.src.replace("off.gif", "on.gif");
	else if(obj.src.indexOf("on.gif") != -1) obj.src = obj.src.replace("on.gif", "off.gif");
}

//png
function setPng24(obj) {
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng24\b/i,'');
	obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	obj.src=''; 
	return '';
}

// Content Display
function contView(obj) {
	var target = document.getElementById(obj);
	target.style.display = (target.style.display=='none' ? 'block':'none');
}

// getFlash
function getFlash(swfName,wt,ht,id,xmlUrl){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+wt+'" height="'+ht+'" id="'+id+'">');
	document.write('<param name="movie" value="'+swfName+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="FlashVars" value="xml_url='+xmlUrl+'" />');
	document.write('<param name="allowScriptAccess" value="always">');
	document.write('<embed src="'+swfName+'" FlashVars="xml_url='+xmlUrl+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="'+wt+'" height="'+ht+'" allowScriptAccess="sameDomain" id="'+id+'"></embed></object>');
}

// tabChange
function tabChange(tabId,imgNum,viewCont) {
	var targetUl = document.getElementsByTagName("ul");
	var contId = viewCont.split(",");
	for (i=0; i<targetUl.length; i++) {
		if (targetUl[i].className.indexOf(tabId) != -1) {
			var targetImg = targetUl[i].getElementsByTagName("img");
			for (j=0; j<targetImg.length; j++)	{
				targetImg[j].src = (j==imgNum ? targetImg[j].src.replace("_off","_on") : targetImg[j].src.replace("_on","_off"));
				document.getElementById(contId[j]).style.display = (j==imgNum ? 'block':'none');
			}
		}
	}
}


// input Focus
function inputFocus(obj,defaultValue) {
	if(obj.value == defaultValue) obj.value = '';
	else return false;
}
function inputBlur(obj,defaultValue) {
	if(obj.value == '') obj.value = defaultValue;
	else return false;
}


//	popUp Window
function openWin(url,winName,intWidth,intHeight) {
	var winPosLeft	= (screen.width -	intWidth) /	2;
	var winPosTop = (screen.height -	intHeight) / 2;
    winPosTop = 20;
	var winOpt = "width="+intWidth+",height="+intHeight+",top="+winPosTop+",left="+winPosLeft+'location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
	var win = window.open(url,	winName,	winOpt);
	if(win.focus)
		win.focus();
}

//	popUp Window no-margin
function openWinTop(url,winName,intWidth,intHeight) {
	var winPosLeft	= 0;
	var winPosTop = 0;
	var winOpt = "width="+intWidth+",height="+intHeight+",top="+winPosTop+",left="+winPosLeft+'location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
	var win = window.open(url,	winName,	winOpt);
	if(win.focus)
		win.focus();
}


// Burn cookie
function setCookie( name, value, expiredays ) 
{ 
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 



function f_PopLayer(obj, top, left, width, height, url)
{
    var div;
    div = $(obj); 
    div.className = "layer";
    div.style.top = top + "px";
    div.style.width = width + "px";
    div.style.height = height + "px";
    div.style.left = left +"px";
    div.style.zIndex = 9990;
    div.style.position = "absolute";
    div.innerHTML = "<iframe src='" + url + "' frameborder='0' scrolling='no' style='width:" + width + ";height:" + height + "'/>";
    Element.show(div);    
}



function f_PopLayerInCenter(obj, width, height, url)
{
    //화면의 중간위치 계산하기
    var scleft = document.documentElement.scrollLeft;
    var sctop = document.documentElement.scrollTop;
	
    var screenwidth = document.documentElement.clientWidth ;
    var screenheight = document.documentElement.clientHeight;
    var left = parseInt((screenwidth - width)/2) + scleft;
    var top = parseInt((screenheight - height)/2) + sctop;
	    
    var div;
    div = $(obj); 
    div.className = "layer";
    div.style.top = top + "px";
    div.style.width = width + "px";
    div.style.height = height + "px";
    div.style.left = left +"px";
    div.style.zIndex = 9990;
    div.style.position = "absolute";
    div.innerHTML = "<iframe src='" + url + "' frameborder='0' scrolling='no' style='width:" + width + ";height:" + height + "'/>";
    Element.show(div);    
}



function f_CloseLayer(obj)
{
    var div = $(obj);
    if(div)
        Element.hide(div);   
}

function ItemToolBar(url)
{
 //alert(url.substring(0,url.indexOf('&')));
    //alert(url.substring(url.indexOf('&')));
    
    var linkprice = url.substring(0,url.indexOf('&'));
    var encodetr = url.substring(url.indexOf('&'));
    
    var u = '/stylet/stylepicksv3/ViewItem.aspx?Link='+linkprice +encodeURIComponent(encodetr);
    //alert(u); 
    if(url.indexOf('11st.co.kr')>-1)
    {
       var s1 = url.substring(0, url.indexOf("tu") + 3);
       var s2 = url.substring(url.indexOf("tu") + 3);
      
       var s3 =   s1 + escape(s2);
        u = '/stylet/stylepicksv3/ViewItem.aspx?Link='+s3;
        
    }
    
    window.open(u,'');
}


//글쓴이 플로그로 가기
function GoWriterFlog(userid)
{
        window.open("http://flog.stylet.com/stylet/flog/?ltype=2&hostUser="+userid,"flog");
        
}

//주소복사하기
function setClipBoard(x)
{
 window.clipboardData.setData('Text', x);
 alert('주소가 복사 되었습니다.');
}


//이미지 에러났을시 
function GetChangeImg(obj)
{
    try
    {
        obj.src = "/stylet/images/flog/etc/mms_ing2.jpg";
    }
    catch(e)
    {
    }
}