function getText(area,url) {

	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}

	xmlhttp.open("GET", url, true);
	//xmlhttp.overrideMimeType("text/html; charset=ISO-8859-1");
	xmlhttp.onreadystatechange=function() {
	  if (xmlhttp.readyState==4) {
		s = xmlhttp.responseText;
//alert(s);
	    document.getElementById(area).innerHTML = s;
	  }
	}
	xmlhttp.send(null);
}
function parentgetURLParam(strParamName){
  var strReturn = "";
  var strHref = parent.window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?"));
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  strReturn = strReturn.replace(/\+/g, " ");
  strReturn = strReturn.replace(/%20/g, " ");
  strReturn = ConvertToProperCase(strReturn);
  strReturn = strReturn.replace("The Us", "The U.S.");
  return unescape(strReturn);
}
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?"));
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
  		// replace + with space 
  		aParam[1] = aParam[1].replace(/\+/g, " ");
  		// replace htmlspace with space 
  		aParam[1] = aParam[1].replace(/%2d/g, "-");
  		aParam[1] = aParam[1].replace(/%20/g, " ");
  		aParam[1] = aParam[1].replace(/%3a/g, ":");
  		// upper case each word in string 
  		aParam[1] = ConvertToProperCase(aParam[1]);
  		// Change us to U.S. (otherwise, appears as Us)
  		aParam[1] = aParam[1].replace("The Us", "The U.S.");
        aParam[1]=strip_first(aParam[1], "Travel - ");
        aParam[1]=strip_colon(aParam[1]);
        //break;
		if (iParam > 0) {
        	strReturn = strReturn + " and " ;
		}
        strReturn = strReturn + aParam[1];
      }
    }
	if (iParam > 1) {
		strReturn = strip_first(strReturn, "and ");
	}
//alert(iParam);
//alert(strReturn);
  }
  return unescape(strReturn);
}
function gup( name ){
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null )
        return "";
    else
        return results[1];
}
function ConvertToProperCase(strTemp)
{
	strTemp = strTemp.toLowerCase()
	
	var test=""
	var isFirstCharOfWord = 1
	
	for (var intCount = 0; intCount < strTemp.length; intCount++) {
	
		var temp = strTemp.charAt(intCount)
		if (isFirstCharOfWord == 1) {
			temp = temp.toUpperCase()
		}
	
		test = test + temp
		if (temp == " ") {
			isFirstCharOfWord = 1
		}
		else isFirstCharOfWord = 0
	}
	return test;
}

function strip_first(mystr, mypattern) {
    var mya = mystr.split(mypattern);
	if (mya.length == 0) {
		return(ConvertToProperCase(mystr));
	}
	else {
//alert('here');
//alert(mya.length)
//alert(mya[mya.length-1]);
		return( ConvertToProperCase(mya[mya.length-1]));
	}
}
function strip_colon(mystr) {
    var mya = mystr.split(":");
	if (mya.length == 0) {
		return(ConvertToProperCase(mystr));
	}
	else {
		return( ConvertToProperCase(mya[0]));
	}
}
function strip_parens(mystr) {
	
    var mya = mystr.split(" (");
	mya[0] = ConvertToProperCase(mya[0]);
	return(mya[0]);
}

function display_param(mytype)
{
// display_param attempts to build the breadcrump or title (mytype) with the parameter from the url.
// The parameters checked are:
// title_auth_isbn === this is a keyword search
// category_like === this is a destination search, where the piece of the destination breadcrumb 
//	was clicked, and we don't have the bisac code.
// cat_id_ex === this is the bisac code for a destination search
	var mydelim=" > ";
	var max = 0;
	if (mytype == "lltitle") { mydelim = ""; }
	if (mytype == "title") { mydelim = " - "; }
	var myvar=getURLParam('title_auth_isbn');
// 	strip out __#replace.title_auth_isbn__
//	this is a kluge for the display page, where the title_auth_isbn is not actually present, yet the code has to try to replace it.  Ugh
	if (myvar.length > 0) {
		myvar = mydelim + myvar;
    	document.write(myvar);
	}
	else {
		myvar=getURLParam('category_like');
		if (myvar.length > 0) {
			myvar = strip_first(myvar, "and ");
			myvar = mydelim + myvar;
    		document.write(myvar);
		}
		else {
			myvar=getURLParam('editdescription');
			if (myvar.length > 0) {
				myvar = strip_first(myvar, "and ");
				myvar = mydelim + myvar;
    			document.write(myvar);
			}
			else
			{
    			myvar=getURLParam('cat_id_ex');
				if (myvar.length > 0) {
    				var myarray = myvar.split("- ");
					myarray[0] = ConvertToProperCase(myarray[0]);
					myarray[0] = strip_first(myarray[0], "And ");
					// bisac codes could be 3 deep.  First level is "Travel"
    				if (myarray.length == 1) {
						mystr = mydelim + myarray[0];
						document.write(mystr);
    				}
    				else
    				{
						if (mytype == "title") { i = myarray.length - 2; }
						else { 
							i=0; 
						}
						if (myarray.length == 2) {
							max=1;
						}
						else {
							max=1;
						}
        				while (i < max)
        				{
							if (mytype == "bread") {
            				document.write("<a href=/category/fodors/bisac.pperl?category_like=");
							}
							myarray[i] = ConvertToProperCase(myarray[i]);
							// remove parens from string
							if (mytype == "bread" ) {
  								myhref = myarray[i].replace(" ","+");
  								myhref = myhref.replace(" ","+");
            					myhref = myhref + ">" + mydelim + myarray[i] + "</a>";
            					document.write(myhref );
							}
            				i = i + 1;
        				}
						max = i + 1;
						if (myarray.length == 3) {
							document.write(mydelim + myarray[i] + mydelim + strip_parens(myarray[i+1]));
							max = i + 1;
						} 	
						else {
							max = i ;
							mystr = ConvertToProperCase(myarray[max]);
							document.write(mydelim + strip_parens(mystr));
						}
					}
				}
			}
		}
	}
}
function display_region(str) {
	str = ConvertToProperCase(str);
	document.write(str);
	return(str);
}
function myfill(frm, isbn) {
    var my_title_auth_isbn = getURLParam('title_auth_isbn');
    var my_cat_id_ex=getURLParam('cat_id_ex');
    var myhref= "/livinglanguage/display.pperl?isbn=" + isbn ;
    if (my_title_auth_isbn.length > 0) {
        myhref = myhref +  "&title_auth_isbn=" + my_title_auth_isbn;
    }
    if (my_cat_id_ex.length > 0) {
        myhref= myhref + "&cat_id_ex=" + my_cat_id_ex;
    }
//alert(myhref);
    location.href = myhref;
}
