//FUNCTION initRollOvers
function initRollOvers(){
	if(!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++){
		if(aImages[i].className.indexOf('ahover') != -1){
			var src = aImages[i].getAttribute('src');
			var isov = src.substring(0,src.lastIndexOf('.'));
			
			if( isov.substring(isov.length-3, isov.length) != "_ov" && isov.substring(isov.length-4, isov.length) != "_off"){
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_ov'+ftype);
	
				aImages[i].setAttribute('hsrc', hsrc);
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				
				aImages[i].onmouseover = function(){
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}
				aImages[i].onmouseout = function(){
					if(!sTempSrc) sTempSrc = this.getAttribute('src').replace('_ov'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
			}
		}		
	}
}


//FUNCTION enableFlash (for IE6.5+ on winXP SP2 KB912945)
function enableFlash(){
	if(navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.toLowerCase().indexOf('win') != -1){
		var all = document.all;
		var lst = new Array();
		var len = all.length;
		for(var i = 0; i < len; i++) {
			var obj = all[i];
			if(obj && obj.nodeName) {
				switch(obj.nodeName.toLowerCase()) {
					case "object":
					case "applet":
					case "embed":
						lst[lst.length] = obj;
						break;
					default:
				}
			}
		}
		for(var i = 0; i < lst.length; i++) {
			lst[i].outerHTML += "";
		}
		lst = null;
	}
}


//FUNCTION commonPop
//pFile = popup File
//pWidth = popup Width [optional]
//pHeight = popup Height [optional]
//pStatus = popup Features[optional]
function commonPop(pFile, pWidth, pHeight,pStatus){
	//var fName = pFile.substring(pFile.lastIndexOf('/')+1, pFile.length);
	var wName = "";
	if(pWidth == null){ pWidth = 700}
	if(pHeight == null){ pHeight = 600}
	if(pStatus == null){ pStatus = 'yes';}
	if(pWidth > screen.availWidth){
		pWidth = screen.availWidth;
		pStatus = 'yes';
	}
	if(pHeight > screen.availHeight-50){
		pHeight = screen.availHeight-50;
		pStatus = 'yes';
	}
	var wFeatures= 'menubar=no,scrollbars='+pStatus+',resizable='+pStatus+',width='+pWidth+',height='+pHeight;
	void(window.open(pFile, wName, wFeatures));
}


//FUNCTION moveOpener
//pFile = file
function moveOpener(pFile){
	if(opener){
		void(opener.location.href = pFile);
	}else{
		void(document.location.href = pFile);
	}
}


//FUNCTION spaceCleaner
function spaceCleaner(){
	var o = document.getElementById('logtag');
	if(o){
		var oChilds = o.childNodes;
		for (i=0; i < oChilds.length; i++){
			if(oChilds[i].tagName == 'IMG'){oChilds[i].style.display = 'none';}
		}
	}
}


//FUNCTION blockopener
function blockopen(id) {
    document.getElementById(id).style.display = "block";
    }
function blockhide(id) {
    document.getElementById(id).style.display = "none";
    }


//FUNCTION Back2Top
function doBackScroll() {
    var pos = getScrollPosition();
    window.scrollTo(Math.max(Math.floor(pos.x / 2),0), Math.max(Math.floor(pos.y - (pos.y / 5)),0));
    if (pos.x > 0 || pos.y > 0) {
        window.setTimeout("doBackScroll()", 35);
        return false;
    }
}

function getScrollPosition() {
    var obj = new Object();
    obj.x = document.body.scrollLeft || document.documentElement.scrollLeft;
    obj.y = document.body.scrollTop || document.documentElement.scrollTop;
    return obj;
}

function addListener(elem, eventType, funcRef, capture) {
    if(!elem) { return false; }

    if(elem.addEventListener) {
        elem.addEventListener(eventType, funcRef, capture);
    } else if(elem.attachEvent) {
        elem.attachEvent('on' + eventType, funcRef);
    } else {
        return false;
    }
    return true;
}

function addLoadListener(e) {
    addListener(document.getElementById('Back2Top'), 'click', doBackScroll, false);
}

addListener(window, 'load', addLoadListener, false);


//form functions
function submit(){ 
document.forms[0].submit(); 
}
function reset(){ 
document.forms[0].reset(); 
}

function submitNum(num){
document.forms[parseInt(num)].submit(); 
}

function formClear() {
document.forms[0].PAGE.value = "";
document.forms[0].submit();
}

var count;
function CheckboxChecked(check){
for(count = 0; count < document.form1.c1.length; count++){
document.form1.c1[count].checked = check;
}
}
var count;
function CheckboxChecked2(check){
for(count = 0; count < document.form2.cb3.length; count++){
document.form2.cb3[count].checked = check;
}
}


//call on init functions
initRollOvers();
enableFlash();
spaceCleaner();