//flash(출력영역ID및NAME,플래시파일경로,WIDTH,HEIGHT,FLASHVARS,BackgroundColor,WMOD)
function flash(fid,fnm,wid,hei,fvs,bgc,wmd) {
	var flash_tag = "";
	flash_tag = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+wid+'" height="'+hei+'" id="'+fid+'" align="middle">';
	flash_tag +='<param name="allowScriptAccess" value="always" />';
	flash_tag +='<param name="allowFullScreen" value="false" />';
	flash_tag +='<param name="movie" value="'+fnm+'" />';
	flash_tag +='<param name="FlashVars" value="'+fvs+'" />';
	flash_tag +='<param name="quality" value="high" />';
	flash_tag +='<param name="bgcolor" value="'+bgc+'" />';
	flash_tag +='<param name="wmode" value="'+wmd+'" />';
	flash_tag +='<embed src="'+fnm+'" quality="high" bgcolor="'+bgc+'" FlashVars="'+fvs+'" wmode="'+wmd+'" width="'+wid+'" height="'+hei+'" name="'+fid+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flash_tag +='</object>';
	
	document.write(flash_tag);
}

// 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 '';
}

// 이미지 오버/아웃
function imageOver(imgs) {
	imgs.src = imgs.src.replace("off.gif", "on.gif");
}
function imageOut(imgs) {
	imgs.src = imgs.src.replace("on.gif", "off.gif");
}

// select full down
$(document).ready(function() {
	var stateA = 'show';
	var stateB = 'show';
	var stateC = 'show';
	var stateD = 'show';
	// line up
	$('#lineUpSelTitle').click(function() {
		if (stateA == 'show') {
			$('#lineUpSel').show();
			stateA = '';
		} else {
			$('#lineUpSel').hide();
			stateA = 'show';
		}
	});

	$('#lineUpSel > ul > li > a').click(function() {
		var seltxt = this.firstChild.nodeValue;
		document.getElementById('lineUpSelTitle').firstChild.nodeValue = seltxt;
		$('#lineUpSel').hide();
		stateA = 'show';
	});


	// Collection
	$('#collectionSelTitle').click(function() {
		if (stateB == 'show') {
			$('#collectionSel').show();
			stateB = '';
		} else {
			$('#collectionSel').hide();
			stateB = 'show';
		}
	});

	$('#collectionSel > ul > li > a').click(function() {
		var seltxt = this.firstChild.nodeValue;
		document.getElementById('collectionSelTitle').firstChild.nodeValue = seltxt;
		$('#collectionSel').hide();
		stateB = 'show';
	});

	// season
	$('#seasonSelTitle').click(function() {
		if (stateC == 'show') {
			$('#seasonSel').show();
			stateC = '';
		} else {
			$('#seasonSel').hide();
			stateC = 'show';
		}
	});

	$('#seasonSel > ul > li > a').click(function() {
		var seltxt = this.firstChild.nodeValue;
		document.getElementById('seasonSelTitle').firstChild.nodeValue = seltxt;
		$('#seasonSel').hide();
		stateC = 'show';
	});

	// season02
	$('#seasonSelTitle02').click(function() {
		if (stateC == 'show') {
			$('#seasonSel02').show();
			stateC = '';
		} else {
			$('#seasonSel02').hide();
			stateC = 'show';
		}
	});

	$('#seasonSel02 > ul > li > a').click(function() {
		var seltxt = this.firstChild.nodeValue;
		document.getElementById('seasonSelTitle02').firstChild.nodeValue = seltxt;
		$('#seasonSel02').hide();
		stateC = 'show';
	});

	// designer
	$('#designerSelTitle').click(function() {
		if (stateD == 'show') {
			$('#designerSel').show();
			stateD = '';
		} else {
			$('#designerSel').hide();
			stateD = 'show';
		}
	});

	$('#designerSel > ul > li > a').click(function() {
		var seltxt = this.firstChild.nodeValue;
		document.getElementById('designerSelTitle').firstChild.nodeValue = seltxt;
		$('#designerSel').hide();
		stateD = 'show';
	});
});


   
/*	General DOM-Traversal Utilities and Helper Functions
	----------------------------------------------- */
	function getElements(classname, tagname, root){
		if(!root) root = document;
		else if (typeof root == "string") root = document.getElementById(root);
		if(!tagname) tagname = "*";
		var all = root.getElementsByTagName(tagname);
		if(!classname) return all;
		var elements = [];
		for(var i = 0; i < all.length; i++){
			var element = all[i];
			if(isMember(element,classname))
				elements.push(element)
		}
		return elements;
	}
	function isMember(element, classname){
		var classes = element.className;
		if(!classes) return false;
		if(classes ==classname) return true;
		var whitespace = /\s+/;
		if (!whitespace.test(classes)) return false;
		var c = classes.split(whitespace);
		for(var i = 0; i < c.length; i++)
			if (c[i] == classname) return true;
		return false;
	}
	function isDescendant(ancestor, descendant){
		if(!ancestor || !descendant) return;
		var similarDescendants = ancestor.getElementsByTagName(descendant.nodeName);
		for(var i=0; i<similarDescendants.length; i++)
			if( similarDescendants[i] == descendant ) return true;
		return false;
	}
    function getAncestors(element){
        var parents = new Array( );
        while( element.parentNode ){
            if( element.parentNode.nodeType == 1 )
                parents.push(element.parentNode);
                element = element.parentNode;
        }
        return parents;
    }


// DropdownMenu 스타일 마우스 오버 레이어
function DropdownMenu(args){
	this.args = args;
	this.list = document.getElementById(args.listId);
	this.itemElements = this.getItems( );
	this.itemObjects = this.setupItems( );
}
DropdownMenu.prototype.getItems = function( ){
	var itemElements = new Array( );
	for(var i=0; i<this.list.childNodes.length; i++)
		if(this.list.childNodes[i].nodeName == 'LI')
			itemElements.push(this.list.childNodes[i]);
	return itemElements;
}
DropdownMenu.prototype.setupItems = function( ){
	var itemObjects, openFunc, closeFunc;
	openFunc = this.openFunc, closeFunc = this.closeFunc;
	itemObjects = new Array( );
	for(var i=0; i<this.itemElements.length; i++)
		itemObjects.push(
			new DropdownItem({
				itemElement: this.itemElements[i],
				hiddenMenuClass: this.args.hiddenMenuClass,
				openFunc: this.args.openFunc,
				closeFunc: this.args.closeFunc
			}) 
		);
	return itemObjects;
}

function DropdownItem(args){
	var instance = this;
	this.itemElement = args.itemElement;
	this.trigger = getElements(args.triggerClass,null,this.itemElement)[0];
	this.openFunc = args.openFunc;
	this.closeFunc = args.closeFunc;
	this.menu = getElements(args.hiddenMenuClass,null,this.itemElement)[0];
	if(this.menu){
		this.itemElement.onmouseover = function(event){instance.handleLIMouseOver(event);}
		this.itemElement.onmouseout = function(event){instance.handleLIMouseOut(event);}
	}
}
DropdownItem.prototype.handleLIMouseOver = function(event){
	var evt, prevElement, useId, tmpName;
	evt = event || window.event;
	prevElement = evt.relatedTarget || evt.fromElement;
	if(prevElement != this.itemElement && !isDescendant(this.itemElement,prevElement)) {
		tmpName = "" + this.itemElement.id;
		useId = tmpName.substring(4,5);
		this.activate( );
	}
}
DropdownItem.prototype.handleLIMouseOut = function(event){
	var evt, nextElement, useId, tmpName;
	evt = event || window.event; 
	nextElement = evt.relatedTarget || evt.toElement;
	if(nextElement != this.itemElement && !isDescendant(this.itemElement,nextElement)) {
		tmpName = "" + this.itemElement.id;
		useId = tmpName.substring(4,5);
		this.deactivate( );
	}
}
DropdownItem.prototype.activate = function(event){
	this.menu.className = this.menu.className.replace(/inactive/g,'');
	var ancestors = getAncestors(this.menu);
	for(var i=0; i<ancestors.length; i++)
		ancestors[i].style.zIndex = '5'
	if(this.openFunc) this.openFunc( );
}
DropdownItem.prototype.deactivate = function(event){
	var ancestors = getAncestors(this.menu);
	for(var i=0; i<ancestors.length; i++)
		ancestors[i].style.zIndex = ''
	this.menu.className += ' inactive';
	if(this.closeFunc) this.closeFunc( );
}

// bg 활성화
$(document).ready(function() {
	$('.popularVideo > ol > li, .casterList > ol > li, .elleFileList > li').mouseover(function() {
		$(this).addClass('overBg');
	});
	
	$('.popularVideo > ol > li, .casterList > ol > li, .elleFileList > li').mouseout(function() {
		$(this).removeClass('overBg');
	});
});

/* line up select(trend) //////// 수정 필요
function trendSelector(id) {
	var idObj = document.getElementById('trendType'+id);
	
	$('.trend > dd > .thumb').click(function() {
		for(i=1; i<8; i++) {
			if(i == id) {
				idObj.src = idObj.src.replace("off.gif", "on.gif");
			} else {
				document.getElementById('trendType'+i).src = document.getElementById('trendType'+i).src.replace("on.gif", "off.gif");
			}
		}
		$('.trend > dd > .thumb').removeClass('selectTrendBeauty');
		$(this).addClass('selectTrendBeauty');
	});
}
*/

// line up select(color)
$(document).ready(function() {
	$('.color > .defult > dd').click(function() {
		$('.color > .defult > dd').removeClass('selectColor');
		$(this).addClass('selectColor');
	});

	$('.color > .related > dd').click(function() {
		$('.color > .related > dd').removeClass('selectColor');
		$(this).addClass('selectColor');
	});
});


// 스페셜 배너
function endBannerMovie() {
	$('#sbannerWrap').hide();
}

// search layer
function searchScale(str) {
	if(str == "O") {
		document.getElementById('search').style.height = "211";
	} else {
		document.getElementById('search').style.height = "20";
	}
}

// hide, show
function showHide(obj, current) {
	if(current == 0) {
		$('#' + obj + '').hide();
	} else {
		$('#' + obj + '').show();
	}
}

// toggle 
function toggle(obj, count) {
	count = count + 1;

	for(i=1; i<count; i++) {
		$('#toggle' + i + '').hide();
	}
	$('#' + obj + '').show();
}

$(document).ready(function() {
	var num = $('.number > li > img').length + 1;
	$('.number > li > a > img, .abc > li > a > img, .hangul > li > a > img').mouseover(function() {
		this.src = this.src.replace("off.gif", "on.gif");
	});

	$('.number > li > a > img, .abc > li > a > img, .hangul > li > a > img').mouseout(function() {
		this.src = this.src.replace("on.gif", "off.gif");
	});
});

function openPopup(){
	window.open('http://old.elle.co.kr/footer/emailPopup.html','email','width=366,height=228');
}



function viewUserLayer(){
	document.getElementById("nameLayer").style.display ='';
}


function viewUserLayerHidden(){
	document.getElementById("nameLayer").style.display ='none';
}

/*
상대발큐브방문
*/
function goTargetCube(targetid){
	//targetid = "QID20090907000000084";
	//window.open("targetcubemain.iht?targetid="+ targetid, "targetCube", "width=600, height=600, menubar=no, toolbar=no, location=no, resizeable=no, status=no, scrollbars=auto");
	window.open("targetcubemain.iht?cubeUserId="+ targetid, "targetCube");
}

/*
	쪽지보내기
*/
	var msgUId="";	
	function sendMessage(userId){
		msgUId = userId;
		//alert(msgUId);
		Ajax.connect({
			url: 'elleweb_root_popup_papersend_check.iht',
			data: 'userId='+userId,
			type: 'post',
			success: sendMessageProc
		});	
	}

	function sendMessageProc(request){
		var XmlDocument = request.responseXML;
		//alert(XmlDocument);
		var result="";
		if(XmlDocument != null){
		var oNode = XmlDocument.getElementsByTagName('data');
			result = oNode[0].getElementsByTagName("value")[0].firstChild.nodeValue; 
		} 
		if(result=="0"){
			var oWindow = Common.popup({
				url: 'elleweb_root_popup_papersend.iht?userId='+msgUId,
				width: 372,
				height: 330,
				name: 'send_message'
			});
		}else {
			alert("로그인을 하신 후 이용 하세요");	
		}	
	}

/*
	팬신청하기
*/
//팬신청
	function sendPanRequireChk(userId){
		userData= userId;
		Ajax.connect({
			url: 'elleweb_root_popup_fanapply_chk.iht',
			data: 'userId='+userId,
			type: 'post',
			success: sendPanRequireChkResult
		});
	}

	var userData="";
	function sendPanRequireChkResult(request){
		var XmlDocument = request.responseXML;
		var result="";
		if(XmlDocument != null){
			var oNode = XmlDocument.getElementsByTagName('data');
			result = oNode[0].getElementsByTagName("value")[0].firstChild.nodeValue; 
		} 

		if(result=="0"){
			sendPanRequire(userData);
		}else if(result=="1"){
			alert("이미 팬 신청 상태 입니다.");
		}else if(result=="2"){
			alert("이미 팬 상태 입니다.");	
		}else if(result=="3"){
			alert("사용자의 사정으로 신청을 받지 않습니다.");	           
		}else if(result=="4"){
			alert("데이터 등록 오류.");	           
		}else if(result=="5"){
			alert("로그인을 하신 후 이용하세요.");	
		}
	}	

	//팬신청	
	function sendPanRequire(userId){
		//var url = "elleweb_root_popup_sendpaper.iht?userId="+userId;
		//window.open(url, "쪽지 보내기", "resizable=no, help=no, Height=500px, Width=370px");
		userData="";
		var oWindow = Common.popup({
			url: 'elleweb_root_popup_fanapply.iht?userId='+userId,
			width: 372,
			height: 321,
			name: 'apply_Pan'
		});
	}

	function LoginCheck(){
		if(!confirm('로그인이 필요합니다.\n로그인 페이지로 이동하시겠습니까?')) {
			return;
		}
		location.href='https://login.elle.co.kr/login/login.html?rurl='+ encodeURIComponent(document.location);
	}


function acecount(){
	//alert("호출");
if(typeof _GUL == 'undefined'){
var _GUL = 'elle.loginside.co.kr';var _GPT='8888'; var _AIMG = new Image(); var _bn=navigator.appName; var _PR = location.protocol=="https:"?"https://"+_GUL+":8443":"http://"+_GUL+":"+_GPT;if( _bn.indexOf("Netscape") > -1 || _bn=="Mozilla"){ setTimeout("_AIMG.src = _PR+'/?cookie';",1); } else{ _AIMG.src = _PR+'/?cookie'; };
document.writeln("<scr"+"ipt language='javascript' src='/elle/svc/ellewb/common/js/acecounter/acecounter_V70.js'></scr"+"ipt>");
}
}
