/*
** ##########################################################
** # "Yet Another Mobile Entertainment Portal" (c) by net-m #
** ##########################################################
**
** Basis JavaScript functions
*/


function sendFormOnSelect(id){
	if (id.options[id.selectedIndex].value !="none"){
		id.form.submit();	
	}
}


function callUrlOnSelect(id){
	if (id.options[id.selectedIndex].value !="none"){
		window.location.href=id.options[id.selectedIndex].value;
	}
}

/* check msisdn */
function msisdnCheck(msisdn){
	if (msisdn.substring(0,1) == '+' && msisdn.length >= 13)
		return true;
	else{
		if (msisdn.substring(0,2) == '00' && msisdn.length >= 14)
			return true;
		else
			return false;
	}
}

/* check tan */
function tanCheck(tannum){
	if (tannum.length >= 4 && tannum.length <= 32)
		return true;
	else
		return false;
}

/* check operatiorId for goPay */
function operatorIdCheck(opid){
	opid = parseInt(opid);
	if(opid != 0 && opid >= 1 && opid <=7)
		return true;
	else
		return false;
}

/* check form1 for goPay payment */
function SendGopay(){
	//if (operatorIdCheck(document.getElementById("gopayoperator").value)){
		if (msisdnCheck(document.getElementById("gopaymsisdn").value) ){
			if (document.getElementById("gopayagb").checked==true) {
				document.gopayform1.sendgopay.value="Bitte warten...";
				return true;
			}
			else {
				alert("Bitte akzeptiere die Allgemeinen Geschäftsbedingungen (AGB)!");
				return false;
			}
		}
		else{
			alert("Du hast die Handynummer nicht richtig eingegeben. Bitte benutze das internationale Format mit der Landesvorwahl und der Netznummer ohne führende 0, z.B. 0049178123456");
			document.getElementById("gopaymsisdn").focus();
			return false;
		}
	//}
	//else{
	//	alert("Du hast kein Netzbetreiber ausgewählt.\nBitte wähle Deinen Netzbetreiber!");
	//	return false;
	//}
	return false;
}

/* check form2 (PIN) for goPay payment */
function SendGopayPin(){
	if (document.getElementById("gopayPin").value!=""){
		return true;
	}
	else{
		alert("Gib bitte die PIN ein!");
		return false;
	}
}