function openPopUp(url, window_name, width, height)
{
	var popup = window.open(url, window_name, "width=" + width + ",height=" + height + ",scrollbars=yes,resizable=yes,left=100,top=100");
 	popup.focus();
}

function JSTest(divId, count)
{
	for(i = 1; i < count; i++){
		document.getElementById(divId + i).style.display = "none";
	}
}

function eventPreview(divId, id){
	var obj = document.getElementById ? document.getElementById(divId) : document.all ? document.all[divId] : null;
		if(obj.style.display != 'none'){
		
			obj.style.display = 'none';
			document.getElementById(id).innerHTML = '<a href="#" onClick="eventPreview(\'' + divId + '\', \'' + id + '\');return false;">[ + ]</a>';
		}else{
			
			obj.style.display = 'block';
			document.getElementById(id).innerHTML = '<a href="#" onClick="eventPreview(\'' + divId + '\', \'' + id + '\');return false;">[ - ]</a>';
		}
}

function displayOut(divId)
{
	document.getElementById(divId).innerHTML = "";	
}

function calendarView(divId, visible){
    if(visible == true){
        document.getElementById(divId).style.display = "block";
    }else{
        document.getElementById(divId).style.display = "none";
    }
}

function roomPlaner(o_id, or_id, lang)
{
	loadText("http://www.xxltravel.de/ajax/quarters_planer.php?o=" + o_id + "&or=" + or_id + "&lang=" + lang, "quarters_calendar");
}

function changeImage(image_id, image_url)
{
	var image = document.getElementById(image_id);
	var waitImage = new Image();
	waitImage.src = 'http://www.xxltravel.de/img/loading.gif';
	if (image && image.src){
		image.src = waitImage.src;
		image.src = image_url;
		image.width = 320;
		image.height = 240;
	}
}

function adjustVerticalLine(containerElementId, adjustElementClassName) {

	var containerElement;

	//Specific browser code
	if (document.getElementById) {
		containerElement = document.getElementById(containerElementId);
	}
	
	if (containerElement) {
		var adjustHeight = containerElement.offsetHeight;
		var adjustElements = getElementsByClassName(document, "div", adjustElementClassName);
		for(var i=0; i<adjustElements.length; i++){
	        adjustElement = adjustElements[i];
        	adjustElement.style.height = adjustHeight + 'px';
    	}
    }
}
function getElementsByClassName(element, tagName, className) {
    var arrElements = (tagName == "*" && element.all)? element.all : element.getElementsByTagName(tagName);
    var arrReturnElements = new Array();
    className = className.replace(/\-/g, "\\-");
    var regExp = new RegExp("(^|\\s)" + className + "(\\s|$)");
    var candidateElement;
    for(var i=0; i<arrElements.length; i++){
        candidateElement = arrElements[i];      
        if(regExp.test(candidateElement.className)){
            arrReturnElements.push(candidateElement);
        }   
    }
    return (arrReturnElements)
}
function quartersRoomView(divId, click){
	if(click == true){
		var obj = document.getElementById ? document.getElementById(divId + '_b') : document.all ? document.all[divId + '_b'] : null;
		if(obj.style.display != 'block' || obj.style.display == ''){
				obj.style.display = 'block';
			}else{
				obj.style.display = 'none';
			}
	}else{
		document.getElementById(divId + '_a').style.cursor= "pointer";
		document.getElementById(divId + '_b').style.cursor= "pointer";
		document.getElementById(divId + '_c').style.cursor= "default";
	}
}
var ajaxRequests = new Array();
function AjaxRequest(url, divName) {
    this.divName = divName;
    this.url = url;
    this.xmlhttp = '';
    this.loaded = false;
};
function getXMLData(ajaxRequest)
{
    var xmlhttp = getXMLHttpObject();
	if (xmlhttp == null) {
		// alert("Fehler beim Anlegen des XMLHttpObject");
		return;
	}
	ajaxRequest.xmlhttp = xmlhttp;
	try {
		ajaxRequests.push(ajaxRequest);
	} catch (error) {
		ajaxRequests[ajaxRequests.length] = ajaxRequest;
	}
	xmlhttp.open("GET", ajaxRequest.url , true);
	xmlhttp.onreadystatechange = handleHttpState;
	xmlhttp.send(null);
}
function getXMLHttpObject() {
	try {
	   var xmlhttp = new XMLHttpRequest();
	} catch (error) {
	   try {
	       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	   } catch (error) {
	       return null;
	   }
	}
	return xmlhttp;
}
// Callback-Funktion
function handleHttpState() {
    var i;
    // alert(ajaxRequests.length);
    for (i = 0; i < ajaxRequests.length; i++) {
        var ajaxRequest = ajaxRequests[i];
        if (ajaxRequest.loaded) continue;
        var xmlhttp = ajaxRequest.xmlhttp;
    	if (xmlhttp.readyState == 4) {
    		if (xmlhttp.status == 200) {
    			// daten erfolgreich geladen: starte Verarbeitung
    			//alert("Daten gefunden: " + ajaxRequest.divName);
    			ajaxRequest.loaded = true;
    			parseData(ajaxRequest);
    			return;
    		} else {
    			// fehler
    			//alert("Fehler beim Abrufen der XML Daten: " + ajaxRequest.divName + ". HTTP-Status: "+ xmlhttp.status + " (" + xmlhttp.statusText + ")");
    		}
    	}
    }
}
function parseData(ajaxRequest) {
	var adsDiv = document.getElementById(ajaxRequest.divName);
	adsDiv.innerHTML = ajaxRequest.xmlhttp.responseText;
}
function loadText(url, divName) {
    var ajaxRequest = new AjaxRequest(url, divName);

	try {
		getXMLData(ajaxRequest);
	} catch (error) {
		//alert('Error');
	}
}

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

function moreAttributes()
{
	document.getElementById('checkboxes').style.display = "block";
}

function textlimit(Obj,maxcount,counter)
{
    function c_len(){    
        if(this.value.length > this.maxcount && this.maxcount != 0) 
            return false;
        update_count(this);    
    }
    
    function upd_count(){    update_count(this);}
    
    function update_count(elem){
        if(elem.counter != null){
            cnt = getObj(elem.counter);
            cnt.innerHTML = elem.value.length
    }}
    
    function check(){
        if (this.value.length  > this.maxcount && this.maxcount != 0) 
            this.value = this.value.substr(0,this.maxcount);
        update_count(this); 
    }
    
    Obj.counter   = counter;      Obj.maxcount  = maxcount;
    Obj.onkeypress= c_len;        Obj.onkeydown = upd_count;    
    Obj.onkeyup   = check;        Obj.onfocus   = check;
    Obj.onblur    = check;        
    Obj.onmouseup = check;

    update_count(Obj);
    
/*************** OTHER USED / NEEDED FUNCTIONS ***************************/
function getObj( ref ) { if( document.getElementById( ref ) != null )//W3C/
return document.getElementById(ref); else if(document.all[ref]!=null)//IE5/
return document.all[ ref ]; else if( document.layers[ ref ] != null )//NN4/
return document.layers[ref]; else alert('Object "'+ref+'" not Found')//ERR/
}/************************************************************************/
}


function offer(url)
{
	url = url.replace(/\|\|/g, '.');
	url = url.replace(/\|/g, '/');
	window.open("http://" + url);	
}