/******************* AJAX - FUCTIONS */
//object detection to return the correct object depending upon broswer type. Used by the getAXHA(); function.
function getNewHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
}

//Function used to update page content with new xhtml fragments by using a javascript object, the dom, and http.
function getsrc(url,elementContainer){
		//document.getElementById(elementContainer).innerHTML = '';
		var theHttpRequest = getNewHttpObject();
		var randomnumber=Math.floor(Math.random()*1001);
		//alert(url);
		// "/(.*?)\/hotels\/(.*?)/"
		if (!url.match(/(.*?)\/hotels\/(.*?)/) || url.match(/(.*?)fulltext(.*?)/)){

		} else {
			setCookie("getsrc",url);
		}
		

		theHttpRequest.onreadystatechange = function() {processAXAH(elementContainer);};
		theHttpRequest.open("GET", url + '&amp;' + randomnumber);
		theHttpRequest.send(false);
	
			function processAXAH(elementContainer){
			   if (theHttpRequest.readyState == 4) {
				   if (theHttpRequest.status == 200) {
					   document.getElementById(elementContainer).innerHTML = theHttpRequest.responseText;
				   } else {
					   document.getElementById(elementContainer).innerHTML="<p><span class='redtxt'>Error!<\/span> HTTP request return the following status message:&nbsp;" + theHttpRequest.statusText +"<\/p>";
				   }
			   }
			}

			
}



function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
     anchor.target = "_blank";
	 anchor.className += " external";
   }
 }
}
window.onload = externalLinks;


function sh(id,a){
	if (document.getElementById(id)){
		document.getElementById(id).style.display=a;
	}
}


//auto show/hide
function ash(id){
	if (document.getElementById(id)){
		if (document.getElementById(id).style.display=="block"){
			sh(id,"none");
		} else {
			sh(id,"block");
		}
	}
}

//change img 

function chimg(id,src){
	if (document.getElementById(id)){
		document.getElementById(id).src=src;
	}
}

function isUrl(s) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(s);
}


function checkUrl(myValue,myId)
{
	if (isUrl(myValue)){
			
	} else {
		document.getElementById(myId).value	= 'http://';
	}
}

// usability
function klickFeld(feld,wert){
	if(feld.value == wert)
	{ feld.value = "";}
}
function verlasseFeld(feld,wert){
	if(feld.value == '')
	{ feld.value = wert; }
}

function loadButtons()
{
	$('a.linkgruen').corner("5px").parent().css('padding', '1px').corner("6px");
	$('a.linkblau').corner("5px").parent().css('padding', '1px').corner("6px");
	$('div.suche').corner("5px").parent().css('padding', '1px').corner("6px");	
}