﻿// JScript
function isUndefined(x) {
   if (typeof x == 'undefined')
       return true
   return false
}
var whitespace = " \t\n\r"
/**
 * characters to be escape/unescape: ', ", \r, \n
 **/
var _ESC_ = {}
_ESC_['"'] = escape('"')
_ESC_["'"] = escape("'")
_ESC_["\r"] = escape("\r")
_ESC_["\n"] = escape("\n")
_ESC_[">"] = escape(">")
_ESC_["<"] = escape("<")

var _UNESC_ = {}
_UNESC_[escape('"')] = '"'
_UNESC_[escape("'")] = "'"
_UNESC_[escape("\r")] = "\r"
_UNESC_[escape("\n")] = "\n"
_UNESC_[escape(">")] = ">"
_UNESC_[escape("<")] = "<"


/* *******************************************************************
**
** getElementValue(elm):
**
** SELECT:
**       return the selected option value or list of values of the
**       selected options.
**       If none is selected, then return either NONE_VALUE or [], 
**       depending on the SELECT is multiple or not.
** RADIO:
**       return the value assigned to the checked radio button 
**       if none of the radio buttons is checked, then return NONE_VALUE. 
** CHECKBOX:
**       If it contains one single checkbox, then return true if it is
**       checked and false otherwise.
**       If it contains multiple checkboxes (i.e., multiple checkboxes
**       having the same name), then return the list of the values 
**       of the checkboxes checked or [] if none is checked.
**       multiple checkboxes with the same name.
** TEXT/TEXTAREA and others:
**       return their corresponding value.
**
**********************************************************************/
var NONE_VALUE = "None"
function getElementValue(elm) {
   switch (elm.type) {
       case "select-one":
           if (elm.options.length < 1) return ""
           return elm.options[elm.options.selectedIndex].value
       case "select-multiple":
           var ar = new Array()
           if (elm.options.length < 1) return ar 
           for (var i=0; i<elm.options.length; i++)
                if (elm.options[i].selected) 
                    ar[ar.length] = elm.options[i].value
           return ar

       case "checkbox":
           return elm.checked 

       case "radio":
           // one should always set value when creating a radio button.
           if (elm.checked) return elm.value 
           return NONE_VALUE 

       default:  
           if (elm.type == [].type) {
               if (elm[0].type == "radio") {
                   for (var i=0; i<elm.length; i++)
                        if (elm[i].checked) return elm[i].value
                   return NONE_VALUE 
               } else if (elm[0].type == "checkbox") {
                   var ar = new Array()
                   for (var i=0; i<elm.length; i++) 
                      if (elm[i].checked) ar[ar.length] = elm[i].value 
                   return ar
               }
           } else { //TEXT, TEXTAREA 
               return elm.value
           }
   }
}

/* *******************************************************************
** setElementValue(elm, new_value)
**    This function works in a way that is approximately symmetric to
**    to the getElementValue(elm).
** SELECT:
**    Locate the option with a value equal to the new_value and make it
**    selected. If the option can not be located, then nothing is done.
** CHECKBOX:
**    Mark the checkbox either checked or unchecked based on the new_value.
**    If the new_value is false (i.e., new_value= 0 || "" || false), then
**    the checkbox is unchecked. Otherwise, the checkbox is checked.
** CHECKBOXes:
**    It tries to locate the checkbox whose value is equal to the new_value.
**    If located, then the checkbox located would be marked as checked.
**    Otherwise, it does nothing.
** RADIO:
**    Turn the radio button on or off based on the evaluation of the new_value  
**    given.
** RADIOS:
**    Turn on the radio button whose value equal to the new_value.
**    If the radio button can not be located, then it does nothing.
**     
**     
**********************************************************************/
function setElementValue(elm, new_value) {
   // add code by jgzhang at 2005-08-02 15:54.
   if (typeof elm == 'undefined') {
       alert ("Error: can't find the Element-- " + new_value)
       return
   }
   // add end.
   switch (elm.type) {
       case "select-one":
       case "select-multiple":
            for (var i=0; i<elm.options.length; i++) {
                 if (elm.options[i].value == new_value) {
                     elm.options.selectedIndex = i
                     break 
                 }
            }
            return 

       case "checkbox":
            if (new_value) 
                elm.checked = true
            else 
                elm.checked = false
            return 

       case "radio":
            if (new_value) 
                elm.checked = true
            else 
                elm.checked = false 
            return 

       default:
           if (elm.type == [].type) {
               if (elm[0].type == "radio") {
                   for (var i=0; i<elm.length; i++) 
                      if (elm[i].value == new_value) {
                          elm[i].checked = true
                          break
                      }
               // some code fixed by lyz at 2006-03-27 17:23
               } else if (elm[0].type == "checkbox") {
                   for (var j=0; j<elm.length; j++) {
                      elm[j].checked = false
                   }
                   if (new_value.constructor == __list_constructor__) {
                       for (var i=0;i<new_value.length;i++) {
                           var _new_value = new_value[i]
                           for (var j=0; j<elm.length; j++) {
                              if (elm[j].value == _new_value) {
                                  elm[j].checked = true
                                  break
                              }
                           }
                       }
                   }else {
                       for (var i=0; i<elm.length; i++) {
                          if (elm[i].value == new_value) {
                              elm[i].checked = true
                              break
                          }
                       }
                   }
               }
               // fixed end
           } else { //TEXT, TEXTAREA 
             elm.defaultValue = new_value
             elm.value = new_value
           }
  }
}

function ShowElementSmartly(elm, offHeight, offWidth){
   var offHeight = offHeight || 0
   var offWidth = offWidth || 0
   var currWinWidth, currWinHeight
   var selfWidth, selfHeight, selfLeft, selfTop

   if (document.body && document.body.clientWidth)
      currWinWidth = document.body.clientWidth + document.body.scrollLeft
   else
      currWinWidth = window.innerWidth
   
   if (document.body && document.body.clientHeight)
      currWinHeight = document.body.clientHeight + document.body.scrollTop
   else
      currWinHeight = window.innerHeight

   selfWidth = elm.offsetWidth 
   selfHeight = elm.offsetHeight
   if (document.all){
      selfLeft = Number(elm.style.left.split('px')[0])
      selfTop = Number(elm.style.top.split('px')[0])
   }else{
      selfLeft = elm.offsetLeft
      selfTop = elm.offsetTop
      var o = elm
      while (o.offsetParent!=null) { 
         oParent = o.offsetParent
         selfLeft += oParent.offsetLeft
         selfTop += oParent.offsetTop
         o = oParent
      }
   }
   
   if (selfLeft + selfWidth > currWinWidth){
      if (selfWidth > currWinWidth)
         elm.style.left = 1 + 'px'
      else if (selfLeft > selfWidth || selfLeft > currWinWidth - selfLeft)
         elm.style.left = (selfLeft - selfWidth+offWidth) + 'px'
   }
   
   if (selfTop + selfHeight > currWinHeight){
      if (selfTop > selfHeight || selfTop > currWinHeight - selfTop)
         elm.style.top = (selfTop - selfHeight+offHeight) + 'px'
   }
}


function ShowCmdMenu(menuId, showhide) {   
    var elm = document.getElementById(menuId)
    if (!showhide) {
        elm.style.visibility='hidden'
    } else {
        elm.style.left = mousePosX + "px"
        elm.style.top  = mousePosY + "px"
        elm.style.visibility='visible'
        ShowElementSmartly(elm)
    }
}

function CmdMenuHTMLCode(id,cmds,captions) {
    var cs = ""
    for (var i=0; i<cmds.length; i++) {
         var cmd = cmds[i]
         var caption = captions[i]
         var s='<tr><td valign=top align=left>'
         s +='<a href="javascript:ShowCmdMenu(\''+id+'\',false);'                         
         s +='handleMenuCommand(' +"'"+cmd+"'"+');">&nbsp;' + caption +'</a></td></tr>'
         cs +=s
    }
    cs +='<tr><td valign=top align=left>' 
    cs += '<a href="javascript:ShowCmdMenu(\''+id+'\',false)">&nbsp;Exit</a></td></tr>'

    var sh = '<div class="cmd_mnu_link" id=\"'+id+'\"'+" style="+'"'+"position: absolute;left:0px;top:0px;"
    sh +='width:130px;z-index:10;visibility:hidden;'
    sh +='border: 2px outset white;">'
    sh +='<table CELLSPACING=0 CELLPADDING=0 WIDTH="100%">'
    var doc = sh + cs + '</table></div>'
    return doc
}

var _hiddenselect_ = {}
function hideSelect(divObj) {
    if (!document.all)
        return
    if (!_hiddenselect_[divObj])
        _hiddenselect_[divObj] = []
    var selects = document.getElementsByTagName("SELECT")
    for (var i=0;i<selects.length;i++){
        var o = selects[i]
        var oLeft = o.offsetLeft
        var oTop = o.offsetTop
        while(o.offsetParent!=null) { 
            oParent = o.offsetParent 
            oLeft += oParent.offsetLeft
            oTop += oParent.offsetTop
            o = oParent
        }
        var divLeft = Number(divObj.style.left.split('px')[0])
        var divTop = Number(divObj.style.top.split('px')[0])
        if (isOverLap(oLeft,divLeft,oTop,divTop,oLeft+selects[i].clientWidth,divLeft+divObj.clientWidth,oTop+selects[i].clientHeight,divTop+divObj.clientHeight)) {
            if (elmIsHidden(selects[i], divObj)) {
                selects[i].style.visibility = 'hidden'
                _hiddenselect_[divObj][_hiddenselect_[divObj].length] = selects[i]
            }
        }
    }
}

function elmIsHidden(selectObj, divObj) {
   var divObj = divObj || new Object()
   var parentObj = selectObj
   while (parentObj) {
      if (parentObj == divObj || (parentObj.style.visibility && parentObj.style.visibility == 'hidden'))
           return false 
      parentObj = parentObj.parentElement
   }
   return true
}

function showSelect(divObj) {
   if (!document.all)
      return
   var selectList = _hiddenselect_[divObj]
   if (!selectList || !selectList.length)
      return
   for (var i=0;i<selectList.length;i++) {
       selectList[i].style.visibility = ''
   }
}

function isOverLap(leftS,leftD,topS,topD,rightS,rightD,bottomS,bottomD) {
   if (leftS > leftD && leftS < rightD)
      if (bottomS > topD && topS < bottomD)
         return true
   if (leftS < leftD && rightS > leftD)
      if (bottomS > topD && topS < bottomD)
         return true
   if (bottomS > topD && topS < bottomD)
      if (leftS > leftD && leftS < rightD)
         return true
   return false
}

function isEmpty(s) {
    if (typeof s == typeof {}) {
        var exists = false
        for (var k in s) {
            exists = true
        }
        return exists
    }else
        return (s == null || s.length == 0)
}

function isWhitespace(s) {
    if (typeof s != typeof 'a')
        return false
    if (isEmpty(s))
        return true
    for (var i=0;i<s.length;i++) {
        if (whitespace.indexOf(s.charAt(i)) == -1)
            return false
    }
    return true
}

var __test_o__ = new Object()
var __string_constructor__ = "".constructor
var __list_constructor__ = [].constructor
var __dict_constructor__ = {}.constructor
var __object_constructor__ = __test_o__.constructor
var __native_code__ = Object.constructor

var __STRING_QUOTE_SYM__ = '"'
function ToCodeString(v, quotestring) {
  switch (v.constructor) {      
      case __string_constructor__:
           if (quotestring) 
              return quoteString( kwSubstitute(v, _ESC_) )
           else
              return kwSubstitute(v, _ESC_)  
      case __list_constructor__:
           var ar=[] 
           for (var i=0; i<v.length;i++)
                ar[i] = ToCodeString(v[i],true)
           return '['+ar.join(',')+']'
           break
      case __dict_constructor__:
      case __object_constructor__:
           var ar=[]
           for (var k in v)
                if (v[k] != null) 
                    ar[ar.length] = quoteString(k) + ':' + ToCodeString(v[k], true) 
           return '{'+ar.join(',')+'}'
      default:
           return v
  }
}

function FromCodeString(s, isrecursive) {
  if (isrecursive) 
      var v = s
  else { 
      s=s.split('\n').join('')
      eval( "var v=" + s )
  }
  switch (v.constructor) {
      case __string_constructor__:
           return kwSubstitute(v, _UNESC_) 
      case __list_constructor__:
           for (var i=0; i<v.length;i++)
                v[i] = FromCodeString(v[i], true)
           return v 
           break
      case __dict_constructor__:
           for (var k in v)
                v[k] = FromCodeString(v[k], true)
           return v 
      default:
           return v
  }
}

function quoteString(s) {
    return __STRING_QUOTE_SYM__ + s + __STRING_QUOTE_SYM__ 
}

function MemDeepCopy(v) {
  switch (v.constructor) {
      case __string_constructor__:
           return ""+v 
      case __list_constructor__:
           var ret = []
           for (var i=0; i<v.length;i++)
                ret[i] = MemDeepCopy(v[i]) 
           return ret 
      case __dict_constructor__:
      case __object_constructor__:
      case __native_code__:
           var ret = {}
           for (var k in v)
                ret[k] = MemDeepCopy(v[k]) 
           return ret 
      default:
           if (typeof v == 'object') {
               var ret = {}
               for (var k in v)
                    ret[k] = MemDeepCopy(v[k]) 
               return ret 
           } 
           return v
  }
}

// keyword substitution.
// Input:
//    s: The source string
//   kw: The keyword dict object.
function kwSubstitute(s, kw) {
  if (!s || !kw) 
      return s
  var v = s || "" + s
  for (k in kw) 
      v = v.split(k).join(kw[k])
  return v
}

////

//In case we do care mouse location 
mousePosX=0
mousePosY=0
function getMouseXY(e) {
    if (document.all) {
    	if (!event) 
    	    return
    	mousePosX = event.clientX + document.body.scrollLeft
	    mousePosY = event.clientY + document.body.scrollTop    	    
       }
    else {
	   mousePosX = e.pageX
       mousePosY = e.pageY
    }
}
//document.onmousemove = getMouseXY

function getIE(e){
   var t=e.offsetTop;
   var l=e.offsetLeft;
   while(e=e.offsetParent){
   t+=e.offsetTop;
   l+=e.offsetLeft;
   }
   return [t,l]
}

function textEntrans(L) {
   return kwSubstitute(L, {'\t':'&nbsp;&nbsp;&nbsp;&nbsp;', '\n': '<br>', ' ': '&nbsp;'})         
}


function isDigit (c) {
    return ((c >= "0") && (c <= "9"))
}

function isEmpty(s) {
    if (typeof s == typeof {}) {
        var exists = false
        for (var k in s) {
            exists = true
        }
        return exists
    }else
        return (s == null || s.length == 0)
}

function isInteger(s) {
    var s = ''+s
    if (isEmpty(s))
       if (arguments.length == 1)
           return false
       else
           return (arguments[1] == true)
    for (var i = 0; i < s.length; i++) {
        var c = s.charAt(i)
        if (!isDigit(c))
            return false
    }
    return true
}

//function _InitScroll(_S1,_S2,_W,_H,_T){
// return "var marqueesHeight"+_S1+"="+_H+";var stopscroll"+_S1+"=false;var scrollElem"+_S1+"=document.getElementById('"+_S1+"');with(scrollElem"+_S1+"){style.width="+_W+";style.height=marqueesHeight"+_S1+";style.overflow='hidden';noWrap=true;}scrollElem"+_S1+".onmouseover=new Function('stopscroll"+_S1+"=true');scrollElem"+_S1+".onmouseout=new Function('stopscroll"+_S1+"=false');var preTop"+_S1+"=0; var currentTop"+_S1+"=0; var stoptime"+_S1+"=0;var leftElem"+_S2+"=document.getElementById('"+_S2+"');scrollElem"+_S1+".appendChild(leftElem"+_S2+".cloneNode(true));setTimeout('init_srolltext"+_S1+"()',"+_T+");function init_srolltext"+_S1+"(){scrollElem"+_S1+".scrollTop=0;setInterval('scrollUp"+_S1+"()',50);}function scrollUp"+_S1+"(){if(stopscroll"+_S1+"){return;}currentTop"+_S1+"+=1;if(currentTop"+_S1+"==(marqueesHeight"+_S1+"+1)) {stoptime"+_S1+"+=1;currentTop"+_S1+"-=1;if(stoptime"+_S1+"=="+_T/50+") {currentTop"+_S1+"=0;stoptime"+_S1+"=0;}}else{preTop"+_S1+"=scrollElem"+_S1+".scrollTop;scrollElem"+_S1+".scrollTop +=1;if(preTop"+_S1+"==scrollElem"+_S1+".scrollTop){scrollElem"+_S1+".scrollTop=0;scrollElem"+_S1+".scrollTop +=1;}}}";
//}

  function _InitScroll(_S1,_S2,_W,_H,_T)
  {
    var marqueesHeight_S1 = _H
	var stopscroll_S1 = false
	var scrollElem_S1 = document.getElementById(_S1)
	with(scrollElem_S1)
	{
	 style.width = _W
	 style.height = marqueesHeight_S1
	 style.overflow = 'hidden'
	 noWrap=true
	}
	scrollElem_S1.onmouseover = new Function(stopscroll_S1=true)
	scrollElem_S1.onmouseout = new Function(stopscroll_S1=false)
	var preTop_S1 = 0
	var currentTop_S1 = 0
	var stoptime_S1 = 0
	var leftElem_S2 = document.getElementById(_S2)
	scrollElem_S1.appendChild(leftElem_S2.cloneNode(true))
	setTimeout(init_srolltext_S1,_T)
	function init_srolltext_S1()
	{
	 scrollElem_S1.scrollTop=0
	 setInterval(scrollUp_S1,50)}
	 function scrollUp_S1()
	 {
	  if(stopscroll_S1)
	  {
	   return
	  }
	  currentTop_S1 +=1
	  if(currentTop_S1 == (marqueesHeight_S1+1)) 
	  {
	    stoptime_S1 += 1
	    currentTop_S1 -= 1
	    if(stoptime_S1 == _T/50) {
	      currentTop_S1 = 0
		  stoptime_S1 = 0
		 }
	  }
	  else
	  {
	    preTop_S1 = scrollElem_S1.scrollTop
		scrollElem_S1.scrollTop +=1
		if( preTop_S1 == scrollElem_S1.scrollTop)
		{
		scrollElem_S1.scrollTop=0
		scrollElem_S1.scrollTop +=1
		}
	  }
	}
  }


String.prototype.TrimBindLength = function(nLen, tp, suf) {
    var suf = (typeof suf == 'undefined' || suf == null)? '...': suf
    var tp = tp || 'right'
    tp = tp.toLowerCase()
    if (nLen==0)
        return ''
    var _tmpLen = 0
    var regEx = /^[\u4e00-\u9fa5\uf900-\ufa2d]+$/
    var _list = this.split('')
    var _s = ''
    var _sym = ''
    if (tp == 'right') {
        for (var i=0;i<_list.length;i++) {
            if (regEx.test(_list[i]))
                _tmpLen += 2
            else
                _tmpLen++
            if (_tmpLen > nLen) {
                return _sym + suf
            }
            if ((_tmpLen+suf.length) > nLen && _sym=='')
                _sym = _s
            _s += _list[i]
        }
    }else if (tp == 'left'){
        for (var i=_list.length-1;i>=0;i--) {
            if (regEx.test(_list[i]))
                _tmpLen += 2
            else
                _tmpLen++
            if (_tmpLen > nLen) {
                return suf + _sym
            }
            if ((_tmpLen+suf.length) > nLen && _sym=='')
                _sym = _s
            _s = _list[i] + _s
        }
    }else {
        return this
    }
    return _s
}

if (!self._PRELOADIMAGES_)
     var _PRELOADIMAGES_ = []
function preLoadImage(p, prefixPath) {
     if (p.constructor == __list_constructor__) {
         if (prefixPath.constructor == __list_constructor__){
           for (var i=0;i<p.length;i++) {
             preLoadImage(p[i], prefixPath[i])
           }    
         }else{         
           for (var i=0;i<p.length;i++) {
             preLoadImage(p[i], prefixPath)
           }  
          }
     }else {
         var _idx = _PRELOADIMAGES_.length
         _PRELOADIMAGES_[_idx] = new Image()
         if (prefixPath)
             p = prefixPath + p
         _PRELOADIMAGES_[_idx].src = p
     }
 }

// to drag a element
var __drag_element_info__ = {
    diffY: 0,
    diffX: 0,
    dragElement: null,
    srcElement: null,
    cursor: "",
    zIndex: 0
}

function startDragElement(srcelm, dragelm) {
    if (!srcelm)
        return
    getMouseXY()
    __drag_element_info__.diffY = mousePosY
    __drag_element_info__.diffX = mousePosX    
    if(srcelm.setCapture)
        srcelm.setCapture()
    __drag_element_info__.srcElement = srcelm
    __drag_element_info__.dragElement = dragelm || srcelm
    __drag_element_info__.cursor = srcelm.style.cursor
    __drag_element_info__.zIndex = __drag_element_info__.dragElement.style.zIndex
    srcelm.style.cursor = 'move'
    __drag_element_info__.dragElement.style.zIndex = 10000
    if (typeof event != 'undefined')
        event.cancelBubble=true
    ///****Add document function Firefox
    document.onmousemove = onDragElement
    document.onmouseup = endDragElement
    
}

function onDragElement() {
    var elm = __drag_element_info__.dragElement
    if (!elm)
        return
    getMouseXY()
    var tmpY = mousePosY - __drag_element_info__.diffY
    var tmpTop = parseInt(elm.style.top) + (tmpY)
    //alert("ddd"+elm.style.top)
    var tmpX = mousePosX - __drag_element_info__.diffX
    var tmpLeft = parseInt(elm.style.left) + (tmpX)    
    __drag_element_info__.diffY = mousePosY
    __drag_element_info__.diffX = mousePosX
    elm.style.top = tmpTop + 'px'
    elm.style.left = tmpLeft + 'px'
}

function endDragElement() {
    var dragelm = __drag_element_info__.dragElement
    var srcelm = __drag_element_info__.srcElement
    if (!dragelm || !srcelm)
        return
    document.onmousemove = getMouseXY
    document.onmouseup = ""
    srcelm.style.cursor = __drag_element_info__.cursor
    dragelm.style.zIndex = __drag_element_info__.zIndex
    if(srcelm.releaseCapture)
        srcelm.releaseCapture()
    __drag_element_info__.diffY = 0
    __drag_element_info__.diffX = 0
    __drag_element_info__.dragElement = null
    __drag_element_info__.srcElement = null
}

mousePosX=0
mousePosY=0
function getMouseXY() {
    if (document.all) {
        if (!event)
            return
        try{
            mousePosX = event.clientX + document.documentElement.scrollLeft
            mousePosY = event.clientY + document.documentElement.scrollTop
        }catch(e){}
    } else {
        var e = arguments[0] || arguments.callee.caller.arguments[0] || null
        if (!e)
            return
        try{
            mousePosX = e.pageX
            mousePosY = e.pageY
        }catch(e){}
    }
}

document.onmousemove = getMouseXY

if (!Array.prototype.indexOf) {
    Array.prototype.indexOf=function(o){
        for(var i=0;i<this.length;i++)
            if(this[i]==o)return i;
        return-1;
    }
}

function getFormAllElmsAndValue(form, isNoName) {
    var isNoName = isNoName || false
    var _legalTag = ['input']
    var _legalType = ['text', 'hidden']
    var _elms = form.elements
    var _doc  = ""
    for (var i=0;i<_elms.length;i++) {
        if (!_elms[i].tagName || _legalTag.indexOf(_elms[i].tagName.toLowerCase())<0)
            continue
        if (!_elms[i].type || _legalType.indexOf(_elms[i].type.toLowerCase())<0)
            continue
        if (_elms[i].name)
            continue
        if (!isNoName && !_elms[i].name)
            continue
        _doc += 'Name: '
        _doc += _elms[i].name + ' '
        _doc += ' -- Value: '+ _elms[i].value+'<br>'
    }
    return _doc
}

function showFormAllElmsAndValue(form, isNoName) {
    MyWin = window.open('','mywin','')
    MyWin.document.write(getFormAllElmsAndValue(form, isNoName))
    MyWin.focus()
}

function toggle(opID) 
{
    var obj = document.getElementById(opID)
	if ( obj.style.display != 'none' ) 
	{
		obj.style.display = 'none'
	}
	else {
		obj.style.display = ''
	}
}

function toggleImg(opID,ID)
{
    var obj = document.getElementById(opID)
    if (obj.style.display == "none")
        document.getElementById(ID).src = "../App_Themes/Default/images/collapsed.png"		
    else
        document.getElementById(ID).src = "../App_Themes/Default/images/expanded.png"		    
}

function getPosition(obj){
   var objThis = obj;
   var oBody = document.body;
   var oLeft = oTop = 0;
   while (objThis && objThis!=oBody){
     oLeft += objThis.offsetLeft;
     oTop += objThis.offsetTop;   
     objThis = objThis.offsetParent;
     }
   return [oLeft,oTop ]
   }


function SelectedAllBox(boo, chkid) {
    var chkid = chkid || "chk";
    var frm = document.forms[0]
    var elm = frm[chkid]
    if (!elm)
        return
    if (typeof elm.length == 'undefined') {
        elm.checked = boo
    }else {
        for (var i=0;i<elm.length;i++) {
            elm[i].checked = boo
        }
    }
}

function SelectedSingleBox(boo, chkid, chkallid) {
    var chkid = chkid || "chk";
    var chkallid = chkallid || "chkall";
    var elm = document.getElementById(chkallid)
    if (!elm)
        return
    if (!boo)
        elm.checked = boo
    else {
        var frm = document.forms[0]
        var elms = frm[chkid]
        if (!elms)
            return
        if (typeof elms.length == 'undefined') {
            elm.checked = elms.checked
        }else {
            for (var i=0;i<elms.length;i++) {
                if (!elms[i].checked) {
                    elm.checked = elms[i].checked
                    return
                }
            }
            elm.checked = true;
        }
    }
}

function CheckHasSelected(chkid) {
    var chkid = chkid || "chk";
    var frm = document.forms[0]
    var elm = frm[chkid]
    if (elm) {
        if (typeof elm.length == 'undefined') {
            if (!elm.checked) {
                alert ('You should choose at least one item.')
                return false
            }else {
                return elm.checked
            }
        }else {
            for (var i=0;i<elm.length;i++) {
                if (elm[i].checked)
                    return true
            }
        }
    }
    alert ('You should choose at least one item.')
    return false
}
if(typeof(HTMLElement)!="undefined" && !window.opera) 
{ 
    HTMLElement.prototype.__defineGetter__("outerHTML",function() 
    { 
        var a=this.attributes, str="<"+this.tagName, i=0;for(;i<a.length;i++) 
        if(a[i].specified) 
            str+=" "+a[i].name+'="'+a[i].value+'"'; 
        if(!this.canHaveChildren) 
            return str+" />"; 
        return str+">"+this.innerHTML+"</"+this.tagName+">"; 
    }); 
    HTMLElement.prototype.__defineSetter__("outerHTML",function(s) 
    { 
        var r = this.ownerDocument.createRange(); 
        r.setStartBefore(this); 
        var df = r.createContextualFragment(s); 
        this.parentNode.replaceChild(df, this); 
        return s; 
    }); 
    HTMLElement.prototype.__defineGetter__("canHaveChildren",function() 
    { 
        return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase()); 
    }); 
} 

function   isIE(){ 
//alert("")
//alert(window.navigator.userAgent)
//alert(window.navigator.userAgent.toString().toLowerCase().indexOf("msie"))
      if   (window.navigator.userAgent.toString().toLowerCase().indexOf("msie") >=1)
        return   true;
      else
        return   false;
}
//alert(isIE())

if(!isIE()){   //firefox   innerText   define
      HTMLElement.prototype.__defineGetter__(           "innerText",
        function(){
          var   anyString   =   "";
          var   childS   =   this.childNodes;
          for(var   i=0;   i <childS.length;   i++)   {
            if(childS[i].nodeType==1)
              anyString   +=   childS[i].tagName=="BR"   ?   '\n'   :   childS[i].innerText;
            else   if(childS[i].nodeType==3)
              anyString   +=   childS[i].nodeValue;
          }
          return   anyString;
        }
      );
      HTMLElement.prototype.__defineSetter__(           "innerText",
        function(sText){
          this.textContent=sText;
        }
      ); 
} 