function check_form() {
	if(document.getElementById("username").value == ''){
		alert("Sie müssen einen Benutzernamen angeben.")
		exit;
	}
	else if (document.getElementById("password").value == ''){
		alert("Sie müssen ein Passwort angeben.");
		exit;
	}
	else {
		document.formLogin.submit()
	}
}

function changeValue() {
	document.getElementById("username").value = '';
}

function checkPotvrda(){
	if(document.getElementById("accept_yes").checked  == true){
		document.getElementById("accept_no").disabled = 'disabled'
	}
	if(document.getElementById("accept_no").checked == true){
		document.getElementById("accept_yes").disabled = 'disabled'
	}
	if(document.getElementById("accept_yes").checked  == false){
		document.getElementById("accept_no").disabled = ''
	}
	if(document.getElementById("accept_no").checked == false){
		document.getElementById("accept_yes").disabled = ''
	}
}

/**
* DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/

function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		alert("Invalid E-mail ID")
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	}

	if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	}

	return true
}

function ValidateForm(alertWrongEmail,alertWrongPass,alertEmptyName,alertEmptySName,alertEmptyUserName,alertEmptyChip,alertEmptyGroup){
	var emailID=document.formUser.email
	var imeID=document.formUser.ime
	var prezimeID=document.formUser.prezime
	var regUserNameID=document.formUser.reg_user_name
	var regPassID=document.formUser.reg_pass
	var regPassReID=document.formUser.reg_pass_re
	var petname = document.getElementById("ime_zivotinje")
	var petgroup = document.getElementById("id_grupa")
	
	if ((petname.value==null)||(petname.value=="")){
		alert(alertEmptyName)
		petname.focus()
		return false
	}
	if ((petgroup.value==null)||(petgroup.value=="")){
		alert(alertEmptyGroup)
		petgroup.focus()
		return false
	}
	if ((imeID.value==null)||(imeID.value=="")){
		alert(alertEmptyName)
		imeID.focus()
		return false
	}
	if ((prezimeID.value==null)||(prezimeID.value=="")){
		alert(alertEmptySName)
		prezimeID.focus()
		return false
	}
	if ((emailID.value==null)||(emailID.value=="")){
		alert(alertWrongEmail)
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	if ((regUserNameID.value==null)||(regUserNameID.value=="")){
		alert(alertEmptyUserName)
		regUserNameID.focus()
		return false
	}
	if ((regPassID.value==null)||(regPassID.value=="")||(regPassID.length < 5)){
		alert(alertWrongPass + regPassID.length)
		regPassID.focus()
		return false
	}
	if (regPassID.value != regPassReID.value){
		alert(alertWrongPass + regPassID.length)
		regPassID.value = '';
		regPassReID.value = '';
		regPassID.focus()
		return false
	}
	return true
}

function change_lang_set(lang_old) {
	
	var strURL = document.URL
	var intPos = strURL.indexOf("newlang")
	if (intPos != -1) {
		var strURL = strURL.substring(0, intPos-1)
	}
	// alert(document.URL + "\n" + strURL + "\n" + strURL.indexOf("?"))
	
	if (strURL.indexOf("?") != -1) {
		window.location.href=strURL+'&newlang='+lang_old;
	} else {
    	 	window.location.href=strURL+'?newlang='+lang_old; 
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function checkDonation(userSTR,errorMessage1,errorMessage2){
	var radioDonation0=document.formDonation.radioDonation_0
	var radioDonation1=document.formDonation.radioDonation_1
	var radioDonation2=document.formDonation.radioDonation_2
	var user=document.getElementById("username")

	if (radioDonation0.checked==false && radioDonation1.checked==false && radioDonation2.checked==false){
		alert(errorMessage1)
		return false
	}
//	if(userSTR == ''){
//		user.style.color = "red";
//		alert(errorMessage2);
//		user.focus();
//		return false
//	}
	return true
}

function patsVote(str,id){
	location.href = '?vote=' + str + ',' + id ; 
}

function errorMail(str){
	if ((str!=null)||(str!="")){
		alert(str)
		return false
	}
	return true
}

function pleaseRegister(str){
	alert(str)
	 document.getElementById("username").style.color = "red";
}
