/* Version $Id: rollovers.js,v 1.3 2005/04/25 09:56:10 cvs Exp $ */

document.write('<link rel="STYLESHEET" type="text/css" href="/include/css/dhtml.css">');
//PRINTVERSION
if (location.search.indexOf('print=true') > -1 || location.hash.indexOf('print=true') > -1) {
	document.write('<link rel="STYLESHEET" type="text/css" href="/include/css/print.css">');
}	

/* PIF: for IE
 * expects class(or classpart)-name "Submit" (nextSubmit or backSubmit)
 * replaces Submit with SubmitFOCUS or the other way round!
 */
function submitFOCUS(item) {
	if (document.all && item.className) {
		var currentClass = item.className;
		if (currentClass.indexOf('SubmitFOCUS') == -1) {
			item.className = currentClass.replace('Submit', 'SubmitFOCUS');
			}
		else {
			item.className = currentClass.replace('SubmitFOCUS', 'Submit');
			}
		}
	}
	
/** a style reference to a div
 *	@param id of div
 *	@param lay layername for n4.x - default is 'maincontent'
 * 	returns stylereference (or n4.x y layerref)
 */
function getStyleRef(id, lay) 
{
	if (document.layers) {
		return false;
	}
	else if (document.all) return document.all[id].style;
	else if (document.getElementById) return document.getElementById(id).style;
}
function setVisibility(id, show, lay) 
{
	var div = getStyleRef(id, lay);
	if (div) div.visibility = (show) ? 'visible' : 'hidden';
}

/** changes the class of an item, here a submit button
 *		call with <... onmouseover="roll_submit(this, true)" onmouseout="roll_submit(this);">
 *	@param item 
 *	@param dir	if true: over if !true: out
 */
function roll_submit(item, dir) 
{
	var currentClass = item.className;
	if (dir) {
		item.className = currentClass + " submitselected";
	}
	else {
		item.className = currentClass.substring(0, currentClass.lastIndexOf(' '));
	}
}

/** a reference to the image
 *	@param img imagename in name or id attribute of img-tag
 *	@param lay layername for n4.x - default is 'maincontent' - value "nodefault" for no layer at all!
 * 	returns imagereference
 */
function getImageRef(img, lay) {
	if (document.images) {
		if (document.layers) {
			//get layer in which the image is
			//register is in position static -> lay == 'nodefault'
			//printversion maincontent is in position static, so not a layer at all
			if (lay != 'nodefault' && !(location.search.indexOf('print=true')>0) )
				lay = (lay) ? 'document.layers["' + lay + '"].' : 'document.layers["maincontent"].'; //default
			else 
				lay = "";
			return eval(lay + 'document.images["' + img + '"]');
		}
		else return document.images[img];
	}
	else return document.getElementById(img);
}

/**	change the src of a given image 
 *	only used in crb step at the moment
 */
function roll_image(img, src) {
	imgRef = getImageRef(img);
	if (imgRef) imgRef.src = src;
}

/** swap arrow-images in various colors
 *	@param img imagename in name or id attribute of img-tag
 *	@dir direction of swapping - true or false
 *	@param lay layername for n4.x - default is 'maincontent', see also getImageRef
 */
function roll_b_w_t(img, dir, lay) { //Black to White
	if (getImageRef(img, lay) && loaded && arrow_w_t_s.src && arrow_b_t_s.src)
	getImageRef(img, lay).src = (dir) ? arrow_w_t_s.src : arrow_b_t_s.src;
}
function roll_b_y(img, dir, lay) { //Black to Yellow
	if (getImageRef(img, lay) && loaded && arrow_y_r_s.src && arrow_b_r_s.src)
	getImageRef(img, lay).src = (dir) ? arrow_y_r_s.src : arrow_b_r_s.src;
}
function roll_b_w(img, dir, lay) { //Black to White
	if (getImageRef(img, lay) && loaded && arrow_w_r_s.src && arrow_b_r_s.src)
	getImageRef(img, lay).src = (dir) ? arrow_w_r_s.src : arrow_b_r_s.src;
}
function roll_w_y(img, dir, lay) { //White to Yellow
	if (getImageRef(img, lay) && loaded && arrow_y_r_s.src && arrow_w_r_s.src)
	getImageRef(img, lay).src = (dir) ? arrow_y_r_s.src : arrow_w_r_s.src;
}
function roll_y_w_l(img, dir, lay) { //White to Yellow left
	getImageRef(img, lay).src = (dir) ? arrow_w_l_s.src : arrow_y_l_s.src;
}
function roll_w_b(img, dir, lay) { //White to Black
	if (getImageRef(img, lay) && loaded && arrow_b_r_s.src && arrow_w_r_s.src)
	getImageRef(img, lay).src = (dir) ? arrow_b_r_s.src : arrow_w_r_s.src;
}
function roll_w_b_l(img, dir, lay) { //White to Yellow left
	getImageRef(img, lay).src = (dir) ? arrow_b_l_s.src : arrow_w_l_s.src;
}
function roll_b_w_l(img, dir, lay) { //Black to White left
	if (getImageRef(img, lay) && loaded && arrow_w_l_s.src && arrow_b_l_s.src)
	getImageRef(img, lay).src = (dir) ? arrow_w_l_s.src : arrow_b_l_s.src;
}
function roll_b_w_m(img, dir, lay) { //Black to White MINI
	if (getImageRef(img, lay) && loaded && arrow_w_r_m.src && arrow_b_r_m.src)
	getImageRef(img, lay).src = (dir) ? arrow_w_r_m.src : arrow_b_r_m.src;
}
function roll_b_y_m(img, dir, lay) { //Black to White MINI
	if (getImageRef(img, lay) && loaded && arrow_y_r_m.src && arrow_b_r_m.src)
	getImageRef(img, lay).src = (dir) ? arrow_y_r_m.src : arrow_b_r_m.src;
}
function roll_b_w_m_l(img, dir, lay) { //Black to White MINI
	if (getImageRef(img, lay) && loaded && arrow_w_l_m.src && arrow_b_l_m.src)
	getImageRef(img, lay).src = (dir) ? arrow_w_l_m.src : arrow_b_l_m.src;
}


/** preloads images... */
function preloadImage(name, file) {
	eval(name + ' = new Image();');
	eval(name + '.src = "' + file + '";');
}
//Preload Arrows
var loaded = 0;

preloadImage('arrow_w_t_s','img/arrow_w_t_small.gif'); //small
preloadImage('arrow_w_r_s','img/arrow_w_r_small.gif'); //small
preloadImage('arrow_w_l_s','img/arrow_w_l_small.gif');
preloadImage('arrow_y_r_s','img/arrow_y_r_small.gif');
preloadImage('arrow_y_l_s','img/arrow_y_l_small.gif');
preloadImage('arrow_b_t_s','img/arrow_b_t_small.gif');
preloadImage('arrow_b_l_s','img/arrow_b_l_small.gif');
preloadImage('arrow_b_r_s','img/arrow_b_r_small.gif');

preloadImage('arrow_w_r_m','img/arrow_w_r_mini.gif'); //mini
preloadImage('arrow_w_l_m','img/arrow_w_l_mini.gif'); //mini
preloadImage('arrow_y_r_m','img/arrow_y_r_mini.gif');
preloadImage('arrow_y_l_m','img/arrow_y_l_mini.gif');
preloadImage('arrow_b_r_m','img/arrow_b_r_mini.gif');
preloadImage('arrow_b_l_m','img/arrow_b_l_mini.gif');

loaded = 1;
