var d;

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

toggle_visibility('waitDiv', 1);

function xoopsGetElementById(id) {
	return document.getElementById(id);
}

function toggle_visibility(id, flag)  {

if (xoopsGetElementById(id)) {
        xoopsGetElementById(id).style.visibility = (flag) ? 'visible' : 'hidden';
        }
}

function showImgSelected(imgId, selectId, imgDir) {
imgDom     = xoopsGetElementById(imgId);
selectDom  = xoopsGetElementById(selectId);
}


function justReturn() {
        return;
}


function openWithSelfMain(url,name,width,height) {
var options = "width=" + width + ",height=" + height + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no";

new_window = window.open(url, name, options);
window.self.name = "main";
new_window.moveTo(((screen.availWidth/2)-(width/2)),((screen.availHeight/2)-(height/2)))
new_window.focus();
}


function setElementColor(id, color) {
        xoopsGetElementById(id).style.color = "#" + color;
}


function setElementFont(id, font) {
        xoopsGetElementById(id).style.fontFamily = font;
}


function setElementSize(id, size) {
        xoopsGetElementById(id).style.fontSize = size;
}


function changeDisplay(id) {
var elestyle = xoopsGetElementById(id).style;

if (elestyle.display == "") {
        elestyle.display = "none";
        } else {
                elestyle.display = "block";
        }
}

function toggleDisplay(id) {
var elestyle = xoopsGetElementById(id).style;

if (elestyle.display == "block" || elestyle.display == "") {
        elestyle.display = 'none';
        } else {
                elestyle.display = "block";
        }
}

function setVisible(id) {
        xoopsGetElementById(id).style.visibility = "visible";
}


function setHidden(id) {
        xoopsGetElementById(id).style.visibility = "hidden";
}


function makeBold(id) {
var eleStyle = xoopsGetElementById(id).style;

if (eleStyle.fontWeight != "bold") {
        eleStyle.fontWeight = "bold";
        } else {
                eleStyle.fontWeight = "normal";
        }
}


function makeItalic(id) {
var eleStyle = xoopsGetElementById(id).style;

if (eleStyle.fontStyle != "italic") {
        eleStyle.fontStyle = "italic";
        } else {
                eleStyle.fontStyle = "normal";
        }
}


function makeUnderline(id) {
var eleStyle = xoopsGetElementById(id).style;

if (eleStyle.textDecoration != "underline") {
        eleStyle.textDecoration = "underline";
        } else {
                eleStyle.textDecoration = "none";
        }
}


function appendSelectOption(selectMenuId, optionName, optionValue) {
var selectMenu = xoopsGetElementById(selectMenuId);
var newoption  = new Option(optionName, optionValue);

selectMenu.options[selectMenu.length] = newoption;
selectMenu.options[selectMenu.length].selected = true;
}


function disableElement(target) {
var targetDom = xoopsGetElementById(target);

if (targetDom.disabled != true) {
        targetDom.disabled = true;
        } else {
                targetDom.disabled = false;
        }
}


function xoopsCheckAll(formname, switchid) {
var ele = document.forms[formname].elements;
var switch_cbox = xoopsGetElementById(switchid);

for (var i=0; i<ele.length; i++) {
        var e = ele[i];
        if ( (e.name != switch_cbox.name) && (e.type == 'checkbox') ) {
                e.checked = switch_cbox.checked;
        }
}
}


function setRequired(arguments) {
var size = setRequired.arguments.length;
for (i=0; i<size; i++) {
        var id    = setRequired.arguments[i];
        var field = xoopsGetElementById(id);
        if (field.value == "") {
                alert("????????? ???? ???? ? ?????????." + setRequired.arguments[i]);
                field.focus();
                return false;
        }
}
}

function toggle_dynmenu(id)  {
        if (xoopsGetElementById(id + '_sub')) {
                var dom = xoopsGetElementById(id + '_sub').style.display;
                if (dom == 'none') {
                        xoopsGetElementById(id + '_sub').style.display = 'inline';
                        xoopsGetElementById(id + '_sign').src   = 'img/minus.gif';
                        xoopsGetElementById(id + '_folder').src = 'img/tree_open.gif';
                        } else if (dom == 'inline') {
                                xoopsGetElementById(id + '_sub').style.display = 'none';
                                xoopsGetElementById(id + '_sign').src   = 'img/plus.gif';
                                xoopsGetElementById(id + '_folder').src = 'img/tree_close.gif';
                        }
        }
}

function wt0(dyn){
    var names, head, brow;
    name=d;
    names = name.split(',')[0].split('/');
    head=names[names.length-1];
    brow='';
    huy=names.length-3;
    for(var i=0; i<huy; i++)
    {brow=brow+'<img src="img/huy" width="8" height="1" hspace="3" align="absmiddle">';}
    brow=brow+'<a href="javascript:toggle_dynmenu('+dyn+');"><img id='+dyn+'_sign height=9 src="img/minus.gif" width=9 align=absMiddle border=0 name='+dyn+'_sign></a><img src="img/tree_open.gif" alt="" name='+dyn+'_folder hspace="3" align="absmiddle" id='+dyn+'_folder><a href="'+name+'">'+head+'</a><span id='+dyn+'_sub style="DISPLAY: inline" name="'+dyn+'_sub"><br>';

    document.write(brow);
}

function wto(dyn){
    var names, head, brow;
    name=d;
    names = name.split(',')[0].split('/');
    head=names[names.length-1];
    brow='';
    huy=names.length-3;
    for(var i=0; i<huy; i++)
    {brow=brow+'<img src="img/huy" width="8" height="1" hspace="3" align="absmiddle">';}
    brow=brow+'<a href="javascript:toggle_dynmenu('+dyn+');"><img id='+dyn+'_sign height=9 src="img/minus.gif" width=9 align=absMiddle border=0 name='+dyn+'_sign></a><img src="img/tree_open.gif" alt="" name='+dyn+'_folder hspace="3" align="absmiddle" id='+dyn+'_folder><a href="'+name+'"><font color=darkyellow>'+head+'</font></a><span id='+dyn+'_sub style="DISPLAY: inline" name="'+dyn+'_sub"><br>';

    document.write(brow);
}

function wt1(name){
    var names, head, brow;
    name=d+'/'+name;
    names = name.split(',')[0].split('/');
    head=names[names.length-1];
    brow='';
    huy=names.length-3;
    for(var i=0; i<huy; i++)
    {brow=brow+'<img src="img/huy" width="8" height="1" hspace="3" align="absmiddle">';}
    brow=brow+'<img src="img/huy" width="9" height="1" align="absmiddle"><img src="img/d_tree_close.gif" hspace="3" align="absmiddle">';
    brow=brow+'<a href="'+name+'">'+head+'</a><br>';
    document.write(brow);
}

function wtJ(name,count,date){
    var names, head, brow;
    name=d+'/'+name;
    names = name.split(',')[0].split('/');
    head=names[names.length-1];
    brow='';
    huy=names.length-3;
    for(var i=0; i<huy; i++)
    {brow=brow+'<img src="img/huy" width="8" height="1" hspace="3" align="absmiddle">';}
    brow=brow+'<img src="img/huy" width="9" height="1" align="absmiddle"><img src="img/d_tree_close.gif" hspace="3" align="absmiddle">';
    brow=brow+'<a href="'+name+'">'+head+' ('+count+')<br>'+date+'</a><br>';
    document.write(brow);
}

function wti(name){
    var names, head, brow;
        name=d+'/'+name;
    names = name.split(',')[0].split('/');
    head=names[names.length-1];
    brow='';
    huy=names.length-3;
    for(var i=0; i<huy; i++)
    {brow=brow+'<img src="img/huy" width="8" height="1" hspace="3" align="absmiddle">';}
    brow=brow+'<img src="img/huy" width="9" height="1" align="absmiddle"><img src="img/tree_open.gif" hspace="3" align="absmiddle">';
    brow=brow+'<a href="'+name+'"><font color=darkyellow>'+head+'</font></a><br>';
    document.write(brow);
}

function wt2(){
	document.write('</span><br>');
}

function wt3(dyn){
	document.write('</span><br>');
toggle_dynmenu(dyn);
}
var pushpop= new Array();
pushpop[0]='HELL';

function p(){
        pushpop[pushpop.length]=d;
        }

function o(){
        d=pushpop[pushpop.length-1];
        pushpop.splice(pushpop.length-1,1);
        }

function wf(img,sx,sy){
dir=d;
names = img.split(',')[0].split('.');
head=names[0]+'.tumb.'+names[1];
document.write('<a href="#" onClick="MM_openBrWindow(\'index.php?dir='+dir+'/'+img+'\',\'_blank\',\'scrollbars=yes,resizable=yes,width='+sx+',height='+sy+'\')"><img SRC="'+dir+'/'+head+'" hspace="20" vspace="20" border="0" style="border:2px #222222 solid;"></a> ');
}


