// Variablen
activeBrowser = navigator.appName;


// --------------------------------------------------------------------------------------
// AJAX FUNCTIONS
// --------------------------------------------------------------------------------------
var req1 = false;

function req1create() {

    req1 = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        req1 = new XMLHttpRequest();
        if (req1.overrideMimeType) {
            req1.overrideMimeType('text/xml');
            // zu dieser Zeile siehe weiter unten
        }
    } else if (window.ActiveXObject) { // IE
        try {
            req1 = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                req1 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!req1) {
        alert('Ende :( Fehler bei HTTPRequest.');
        return false;
    }
}


function req1statechange() {
  	
	if (req1.readyState == 4) {
     if (req1.status == 200) {
         document.getElementById("locationDetail").innerHTML = req1.responseText;
     } else {
         alert('Bei dem Request ist ein Problem aufgetreten.');
     }
	}

}


// --------------------------------------------------------------------------------------
function switchDay(activeTimestamp) {
  req1create();

  req1.onreadystatechange = function () {
	  
		if (req1.readyState == 4) {
	    if (req1.status == 200) {
			
	      document.getElementById("calendarDates").innerHTML = req1.responseText;
				
	    }
		}
		
	};
  req1.open('POST', '/_de/ajax/list_dates.html', true);
  req1.setRequestHeader("Content-type", "application/charset=ISO-8859-1");
  req1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  req1.setRequestHeader("Connection", "close");
  req1.send('control=true&activeTimestamp=' + activeTimestamp);
}


// --------------------------------------------------------------------------------------
function newDate(activeTimestamp) {
  
	document.getElementById("addDateForm").startDay.value = activeTimestamp;
	document.getElementById("addDateForm").endDay.value = activeTimestamp;
	
	openPopup('addDate');
	
}


// --------------------------------------------------------------------------------------
function saveDate() {
  
	document.getElementById("addDateForm").submit();
	
}


// --------------------------------------------------------------------------------------
function saveBook() {
  
	document.getElementById("addBookForm").submit();
	
}


// --------------------------------------------------------------------------------------
function checkBook(formular, profilId) {
  req1create();

  var strPosts = "control2=true&profilId=" + profilId;
  
	if (formular != false) {
	  var numElements = formular.elements.length;  
		
		for (var i = 0; i < numElements; i++) {

			activeElement = formular.elements[i];
			
			if (activeElement.type != "radio" && activeElement.type != "checkbox" && activeElement.name != undefined && activeElement.type != "submit")		  
	
				strPosts = strPosts + "&" + activeElement.name + "=" + activeElement.value;
			  
			else {		  
				
				activeElementName = activeElement.name;
				
				if (activeElement.type == "radio")
				  activeElementName = activeElementName.substring(0,activeElement.name.length-2);
				
				if (activeElement.checked)
			    strPosts = strPosts + "&" + activeElementName + "=" + activeElement.value;
				
			}
			
		} // for:i
	} // if:formular 	

  req1.onreadystatechange = function () {

		if (req1.readyState == 4) {

	    if (req1.status == 200) {

	      document.getElementById("addBookInfo").innerHTML = req1.responseText;
				openPopup('addBook');
	    }
		}
		
	};
  req1.open('POST', '/inc/edit/member/bookingrequest.html', true);
  req1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  req1.setRequestHeader("Connection", "close");
  req1.send(strPosts);
	
	return false;
	
}


// --------------------------------------------------------------------------------------
function setValue(element, value) {
  
	document.getElementById(element).value = value;
  
  return false;
}
