function confirmDelete()
{
	conf  = confirm('Wollen Sie diesen Datensatz wirklich löschen?');
	if(!conf)
		return false;
}

function switchValid(pWert)
{
	if(pWert != "alle")
	{
		document.getElementById('rabatt_row').style.display = "";
		
		//Ladet nach Auswahl alle Filialen oder Länder in die Standorte
		document.getElementById('standorte').innerHTML = "";
		document.getElementById('userstandorte').innerHTML = "";

		var host = "http://"+location.host;
		$(document).ready(function(){
			$.ajax({
				  type: 'POST',
				  dataType: 'string',
				  data: ( {auswahl: pWert} ),
				  url: host+'/ajaxRabatte.html',
				  error: function (){ alert('Query not Operated');} ,
				  success: function(transport) 
				  {
					  	var response = transport;
						var contents = response.split("---");
						
						for (var i = 0; i < contents.length; i++)
						{
							document.getElementById('standorte').innerHTML += "<option id="+ i +" value='" + contents[i] + "' onclick='javascript:addUserStandortee(" + i + ",this.value)'>" + contents[i] + "</option>";
						}
				  }
			});
		});
	}
	else
		document.getElementById('rabatt_row').style.display = "none";
}

function switchValid2(pWert)
{
	if(pWert != "alle")
	{
		document.getElementById('rabatt_row').style.display = "";
		
		//Ladet nach Auswahl alle Filialen oder Länder in die Standorte
		//document.getElementById('standorte').innerHTML = "";
		//document.getElementById('userstandorte').innerHTML = "";

		var host = "http://"+location.host;
		$(document).ready(function(){
			$.ajax({
				  type: 'POST',
				  dataType: 'string',
				  data: ( {auswahl: pWert} ),
				  url: host+'/ajaxRabatte.html',
				  error: function (){ alert('Query not Operated');} ,
				  success: function(transport) 
				  {
					  	var response = transport;
						var contents = response.split("---");
						
						for (var i = 0; i < contents.length; i++)
						{
							document.getElementById('standorte').innerHTML += "<option id="+ i +" value='" + contents[i] + "' onclick='javascript:addUserStandortee(" + i + ",this.value)'>" + contents[i] + "</option>";
						}
				  }
			});
		});
	}
	else
		document.getElementById('rabatt_row').style.display = "none";
}


function addUserStandortee(StandortId, StandortName)
{
	if( document.getElementById('standorte').selectedIndex == -1 )
	{
		alert("Select Place first");
	}
	else
	{
		var arrStandorte	= StandortName;
		var arrIndex		= StandortId;
		
		document.getElementById('userstandorte').innerHTML += "<option selected='selected' onClick='javascript:removeUserStandortee("+ arrIndex +",\"" + arrStandorte + "\")' id="+ arrIndex +" value='" + arrStandorte + "'>" + arrStandorte + " <p onClick='javascript:removeUserStandortee("+ arrIndex +", " + arrStandorte + ")'></p>" + "</option>";
		
		var d = document.getElementById('standorte');
		var olddiv = document.getElementById(arrIndex);
		d.removeChild(olddiv);
	}
}


function removeUserStandortee(StandortId, StandortName)
{
	var d = document.getElementById('userstandorte');
	var olddiv = document.getElementById(StandortId);
	d.removeChild(olddiv);
	
	var arrStandorte  = StandortName;
	var arrIndex = StandortId;
	
	document.getElementById('standorte').innerHTML += "<option id="+ arrIndex +" value='" + arrIndex + "' onclick='javascript:addUserStandortee(" + arrIndex + ",\"" + arrStandorte + "\")'>" + arrStandorte + "</option>";
	
	var elem = document.getElementById('userstandorte');
	for (var i = 0; i < elem.options.length; i++) 
	{
        elem.options[i].selected = 'selected';
    }	
}


/*
var belegt = new Array();

$(document).ready( function(){
// Function startet sobald ein Standort gewählt wurde und ein neues Element angewählt wird
		$('#standort').blur(function(){
		// Prüfung: Ist der Wert des Standortes nicht null
		if(this.value != '0'){
			var FilialId = $('#standort').val();
			$.ajax({
				  type: 'POST',
				  dataType: 'json',
				  data: ( {FilialId: FilialId} ),
				  url: HOST+'/ajaxBuchung.html',
				  error: function (){ alert('Query not Operated');} ,
				  success: function(data) {
					  bookedDays = data;
					  			
					}
			});
		}
	});
});
*/
