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 + "'"

        window.open( page, name, option );
}

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 na_restore_img_src(name, nsdoc)
{
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img && img.altsrc) {
    img.src    = img.altsrc;
    img.altsrc = null;
  } 
}


function na_preload_img()
{ 
  var img_list = na_preload_img.arguments;
  if (document.preloadlist == null) 
    document.preloadlist = new Array();
  var top = document.preloadlist.length;
  for (var i=0; i < img_list.length-1; i++) {
    document.preloadlist[top+i] = new Image;
    document.preloadlist[top+i].src = img_list[i+1];
  } 
}

function na_change_img_src(name, nsdoc, rpath, preload)
{ 
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img) {
    img.altsrc = img.src;
    img.src    = rpath;
  } 
}


function bluring()
{ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
document. onfocusin=bluring; 




// 뉴게시판의 경우에는 new로 변경 
var type = "new"; 

String.prototype.cut = function(byte) 
{ 
    var string = this; 
    var history = 0; 
    var max = string.length; 
    for(var i = 0; i < max; i++) 
    { 
        if(string.charCodeAt(i) > 128) 
        { 
            history += 2; 
        } 
        else 
        { 
            history += 1; 
        } 
        if(history > byte) 
        { 
            string = string.substring(0, i) + "..."; 
            break; 
        } 
    } 
    return string; 
}


function getList(code, count, byte) 
{ 
    var no; 
    var date; 
    var subject; 
    var source = ""; 
    var history = 0; 

    if(type == "new") 
    { 
        var link = "/front/php/b/board_read_new.php?"; 
    } 
    else 
    { 
        var link = "/front/php/b/board_read.php?"; 
    } 

    var form = window.frames["iframe" + code].document.getElementById("list"); 
    var max = form.length; 

    for(var i = 0; i < max; i++) 
    { 
        if(form.elements[i].name == "no[]") 
        { 
            no = form.elements[i].value; 
        } 
        if(form.elements[i].name == "date[]") 
        { 
            date = form.elements[i].value.substr(5, 5); 
        } 
        if(form.elements[i].name == "subject[]") 
        { 
            subject = form.elements[i].value.cut(byte); 
        } 
        if(no && date && subject) 
        { 
            source += "<div class='list'> [" + date + "] <a href='" + link + "board_no=" + code + "&no=" + no + "'>" + subject + "</a></div>"; 
            no = ""; 
            date = ""; 
            subject = ""; 
            history += 1; 
        } 
        if(history == count) 
        { 
            break; 
        } 
    }

    if(!source) 
    { 
        source = "<div class='null'>등록된 글이 없습니다</div>"; 
    } 
    document.getElementById("board" + code).innerHTML = source; 
    return; 
}


function getList2(code, count, byte) 
{ 
    var no; 
    var date; 
    var subject; 
    var img; 
    var source = ""; 
    var history = 0; 

    if(type == "new") 
    { 
        var link = "/front/php/b/board_read_new.php?"; 
    } 
    else 
    { 
        var link = "/front/php/b/board_read.php?"; 
    } 

    var form = window.frames["iframe" + code].document.getElementById("list"); 
    var max = form.length; 

source += "<table cellpadding=0 cellspacing=0 width=412><tr>";

    for(var i = 0; i < max; i++) 
    { 
        if(form.elements[i].name == "no[]") 
        { 
            no = form.elements[i].value; 
        } 
        if(form.elements[i].name == "date[]") 
        { 
            date = form.elements[i].value.substr(5, 5); 
        } 
        if(form.elements[i].name == "subject[]") 
        { 
            subject = form.elements[i].value.cut(byte); 
        } 
        if(form.elements[i].name == "img[]") 
        { 
            img = form.elements[i].value; 
        } 
        

	if(no && date && subject && img) 
        { 

            source += "<td width='85' align='center' valign='top'><a href='" + link + "board_no=" + code + "&no=" + no + "'><img src='" + img + "' width='65' height='65' border='0' style='margin: 0 0 3 0;'></a><br>" + subject + "</td>"; 
           
	   no = ""; 
            date = ""; 
            subject = ""; 
            img = ""; 
            history += 1; 
        } 

        if(history == count) 
        { 
            break; 
        } 
    } 

       source += " </tr></table>"; 

    if(!source) 
    { 
        source = "<div class='null'>등록된 글이 없습니다</div>"; 
    } 
    document.getElementById("board" + code).innerHTML = "<table cellpadding=0 cellspacing=0 width=412><tr>"+source+"<tr></table>";
    
	return; 
}


function getList3(code, count, byte) 
{ 
    var no; 
    var date; 
    var subject; 
    var img; 
    var source = ""; 
    var history = 0; 

    if(type == "new") 
    { 
        var link = "/front/php/b/board_read_new.php?"; 
    } 
    else 
    { 
        var link = "/front/php/b/board_read.php?"; 
    } 

    var form = window.frames["iframe" + code].document.getElementById("list"); 
    var max = form.length; 

source += "<table cellpadding=0 cellspacing=0 width=320><tr>";

    for(var i = 0; i < max; i++) 
    { 
        if(form.elements[i].name == "no[]") 
        { 
            no = form.elements[i].value; 
        } 
        if(form.elements[i].name == "date[]") 
        { 
            date = form.elements[i].value.substr(5, 5); 
        } 
        if(form.elements[i].name == "subject[]") 
        { 
            subject = form.elements[i].value.cut(byte); 
        } 
        if(form.elements[i].name == "img[]") 
        { 
            img = form.elements[i].value; 
        } 
        

	if(no && date && subject && img) 
        { 

            source += "<td width='130' align='center' valign='top'><a href='" + link + "board_no=" + code + "&no=" + no + "'><img src='" + img + "' width='120' height='120' border='0' style='margin: 0 0 3 0;'></a><br>[" + date + "] " + subject + "</td>"; 
           
	   no = ""; 
            date = ""; 
            subject = ""; 
            img = ""; 
            history += 1; 
        } 

        if(history == count) 
        { 
            break; 
        } 
    } 

       source += " </tr></table>"; 

    if(!source) 
    { 
        source = "<div class='null'>등록된 글이 없습니다</div>"; 
    } 
    document.getElementById("board" + code).innerHTML = "<table cellpadding=0 cellspacing=0 width=320><tr>"+source+"<tr></table>";
    
	return; 
}