function initclick() {
  if (!document.getElementById) return
  var imgOriginSrc;
  var imgTemp = new Array();
  var imgarr = document.getElementsByTagName('input');
  for (var i = 0; i < imgarr.length; i++) {
    if (imgarr[i].getAttribute('csrc')) {
        imgTemp[i] = new Image();
        imgTemp[i].src = imgarr[i].getAttribute('csrc');
        imgarr[i].onmousedown = function() {
            imgOriginSrc = this.getAttribute('src');
            this.setAttribute('src',this.getAttribute('csrc'))
        }
        imgarr[i].onmouseup = function() {
            this.setAttribute('src',imgOriginSrc)
        }
    }
  }
}

function clearDefault() {
  if (!document.getElementById) return
  var inputs = document.getElementsByTagName('input');
  for (var i=0;i<inputs.length;i++) {
    var input = inputs[i];
    if (("text" == input.getAttribute("type") || "password" == input.getAttribute("type")) && input.defaultValue) {
      input.onfocus = function() {
        if (this.defaultValue == this.value) this.value = '';
      }
      input.onblur = function() {
        if (this.value == '') this.value = this.defaultValue;
      }
    }
  }
}

function repositionHelp() {
  helpDiv = $('help');
//  helpDiv.innerHTML;
  newDiv = document.createElement('div');
  newDiv.innerHTML = helpDiv.innerHTML;
  document.body.removeChild(helpDiv);
  $('imagewrapper').insertBefore(newDiv,$('imagewrapper').firstChild);
  newDiv.setAttribute('id','help');
}

function helpSection() {
  repositionHelp(); // place the help section at the top of the site
  helpEffect = new fx.Height('help',{duration: 300, onComplete: function() {  
    if ($('help').style.height == "1px") {
      $('help').style.display = 'none';
    }
  }});
//  helpEffect.hide();
  if (!document.getElementById) return
  var helpSection = $('help');
  var helpLink = $('helplink'); // Modify the Help Link to display the help section
/*
  helpLink.onmouseover = function() {
    helpEffect.toggle();
  }
*/
  helpLink.onclick = function() {
    helpEffect.toggle();
    return false;
  }
/*
if (readCookie('help') != 'seenit') {
    window.setTimeout(function() {helpEffect.toggle() },400);
    createCookie('help','seenit',365);
  }
*/
}
function showlist(thelist) {
	if (document.getElementById) {
		var listCookie = readCookie('listCookie');
		if (listCookie) {
			var defList = listCookie;
		} else {
			var defList = 'websites';
		}
		if (!(thelist)) {
			var thelist = defList;
		}
		var listclass = 'toggler';
		var lists = document.getElementsByTagName("ul");
		for (var i=0; i < lists.length; i++) {
			var list = lists[i];
			var id = list.id;
			var css = list.className;
			if ((id != thelist) && (css == listclass)) {
				list.style.display = "none";
			}
			else {
				list.style.display = "block";
			}
		}
		createCookie('listCookie',thelist,'365');
	}
}
function hoverlinks() {
	if (!(document.getElementById)) return;
	var lists = document.getElementsByTagName("li");
	for (var i=0; i<lists.length; i++) {
		list = lists[i];
		if (list.getElementsByTagName("ul").length > 0) { // List item has child lists
			listAnchor = list.getElementsByTagName("a");
			sublist = list.getElementsByTagName("ul");
			sublist = sublist[0];
			if ('toggler' == sublist.className) {
				listAnchor[0].setAttribute('onclick',"showlist('"+sublist.id+"'); return false;");
			}
		}
	}
}
addEvent(window, 'load', initclick);
addEvent(window, 'load', clearDefault);
addEvent(window, 'load', helpSection);
//addEvent(window, 'load', showlist);
//addEvent(window, 'load', hoverlinks);

function popup(theURL,width,height) {
	window.open(theURL,'','width='+width+',height='+height+',location=no,menubar=no,toolbar=no,scrollbars=yes,resizeable=yes,left=200,top=100')
}
