String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/gi, "");
}

String.prototype.replaceAll = function(str1, str2)
{
    var temp_str = this.trim();
    temp_str = temp_str.replace(eval("/" + str1 + "/gi"), str2);
    return temp_str;
}


var _currentId = 1;


// ÅÇ¸Þ´º
var tab = {
    on : '_over',
    imgType :'.gif',
    menu : function(obj, onName, imgType){
        if(onName!=undefined){this.on = onName}
        if(imgType!=undefined){this.imgType = '.'+imgType}

        var pObj = obj.parentNode;
        var child = this.getChildNodeIndex(pObj);
        var n = parseInt(obj.id.replace('tab'+child[0], ""));

        for(var i=1;i<=child[1];i++){
            if(i==n){

                _currentId = i;
                try{

                    $('tab'+child[0]+i).src = $('tab'+child[0]+i).src.replace(this.on+this.imgType, "").replace(this.imgType,"")+this.on+this.imgType;
                }catch(e){}

                try{
                    $('div'+child[0]+i).style.display = '';
                }catch(e){}
            }
            else{
                try{
                    $('tab'+child[0]+i).src = $('tab'+child[0]+i).src.replace(this.on+this.imgType, "").replace(this.imgType,"")+this.imgType;
                }catch(e){}
                try{
                    $('div'+child[0]+i).style.display = 'none';
                }catch(e){}
            }
        }
    },

    getChildNodeIndex : function(obj){
        var divObj = null;
        var cnt = 0;
        var divCnt = 0;
        var index = new Array();
        index[0] = this.getRandomCode(3);

        if(obj.nodeName == 'A'){
            obj = obj.parentNode;
        }
        if(obj.className == 'tab_buttons_area'){

            obj = obj.parentNode;
        }



        for(var i=0;i<=obj.childNodes.length;i++){
            try{
                if(obj.childNodes[i].nodeType == 1){

                    if(obj.childNodes[i].className == 'tab_buttons_area'){
                        var objImage = obj.childNodes[i];

                        for(var j=0;j<objImage.childNodes.length;j++){

                            if(objImage.childNodes[j].nodeType==1){
                                if(objImage.childNodes[j].nodeName=='IMG'){
                                    cnt++;
                                    objImage.childNodes[j].id = 'tab'+index[0]+cnt;

                                }else if(objImage.childNodes[j].nodeName=='A'){
                                    cnt++;
                                    objImage.childNodes[j].firstChild.id = 'tab'+index[0]+cnt;
                                }
                            }
                        }
                    }
                    else if(obj.childNodes[i].className == 'tab_div_contents')
                    {


                        var divObj = obj.childNodes[i];


                        for(var j=0;j<divObj.childNodes.length;j++){
                            if(divObj.childNodes[j].nodeType==1 && divObj.childNodes[j].nodeName=="DIV"){
                                divCnt++;
                                divObj.childNodes[j].id = 'div'+index[0]+divCnt;
                            }
                        }
                    }
                }
            }catch(e){}
        }

        index[1] = cnt;
        return index;
    },

    getRandomCode : function(iLength) {
        var arr="0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",");
        var randomStr = "";
        
        for (var j=0; j<iLength; j++) {
            randomStr += arr[Math.floor(Math.random()*arr.length)];
        }
        return randomStr;
    }
}


function over(obj){
	obj.src = obj.src.replace("_over", "").replace(".gif", "_over.gif");
}
function out(obj){
	obj.src = obj.src.replace("_over.gif", ".gif");
}


