function axPostRequest(myurl,mysrcid,mydestid) {
    new Ajax.Request (myurl, {
    method: 'post',
    parameters: $(mysrcid).serialize(),
    onSuccess: function(transport){
      var response = transport.responseText || "no response text";
      printMessage(mydestid,response);
    },
    onFailure: function(){ alert('Something went wrong...') }
  });

}

function axGetRequest(myurl,mydestid) {
    printMessage(mydestid,"<img src=\"./images/loading.gif\" alt=\"loading...\">");
    new Ajax.Request (myurl, {
    method: 'get',
    onSuccess: function(transport){
      var response = transport.responseText || "no response text";
      printMessage(mydestid,response);
    },
    onFailure: function(){ alert('Something went wrong...') }
  });

}

function printMessage(myid,mymsg) {
    document.getElementById(myid).innerHTML = mymsg;
}

function openWindow(myurl,mywidth,myheight) {
    myWindow = window.open(myurl, "phPopUp", "width="+mywidth+",height="+myheight+",scrollbars=yes");
    myWindow.focus();
}

function saveBox(myid,myvalue) {
    setValue = myid+"="+myvalue+";";
    document.cookie = setValue;
}

function saveValue(myid) {
    var myValue = getValueFromObject(myid);
    setValue = myid+"="+myValue+";";
    document.cookie = setValue;
}

function hideBlock(myid) {
    document.getElementById(myid).setAttribute('style', 'display:none;', 0);
    document.getElementById(myid).style.display = 'none';
}

function showBlock(myid) {
    document.getElementById(myid).setAttribute('style', 'display:block;', 0);
    document.getElementById(myid).style.display = 'block';
}

function changeBox(changeid) {
    if(document.getElementById(changeid).style.display=="block") {
        hideBlock(changeid);
    } else {
        showBlock(changeid);
    }
}

function cA(myid) {
    document.getElementById(myid).setAttribute("class", "active", 0);
}

function cI(myid) {
    document.getElementById(myid).setAttribute("class", "", 0);
}

function changeTextsize(myid,mysize) {
    document.getElementById(myid).setAttribute("style", "font-size:"+mysize+";", 0);
}

function getValueFromObject(myid) {
    var myvalue = document.getElementById(myid).value;
    return myvalue;
}

function fadeMsg(myid) {
    window.setTimeout("fadeMsgFunction('"+myid+"')",1000);
}

function fadeMsgFunction(myid) {
    changeOpac(100, myid);
    shiftOpacity(myid, 1000);
    window.setTimeout("hideBlock('"+myid+"')",1000);
}

function opacity(myid, opacStart, opacEnd, millisec) {

	var speed = Math.round(millisec / 100);
	var timer = 0;

	if(opacStart > opacEnd) {


		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + myid + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++) {
			setTimeout("changeOpac(" + i + ",'" + myid + "')",(timer * speed));
			timer++;
		}
	}
}

function changeOpac(opacity, myid) {
	var object = document.getElementById(myid).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(myid, millisec) {
	if(document.getElementById(myid).style.opacity == 0) {
		opacity(myid, 0, 100, millisec);
	} else {
		opacity(myid, 100, 0, millisec);
	}
}

function reloadCaptcha(myid) {
    document.getElementById(myid).setAttribute('src', '/lib/captcha.php?'+Math.floor(1111+(9999999-1111+1)*(Math.random())), 0);
    document.getElementById(myid).src = '/lib/captcha.php?'+Math.floor(1111+(9999999-1111+1)*(Math.random()));
}

function textcounter(myid,mycounter,maxlimit) {
    if( document.getElementById(myid).value.length > maxlimit ) {
        document.getElementById(myid).value = document.getElementById(myid).value.substring(0, maxlimit);
    } else {
        var mycounts = maxlimit - document.getElementById(myid).value.length;
        printMessage(mycounter,"Noch "+mycounts+" Zeichen");
    }
}