var xmlHttp;
var xmlHttp02;
var xmlHttp03;
function makeXMLHttpRequest(){
    if (window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    }
}
    
function createXMLHttpRequest() {
        xmlHttp = makeXMLHttpRequest();
}
    
function createXMLHttpRequest02() {
        xmlHttp02 = makeXMLHttpRequest();
}
    
function createXMLHttpRequest03() {
        xmlHttp03 = makeXMLHttpRequest();
}

function FlashInsert(FlashIDName, FlashFileName, FlashWidth, FlashHeight, WMODESetting, FlashVars, FlashBGColor)
{
	if(FlashVars == undefined)
		FlashVars = ""

	if(FlashBGColor == undefined){
		FlashBGColor = ""
	}
	flashCode = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
				'CODEBASE="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,22,0" ' + 
				' ID="'+FlashIDName+'" WIDTH="' + FlashWidth + '" HEIGHT="' + FlashHeight + '" ALIGN="middle">' + 
				'<PARAM NAME="movie" VALUE="'+ FlashFileName +'">' + 
				'<PARAM NAME="quality" VALUE="high">' + 
				'<PARAM NAME="bgcolor" VALUE="'+FlashBGColor+'">' +
				'<PARAM NAME="menu" VALUE="false">' + 
				'<param name="allowScriptAccess" value="always" />' + 
				'<param name="scale" value="Noborder" />' +
				'<PARAM NAME="FlashVars" VALUE="' + FlashVars + '">' + 
				'<PARAM NAME="wmode" VALUE="' + WMODESetting + '">' + 
				'<EMBED SRC="'+ FlashFileName + '" allowScriptAccess="always" FlashVars="' + FlashVars + '" NAME="'+FlashIDName+'"' + 
				' WIDTH="' + FlashWidth + '" HEIGHT="' + FlashHeight + '" wmode="'+WMODESetting+'" QUALITY="high"' + 
				' ALIGN="middle" WMODE="'+WMODESetting+'" TYPE="application/x-shockwave-flash" ' + 
				' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" >' + 
				'</EMBED>' + 
				'</OBJECT>';

	document.write(flashCode);
}

function MovieInsert(movieName, width, height, showaudiocontrols)
{
	document.write('<embed src="'+movieName+'" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"');
	document.write('volume="-6800" ');
	document.write('autostart="1" ');
	document.write('ShowControls="true" ');
	document.write( 'showaudiocontrols="'+showaudiocontrols+'" enablecontextmenu="false"'); // º¼·ý ÄÁÆ®·Ñ·¯ Á¦°Å, ¿À¸¥ÂÊ ¸¶¿ì½º ±ÝÁö
	document.write('loop="false" ');
	document.write('width="'+width+'" ');
	document.write('height="'+height+'" ');
	document.write('TransparentAtStart="true" ');
	document.write('type="application/x-mplayer2" >');
	document.write('</embed>');
}
function winOpen(url, name, width, height, scroll) 
{
	var urlname = url;
	window.open(urlname, name,"height="+height+",width="+width+", left=100, top=100,menubar=no,directories=no,resizable=no,status=no,scrollbars="+scroll);
}


function iskorea_isNumber ()
{
	if ((event.keyCode<48)||(event.keyCode>57)){
		alert("¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù ´Ù½Ã ÀÔ·ÂÇÏ¼¼¿ä!");
		event.returnValue=false;
	}
}

function IsNumber(val)
{
	for(var i = 0; i < val.length; i++)
	{
		var chr = val.substr(i,1);
		if(chr < '0' || chr > '9')
		{            
			return false;
		}
	}
	return true;   
}

function IsZero(val)
{
	if (val=="")
	{
		return 0
	}
	val = val.toString()
	if(val != "0")
	if(val.substring(0,1)=="0")
	{
		val = val.substring(1,val.length)
	}
	return val; 
}


//ÀÌ¸ÞÀÏÃ¼Å©
function IsEmail(val) {
	//»ç¿ë¹ý inputCheck(ÆûÀÌ¸§, ¿¤¸®¸ÕÆ®ÀÌ¸§, Ç×¸ñ)
	var inputStr = val;
	emailchk = 0
	for (var j=0; j < inputStr.length ; j++ ) {
		var ch= inputStr.substring(j,j+1);
		if (ch == "@" | ch== "." ) {
			emailchk = emailchk + 1;
		}
	}
	if (emailchk < 2 ) {
		return false;
	}
	return true;
}

function checkFileExt(imgArray, file) {
	if (!file) 
		return false;
	while(file.indexOf("\\")!=-1){
		file = file.slice(file.indexOf("\\") + 1);

		ext = file.slice(file.lastIndexOf(".")).toLowerCase();
		for (var i = 0; i < (imgArray).length; i++) {
			if (imgArray[i] == ext){
				return true;
				break;
			}
		}
	}
	return false;
}


//Æ¯¼ö¹®ÀÚ Çã¿ëÇÏÁö ¾ÊÀ½
function IsKorEngName(val){
	var special = '`~!@#$%^&*()-_=+|\{}[];:"\'<>,.?\/'; 
	var i ; 
	var t = val; 

	for ( i=0; i<t.length; i++ ){
		if( special.indexOf(t.substring(i,i+1))>=0) {
			break ; 
		}
	}
	if ( i != t.length ) {
		return false;
	}
	return true; 
}

//Æ¯¼ö¹®ÀÚ Çã¿ëÇÏÁö ¾ÊÀ½
function IsKorEngName2(val){
	var special = '`~!@#$%^&*()-_=+|\{}[];:"\'<>,.?\/ '; 
	var i ; 
	var t = val; 

	for ( i=0; i<t.length; i++ ){
		if( special.indexOf(t.substring(i,i+1))>=0) {
			break ; 
		}
	}
	if ( i != t.length ) {
		return false;
	}
	return true; 
}


function onlyEng(objtext1) {
	var inText = objtext1.value;
	var ret;	
	for (var i = 0; i < inText.length; i++) {
		ret = inText.charCodeAt(i);
		if ((ret > 122) || (ret < 48) || (ret > 57 && ret < 65) || (ret > 90 && ret < 97)) {
			alert("¿µ¹®ÀÚ¿Í ¼ýÀÚ¸¸À» ÀÔ·ÂÇÏ¼¼¿ä");
			objtext1.value = "";
			objtext1.focus();
			return false;
		}
	}
	return true;
}


///ÁÖ¹Î ¹øÈ£ À¯È¿ Ã¼Å©
function jCheck(j){
	var resno = j;

	// 710000-1000000 => 7100001000000
	if(resno.substr(6,1)=='-'){
		resno=resno.replace('-','');
	}

	// ÁÖ¹Î¹øÈ£ÀÇ ÇüÅÂ¿Í 7¹øÂ° ÀÚ¸®(¼ºº°) À¯È¿¼º °Ë»ç
	fmt = /^\d{6}[1234]\d{6}$/;
	if (!fmt.test(resno)) {
		return false;
	}

	// ³¯Â¥ À¯È¿¼º °Ë»ç
	birthYear = (resno.charAt(6) <= "2") ? "19" : "20";
	birthYear += resno.substr(0, 2);
	birthMonth = resno.substr(2, 2) - 1;
	birthDate = resno.substr(4, 2);
	birth = new Date(birthYear, birthMonth, birthDate);

	if ( birth.getYear() % 100 != resno.substr(0, 2) ||
		birth.getMonth() != birthMonth ||
		birth.getDate() != birthDate) {
	}

	// Check Sum ÄÚµåÀÇ À¯È¿¼º °Ë»ç
	buf = new Array(13);
	for (i = 0; i < 6; i++) buf[i] = parseInt(resno.charAt(i));
	for (i = 6; i < 13; i++) buf[i] = parseInt(resno.charAt(i));

	multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
	for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);

	if ((11 - (sum % 11)) % 10 != buf[12]) {
		return false;
	}

	jumin2_val = resno.substr(6)
	if(jumin2_val == '0000000' || jumin2_val == '1111111' || jumin2_val == '2222222' ||
	jumin2_val == '3333333' || jumin2_val == '4444444' || jumin2_val == '5555555' ||
	jumin2_val == '6666666' || jumin2_val == '7777777' || jumin2_val == '8888888' || 	
	jumin2_val == '9999999') {
		return false;
	}

	return true;
}

//ÀüÈ­¹øÈ£ Ã¼Å©
function is_phone(val) {
	var regPhone =/^[0]{1}[0-9]{1,2}-[1-9]{1}[0-9]{2,3}-[0-9]{4}$/;

	if(!regPhone.test(val)){
		return false;
	}
	return true;
}

// »ç¾÷ÀÚ ¹øÈ£ Ã¼Å© => ÇÏÀÌÇÂÀÌ ¾ø´Â ¼ýÀÚ¸¸ 
function orgNoCheck(j) {
	var str = replaceStr(j, "-","");
    var mul_by = new Array(1,3,7,1,3,7,1,3,5);
    var arr_org_no = new Array(10);
    var sum = 0;

	if(str.length > 10)
		return false;

    for (i=0; i<10; i++){
       arr_org_no[i] = str.charAt(i);
    }
    for (i=0; i<9; i++){
       sum += arr_org_no[i] * mul_by[i];
    }
    sum += arr_org_no[8] * 5 / 10 ;
    sum = Math.floor(sum);
    var chk_flag = sum % 10 ;
    chk_flag = (chk_flag == 0) ? 0 : (10 - chk_flag) ;
    
	if ( arr_org_no[9] == chk_flag){
		if(str=="1231212345"){
			return false;
		}
		return true;
	}else{ 
		return false;
    }
}

// ºóÄ­ »èÁ¦ ·çÆ¾
function replaceStr(strOriginal, strFind, strChange){
	var lszTrim = strOriginal;
	var j = 0;
	for(var i = 0; i < strOriginal.length; i++){
		if(strOriginal.substring(i, i+1) == strFind){
			if(i > 0)
				lszTrim = strOriginal.substring(0, i);
			else
				lszTrim = strChange;

			lszTrim = lszTrim + strOriginal.substring(i+1);

			strOriginal = lszTrim;
		}
	}
	return lszTrim;
}


function checkBox(form_name, elm, msg)
{
	var checked = false;
	var form = eval("document."+ form_name +".elements['"+elm+"']");
	if(form)
	{
		if(form.length)
		{
			for(i=0; i < form.length;i++)
			{
				if(form[i].checked)
				{
					checked=true;
					break;
				}
			}
		}
		else
		{
			if(form.checked)
			{
				checked=true;
			}
		}
	}
	else
		return false;

	if(!checked)
	{
		alert(msg)
		return false;
	}
	else
		return true;
}

function checkSelect(form_name, elm, msg)
{
	var checked = false;
	var check_cnt = 0;
	var form = eval("document."+ form_name +".elements['"+elm+"']");
	if(form)
	{
		if(form.length)
		{
			for(i=0; i < form.length;i++)
			{
				if(form[i].selected)
				{
					checked=true;
					check_cnt+=1;
				}
			}
		}
		else
		{
			if(form.selected)
			{
				checked=true;
				check_cnt+=1;
			}
		}
	}
	else
		return check_cnt;

	if(!checked)
	{
		alert(msg)
		return check_cnt;
	}
	else
		return check_cnt;
}

function checkAll(form_name, elm)
{
	var checked = false;
	var form = eval("document."+ form_name +"."+ elm);
	if(form)
	{
		if(form.length)
		{
			for(i=0; i < form.length;i++)
			{
				form[i].checked=true;
			}
		}
		else
		{
			form.checked=true;
		}
	}
}

function checkedAll(form_name, elm, obj)
{
	var form = eval("document."+ form_name +".elements['"+elm+"']");
	var check =(obj.checked)?true:false;
	if(form)
	{
		if(form.length)
		{
			for(i=0; i < form.length;i++)
			{
				form[i].checked=check
			}
		}
		else
		{
			form.checked=check
		}
	}
}


function onlyEng(objtext1) {
	var inText = objtext1.value;
	var ret;	
	for (var i = 0; i < inText.length; i++) {
		ret = inText.charCodeAt(i);
		if ((ret > 122) || (ret < 48) || (ret > 57 && ret < 65) || (ret > 90 && ret < 97)) {
			alert("¿µ¹®ÀÚ¿Í ¼ýÀÚ¸¸À» ÀÔ·ÂÇÏ¼¼¿ä");
			objtext1.value = "";
			objtext1.focus();
			return false;
		}
	}
	return true;
}


function checkStrLength(lvStr, len){
    var resultSize = 0;
	var krSize = 0;
	var byteSize = 0;
    if (lvStr == null) return 0;
    for(var i=0; i<lvStr.length; i++){
        var c = escape(lvStr.charAt(i));
        if(c.length == 1) byteSize ++;
        else if(c.indexOf("%u") != -1) krSize ++;
        else if(c.indexOf("%") != -1) byteSize += c.length/3;
    }
	resultSize = Math.round(krSize + (byteSize / 2));
	if(resultSize > len)
		return false;
	else
		return true;
}


function setAttach(obj1, obj2, idx){
	if(isArray(obj1)){
		obj1[idx].click();
		obj2[idx].value = obj1[idx].value;
		return;
	}
	else{
		obj1.click();
		obj2.value = obj1.value;
		return;
	}
}


function delFile(form1, form2, path, file){
	if(form1)
		form1.value = "";
	if(form2)
		form2.value = "";
	if(file != ""){
		ajaxDelFile(path, file);
	}
}

function ajaxDelFile(path, file) {
    var url = "../../common/deleteFile.asp?path=" 
        + path + "&file=" + file + "&ts=" + new Date().getTime();
    createXMLHttpRequest();
//    xmlHttp.onreadystatechange = handle;
    xmlHttp.open("GET", url, true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=euc-kr');
    xmlHttp.send(null);
}

function ajaxDelFile02(path, file) {

    var url = "../common/deleteFile.asp?path=" 
        + path + "&file=" + file + "&ts=" + new Date().getTime();
    createXMLHttpRequest();
//    xmlHttp.onreadystatechange = handle;
    xmlHttp.open("GET", url, true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=euc-kr');
    xmlHttp.send(null);
}

function isArray(obj){
	return(typeof(obj.length)=="undefined")?false:true;
}

function popupView(obj){
	photoObj = document.all.photoViewArea;
//	if(photoObj.style.display == "")
//		closePopupView();


	html = '<div id="photoView" style="position:absolute;">' +
	'<table border="0" cellpadding="0" cellspacing="0">' +
	'	<tr>' +
	'		<td class="photoView01"><img src="../images/photoView01.png" style="filter:alpha(opacity=0);" width="21" height="18" border="0"></td>' +
	'		<td class="photoView05"></td>' +
	'		<td class="photoView02"><img src="../images/photoView02.png" style="filter:alpha(opacity=0);" width="23" height="18" border="0"></td>' +
	'	</tr>' +
	'	<tr>' +
	'		<td class="photoView06"></td>' +
	'		<td style="padding:5px" bgcolor="FFFFFF"><img src="'+obj.src+'" onLoad="resetPhotoView(this)" onClick="closePopupView()" style="cursor: pointer;" border="0"></td>' +
	'		<td class="photoView07"></td>' +
	'	</tr>' +
	'	<tr>' +
	'		<td class="photoView03"><img src="../images/photoView03.png" style="filter:alpha(opacity=0);" width="21" height="24" border="0"></td>' +
	'		<td class="photoView08"></td>' +
	'		<td class="photoView04"><img src="../images/photoView04.png" style="filter:alpha(opacity=0);" width="23" height="24" border="0"></td>' +
	'	</tr>' +
	'</table>' +
	'</div>';

	photoObj.innerHTML = html
	photoObj.style.display = "";
}

function resetPhotoView(obj){
//	document.all.photoView05.style.width = obj.width + 20
//	document.all.photoView08.style.width = obj.width + 20
//	document.all.photoView06.style.height = obj.height + 20
//	document.all.photoView07.style.height = obj.height + 20

	var openWindowWidth  = obj.width + 40;
	var openWindowHeight = obj.height + 40;
	var xpos = ( screen.availWidth  -  openWindowWidth  ) / 2;
	var ypos = ( (screen.height/2) - (openWindowHeight / 2) + document.documentElement.scrollTop);
	document.all.photoView.style.left = xpos;
	document.all.photoView.style.top = ypos;

}
function closePopupView(){
	obj = document.all.photoViewArea;
	if(obj)
		obj.style.display = "none";

}

function getCheckFormValue(obj){
	var returnVal = "";
	if(isArray(obj)){
		for(i=0; i < obj.length; i++){
			if(obj[i].checked){
				returnVal = obj[i].value;
			}
		}
	}
	else{
		if(obj.checked){
			returnVal = obj.value;
		}
	}
	return returnVal;
}

function goURL(link){
	location.href = link;
}

function openProgress() {
	var timeoutNextCheck = 8000;
	var topY = parseInt((document.body.clientHeight/2)) + document.body.scrollTop + 50;
	if(topY < 0)
		topY = 0;

	if(document.getElementById('progressBar')){
		progressDiv = document.getElementById('progressBar');
	}
	else{
		progressDiv = document.createElement('div');
		progressDiv.setAttribute('id','progressBar');
		document.body.appendChild(progressDiv);
		progressDiv.style.position = 'absolute';
	}
	progressDiv.style.top = topY;
	progressDiv.style.left = 120+ (document.body.clientWidth/2 - 260/2);

	var content = "";
	content += "<table width ='260' height='30' style='border-width:2; border-color:284C7E; border-style:solid;' width='100%' height='100%' bgcolor='FFFFFF'>";
	content += "<tr>";
	content += "	<td align='center' style='font-size:9pt;'><img src='../images/searching.gif'></td>";
	content += "</tr>";
	content += "</table>";
	document.getElementById("progressBar").innerHTML = content;
	document.getElementById("progressBar").style.display = '';

	setTimeout ("checkLoadData()", timeoutNextCheck);
}

function checkLoadData(){
	var progressBar = document.getElementById('progressBar');
	if(progressBar){
		if(progressBar.style.display ==""){
			loadDataInfo(pageNum);
		}
	}
}

function closeProgress(){
	var progressBar = document.getElementById('progressBar');
	if(progressBar)
		progressBar.style.display="none";
}

function trim(str, schStr) {
   while ( ( str.charAt(0)  == schStr ) || ( str.charAt( str.length - 1) == schStr ) ) {
      if ( str.charAt(0)  == schStr ) {
         str = str.substring(1, str.length - 1);
      }

      if ( str.charAt(str.length - 1) == schStr ) {
         str = str.substring(0, str.length - 2);
      }
   }
   return str;
}

function jfn_ctr_flashHeight(n){
	document.getElementById("listPageFlash").height=n+30;
}


function jfn_open_mallGuide(params){
	winOpen('../mallGuide/mall_guide.asp?'+params, 'mall_guide', 940, 660, 'no')
}

function jfn_click_topBtn(){
	location.href="#";
}

function jfn_display_shopInfo(){
	if(document.all.shopInfomation.style.display  == "")
		document.all.shopInfomation.style.display = "none";
	else{
		document.all.shopInfomation.style.display = "";
	}
}

function viewStore_id(url){
	if(opener){
		try {
			opener.location.href = url;
			window.opener.focus();
		} catch (e) {
			window.open(url,"","");
		}
	}
	else{
		location.href = url;
	}
}

function openWin_login(){
	winOpen('/memberShip/pop_login.asp', 'login', 450, 350, 'no');
}

function jfn_view_store_id(id){
	jfn_open_mallGuide("id="+ id);
}

function jfn_view_ecoupon(couponNum){
	location.href="/malling/malling_coupon.asp?couponNum="+couponNum;
}

function openWin_login_goUrl(val){
	winOpen('/memberShip/pop_login.asp?goUrl='+val, 'login', 450, 350, 'no');
}

