/******************* 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;
	}
}
