 

/* ajax functions */
function checkIfContentLoaded(cVarName,elementID,url,pars) {
	var cVarValue = eval(cVarName);	
	if(cVarValue=="yes" && elementContainerID==null) {getElementContent(elementID,url,pars);}	
}
function getElementContent(elementID,url,pars) {
  var xhr = createXMLHttpRequest();
  findElement(elementID).innerHTML = '<img src="http://www.bookahotel.ro/_images/loading.gif" border="0" class="loader" />';
  xhr.onreadystatechange = function() {  	
    if (xhr.readyState==4) { // Request finished
	  findElement(elementID).innerHTML = '';
      if (xhr.status==200) {
	  	var str_inner_html = findElement(elementID).innerHTML;
        str_inner_html += xhr.responseText;	
		str_inner_html = removeCRLF(str_inner_html);
		str_inner_html = replaceWideWithBasicASCII(str_inner_html);
		findElement(elementID).innerHTML = str_inner_html;
      } else {
        alert("Message returned, but with error status.");
      }
    }
  }
  xhr.open("get", url+'&'+pars, true);
  xhr.send(null);
}
function createXMLHttpRequest() {
  try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
  try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
  try { return new XMLHttpRequest(); } catch(e) {}
  alert("XMLHttpRequest not supported");
  return null;
}

function removeCRLF(str) {	
	if (BrowserDetect.browser=="Explorer") {
			}
	return str;
}


function replaceWideWithBasicASCII(str) { 
		str=str.replace(/／/gi, "/");
		str=str.replace(/﹡/gi, "*");
		//str=str.replace(/”/gi, "\"");
		//str=str.replace(/΄/gi, "'");
		str=str.replace(/％/gi, "%");
		str=str.replace(/＆/gi, "&");
		str=str.replace(/＋/gi, "+");
		str=str.replace(/＼/gi, "\\");
		str=str.replace(/＄/gi, "$");
		str=str.replace(/＜/gi, "<");
		str=str.replace(/＞/gi, ">");
		str=str.replace(/＝/gi, "=");
		str=str.replace(/？/gi, "?");
		str=str.replace(/＃/gi, "#");
		str=str.replace(/？/gi, "?");	
		str=str.replace(/＂/gi, "”");	
		str=str.replace(/＇/gi, "΄");
	return str;
}
/* end ajax functions */

