// ¹öÆ° ·Ñ¿À¹ö
function mm_over(obj)
{
 var img = obj.src.split('.gif');
 obj.src = img[0] + '_over.gif';
}
function mm_out(obj)
{
 var img = obj.src.split('_over.gif');
 obj.src = img[0] + '.gif';
}


// ¸µÅ© Á¡¼± ¼û±è
function autoblur() {
        if(event.srcElement.tagName == "A") document.body.focus();
}
document.onfocusin = autoblur;



// È­¸é Áß¾ÓÀ¸·Î »õÃ¢¶ç¿ì±â 
function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}


// ºê¶ó¿ìÀú µ¿ÀûÀ¸·Î ¸®»çÀÌÂ¡
function resizeWin(maxX,maxY,speed,delay,win){
    this.obj = "resizeWin" + (resizeWin.count++);
    eval(this.obj + "=this");
    if (!win)     this.win = self;    else this.win = eval(win);
    if (!maxX)    this.maxX = 400;    else this.maxX = maxX;
    if (!maxY)    this.maxY = 300;    else this.maxY = maxY;
    if (!speed)   this.speed = 1/2;   else this.speed = 1/speed;
    if (!delay)   this.delay = 0;    else this.delay = delay;
    this.doResize = (document.all || document.getElementById);
    this.stayCentered = false;
    
    this.initWin =     function(){
        if (this.doResize){
            this.resizeMe();
            }
        else {
            this.win.resizeTo(this.maxX + 10, this.maxY - 20);
            }
        }

    this.resizeMe = function(){
        this.win.focus();
        this.updateMe();
        }
    
    this.resizeTo = function(x,y){
        this.maxX = x;
        this.maxY = y;
        this.resizeMe();
        }
        
    this.stayCentered = function(){
        this.stayCentered = true;
        }

    this.updateMe = function(){
        this.resizing = true;
        var x = Math.ceil((this.maxX - this.getX()) * this.speed);
        var y = Math.ceil((this.maxY - this.getY()) * this.speed);
        if (x == 0 && this.getX() != this.maxX) {
            if (this.getX() > this.maxX) x = -1;
            else  x = 1;
            }
        if (y == 0 && this.getY() != this.maxY){
            if (this.getY() > this.maxY) y = -1;
            else y = 1;
            }
        if (x == 0 && y == 0) {
            this.resizing = false;
            }
        else {
            this.win.top.resizeBy(parseInt(x),parseInt(y));
            if (this.stayCentered == true) this.win.moveTo((screen.width - this.getX()) / 2,(screen.height - this.getY()) / 2);
            setTimeout(this.obj + '.updateMe()',this.delay)
            }
        }
        
    this.write =  function(text){
        if (document.all && this.win.document.all["coords"]) this.win.document.all["coords"].innerHTML = text;
        else if (document.getElementById && this.win.document.getElementById("coords")) this.win.document.getElementById("coords").innerHTML = text;
        }
        
    this.getX =  function(){
        if (document.all) return (this.win.top.document.body.clientWidth + 10)
        else if (document.getElementById)
            return this.win.top.outerWidth;
        else return this.win.top.outerWidth - 12;
    }
    
    this.getY = function(){
        if (document.all) return (this.win.top.document.body.clientHeight + 29)
        else if (document.getElementById)
            return this.win.top.outerHeight;
        else return this.win.top.outerHeight - 31; 
    }
    
    this.onResize =  function(){
        if (this.doResize){
            if (!this.resizing) this.resizeMe();
            }
        }

    return this;
}
resizeWin.count = 0;


// ÆË¾÷¿¡¼­ ¸µÅ©½Ã ºÎ¸ðÃ¢¿¡ ³»¿ë »Ñ·ÁÁÖ°í ÆË¾÷ ½º½º·Î ´ÝÈû
function linkToOpener(URL){
if (window.opener && !window.opener.closed)
window.opener.location = URL;
window.close();
}


function winopen_open()
{
	var targeturl="http://www.whoismall.com/index_v4.phtml?mode=opendemo"
	newwin=window.open("","","scrollbars")
	if (document.all){
	newwin.moveTo(0,0)
	newwin.resizeTo(screen.width,screen.height)
	}
	newwin.location=targeturl
}


// ÈÄÀÌÁî¸ô °ü¸®ÀÚµ¥¸ð
function winopen()
{
var targeturl="http://www.whoismall.com/index_v4.phtml?mode=demo"
newwin=window.open("","","scrollbars")
if (document.all){
newwin.moveTo(0,0)
newwin.resizeTo(screen.width,screen.height)
}
newwin.location=targeturl
}

function winopen_use()
{
var targeturl="http://www.whoismall.com/index_v4.phtml?mode=demo3"
newwin=window.open("","","scrollbars")
if (document.all){
newwin.moveTo(0,0)
newwin.resizeTo(screen.width,screen.height)
}
newwin.location=targeturl
}


function winopen2()
{
var targeturl="http://www.whoismall.com/index_v4.phtml?mode=demo2"
newwin=window.open("","","scrollbars")
if (document.all){
newwin.moveTo(0,0)
newwin.resizeTo(screen.width,screen.height)
}
newwin.location=targeturl
}

//ÄÁÅÙÃ÷¸ô µ¥¸ð
function winopen_contents()
{
	var targeturl="http://www.whoismall.com/index_v4.phtml?mode=ContentsDemo"
	newwin=window.open("","","scrollbars")
	if (document.all){
	newwin.moveTo(0,0)
	newwin.resizeTo(screen.width,screen.height)
	}
	newwin.location=targeturl
}

//ÇØ¿Ü±¸¸Å´ëÇà¹öÀü µ¥¸ð
function winopen_special()
{
	var targeturl="http://www.whoismall.com/index_v4.phtml?mode=special"
	newwin=window.open("","","scrollbars")
	if (document.all){
	newwin.moveTo(0,0)
	newwin.resizeTo(screen.width,screen.height)
	}
	newwin.location=targeturl
}


// µå·¡±× ±ÝÁö
/*
var omitformtags=["input", "textarea", "select"]

omitformtags=omitformtags.join("|")

function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}

function reEnable(){
return true
}

if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
*/

// »óÅÂÇ¥½ÃÁÙ ¸µÅ© URL ¼û±è
function hidestatus(){
    window.status=''
return true
}

if (document.layers)
    document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
    document.onmouseover=hidestatus
    document.onmouseout=hidestatus


// ÀÌ¹ÌÁö ½º¿Ò (¿ì¼öµðÀÚÀÎ»óÁ¡ Àû¿ë)
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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}


function MsgList(Url,cate)
{   
    var pForm = document.TheForm;
	pForm.Qtype.value=cate;
	pForm.action =Url;
	pForm.submit();
}




var rolling_banner = function(ta){
	this.ta = ta;
//	this.ta.className = 'rolling_banner';	
	this.ta_id = 'roll_'+(this.ta.id||this.ta.name);
	this.gap = 5;					//¿òÁ÷ÀÌ´Â ÇÈ¼¿´ÜÀ§
	this.gap_count=0;			//Ä«¿îÆÃ¿ë:°ÇµéÁö ¸¶¼¼¿ä
	this.gap_time = '3000';		//¿òÁ÷ÀÌ´Â ´ÜÀ§½Ã°£
	this.gap_sleep = '10000';	//È­¸éÀÌ ¸ØÃçÀÖÀ» ´ÜÀ§½Ã°£
	this.over_stop = true;  //¸¶¿ì½º¸¦ ¿Ã·ÈÀ» ¶§ ¸ØÃâ °ÍÀÎ°¡?
	this.timer = null;
	eval(this.ta_id+'=this');
	var temp = eval(this.ta_id);
	this.init_div();	
}
rolling_banner.prototype.start = function(){	//·Ñ¸µ ½ÃÀÛ
	this.ta.readonly =false;
	this.stop =false;	
	if(!this.timer){ this.rolling();	 }
}
rolling_banner.prototype.stop = function(){	//·Ñ¸µ ½ÃÀÛ
	this.stop =true;
}
rolling_banner.prototype.init_div = function(){	//<div> »©°í ÀüºÎ Á¦°Å , ½ºÅ¸ÀÏ ÃÊ±âÈ­
	this.ta.style.position="relative";
	this.ta.style.overflow="hidden";
  	this.ta.onmouseover=function(){ eval("this.readOnly=true;"); }
  	this.ta.onmouseout=function(){ eval("this.readOnly=false;"); }

	var child = this.ta.childNodes;
	var ch = this.ta.firstChild;
	var ch2 = null;
	while(ch){
		ch2 = ch.nextSibling;
		if(ch.nodeName.toLowerCase() !='div'){
		this.ta.removeChild(ch);
		}else{
		ch.style.position = "relative";
		ch.style.borderStyle='none';
		ch.style.top='0px';
		}
		ch=ch2;
	}
}
rolling_banner.prototype.strtonum = function(str){
	var num = parseInt(str);
	if(isNaN(num)) num = '0';
	return num
}
rolling_banner.prototype.strtopx = function(str){
	var num = this.strtonum(str);
	return num+'px';
}
rolling_banner.prototype.rolling = function(){
	if(this.gap_count==0){
		this.sleep();
		this.gap_count+=1;
		return;
	}
	if(!this.ta.readOnly && !this.stop){
		this.rolling_top();
	}
	this.timer = null;
	var re = this.ta_id+'.rolling()';
	this.timer = setTimeout(re,this.gap_time);
}
rolling_banner.prototype.rolling_top = function(){
	this.gap_count+=parseInt(this.gap);
	var ch1 = this.ta.firstChild;
	var child = this.ta.childNodes;
	var ta_ch = null;
	var	top_ori = this.strtonum(child[0].style.top);
	var top = this.strtopx(top_ori-parseInt(this.gap));			
	for(var i=0,m=child.length;i<m;i++){
		child[i].style.top=top;
	}
	if(this.gap_count >= this.strtonum(ch1.style.height)){
		var temp =ch1.cloneNode(true);	
		this.ta.removeChild(ch1);
		this.ta.appendChild(temp);
		for(var i=0,m=child.length;i<m;i++){
			child[i].style.top='0px';
		}		
	this.gap_count = 0		
	}
}
rolling_banner.prototype.sleep = function(){
	this.timer = null;
	var re = this.ta_id+'.rolling()';
	this.timer = setTimeout(re,this.gap_sleep);
}
