function onoff(id) {
var item = document.getElementById(id);
if(item.style) {
	if(item.style.display == "none"){ item.style.display = ""; 
	}else {item.style.display = "none"; 
	}
}else{ item.visibility = "show"; item.style.zIndex = "3"; 
}
}

function on(){
var arguments = on.arguments;
var item = null;
for (var i=0; i < arguments.length; i++)
{
item = document.getElementById(arguments[i]);
if(item.style) {
	if(item.style.display == "none"){ item.style.display = ""; 
	}
}else{ item.visibility = "show"; item.style.zIndex = "99"; 
}
}
}

function off(){
var arguments = off.arguments;
var item = null;
for (var i=0; i < arguments.length; i++)
{
item = document.getElementById(arguments[i]);
if(item.style) {
	item.style.display = "none";
}else{ item.visibility = "none";
}
}
}

function ShowOrHide(d1, d2) {
	  if (d1 != '') onoff(d1);
	  if (d2 != '') onoff(d2);
}

function popwin(url,title){
var newwin = window.open(url, title, 'width=450,height=350,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no');
newwin.focus();
}

function movehtml(from,to){
document.getElementById(to).innerHTML=document.getElementById(from).innerHTML;
document.getElementById(from).innerHTML = '';
}
  
function posinwin(thediv,theoffset){
var winheight = document.documentElement.clientHeight;
var divpos = document.getElementById(thediv).offsetTop + theoffset;

if(divpos > winheight) return true;

}

function getdivheight(thediv){
var winheight = document.documentElement.clientHeight;
var divheight = document.getElementById(thediv).offsetHeight;
return divheight;
}

function mindocwrapheight(offset){
var main = document.getElementById('main');
var head = document.getElementById('head');
var docwrap = document.getElementById('docwrap');
var mainheight = main.offsetHeight;
var headheight = head.offsetHeight;
var docwrapheight = docwrap.offsetHeight;
if(docwrapheight + headheight < mainheight) docwrap.style.height = mainheight - offset - headheight +'px';
//alert(docwrapheight + (mainheight - headheight - docwrapheight));
//docwrap.style.height = docwrapheight + (mainheight - headheight - docwrapheight);
}

function refresh(){
document.location=document.location;
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function moveIt(obj, mvTop, mvLeft, minTop, minLeft) {
	obj.style.position = "absolute";
	if(mvTop) obj.style.top = mvTop+'px';
	if(mvLeft) obj.style.left = mvLeft+'px';
	if(minTop > mvTop) obj.style.top = minTop+'px';
	if(minLeft > mvLeft) obj.style.left = minLeft+'px';
}

function external() {
 if (document.getElementsByTagName) {
  var i, a;
  a = document.getElementsByTagName('a');
  for (i in a) {
   if (a[i].getAttribute('href') && 
       a[i].getAttribute('rel') == 'external') a[i].target = '_blank';
  }
 }
}

function getElementsByClass(searchClass,tag,node) {
	var classElements = new Array();
	var i, j;
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function alternateclass(sourceclass,altclass,tag){
var Elements = getElementsByClass(sourceclass,tag);
var i;
if(Elements){
	for(i = 0; i < Elements.length; i++){
		if(i % 2 == 0){
       	Elements[i].className = sourceclass;
     	}else{
       	Elements[i].className = altclass;
     	}
	}
 }
}

function tasks(){
alternateclass('altright','altleft','img');
}
