//******************************************************************************************************
// Eexplanation : Flash goto menu
//******************************************************************************************************


//******************************************************************************************************
// Eexplanation : Flash logger Event
//******************************************************************************************************
function loggerLocation(title, url) {
	location.href = url;
}


//******************************************************************************************************
// Eexplanation : 우편번호 새창 띄우기
//******************************************************************************************************

//function findZipcode(form, str) {
function findZipcode() {
	//formName = form.name;
	//newURL = "/member/ZipcodeSearch.aspx?sort=" + str + "&formName=" + formName;
	newURL = "../Join/ZipcodeSearch.aspx";
	//searchWindow=window.open(newURL, 'zipcodeSearch', 'width=468,height=245,left=200,top=100, toolbar=no,scrollbars=yes,resizable=no');
	searchWindow = window.open(newURL, 'zipcodeSearch', 'width=420,height=345,left=200,top=100, toolbar=no,scrollbars=no,resizable=no');
}


//function findZipcode(form, str) {
function findZipcode2(type) {
	//formName = form.name;
	//newURL = "/member/ZipcodeSearch.aspx?sort=" + str + "&formName=" + formName;
	newURL = "/Join/ZipcodeSearch.aspx?Type=" + type;
	//searchWindow=window.open(newURL, 'zipcodeSearch', 'width=468,height=245,left=200,top=100, toolbar=no,scrollbars=yes,resizable=no');
	searchWindow = window.open(newURL, 'zipcodeSearch', 'width=420,height=345,left=200,top=100, toolbar=no,scrollbars=no,resizable=no');
}

//******************************************************************************************************
// Eexplanation : 메세지를 표시하고 계속 진행한다.
// Input Value  : msg(표시할 메세지)
//******************************************************************************************************

function message(msg) {
	alert(msg);
}


//******************************************************************************************************
// Eexplanation : 에러메세지 표시후 이전 페이지로 돌린다.
// Input Value  : msg(표시할 메세지)
//******************************************************************************************************

function errmsg(msg) {
	if(msg == "") {
		msg = "정상적인 접근 바랍니다!!";
	}
	alert(msg);
	history.go(-1);
}


//******************************************************************************************************
// Eexplanation : 에러메세지 표시후 이전 페이지로 돌린다.
// Input Value  :$msg(표시할 메세지)
//******************************************************************************************************

function msgClose(msg) {
	alert(msg);
	window.close();
}


//******************************************************************************************************
// Eexplanation : 에러메세지 표시후 지정 페이지로 돌린다.
// Input Value  : msg(표시할 메세지), url(이동할 주소)
//******************************************************************************************************

function msgMove(msg, url) {
	alert(msg);
	location.href = url;
}


//******************************************************************************************************
// Eexplanation : 에러메세지 표시후 지정 페이지로 돌린다.
// Input Value  : url(이동할 주소)
//******************************************************************************************************

function openerCM(url) {
	window.close();
	opener.location.href = url;
}


//******************************************************************************************************
// Eexplanation : 에러메세지 표시후 지정 페이지로 돌린다.
// Input Value  : url(이동할 주소)
// Sample		: openWindow('파일명','타겟','scrollbars=yes,width=900,height=660,left=0,top=0')
//******************************************************************************************************

function openWindow(url,target,option) {
	window.open(url,target,option);
}


//******************************************************************************************************
// Eexplanation : 모달창으로 새창을 띄운다.
// Input Value  : url(이동할 주소)
// Sample		: openWindow("파일명", "타겟", "dialogWidth:400px; dialogHeight:250px;status:no; help:no; scroll:no")
//******************************************************************************************************

function infoWindow(URL){
	window.showModalDialog(URL, "", "dialogWidth:400px; dialogHeight:250px;status:no; help:no; scroll:no");
}


//******************************************************************************************************
// Eexplanation : 창을 닫는다
//******************************************************************************************************

function closeWindow() {
	window.close();
}


//******************************************************************************************************
// Eexplanation : 셀렉트 버튼을 선택하면 이동한다.
// Input Value  : form(폼이름), fn(필드명), url(기본주소)
// Sample		: <select name=field_name onchange="Quick_Link(this.form, 'field_name', '/sample/sample.php?sample_id=');">
//******************************************************************************************************

function Jump_Category(form, fn, url) {
	var select = form.fn.selectedIndex;

	if(form.fn.options[select].value != "") {
		location=url + form.fn.options[select].value;
	}
}


//******************************************************************************************************
// Eexplanation : 다시 한번 묻는다.
// Input Value  : msg, url, val
//******************************************************************************************************

function msgConfirm(msg, url, val) {
	var val;
	ans = confirm(msg)
	if ( ans== true){
		str = url + val
		location.href = str;
	}
}



//******************************************************************************************************
// Eexplanation : 페이지 로딩시 포커스가 필요할때
// Input Value  : form(this.form), fieldName
//******************************************************************************************************

function selectFocus(form, fieldName) {
	form.recom_id.focus();
	return;
}


//******************************************************************************************************
//******************************************************************************************************
//******************************************************************************************************
//****************************   여기서부터는 일반적인 함수 외에 새로 추가되는 것들 **************************
//******************************************************************************************************
//******************************************************************************************************
//******************************************************************************************************




//******************************************************************************************************
// Eexplanation : 클래스 문서 작성시 쓰기창을 띄운다.
// Input Value  : class_id, item_id, type(insert, modify)
//******************************************************************************************************

function docClassOpen(class_id, item_id, type) {
	if(item_id == 0) {
		mode = "insert";
	} else {
		mode = "modify";
	}
	url = "write.php?class_id=" + class_id + "&item_id=" + item_id + "&type=" + type + "&mode=" + mode;
	window.open(url, 'write', 'scrollbars=no,width=400,height=650,left=600,top=0');
}


//******************************************************************************************************
// Eexplanation : 입력값이 빈값인지 판별한다.
// Input Value  : str(form.name.value값)
//******************************************************************************************************

function isEmpty(str) {

	for ( var i = 0 ; i < str.length ; i++ ) {
		if ( str.substring(i, i+1) != " " ) {
			return false;
		}
	}

	return true;

}


//******************************************************************************************************
// Eexplanation : 입력값의 최소, 최대치 안의 글자수인지 판별한다.
// Input Value  : str(form.name.value값), minlen, maxlen
//******************************************************************************************************

function checkLength(str, minlen, maxlen) {

	if (str.length < minlen || str.length > maxlen) {
		return false;
	}

	return true;

}


//******************************************************************************************************
// Eexplanation : 한글인지 판별한다.
// Input Value  : str(form.name.value값)
//******************************************************************************************************

function isHangul(str) {

	var re = /[a-zA-Z0-9\s~!@#\$%\^&\*\(\)_\+\{\}|:"<>\?`\-=\[\]\\;',\.\/]/; // matches a alphanumeric character or space

	if (re.test(str)) {
		return false;
	}

	return true;

}


//******************************************************************************************************
// Eexplanation : 숫자인지 판별한다.
// Input Value  : str(form.name.value값)
//******************************************************************************************************

function isNumber(str, allowable) {

	valid = true;
	cmp = "0123456789" + allowable;

	for (i=0; i<str.length; i++) {
		if (cmp.indexOf(str.charAt(i)) < 0) {
			valid = false;
			break;
		}
	}

	return valid;

}


//******************************************************************************************************
// Eexplanation : 이름인지 판별한다.
// Input Value  : str(form.name.value값)
//******************************************************************************************************

function checkName(str) {

	if (!checkLength(str, 2, 80, false) || !isHangul(str)) {
		return false;
	}

	return true;

}



//******************************************************************************************************
// Eexplanation : 전자우편주소를 판별한다.
// Input Value  : str(form.name.value값)
//******************************************************************************************************

function checkEmail(str) {

	valid = false;

	if (str == "")
		alert("Email주소를 입력하여 주십시오!!");
	else if (str.indexOf(" ") != -1)
		alert("Email주소에 공백은 허용되지 않습니다!!");
	else if (str.indexOf("@") < 1)
		alert("Email주소 지정이 잘못되었습니다. '@'이 누락되었습니다!!");
	else if (str.indexOf(".") == -1)
		alert("Email주소 지정이 잘못되었습니다. '.'이 누락되었습니다!!");
	else if (str.indexOf(".") - str.indexOf("@") == 1)
		alert("Email주소 지정이 잘못되었습니다. '@' 다음에 바로 '.'이 올 수 없습니다!!");
	else if (str.charAt(str.length-1) == '.')
		alert("Email주소 지정이 잘못되었습니다. '.'은 Email주소 끝에 올 수 없습니다!!");
	else
		valid = true;

	return valid;

}


//******************************************************************************************************
// Eexplanation : 투표하기전에 체크를 진행한다.
//******************************************************************************************************

function pollCheck(form){

	var pollChecked = '';

	if(form.pollUsed.value == "Y") {

		alert("이미 투표를 하셨습니다!!");
		return false;

	} else {

		for(var i =0 ; i < form.poll.length; i ++){
			if(form.poll[i].checked == true){
				pollChecked = 'OK';
			}
		}

		if(pollChecked != 'OK') {
			alert ('투표 항목이 선택되어지지 않았습니다.');
			return false;
		}

	}

}


//******************************************************************************************************
// Eexplanation : 돈 표시시 3자리마다 콤마 삽입
//******************************************************************************************************

function commaSplit(str) {

	if(str.value.charAt(0) == 0 && str.value != "0") {
		str.value = "";
	}

	txtNumber = str.value;
	txtNumber = txtNumber.replace(/,/gi, "");

	if(txtNumber >= 1000000000000) {
		alert("단위는 원이며 1조이하의 금액으로 제한합니다!!");
	}

	if (isNaN(txtNumber)) {
		alert('숫자만 입력 가능합니다.');
		str.value = '';
		str.focus();
	} else {

		var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
		var arrNumber = txtNumber.split('.');

		arrNumber[0] += '.';
		do {
			arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
		} while (rxSplit.test(arrNumber[0]));

		if (arrNumber.length > 1) {
			str.value = arrNumber.join('');
		} else {
			str.value = arrNumber[0].split('.')[0];
		}

	}

}


//******************************************************************************************************
// Eexplanation : id값을 숨기거나 보여준다.
//******************************************************************************************************
function showmenu(str) {
	str.style.display = "";
}

function hidemenu(str) {
	str.style.display = "none";
}

//******************************************************************************************************
// Eexplanation : RollOver 버튼
//******************************************************************************************************
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.0
  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 && document.getElementById) x=document.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];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

/*
// ========================= 링크 점선 없앰 ============================
// 둘중 하나 사용..
function bluring(){
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG")
		document.body.focus();
}
//document.onfocusin=bluring;

function allblur() {
	for (i = 0; i < document.links.length; i++)
		document.links[i].onfocus = document.links[i].blur;
}

document.onfocusin = allblur;

// ========================= 링크 점선 없앰 ============================
*/
function IEHOUSE_LOGIN_POPUP(){
    //var popupURL = "/member/login_Pop.aspx";
	//var popup =   window.open(popupURL,"pdmaker",'toolbar=0,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=420,height=330,top=0,left=0');
    location.href = "/Theme/Vip_Lounge_Detail.aspx";
}

// ========================= IE패치작업_Flash  ============================
function ie_view(objhtml) {
	document.write(objhtml);
}

function IE_FlashView(url,width,height,flashvars,wmode){
	var FlashView=
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+width+"' height='"+height+"' align='middle'>"+
	"<param name='movie' value='"+url+"' />"+
	"<param name='menu' value='false' />"+
	"<param name='FlashVars' value='"+flashvars+"' />"+
	"<param name='wmode' value='transparent' />"+
	"<param name='quality' value='high' />"+
	"<embed src='"+url+"' menu='false' quality='high' width='"+width+"' height='"+height+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object>";

	document.write(FlashView);
}
// ========================= IE패치작업_Flash  ============================


	function setSWF(id, swf, w, h, o) {
		var opt = jQuery.extend({ allow:'sameDomain', wmode:'opaque', vars:false, style:false }, o);
		var params  = '<param name="allowScriptAccess" value="' + opt.allow + '" />'; // never|sameDomain|always
			params += '<param name="movie" value="' + swf + '" />';
			params += '<param name="quality" value="high" />';
			params += '<param name="allowFullScreen" value="false" />';
			params += '<param name="wmode" value="' + opt.wmode + '" />'; // window|opaque|transparent
		if (opt.vars)
			params += '<param name="FlashVars" value="' + opt.vars + '" />';
		var output  = '<object id="' + id + '" ';
		if (opt.style)
			output += 'style="' + opt.style + '" ';
			output += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + w + '" height="' + h + '">';
			output += params;
			output += '<!--[if !IE]> <-->';
			output +='<object id="' + id + '" ';
		if (opt.style)
			output += 'style="' + opt.style + '" ';
			output += 'type="application/x-shockwave-flash" data="' + swf + '" width="' + w + '" height="' + h + '">';
			output += params;
			output += '<\/object>';
			output += '<!--> <![endif]-->';
			output += '<\/object>';
		document.write(output);
	}


//왼쪽 브랜드 서치
function follow_banner(div_id, origin_top, limit_top, margin_top) {
	var d, t, s, g, target_height;
	origin_top *= 1;
	limit_top *= 1;
	margin_top *= 1;

	d = document.getElementById(div_id);
	s = document.documentElement.scrollTop + "";

	target_height = s.toInteger() + margin_top;

	if (target_height < limit_top) {
		target_height = origin_top;
	}
	t = d.style.top.toInteger();
 
	if (t != target_height) {
		g = Math.ceil((t - target_height) / 5);
		if (g > 50) {
			g = 50;
		} else if (g < -50) {
			g = -50;
		}
		d.style.top = (t - g) + "px";
	}

	setTimeout("follow_banner('" + div_id + "', " + origin_top + ", " + limit_top + ", " + margin_top + ");", 30);
}


		
//Wish List에 담기		
// 구매 또는 장바구니 담기
function WishList(PrstCd , ColorCd , PrdSize , OptCD) {


	if (PrstCd == "" || ColorCd == "") {
		alert("상품 정보가 부족합니다")
		return;
	}


	var uri = "/Shop/WishInsert.aspx?PrstCd=" + PrstCd + "&ColorCd=" + ColorCd + "&PrdSize=" + PrdSize + "&OptCd=" + OptCD;
	var p = window.open(uri,'winpopup','toolbar=no,status=no,mnubar=no,scrollbars=no,resizable=no,width=450,height=270,top=250,left=320');

    try
    {
        p.focus();
    }
    catch(e)
    {}

}  



// 큰 이미지 보기
function showLargeImage(prstCd, method, imgNm) {
	var popupURL = "DetailViewLargeImage.aspx?prstCd=" + prstCd + "&method=" + method + "&imgNm=" + imgNm;
	var popup = window.open(popupURL, 'PrdZoom', 'width=815, height=690, top=0, left=0, status=yes, resizable=yes, scrollbars=yes');
	
    try
    {
	    popup.focus();
    }
    catch(e)
    {}
    	

}

//검색 부분을 처리해준다....

var SubFlag = false;
function frmSearchSubmit()
{
	if(SubFlag)
	{
		alert("검색중입니다. 잠시만 기다려주세요. ");
		return false;
	}
	if(document.frmSearch.Question.value == "")
	{
		document.frmSearch.Question.value = document.frmSearch.QuestionTemp.value;
	}
	if(document.frmSearch.Question.value.length < 2 ||  document.frmSearch.Question.value.length > 20)
	{
		alert("검색어는 2자이상 20자이하로 입력하세요.");
		document.frmSearch.QuestionTemp.focus();
		document.frmSearch.Question.value = "";
		return false;
	}

	//document.frmSearch.QuestionTemp.value = " 검색중입니다";
	document.frmSearch.action = "/Shopping/Search.asp";
	SubFlag = true;
	return true;
}




// 큰 이미지 보기
function CpDn_Prd(prstCd, colorCd, Seq) {
	var popupURL = "/Shop/CpDn/CpDn_Prd.aspx?prstCd=" + prstCd + "&colorcd=" + colorCd + "&Seq=" + Seq;
	var popup = window.open(popupURL, 'CpDn_Prd', 'width=150, height=150, top=0, left=0, status=yes, resizable=yes, scrollbars=No');
	
    try
    {
	    popup.focus();
    }
    catch(e)
    {}
    	

}