/*******************************************************
	2010-11-09 ÇÑ±¹µ¥ÀÌÅÍÅë½Å ¼±ÀÓ¿¬±¸¿ø Á¤¿ë±â 
	
	common.js, ajax_call.js, string.js, date.js, addon.js, cookie.js ÆÄÀÏ ÅëÇÕ

*******************************************************/

 function loc_url(loc) {
	window.location.href=loc
 }

 function LoadFlashMV(td_name,idname, moviesrc, bgcolor, swliveconnect, width, height, allowScriptAccess, wmode) {
    var html_text

	html_text = '<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
	html_text = html_text + 'codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" '
	html_text = html_text + 'WIDTH="' + width + '" HEIGHT="' + height + '" id="' + idname + '"  name="' + idname 
	html_text = html_text + '" ALIGN="">'
	html_text = html_text + '<PARAM NAME=movie VALUE="' + moviesrc + '"><PARAM NAME=allowScriptAccess value="always">'
	html_text = html_text + '<PARAM NAME=menu VALUE=false><PARAM NAME=quality VALUE=high>'
	if (wmode != "") {
	    html_text = html_text + '<PARAM NAME=wmode VALUE=transparent>'
	}
	html_text = html_text + '<PARAM NAME=bgcolor VALUE=' + bgcolor + '>'
	html_text = html_text + '<PARAM NAME=swliveconnect VALUE=' + swliveconnect + '>'
	html_text = html_text + '<EMBED src="' + moviesrc + '" wmode=transparent menu=false quality=high bgcolor="' + bgcolor 
	html_text = html_text + '" WIDTH="' + width + '" HEIGHT="' + height + '" NAME="' + idname 
	html_text = html_text + '" ALIGN="" allowScriptAccess="always" TYPE="application/x-shockwave-flash" ' 
	html_text = html_text + 'PLUGINSPAGE="http://www.adobe.com/go/getflashplayer"></EMBED></OBJECT>'

    document.all[td_name].innerHTML = html_text
 }

 function LoadFLV(mv_path,width,height,bgcolor,flashVar) {
	html = '';
	html += '<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+'">';
	html += '<param name="movie" value="'+mv_path+'">';
	html += '<param name="quality" value="high">';
	html += '<param name="allowFullScreen" value="true">';	
	html += '<param name="allowScriptAccess" value="always">';
	html += '<param name="FlashVars" value="'+flashVar+'">';
	html += '<param name="wmode" value="">';
	html += '<param name="bgcolor" value="'+bgcolor+'">';
	html += '<embed src="'+mv_path+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" name="flashvars" allowScriptAccess="always" allowFullScreen="true"></embed>';
	html += '</object>';
	document.write(html);
 }

 function LoadMV(td_name, idname, moviesrc, width, height, ShowControls) {
    var html_text

	html_text = '<OBJECT classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" '
	html_text = html_text + 'WIDTH="' + width + '" HEIGHT="' + height + '" id="' + idname + '">'
	html_text = html_text + '<PARAM NAME=filename VALUE="' + moviesrc + '">'
	html_text = html_text + '<PARAM NAME=ShowControls VALUE=' + ShowControls + '></object>'
 }

 function OuterJS_FlashEmbed(idname, moviesrc, bgcolor, swliveconnect, width, height, allowScriptAccess, wmode) {
	document.write('<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" WIDTH="' + width + '" HEIGHT="' + height + '" id="' + idname + '"  name="' + idname + '" ALIGN="">  ') ;
	document.write('<PARAM NAME=movie VALUE="' + moviesrc + '">  ') ;
	document.write('<PARAM NAME=allowScriptAccess value="always">  ') ;
	document.write('<PARAM NAME=menu VALUE=false> ') ; 
	document.write('<PARAM NAME=quality VALUE=high>  ') ;
	if (wmode != "")
	{
		document.write('<PARAM NAME=wmode VALUE=transparent>  ') ;
	}
	document.write('<PARAM NAME=bgcolor VALUE=' + bgcolor + '> ') ;
	document.write('<PARAM NAME=swliveconnect VALUE=' + swliveconnect + '> ') ;
	document.write('<EMBED src="' + moviesrc + '" menu=false quality=high bgcolor="' + bgcolor + '" WIDTH="' + width + '" HEIGHT="' + height + '" NAME="' + idname + '" ALIGN=""  WMODE="transparent" allowScriptAccess="always" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.adobe.com/go/getflashplayer"></EMBED> ') ;
	document.write('</OBJECT> ') ;
 }

 function OuterJS_MovieEmbed(idname, moviesrc, width, height, ShowControls) {
	document.write('<OBJECT classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" WIDTH="' + width + '" HEIGHT="' + height + '" id="' + idname + '">  ') ;
	document.write('<PARAM NAME=filename VALUE="' + moviesrc + '">  ') ;
	document.write('<PARAM NAME=ShowControls VALUE=' + ShowControls + '> ') ; 
	document.write('</OBJECT> ') ;
 }

 function LogOut() {
    var get_url 

	get_url = "/member/ajax/member_manage.asp?f_name=LogOut"
	GetAjaxInfoA(true,get_url,"LogOut_result")
 }

 function LogOut_result(msg) {
    var arrValue

	arrValue = msg.split("[sp]")
	if(parseInt(arrValue[0]) <= 0) {
	   alert(arrValue[1])
	   return
	}

	location.href = "/contents/list/cts_detail_list.asp"
 }

 function ebook_open(sLink) {
    window.open(sLink, "ebook_event", "width=1024, height=768, channelmode=no, resizable=yes, fullscreen=yes, status=yes"); 
 }

 function Event1() {
    ebook_open("http://tv.allurekorea.com/ebook/ebrochure/perfume/viewer.asp");
 }
 function openexp() {
	document.getElementById('menuz').style.zIndex = '111';
 }
 function closeexp() {
	document.getElementById('menuz').style.zIndex = '100';
 }

/*******************************************************/
/* date.js 2010-11-09 ÇÑ±¹µ¥ÀÌÅÍÅë½Å ¼±ÀÓ¿¬±¸¿ø Á¤¿ë±â */

 function IsDate(datestr) {
	var arrValue, tmpDate
	
	arrValue = datestr.split("-")
	tmpData = new Date(datestr.replace(/-/g,'/'))
	if(parseInt(arrValue[1]) == (tmpData.getMonth()+1)) {
	   return true
	} else {
	   return false
	}
 }

 function RightDate(datestr,nWay) {
	var arrValue, tmpDate, rtnValue
	var nDiff, arrTemp

	arrValue = datestr.split("-")
	tmpData = new Date(datestr.replace(/-/g,'/'))
	if(parseInt(arrValue[1]) == (tmpData.getMonth()+1)) {
	   rtnValue = datestr
	} else {
       if(nWay==0) {
		  rtnValue = tmpData.getYear() + "-" + (tmpData.getMonth()+1)
		  rtnValue = rtnValue + "-1"
	   } else {
	      nDiff = (-1)*tmpData.getDate()
	      rtnValue = DateAdd(nDiff,datestr)
	   }
	}	

    arrTemp = rtnValue.split("-")
    if(arrTemp[0].length==2) {
	   rtnValue = "19" + rtnValue
	}

	return rtnValue
 }

 function DateDiff(f_date,t_date) {
	var date1, date2, nDiff

    if(!IsDate(f_date) || !IsDate(t_date)) {
	   return 999
	}

	date1 = f_date.replace(/-/g,'/')
	date2 = t_date.replace(/-/g,'/')
	nDiff = (new Date(date2) - new Date(date1)) / (60*60*24*1000)
	return nDiff
 }

 function DateAdd(nAdd,datestr) {
	var tmpDate, newDate, rtnValue

    tmpData = new Date(datestr.replace(/-/g,'/'))
	newDate = new Date(tmpData.getTime() + 60*60*24*1000*nAdd) 
	rtnValue = newDate.getYear() + "-" + (newDate.getMonth()+1)
	rtnValue = rtnValue + "-" + newDate.getDate()

	return rtnValue
 }

 function GetToday() {
	var today, rtnValue

	today = new Date()
    rtnValue = today.getYear() + "-" + (today.getMonth()+1) + "-" + today.getDate()

	return rtnValue
 }

/*******************************************************/

/*******************************************************/
/* addon.js 2010-11-09 ÇÑ±¹µ¥ÀÌÅÍÅë½Å ¼±ÀÓ¿¬±¸¿ø Á¤¿ë±â */

// document.onkeydown = OnKeyCheck
// document.oncontextmenu = OnRightMouseCheck
// document.ondragstart = OnDragCheck
// document.onselectstart = OnSelectCheck

/*******************************************************/

/*******************************************************/
/* cookie.js 2010-11-09 ÇÑ±¹µ¥ÀÌÅÍÅë½Å ¼±ÀÓ¿¬±¸¿ø Á¤¿ë±â */


function setCookie( name, value, expiredays ) {
   var todayDate = new Date();
   todayDate.setDate( todayDate.getDate() + expiredays );
   document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function getCookie(str) {
   var key = str + "=" ;
   var key_len = key.length ;
   var cookie_len = document.cookie.length;
   var i = 0;
   while (i < cookie_len ) {
	  var j = i + key_len;
	  if ( document.cookie.substring( i, j ) == key ) {
		 var cookie_end = document.cookie.indexOf(";",j);
		 if (cookie_end == -1) {
			cookie_end = document.cookie.length;
		 }
		 return document.cookie.substring(j,cookie_end );
	  }
	  i++
   }
   return ""
}

function DeleteCookie (name) {  
   var exp = new Date();  
   exp.setTime (exp.getTime() - 1);  
   var cval = getCookie (name);  
   document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

/*******************************************************/

/*******************************************************/
/* string.js 2010-11-09 ÇÑ±¹µ¥ÀÌÅÍÅë½Å ¼±ÀÓ¿¬±¸¿ø Á¤¿ë±â */

 function TrimStr(str) {
	var rtnValue = str.replace(/(^\s*)|(\s*$)/g, "");
	return rtnValue
 }

 function ByteLen(str) {
	var nLen, i, ch

	nLen = str.length
	nByteLen = 0
	for(i=0;i<nLen;i++) {
		ch = str.charAt(i)
		if(escape(ch).length > 4) {
		   nByteLen += 2
		} else {
		   nByteLen++
		}
	}

	return nByteLen
 }

 function CheckKr1(str) {
    var i, n_count;

    n_count = 0;
	for(i=0;i<str.length;i++) {
	    if(str.charCodeAt(i) >=0 && str.charCodeAt(i) <= 127) {
		   n_count = n_count + 1;
		}
	}

	if(n_count == 0) {
	   return true;
	} else {
	   return false;
	}
 }

 function CheckKr2(str) {
    var i, n_count;

    n_count = 0;
	for(i=0;i<str.length;i++) {
	    if(str.charCodeAt(i) < 0 || str.charCodeAt(i) > 127) {
		   n_count = n_count + 1;
		}
	}

	if(n_count > 0) {
	   return true;
	} else {
	   return false;
	}
 }

/*******************************************************/

/*******************************************************/
/* ajax_call.js 2010-11-09 ÇÑ±¹µ¥ÀÌÅÍÅë½Å ¼±ÀÓ¿¬±¸¿ø Á¤¿ë±â */

 var obj_xmlhttp;
 var call_func;

 function GetAjaxInfoA(b_async,s_url,callback_func) {
    obj_xmlhttp = zXmlHttp.createRequest()
    obj_xmlhttp.open("get",s_url,b_async);

	if(b_async) {
	   call_func = eval(callback_func)
	   obj_xmlhttp.onreadystatechange = GetResponseText;
	   obj_xmlhttp.send(null);
	} else {
	   obj_xmlhttp.send(null);

	   if(obj_xmlhttp.readyState == 4) {
		  if(obj_xmlhttp.status == 200) {
			 return obj_xmlhttp.responseText
		  } else {
			 return "-1[sp]An error occurred: " + obj_xmlhttp.statusText
		  }            
	   }
	}
 }

 function GetAjaxInfoB(b_async,f_obj,callback_func) {
	var html_body

    html_body = GetParamInfo(f_obj);

    obj_xmlhttp = zXmlHttp.createRequest()
    obj_xmlhttp.open("post",f_obj.action,b_async);
    obj_xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");

	if(b_async) {
	   call_func = eval(callback_func)
	   obj_xmlhttp.onreadystatechange = GetResponseText;
	   obj_xmlhttp.send(html_body);
	} else {
	   obj_xmlhttp.send(html_body);
	   if(obj_xmlhttp.readyState == 4) {
		  if(obj_xmlhttp.status == 200) {
			 return obj_xmlhttp.responseText
		  } else {
			 return "-1[sp]An error occurred: " + obj_xmlhttp.statusText
		  }            
	   }
	}
 }

 function GetResponseText() {
	if(obj_xmlhttp.readyState == 4) {
	   if(obj_xmlhttp.status == 200) {
		  return call_func(obj_xmlhttp.responseText)
	   } else {
		  return call_func("-1[sp]An error occurred: " + obj_xmlhttp.statusText)
	   }
	}  
 }

 function GetParamInfo(oForm) {
	var aParams = new Array();
	var sParam, form_check, i, j

	for (i=0 ; i < oForm.elements.length; i++) {	
		form_check = oForm.elements[i].type != "radio" && oForm.elements[i].type != "checkbox"
		form_check = form_check && oForm.elements[i].type != "select-multiple"
		form_check = form_check || (oForm.elements[i].type == "radio" && oForm.elements[i].checked)
		form_check = form_check || (oForm.elements[i].type == "checkbox" && oForm.elements[i].checked)
		if(form_check) {
		   sParam = escape(oForm.elements[i].name);
		   sParam += "=";
		   sParam += escape(oForm.elements[i].value);
		   aParams.push(sParam);
		} else if(oForm.elements[i].type == "select-multiple" && oForm.elements[i].value != "") {
		   for(j=0;j<oForm.elements[i].options.length;j++) {
			   if(oForm.elements[i].options[j].selected) {
			      sParam = escape(oForm.elements[i].name);
			      sParam += "=";
			      sParam += escape(oForm.elements[i].options[j].value);
			      aParams.push(sParam);			   
			   }
		   }	
		}
	} 
	
	return aParams.join("&");        
 }

 function addLoadEvent(func) {   
    var oldonload = window.onload;   
    if(typeof window.onload != 'function') {   
       window.onload = func;   
    } else {   
       window.onload = function() {   
        if(oldonload) {   
           oldonload();   
        }   
        func();   
       }   
    }   
 }   

 var isMobile = false;
 var urAgent = navigator.userAgent.toLowerCase();

 var mobilePhones = new Array('iphone','ipod','ipad','android');
 
 for(var i=0;i<mobilePhones.length;i++) {
	if(urAgent.indexOf(mobilePhones[i]) != -1) {
	   isMobile = true;
	   break;
	}
 }
