function focusFirstFormElement(focusableElement) {
	try {
		var f = document.forms[0];		
		if(f==null) {
			throw "No Form found!";
		}
		var focusDone = false;	
		var regex = new RegExp(/^select/); //jedes Auswahlfeld (single,multi)
		if(focusableElement!='') {
			//alert(focusableElement);
			try {
				var e = eval("f."+focusableElement);
				if(e.type == "text" || regex.test(e.type)) {
					e.focus();
					focusDone = true;
				}
			}
			catch(exc) {
			}
		}
		var i = 0;
		while(i<f.length && !focusDone) {
			try {
				var e = f.elements[i];
				//alert(e.type+" i: "+i);
				if(e.type == "text" || regex.test(e.type)) {
					e.focus();
					focusDone = true;
				}
			}
			catch(e1) {
			}
			i++;
		}//while
	}
	catch (e) {
	}
}
function resizeWindow() {
	window.resizeTo(window.screen.availWidth*0.9,window.screen.availHeight*0.9);
}
function useValuesOfFirstDropDownElement(f,namePrefix) {
	var	firstFound = false;
	var i = 0;
	
	var regex = new RegExp("^"+namePrefix);
	var regexSel = new RegExp(/^select/);
	firstSelectedIndex = 0;
	while(i<f.length) {
		var e = f.elements[i];
		if(regex.test(e.name) && regexSel.test(e.type)) {
			if(!firstFound) {
				firstSelectedIndex = e.selectedIndex;
				if(firstSelectedIndex != 0) {
					//alert(i+") "+e.name +" :,: "+ e.type+" -> "+e.selectedIndex);
					firstFound = true;
				}//if
			} 
			else {
				//alert(e.name +" :,: "+ e.type+" -> "+firstSelectedIndex);
				e.selectedIndex = firstSelectedIndex;	
			}
		}//if
		i++;
	}//while
}
function easyDate(textfield) {
	if(textfield.type == "text") {
		var tfValue = textfield.value;
		var day;
		var month;
		var year;
		if(tfValue.match(/\d{8}/)){
			day = tfValue.substring(0,2);
			month = tfValue.substring(2,4);
			year = tfValue.substring(4);
			//setzen des transformierten datums
			textfield.value = day+"."+month+"."+year;
		}//if
	}//if
}
function easyTime(textfield) {
	var hour;
	var min;
	if(textfield.type == "text") {
		var tfValue = textfield.value;
		//Wenn 8 Zahlen kommen handelt es sich wahrscheinlich um ein schnell eingegebenes datum
		if(tfValue.match(/\d{4}/)) {
			hour = tfValue.substring(0,2);
			min = tfValue.substring(2);
			//schreibe neu
			textfield.value = hour +":"+	min;
		}
	}
}//end of easyTime
function ask(ziel,msg) {
	if(confirm(msg)) {
		document.location.href = ziel;
	}
}

/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

/**
 * (c) phpmyadmin 2006
 * (adapted) fhjo Michael Oberwasserlechner
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer   the row number
 * @param   string    the action calling this script (over, out or click)
 * @return  boolean  whether pointer is set or not
 */
function sP(theRow, theRowNum, theAction,pref,theDefaultClass)
{
	return sP(theRow,theRowNum, theAction, pref, theDefaultClass,0)
} 
function sP(theRow, theRowNum, theAction,pref,theDefaultClass,changeCursor)
{
//	var thePointerColor = '#CCFFCC';
//	var theMarkColor = '#FFCC99';
//	var theDefaultColor = '';
	var thePointerClass = pref+'Pointer';
	var theMarkClass = pref+'Mark';
	if(typeof(theRow.className)=='undefined') {
		return false;
	}
    // 1.1 Sets the mouse pointer to pointer on mouseover and back to normal otherwise.
    if(changeCursor==1) {
    	theRow.style.cursor='pointer';
    }
    else if (theAction == "click") { //theAction == "over" || 
        theRow.style.cursor='pointer';
    } else {
        theRow.style.cursor='default';
    }
    // 3. Gets the current color...
    var domDetect    = null;
    var currentClass = null;
    var newClass     = null;
    currentClass = theRow.className;
    if(currentClass=='') {
    	currentClass=theDefaultClass;
	}    
    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentClass == ''
        || currentClass.toLowerCase() == theDefaultClass.toLowerCase()) {
        if (theAction == 'over' && thePointerClass != '') {
            newClass = thePointerClass;
        }
        else if (theAction == 'click' && theMarkClass != '') {
            newClass = theMarkClass;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentClass.toLowerCase() == thePointerClass.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newClass              = theDefaultClass;
        }
        else if (theAction == 'click' && theMarkClass != '') {
            newClass = theMarkClass;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentClass.toLowerCase() == theMarkClass.toLowerCase()) {
        if (theAction == 'click') {
            newClass = (thePointerClass != '')
                                  ? thePointerClass
                                  : theDefaultClass;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4
   // 5. Sets the new color...
    if (newClass) {
        theRow.className = newClass;
    } // end 5
    return true;
} // end of the 'setPointer()' function
/**
 * Javascript link
 */
function call(link) {
	document.location.href = link;
}
