﻿
function getSourceElement(evt) {
   if ( window.event) {
      return window.event.srcElement;
   } else {
      return evt.target;
   }
}

function mseOver (evt) {
	ths = getSourceElement(evt) ;
	ths.style.borderStyle = 'groove' ; //'ridge' ;
}

function mseDown (evt) {
	ths = getSourceElement(evt) ;
	ths.style.borderStyle = 'inset' ;
	ths.style.color = 'white' ;
}

function mseUp (evt,loc) {
	ths = getSourceElement(evt) ;
	if ( ths.style.borderStyle.substring(0,5) != 'inset' )
		return ;
	ths.style.borderStyle = 'outset' ;
	ths.style.color = 'black' ;
	if ( ths.getAttribute('hspLink') != null )
		document.location = ths.getAttribute('hspLink') ;
}

function mseOut (evt) {
	if ( ! getSourceElement )
		return ;
	ths = getSourceElement(evt) ;
	ths.style.borderStyle = 'outset' ;
}


//// THIS MUST BE EXECUTED AT THE BOTTOM OF <BODY>
function HspSetupHspDivs () {
	var allDivs = document.getElementsByTagName('DIV') ;
	for ( var idx=0; idx < allDivs.length; idx += 1 ) {
  	var div = allDivs[idx] ;
		if ( div.getAttribute('hspClass') == null )
			continue ;
		switch ( div.getAttribute('hspClass') )
		{
			case 'Button':
				div.onmouseover = mseOver ;
				div.onmousedown = mseDown ;
				div.onmouseup   = mseUp ; //function () {mseUp(div,'contest/form.htm');} ; // won't work in damn IE 6
				if ( div.getAttribute('hspLink') != null )
					div.onclick = null ;
				//else
				//	div.setAttribute('hspLink', div.onclick) ;
				div.onmouseout  = mseOut ; //function () { var fuckMs = new String; fuckMs=idx; mseOut(fuckMs); } ; // won't work in damn IE 6
				break ;
		}
	}
}
HspSetupHspDivs() ;