function open_window( filename, option, name )
{
	if( !name )
	{
		name = 'new'
	}


        win = window.open( filename, name, option );

        return win
}

function window_open( page, name, top, left, width, height )
{
	option = "'toolbar=no," +
		"location=no," +
		"directories=no," +
		"status=no," +
		"menubar=no," +
		"scrollbars=yes," +
		"resizable=yes," +
		"width=" + width + "," +
		"height=" + height + "," +
		"top=" + top + "," +
		"left=" + left + "'"

	var w=window.open( page, name, option );
	w.focus();
}

function open_poll_pop( mode, no )
{
	page = '/front/php/poll_r.php?mode=' + mode + '&no=' + no;
	window_open( page, 'poll', 100, 300, 466, 382 );
}

/*Left menu ¹ÝÅõ¸í ·¹ÀÌ¾î ±¸Çö*/
function Layer_overload(LayerName,Status) 
{
    if (navigator.appName == "Netscape")
    {
		LayerN = document.getElementById(LayerName).style;
		if (Status == 'show') LayerN.visibility = 'visible';
		if (Status == 'hide') LayerN.visibility = 'hidden';
    }	
    else
    {
		LayerN = document.all[LayerName].style;
		if (Status == 'show') LayerN.visibility = 'visible';
		if (Status == 'hide') LayerN.visibility = 'hidden';
    }
}

/*Left menu±¸Çö*/
var old='';

function menu(name)
{
	submenu=eval("submenu_"+name+".style");
	if(old!=submenu)
	{
		if(old!='')
		{
			old.display='none';
		}
		submenu.display='block';
		old=submenu;
	}
	else
	{
		submenu.display='none';
		old='';
	}
}


function Layer_rollover(img_name,img_url)
{
	var menu;	
	//tmp = new String( "document."+img_name );
	menu=eval("document."+img_name);		
	menu.src = img_url;
	return;
}

function image_zoom( product_no, main_cate_no, display_group )
{
	//href = '/front/php/image_zoom.php?img='+image+'&product_no='+document.frm.product_no.value;
	href = '/front/php/image_zoom.php?product_no='+product_no+'&main_cate_no='+main_cate_no+'&display_group='+display_group;
	option = 'toolbar=no,scrollbars=no,resizable=yes,width=800,height=640,left=0,top=0';
	win_name = 'image'

	window.open( href, win_name, option );
}

/*
 * Ãâ¼®Ã¼Å© ÆË¾÷
 */
function attend_popup() 
{
	url = "/front/php/attend_event_popup.php";
	winname = "attend_event_popup" ;
	option = "toolbar=no location=no scrollbars=yes width=700 height=900";
	opener = window.open( url, winname, option ) ;
}/* ºÎµå·´°Ô ¿òÁ÷ÀÌ´Â ¹è³Ê */
function get_position(divname) {
  var start, end, scale;
  start = parseInt (document.getElementById(divname).style.top, 10);
  end = document.body.scrollTop ? document.body.scrollTop: document.documentElement.scrollTop;
  if ( start != end ) {
    scale = Math.ceil( Math.abs( end - start ) / 20 ); // ¼Óµµ default : 20
    if ( end < start )  scale = -scale;
    document.getElementById(divname).style.top = parseInt (document.getElementById(divname).style.top, 10)+ scale + "px";
  }
  setTimeout ("get_position('"+divname+"')", 10); // ºÎµå·¯¿î Á¤µµ default : 5 ~ 10
}

function scroll_start(divname) {
  if(document.getElementById(divname)) {
    document.getElementById(divname).style.top = document.body.scrollTop ? document.body.scrollTop: document.documentElement.scrollTop+"px";
    document.getElementById(divname).style.position = "absolute";
    get_position(divname);
    return true;
  }
}

/* ºÎµå·´°Ô ¿òÁ÷ÀÌ´Â ¹è³Ê ³¡ */


function set_move_banner() {
  return;
}

/* ¸µÅ© Á¡¼± ¾ø¾Ö±â */
function bluring() {
    if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") {
        document.body.focus();
    }
}
document.onfocusin=bluring;
/* ¸µÅ© Á¡¼± ¾ø¾Ö±â ³¡ */

function window::onload() {
  scroll_start("scroll_banner");
  scroll_start("scroll_banner_r");
}
/* copyright by @hanmail.net */
/* ¹«´Ü »ç¿ë ±ÝÁö */

var scroll = function(obj) {
  this.move = function() {
    this.state;
    if(this.state==1) { return; }
    this.stop = 0;
    for(i=1; i<=2; i++) {
      this.divbox = eval(document.getElementById('wrap'+obj+'_'+i));
      this.wrap1 = document.getElementById('wrap'+obj+'_1');
      this.wrap2 = document.getElementById('wrap'+obj+'_2');
      this.wrap1_top = parseInt(this.wrap1.style.top);
      this.wrap1_left = parseInt(this.wrap1.style.left);
      this.wrap2_top = parseInt(this.wrap2.style.top);
      this.wrap2_left = parseInt(this.wrap2.style.left);
      for(k=0; k<this.stopPositionSize; k++) {
        if(this.direction=="up" || this.direction=="down") {
          if((this.stopPosition[k]==Math.abs(this.wrap1_top) || this.wrap1_top==0 || this.wrap1_top==this.realHeight) && this.delay!=this.delay_chk) {
            this.stop=1;
            if(this.wrap1_top>=0) this.wrap2.style.top = -this.realHeight + this.wrap1_top;
            if(this.wrap1_top<0) this.wrap2.style.top = this.realHeight + this.wrap1_top;
          }
        } else {
          if((this.stopPosition[k]==Math.abs(this.wrap1_left)  || this.wrap1_left==0 || this.wrap1_left==this.realWidth) && this.delay!=this.delay_chk) {
            this.stop=1;
            if(this.wrap1_left>=0) this.wrap2.style.left = -this.realWidth + this.wrap1_left;
            if(this.wrap1_left<0) this.wrap2.style.left = this.realWidth + this.wrap1_left;
          }
        }
      }
      if(this.stop) { this.delay_chk++; return; } else { this.delay_chk=0; }

      if(this.direction=="up") {
        this.divbox.style.top=parseInt(this.divbox.style.top) - 2;
        if(parseInt(this.divbox.style.top) < -this.realHeight) this.divbox.style.top = this.realHeight;
      }
      else if(this.direction=="down") {
        this.divbox.style.top = parseInt(this.divbox.style.top) + 2;
        if(parseInt(this.divbox.style.top) > this.realHeight) this.divbox.style.top = -this.realHeight;
      }
      else if(this.direction=="right") {
        this.divbox.style.left = parseInt(this.divbox.style.left) + 2;
        if(parseInt(this.divbox.style.left) > this.realWidth) this.divbox.style.left = -this.realWidth ;
      }
      else if(this.direction=="left") {
        this.divbox.style.left = parseInt(this.divbox.style.left) - 2;
        if(parseInt(this.divbox.style.left) < -this.realWidth) this.divbox.style.left = this.realWidth ;
      }
    }
  }


  this.start = function(direction) {
    this.direction = direction;
    if(!this.direction) this.direction = "left";

    this.delay_chk = 0;
    var self = this;

    if(!this.interval) this.interval = 1;
    if(!this.scrollWidth) this.scrollWidth = 300;
    if(!this.visibleWidth) this.visibleWidth = 300;
    if(!this.visibleHeight) this.visibleHeight = 30;
    if(!this.realHeight) this.realHeight = 120;
    if(!this.realWidth) this.realWidth = this.cnt*this.scrollWidth;

    this.stopPosition = new Array;
    for (i=1; i<this.cnt; i++) { this.stopPosition[i] = i*this.scrollWidth; }
    this.stopPositionSize = this.stopPosition.length;

    if(this.direction=="up" || this.direction=="down") { divleft=0;  divtop=this.realHeight; } else { divleft=this.realWidth;  divtop=0; }
    document.write("<div style='position:relative;width:" + this.visibleWidth + ";height:" + this.visibleHeight + ";overflow:hidden;' onmouseover='obj"+obj+".state=1' onmouseout='obj"+obj+".state=0'><div id='wrap"+obj+"_1' style='position:absolute;width:"+ this.realWidth + ";height:"+ this.realHeight +";left:0;top:0;'>"+document.getElementById('rolling'+obj).innerHTML+"</div><div id='wrap"+obj+"_2' style='position:absolute;width:"+ this.realWidth + ";height:"+ this.realHeight +";left:" + divleft +";top:" + divtop + ";'>"+ document.getElementById('rolling'+obj).innerHTML+"</div></div>");
    window.setInterval(function() {self.move()}, this.interval);
  }

}
/* copyright by @hanmail.net */
var rolling_banner = function(obj) {
  if(!obj) obj = 1;
  this.obj = obj;
  this.interval = 2000;
  this.default_url = "/web/upload/";
  var self = this;
  this.n = 1;
  this.content = document.getElementById('rolling_content'+this.obj).getElementsByTagName('div');
  this.cnt = this.content.length;
  this.wrap = document.getElementById("rolling_banner"+this.obj);
  this.start = function() {
    for(i=1; i<=this.cnt; i++) {
      if(i == this.n) document.getElementById("num"+this.obj+"_"+i).src = this.default_url+"on.gif";
      else document.getElementById("num"+this.obj+"_"+i).src = this.default_url+"off.gif";
    }
    document.getElementById("num"+this.obj+"_"+this.n).src = this.default_url+"on.gif";
    if (navigator.appName.indexOf("Microsoft") != -1) {
      this.wrap.filters[0].apply();
      this.wrap.filters[0].play();
    }
    this.wrap.innerHTML = this.content[this.n-1].innerHTML;
    if(this.n<this.cnt) this.n=this.n+1; else this.n=1;
    this.timeout = setTimeout(function() {self.start();}, this.interval);
  }
  this.stop = function() { clearTimeout(this.timeout);}
  this.restart = function() { this.timeout = setTimeout(function() {self.start()}, this.interval); }
  this.change = function(n) {
    this.stop();
    this.n = n;
    for(i=1; i<=this.cnt; i++) {
      if(i == this.n) document.getElementById("num"+this.obj+"_"+i).src = this.default_url+"on.gif";
      else document.getElementById("num"+this.obj+"_"+i).src = this.default_url+"off.gif";
    }
    if (navigator.appName.indexOf("Microsoft") != -1) {
      this.wrap.filters[0].apply();
      this.wrap.filters[0].play();
    }
    this.wrap.innerHTML = this.content[this.n-1].innerHTML;
    if(this.n<this.cnt) this.n=this.n+1; else this.n=1;
  }
}

function selValueMenu(thisId,thisIndex,thisString) {
	var objId = thisId;
	var nowIndex = thisIndex;
	var valueString = thisString;
	var sourceObj = document.getElementById(objId);
	var nowSelectedValue = document.getElementById(objId+"reValue"+nowIndex).value;
	if (sourceObj) sourceObj.value = nowSelectedValue;
	if (sourceObj.onchange) sourceObj.onchange();
}

function selValueMenu(thisId,thisIndex,thisString) {
	var objId = thisId;
	var nowIndex = thisIndex;
	var valueString = thisString;
	var sourceObj = document.getElementById(objId);
	var nowSelectedValue = document.getElementById(objId+"reValue"+nowIndex).value;
	if (sourceObj) sourceObj.value = nowSelectedValue;
	if (sourceObj.onchange) sourceObj.onchange();
}

function makSel_url(thisId) {
	var objId = thisId;
	var obj = document.getElementById(objId);
    var nowPage = window.location.href;
    var loc = nowPage.split("=");
	newSel  = "<div id='" + objId + "' class='newSelTab'>";
	newSel += "<ul>";
	for (var i=0 ; i < obj.options.length ; i++) {
		var nowValue = obj.options[i].value;
		var nowText = obj.options[i].text;
		if ( loc[5] == nowValue || !nowValue && !loc[5]) {
		var classVar = "on";
		var tagVar1 = "";
		var tagVar2 = "";
	   }
	   else {
	   	var classVar = "";
 		var tagVar1 = "<span>";
 		var tagVar2 = "</span>";
	   }
			    newSel += "<li class='"+classVar+"'>";
				newSel += "<div class='tabL'></div>";
				newSel += "<div class='tabC' onClick=\"selValueMenu('"+ objId + "' , " + i + " , '" + nowValue + "')\">" +tagVar1+ "&nbsp;" + nowText + "&nbsp;" +tagVar2+ "</div>";
				newSel += "<div class='tabR'></div>";
				newSel += "</li>";
				newSel += "<input style='display:none;' type='hidden' id='"+ objId + "reValue" + i + "' value='" + nowValue + "'>";
	}
	newSel += "</ul>";
	newSel += "</div>";
	document.write(newSel);
}
