var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
function getRef(id) {
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}
var isNS = navigator.appName == "Netscape";
function moveRightEdge() {
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
	if (isNS4) {
		yMenuFrom   = divMenu.top;
		yMenuTo     = windows.pageYOffset + 0;   // À§ÂÊ À§Ä¡
	} else if (isDOM) {
		yMenuFrom   = parseInt (divMenu.style.top, 10);
		yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + 0; // À§ÂÊ À§Ä¡
		if(yMenuTo >158)
			yMenuTo-=158;
		else yMenuTo=0;
	}
	timeoutNextCheck = 500;
	if (yMenuFrom != yMenuTo) {
		yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
		if (yMenuTo < yMenuFrom)
			yOffset = -yOffset;
		if (isNS4)
			divMenu.top += yOffset;
		else if (isDOM)
			divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
			timeoutNextCheck = 10;
	}
	setTimeout ("moveRightEdge()", timeoutNextCheck);
}

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

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_showHideLayers() { //v6.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; }
}

// form.reset
function formClear(Obj)
{
	Obj.reset();
}

//°´Ã¼ È°¼º,ºñÈ°¼º ¼³Á¤ ÇÔ¼ö
function showObject(Obj,Boolen)
{
	if(Boolen){					//È°¼ºÈ­
		Obj.disabled = false;
		Obj.style.background = "#ffffff";
	}
	else{						//ºñÈ°¼ºÈ­
		Obj.disabled = true;
		Obj.style.background = "#dddddd";
	}
}
//°´Ã¼ È°¼º,ºñÈ°¼º ¼³Á¤ ÇÔ¼ö
function checkshowObject(Obj,Boolen)
{
	Boolen ? Obj.disabled = false: Obj.disabled = true;
}

/* ¹è¿­ Ã³¸® ÇÔ¼ö */
//Ãß°¡
function addArray(Obj,Val)
{
	var arrLength= Obj.length;
	Obj[arrLength] = Val;
}

//»èÁ¦
function delArray(Obj,Index)
{
	var temp=new Array();
	var nextIndex = Index +1;

	for(i=0,j=0;i<Obj.length;i++){
		if(i!=Index){
			temp[j] = Obj[i];
			j++;
		}
	}
	for(i=0;i<temp.length;i++)
		Obj[i]=temp[i];
	return temp.length;
}

//Á¤·Ä   0:³»¸²Â÷¼ø  1:¿À¸§Â÷¼ø
function sortArray(Obj,Method)
{
	Obj.sort();
	if(!Method)
		Obj.reverse();
}

//ÇÑ±ÛÃ¼Å©
function hanCheck(Str)
{
	var Re=false;
	for(i=0;i<Str.length;i++){
		var a=Str.charCodeAt(i);
		if (a > 128) {
			Re=true;
		}
	}
	return Re;
}

//ÆÄÀÏ¸í ÇÑ±Û Ã¼Å©
function filehanCheck(Str)
{
	var Arr = new Array();
	var Re=false;
	Arr=Str.split("\\");
	return hanCheck(Arr[Arr.length-1]);
}

//¼ýÀÚÃ¼Å©
function numCheck(Str)
{
    var Re=true;
	for(i=0;i<Str.length;i++){
		var a=Str.charCodeAt(i);
		if(a<48 || a>57)
			Re=false;
	}
	return Re;
}

//¿¬¶ôÃ³Ã¼Å©
function telCheck(Tel1, Tel2, Tel3){
	var Re=true;
	if(!numCheck(Tel1) ||!numCheck(Tel2) ||!numCheck(Tel3) )
		Re = false;
	else if(Tel1.length <2 || Tel1.length >3)
		Re = false;
	else if(Tel2.length <3 || Tel2.length >4)
		Re = false;
	else if(Tel3.length <4 || Tel3.length >4)
		Re = false;
	return Re;
}

//ÀÌ¹ÌÁöÈ®´ë
function zoom(File,Width,Height)
{
	if(!Width || !Height){
		alert("ÀÌ¹ÌÁö°¡ Á¸ÀçÇÏÁö ¾Ê°Å³ª ÀÌ¹ÌÁö Å©±âÁ¤º¸°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
	}else{
		window.open("./zoom.php?img="+File,"","scrollbars=yes,resizable=yes,width="+Width+",height="+Height+",top=10,left=20");
	}
}
function zooms(Title,Dir,Files,Width,Height)
{
	if(!Width || !Height){
		alert("ÀÌ¹ÌÁö°¡ Á¸ÀçÇÏÁö ¾Ê°Å³ª ÀÌ¹ÌÁö Å©±âÁ¤º¸°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
	}else{
		window.open("./zooms.php?Title="+Title+"&Dir="+Dir+"&Files="+Files,"","scrollbars=yes,resizable=yes,width="+Width+",height="+Height+",top=10,left=20");
	}
}

function zoom2(File,Width,Height)
{
	if(!Width || !Height){
		alert("ÀÌ¹ÌÁö°¡ Á¸ÀçÇÏÁö ¾Ê°Å³ª ÀÌ¹ÌÁö Å©±âÁ¤º¸°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
	}else{
		if(Width<700) Width=700;

		Width+=3;
		Height+=70;
		window.open("./zoom2.php?idx="+File,"","scrollbars=yes,resizable=yes,width="+Width+",height="+Height+",top=10,left=20");
	}
}

function zoom3(File,Width,Height)
{
	if(!Width || !Height){
		alert("ÀÌ¹ÌÁö°¡ Á¸ÀçÇÏÁö ¾Ê°Å³ª ÀÌ¹ÌÁö Å©±âÁ¤º¸°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
	}else{
		Width+=200;
		//Height+=70;
		window.open("./zoom3.php?idx="+File,"","scrollbars=yes,resizable=yes,width="+Width+",height="+Height+",top=10,left=20");
	}
}

function zoom2_gongu(File,Width,Height)
{

	window.open("./zoom2_gongu.php?idx="+File,"","scrollbars=no,width="+Width+",height="+Height+",top=10,left=20");

}

//ÀÌ¹ÌÁöÈ®´ë (Å¸ÀÌÆ²)
function zoomTitle(File,Width,Height,Title)
{
	if(!Width || !Height){
		alert("ÀÌ¹ÌÁö°¡ Á¸ÀçÇÏÁö ¾Ê°Å³ª ÀÌ¹ÌÁö Å©±âÁ¤º¸°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
	}else{
		window.open("./zoom.php?img="+File+"&title="+Title,"","scrollbars=no,width="+Width+",height="+Height+",top=20,left=20");
	}
}

//<tr> ¹è°æ»ö ¹Ù²Ù±â
function bgcolorChange(Obj,Color)
{
	Obj.backgroundColor = Color;
}

//ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
function bsshChek(ssh1,ssh2)
{
	var reginum = ssh1+ssh2;
	var weight = "234567892345";
	var sum = 0;
	if (isNaN(reginum) || reginum.length != 13) return false;

	for (var i=0;i<12;i++)
		sum = sum + (reginum.substring(i,i+1) * weight.substring(i,i+1));

	var result = (11 - (sum % 11)) % 10;
	if (result != reginum.substring(12,13)) return false;
	return true;
}

//¸¸³ªÀÌ Ã¼Å©
function manChek(ssh1)
{
	var today = new Date();
	var day = today.getDate();
	var month = today.getMonth()+1;
	var year = today.getYear();

	ssh=year*10000+month*100+day;
	ssh=ssh-ssh1-19000000;
	return ssh;
}

//ÀÌ¸ÞÀÏÃ¼Å©
function isEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
/*
  var mail_array = str.split("@");
  if(mail_array[1] == 'hanmail.net' || mail_array[1] == 'daum.net')
	  return false;
*/
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

//»óÇ° ¼±ÅÃ
function selectGoods(Obj)
{
	Action="goods_select.php?Obj="+Obj;
	window.open(Action,"","scrollbars=yes,width=750,height=670,top=20,left=150");
}

//ÄíÅ°ÀúÀå
function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	todayDate.setHours(0);
	todayDate.setMinutes(0);
	todayDate.setSeconds(0);

	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
	//document.cookie = name + "=" + escape( value ) + "; path=/;";
}

function getCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;

	while (i < clen) 
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function getCookieVal(offset) 
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

//Ä®·¯ ¹Ú½º
//       setColor(string mul|sin, string bg|style  string  id)
function setColor(Part1,Part2,Obj)
{
	window.open("./color.php?part1="+Part1+"&part2="+Part2+"&target="+Obj,"","scrollbars=yes,width=350,height=110,left=300,top=300");
}
function subsetColor(Part1,Part2,Obj,tForm)
{
	window.open("./sub_color.php?part1="+Part1+"&part2="+Part2+"&target="+Obj+"&tForm="+tForm,"","scrollbars=yes,width=350,height=110,left=300,top=300");
}

//1Â÷Ä«Å×°í¸® ¸¶¿ì½º ¾Æ¿ô ¼³Á¤
function layerImgOut(Name,Src)
{
	Name.src=Src;
}

//»óÇ° °Ë»ö Æû
function goodsSearchSendit(Obj)
{
	if(Obj.searchstring.value==""){
		alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.");
		Obj.searchstring.focus();
	}else{
		Obj.submit();
	}
}

//¸ÞÀÏº¸³»±â
function sendMail(To)
{
	window.open("http://www.porart.com/email/mail.php?To="+To,"","scrollbars=yes,left=200,top=200,width=400,height=500");
}

//°ü·ÃÀÌ¹ÌÁö ¿Ã¸®±â »õÃ¢
function inputImg(Part,Code)
{
	var form=document.writeForm;
	window.open("http://www.porart.com/admin/input_img.php?part="+Part+"&code="+Code,"","scrollbars=yes,left=200,top=200,width=467,height=500");
}

function askloginErr()
{
	alert("È¸¿ø¸Þ´ºÀÔ´Ï´Ù. ·Î±×ÀÎ ÇØÁÖ½Ê½Ã¿À.");
}

function trans_info_view()
{
	window.open("http://www.porart.com/trans_info.php","","scrollbars=yes,resizable=yes,width=700,height=800,top=10,left=200");
}

function content_roll(div_id, banner_height, banner_delay, banner_speed, this_height)
{
	var div_tag = document.getElementById(div_id);
	var table_tag, i;

	this_height++;
	this_height++;
	if(this_height < banner_height)
	{
		div_tag.style.top = -this_height;
		setTimeout("content_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", " + this_height + ");", banner_speed);
	} else {
		table_tag = div_tag.getElementsByTagName("TABLE");
		div_tag.appendChild(table_tag[0]);
		div_tag.style.top = 0;
		setTimeout("content_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", 0);", banner_delay);
	}
	return true;
}
function content_roll_start(div_id, banner_height, banner_delay, banner_speed, this_height)
{
	setTimeout("content_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", " + this_height + ");", banner_delay);
}


//###################################################################
// ¼³ ¸í : ¿À¸¥ÂÊ ¸¶¿ì½º Å¬¸¯ ±ÝÁö
//###################################################################
function returnEventFalse() {
	event.returnValue = false;
}

function returnEventTrue() {
	event.returnValue = true;
}

function returnEventStatus() {
	window.status=("::: porart :::");
	return true;
}

var webServerName = location.host;

//document.onmouseover	= returnEventStatus;
//document.onmouseout		= returnEventStatus;

//document.oncontextmenu	= returnEventTrue;
//document.ondragstart	= returnEventTrue;
//document.onselectstart	= returnEventTrue;

//document.oncontextmenu	= returnEventFalse;
//document.ondragstart	= returnEventFalse;
//document.onselectstart	= returnEventFalse;

function view_flash(L,W,H){
	document.write("<object width='"+W+"' height='"+H+"' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' id='V000289597'>");
	document.write("<param name='allowScriptAccess' value='always' />");
	document.write("<param name='movie' value='"+L+"' />");
	document.write("<param name='quality' value='high' />");
	document.write("<param name='allowFullScreen' value='true' />");
	document.write("<embed src='"+L+"' width='"+W+"' height='"+H+"' name='V000289597' allowFullScreen='true' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>");
	document.write("</object>");
}

function add_bookmark(){
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		window.external.AddFavorite('http://www.porart.com/event/bookmark', 'Æ÷ÅÐ¾ÆÆ®');
		hiddenframe.location.href="http://www.porart.com/event/bookmark/index.php?bookmark=addbookmark";
	}else{
		alert('ÀÎÅÍ³Ý ÀÍ½ºÇÃ·Î¾î¸¸ °¡´ÉÇÕ´Ï´Ù');
	}
	return false;
}

function add_startpage(){
	if(document.all && window.external){
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage('http://www.porart.com/event/bookmark');
		hiddenframe.location.href="http://www.porart.com/event/bookmark/index.php?bookmark=addbookmark";
	}else{
		alert('ÀÎÅÍ³Ý ÀÍ½ºÇÃ·Î¾î¸¸ °¡´ÉÇÕ´Ï´Ù');        
	}
	return false;
}
