/**
 * Sets action of the current input form via the common available hidden field action.
 * This is usually used in onClick Events of Form Buttons
 **/
function setAction(action,submit) {
	document.getElementById('action').value=action;

	if(submit) document.forms[0].submit();
}

function setUebung(sportler2trainplan2uebungen_id,status) {
	document.getElementById('sportler2trainplan2uebungen_id').value=sportler2trainplan2uebungen_id;
	document.getElementById('status').value=status;
}

function setNumberAndOrder(number,order) {
	document.getElementById('ueb_id').value=number;
	document.getElementById('order').value=order;
}
/*
function confirmMessage(confirmation_message) {

    if (confirmation_message=="") {
        return true;
    } else {
        res=confirm(confirmation_message);
        if (res==true) {
            return true;
            setAction('delete',true);
        } else {
            return false;
        }
    }
}*/
function confirmMessage(confirmMsg) {
    if (confirmMsg == "") {
        return true;
    } else {
        if (confirm(confirmMsg) == true) {
            return true;
	    } else {
            return false;
        }
    }
}

function showVideo(videoOn, videoOf){
	document.getElementById(videoOn).style.display="block";
	document.getElementById(videoOf).style.display="none";
}

function writeForFlash(video){

	document.write('<object type="application/x-shockwave-flash" data="video/FlowPlayer.swf" width="320" height="240" id="FlowPlayer">');
	document.write('<param name="allowScriptAccess" value="sameDomain">');
	document.write('<param name="movie" value="video/FlowPlayer.swf">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="scale" value="noScale">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="flashvars" value="videoFile='+video+'&autoPlay=true&loop=false">');
	document.write('</object>');
}

function changeSort(orderBy) {

	if (document.forms[0].orderBy.value == orderBy && document.forms[0].orderType.value == "ASC") {
		document.forms[0].orderType.value = "DESC";

	} else {

		document.forms[0].orderBy.value = orderBy;
		document.forms[0].orderType.value = "ASC";

	}

	setAction('changeSort',true);

}


function openWin(url, param, name, winWidth, winHeight, scrollbars) {

	var ns4 = (document.layers) ? true:false;
	var winW = 800;
	var winH = 500;

	if(ns4) {
		sH = screen.availHeight;
		sW = screen.availWidth;
	} else {
		sH = screen.height;
		sW = screen.width;
	}
	var winX = (sW - winW) / 2;
	var winY = (sH / 2) - (winH / 2);


	if(!winWidth) winWidth = "420";
	if(!winHeight) winHeight = "420";
	return window.open(url+'?'+param, name);
}

function open_filechooser(url, name, winWidth, winHeight, scrollbars, id) {

	var ns4 = (document.layers) ? true:false;
	var winW = 800;
	var winH = 500;

	if(ns4) {
		sH = screen.availHeight;
		sW = screen.availWidth;
	} else {
		sH = screen.height;
		sW = screen.width;
	}
	var winX = (sW - winW) / 2;
	var winY = (sH / 2) - (winH / 2);


	if(!winWidth) winWidth = "420";
	if(!winHeight) winHeight = "420";
	return window.open(url+'&feld='+id, name);
}

function setFile(id, feld) {

	//alert(document.getElementById(id).value);

	opener.document.getElementById(feld).value = document.getElementById(id).value;
	self.close();
}

function setId(id) {
	document.getElementById('zielzeittrainingsplan_id').value = id;
}