// JS for STA GETS
/**
	$Revision: 1.19.2.17 $
*/
// browser check ##########################################
var ns4 = (document.layers) ? 1 : 0; // Netscape 4
var op = (window.opera) ? 1 : 0; // Opera
var op7 = (navigator.userAgent.match(new RegExp("[\w\s ]*Opera.7[\w\s ]*"))) ? 1 : 0; // Opera 7
var op8 = (navigator.userAgent.match(new RegExp("[\w\s ]*Opera.8[\w\s ]*"))) ? 1 : 0; // Opera 8
var ie = (document.all && !op) ? 1 : 0; // MS Internet Explorer
var ie50 = (ie && !document.createEventObject) ? 1 : 0; // MS Internet Explorer 5.0
var moz = (document.getElementById && !ie) ? 1 : 0; // Mozilla/Gecko Browser
var saf = (navigator.userAgent.lastIndexOf("Safari") > 0);
var osx = (navigator.userAgent.lastIndexOf("OS X") > 0);

// quick navigation NAV2 language chooser #################
function showLang(elid,bol) {
	posi = bol ? '0px' : '-5000px';
	document.getElementById(elid).style.left = posi;
}

// Form handler generic ###################################
function genericForm() {
	this.myForm = "";
}
genericForm.prototype = new Object();

genericForm.prototype.recurseForm = function(obj) {
	var searchObj = obj.parentNode;
	if(searchObj.tagName == "FORM") {
		this.myForm = searchObj;
	} else {
		this.recurseForm(searchObj);
	}
}

genericForm.prototype.setHidden = function(id,val) {
	document.getElementById(id).value = val;
}

// submitForm generic -----
function FormSubmit(obj) {
	this.recurseForm(obj);
}

FormSubmit.prototype = new genericForm();

FormSubmit.prototype.submit = function() {
	this.myForm.submit();
}

FormSubmit.prototype.getName = function() {
	return this.myForm.name;
}

// caller functions
function submitForm(obj) {
	form = new FormSubmit(obj);
	form.submit();
}

function submitSearchForm(obj,obj2bChecked) {
	if(checkSearchStr(obj2bChecked,false)) {
		submitForm(obj);
	}
}

function checkSearchStr(obj2bChecked,onsub) { // onsub: if triggered via onsubmit(), NOT submit();
	var tmpObj = document.getElementById(obj2bChecked);
	var sstr = tmpObj.value;
	sstr = sstr.replace(/^\s+/g, '').replace(/\s+$/g, ''); // leading and trailing space
	tmpObj.value = sstr.replace(/\s+/,' '); // space in between
	if(sstr.length > 2) return true;
	else {
		try{alert(err_search);} catch(e){alert("Please enter more than 2 characters.");} // default value
		return false;
	}
}
	
function getFormName(obj) {
	sform = new FormSubmit(obj);
	return sform.getName();
}

// ####################################################################
// generic search function for <div> with specific CSS classes
function getDivElementsByClassName(classname) {
	var nodepts = window.document.getElementsByTagName("div");
	var count = nodepts.length-1; var hits = new Array(); var i=0;
	do {
		if(nodepts[count].className.indexOf(classname,0)!= -1) {
			hits[i++] = nodepts[count];
		}
	} while (count--);
	return hits;
}

// generic adds and replaced for CSS classes
function addCl(el,classname) {
	el.className += " "+classname;
}
function killCl(el,classname) {
	var expreg = new RegExp("[\w\s ]*"+" "+classname+"[\w\s ]*");
	el.className=el.className.replace(expreg, "");
}

// search all buttons and add a mouseover #############################
var btnClass = "btn_r"; // classes that all <div> buttons have
var divhover = "btn_rdivhover"; // class:hover of <div> button element
var ahover = "btn_rahover"; // class:hover of <a> button element

function ieHover() {
	var btnDivs = getDivElementsByClassName(btnClass);
	if(btnDivs.length<1) return; // no buttons in there? 
	var count = btnDivs.length-1;
	do {
		btnDivs[count].onmouseover=function() {
			this.style.backgroundPositionX = "100%";
			this.style.backgroundPositionY = "-50px";
			this.firstChild.style.backgroundPositionX = "0px";
			this.firstChild.style.backgroundPositionY = "-50px";
			/* addCl(this, divhover); IE6 bug
			addCl(this.firstChild, ahover); */
		}
		btnDivs[count].onmouseout=function() {
			this.style.backgroundPositionX = "100%";
			this.style.backgroundPositionY = "0px";
			this.firstChild.style.backgroundPositionX = "0px";
			this.firstChild.style.backgroundPositionY = "0px";
			/* killCl(this, divhover); IE6 bug
			killCl(this.firstChild, ahover); */
		}	
	} while (count--);
}

// search for all button elements
if(ie) window.attachEvent("onload", ieHover);


// #####################################################################
// print popup
function printPopup(anchor) {
	var printWin = window.open(anchor.href, "printWin", "dependent=yes,scrollbars=yes,menubar=yes,toolbar=no,status=no,location=no,locationbar=no,resizable=yes,width=560,height=520,top=20,left=20");
	printWin.focus();
}

// context help
function helpPopup(link) {
	var helpWin = window.open(link.href, "helpWin", "dependent=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,location=no,locationbar=no,resizable=yes,width=620,height=520,top=20,left=20");
	helpWin.focus();
}

// media detection switch ###############
function flashSwitch(el) {
	var idClass = "noflash";
	elem = document.getElementById(el);
	addCl(elem,idClass);
}

// select box navigation ###############
function goSelect(sel,val) {
	if(val && val!=0 && val!="false") document.location.href = val;
	else if(val==0 || val=="false") sel.selectedIndex=0;
}