function isIE()
{
  return window.event?true:false;
}

function GetPageSize()
{
  var width = window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
  var height = isIE()?document.body.clientHeight:document.documentElement.offsetHeight;
  return [width,height];
}

function GetWindowSize()
{
  var width = window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
  var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;;
  return [width,height];
}


function GetScrollPosition()
{
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];

}

function DoNothing()
{
  event.returnValue = false;
  event.cancelBubble = true;
  return false;
}

function DoTopicOptionMouseOver(obj)
{
  var color = obj.style.color;
  obj.setAttribute('previousColor', color);
  obj.style.color = 'red';
}

function DoTopicOptionMouseOut(obj)
{
  var color = obj.getAttribute('previousColor');
  if(!color) color = '';
  obj.style.color = color;
}

function DoTopicOptionClick(obj)
{
  obj.style.textDecoration  = (obj.style.textDecoration=='line-through')?'':' line-through ';
}

function DoSubmitPostForm()
{
  var form=document.getElementById('formPostEditor');
  form.content.value = HTMLEditorGetContent();
  if(form.title.value=='')
  {
    alert('No title specified');
    return false;
  }
  form.submit();
}

function DoAssignEvent(obj,evt,fun)
{
  if( window.attachEvent)
  {
    // for MS IE
    obj.attachEvent('on'+evt, fun);
  }
  else if(window.addEventListener)
  {
    // for W3c
    obj.addEventListener(evt, fun, false);
  }
}


function DoBulkSelect(checkbox)
{
  var objs = document.getElementsByName(checkbox.name);
  if(objs.length<=1) return ;
  for(var i=0;i<objs.length;i++)
  {
    if(objs[i].value==checkbox.value) continue;
    objs[i].checked = checkbox.checked;
  }
}

function DoBulkAction(obj)
{
  var ids='0';
  var objs = document.getElementsByName( obj.getAttribute('_idsname'));
  for(var i=0;i<objs.length;i++)
  {
    if(objs[i].checked && objs[i].value>0)
    {
      ids += ',' + objs[i].value ;
    }
  }
  
  if(ids=='0')
  {
    alert("No Item Selected");
    return false;
  }
  
  if(confirm('Sure to operate?'))
  {
    
    var f=document.getElementById('mainForm');
    f.elements['action'].value = obj.getAttribute('_action');
    f.elements['ids'].value = ids;
    f.submit();
  }
}


function DoPasswordCheck(obj1,obj2)
{
  var obj1=document.getElementById(obj1);
  var obj2=document.getElementById(obj2);
  if(!(obj1 && obj2 && obj1.value==obj2.value))
  {
    alert('Password Not Match');
    return false;
  }
  return true;
}
