var _defw=1024;
var _pindex=new Array(),_tagindex=new Array();
var _cmdstr,_selector,_prop,_val;
var _elem,_len,_ct,_event,_action,_trueval,_num,_suffix;

function _splitstr(_cmdstr){
        _cmdstr=_cmdstr.replace(/\stop\s+/,' _top ');
        _cmdstr=_cmdstr.replace(/\stop$/,' _top');
        _pindex=_cmdstr.split(' ');
        _len=_pindex.length;
        _selector=_pindex[0];
        if (_selector != "screen" && _selector != "window")
          if (!document.getElementById(_selector) && window[_selector])
            _selector=window[_selector];
        _prop=_pindex[1];
        if (_len==3){
                _event=(_prop.substring(0,2)=='on')? true:false;
                _val=_pindex[2];
                if (!document.getElementById(_val) && window[_val])
                        _val=window[_val];
                else if (!_event){
                        if (_val.indexOf('*')!=-1){
                                _trueval=_val.substring(1);
                                _num=parseFloat(_trueval);
                                _suffix=_trueval.substring((_num+'').length);
                                _val=Math.round(_num*screen.width/_defw)+_suffix;
                        }
                }
        }
}

function check(_cmdstr){
        if (document.getElementById && document.getElementsByTagName){
                _splitstr(_cmdstr);
                if (_selector=='screen'){
                        if (_prop=='height')
                                return screen.height;
                        if (_prop=='width')
                                return screen.width;
                }
                if (_selector=='window')
                        return _checkwindow(_prop);
                else if (_prop=='height')
                        return document.getElementById(_selector).offsetHeight;
                else if (_prop=='width')
                        return document.getElementById(_selector).offsetWidth;
                else if (_prop=='_top')
                        return document.getElementById(_selector).offsetTop;
                else if (_prop=='left')
                        return document.getElementById(_selector).offsetLeft;
                else if (_prop=='src')
                        return document.getElementById(_selector)[_prop];
                else
                        return document.getElementById(_selector).style[_prop];
  }
}

function _checkwindow(_prop){
        if (_prop=='height'){
                if (window.innerHeight)
                        return window.innerHeight;
                else if (document.documentElement&&document.documentElement.clientHeight)
                        return document.documentElement.clientHeight;
                else if (document.body&&document.body.clientHeight)
                        return document.body.clientHeight;
        }
        else if (_prop=='width'){
                if (window.innerWidth)
                        return window.innerWidth;
                else if (document.documentElement&&document.documentElement.clientWidth)
                        return document.documentElement.clientWidth;
                else if (document.body&&document.body.clientWidth)
                        return document.body.clientWidth;
        }
}

function set(_cmdstr){
        if (document.getElementById && document.getElementsByTagName){
                _splitstr(_cmdstr);
                _num=0;
                if (document.getElementById(_selector)){
                        _elem=document.getElementById(_selector);
                        _setprop();
                }
                else
                        _setclass();
        }
}

function _setclass(){
        _tagindex=document.getElementsByTagName('*');
        _len=_tagindex.length;
        if (!_len && document.all){
                _tagindex=document.all;
                _len=_tagindex.length;
        }
        for (_ct=0;_ct<_len;_ct++){
                _elem=_tagindex[_ct];
                if (_elem.className == _selector){
                        _elem.number=_num;
                        _num++;
                        _setprop();
                }
        }
}

function _setprop(){
        if (_prop=="src")
                _elem.src=_val;
        else if (_event)
                _elem[_prop]=_val;
        else if (_prop=="class")
                _elem.className=_val;
        else if (_prop=="_top")
                _elem.style.top=_val;
        else
                _elem.style[_prop]=_val;
}
