function or_getFeedType(xmlDoc){
	try
	{
		this.metadata = xmlDoc.getElementsByTagName("MetaData")[0];
		feedtype = this.metadata.getElementsByTagName("Label")[0].firstChild.nodeValue;
		if(feedtype=="listings"){
			return true;
		}else{
			return false;
		}
	}
	catch (myError)
	{
		return false;
	}
}
function or_getMarket(xmlDoc){
	try
	{
		this.metadata = xmlDoc.getElementsByTagName("MetaData")[0];
		thisvalue = this.metadata.getElementsByTagName("Market")[0].firstChild.nodeValue;
		return thisvalue;
	}
	catch (myError)
	{
		return "us";
	}
}
function or_getKeyword(xmlDoc){
	try
	{
		this.metadata = xmlDoc.getElementsByTagName("MetaData")[0];
		thisvalue = this.metadata.getAttribute("keywords");
		return thisvalue;
	}
	catch (myError)
	{
		return "";
	}
}
function or_getRelatedTerms(xmlDoc){
	try
	{
		this.relatedTermsXml = or_getElementById(xmlDoc,"relatedTerms");
		searchResults = this.relatedTermsXml.getElementsByTagName("Search");
		relatedTerms = new Array();
		for (x=0;x<searchResults.length ;x++ )
		{	
			thisKey = searchResults[x].firstChild.nodeValue+"";
			thisValue = searchResults[x].getAttribute("queryParams");
			
			relatedTerms.push(Array(thisKey,Right(thisValue,thisValue.length-3)));
		}
		return relatedTerms;
	}
	catch (myerror)
	{
		return new Array();
	}

}
function or_getNextArgs(xmlDoc){
	try
	{
		thisValue = xmlDoc.getElementsByTagName("NextArgs")[0].firstChild.nodeValue;
		return Right(thisValue,thisValue.length-3);
	}
	catch (myerror)
	{
		return "";
	}

}
function or_getPrevArgs(xmlDoc){
	try
	{
		thisValue = xmlDoc.getElementsByTagName("PrevArgs")[0].firstChild.nodeValue;
		return Right(thisValue,thisValue.length-3);
	}
	catch (myerror)
	{
		return "";
	}

}
function or_getAdListings(xmlDoc){
	try
	{
		//alert("adlistings");
		this.relatedTermsXml = or_getElementById(xmlDoc,"adListings");
		adListingResults = this.relatedTermsXml.getElementsByTagName("Listing");
		//alert(adListingResults);
		adListings = new Array();
		for (x=0;x<adListingResults.length ;x++ )
		{	
			title = adListingResults[x].getAttribute("title");

			descriptionstr = adListingResults[x].getAttribute("description");

			sitehost = adListingResults[x].getAttribute("siteHost");

			biddedListing = adListingResults[x].getAttribute("biddedListing");

			clickurl = adListingResults[x].getElementsByTagName("ClickUrl")[0].firstChild.nodeValue;
			
			adListings.push(Array(title,descriptionstr,sitehost,clickurl,biddedListing));
		}
		return adListings;
	}
	catch (myerror)
	{
		//alert("adlistings error:"+myerror);
		return new Array();
	}
	
}
function or_getWebListings(xmlDoc){
	try
	{
		//alert("adlistings");
		this.relatedTermsXml = or_getElementById(xmlDoc,"webListings");
		webListingResults = this.relatedTermsXml.getElementsByTagName("Listing");
		//alert("adlistings2");
		webListings = new Array();
		//alert(adListingResults.length);
		for (x=0;x<webListingResults.length ;x++ )
		{	
			title = webListingResults[x].getAttribute("title");
			//alert(title);
			descriptionstr = webListingResults[x].getAttribute("description");
			//alert(descriptionstr);
			sitehost = webListingResults[x].getAttribute("siteHost");
			//alert(sitehost);
			biddedListing = adListingResults[x].getAttribute("biddedListing");

			clickurl = webListingResults[x].getElementsByTagName("ClickUrl")[0].firstChild.nodeValue;
			//alert(clickurl[0].firstChild.nodeValue);
			
			webListings.push(Array(title,descriptionstr,sitehost,clickurl,biddedListing));
		}
		return webListings;
	}
	catch (myerror)
	{
		//alert("adlistings error");
		return new Array();
	}
	
}
function or_getPopularCategories(xmlDoc){
	try
	{
		this.relatedTerms = or_getElementById(xmlDoc,"popularCategories");
		categoryResults = this.relatedTerms.getElementsByTagName("Category");
		
		popularCategories = new Array();
		for (y=0;y<categoryResults.length ;y++ )
			{	
			thisCKey = categoryResults[y].getAttribute("title")+"";
			thisCValue = categoryResults[y].getAttribute("queryParams");
			popularCategories.push(Array(thisCKey,"params",Right(thisCValue,thisCValue.length-3)));
			searchResults = categoryResults[y].getElementsByTagName("Search");
			
			for (x=0;x<searchResults.length ;x++ )
			{	
				thisKey = searchResults[x].firstChild.nodeValue+"";
				thisValue = searchResults[x].getAttribute("queryParams");
				
				popularCategories.push(Array(thisCKey,thisKey,Right(thisValue,thisValue.length-3)));
			}
		}
		return popularCategories;
	}
	catch (myerror)
	{
		return new Array();
	}

}
function or_getSearchBoxParams(xmlDoc){
	try
	{
		thisValue = or_getElementById(xmlDoc,"searchBox").getAttribute("queryParams");
		return Right(thisValue,thisValue.length-3);
	}
	catch (myerror)
	{
		return "";
	}

}
function or_getPartnerTerms(xmlDoc){
	try
	{
		thisElement = or_getElementById(xmlDoc,"partnerTerms");
		if(thisElement==null){
			return "";
		}else{
			thisValue = thisElement.getAttribute("queryParams");
			return Right(thisValue,thisValue.length-3);
		}
	}
	catch (myerror)
	{
		return "";
	}

}
function or_getElementById(xmlDoc,idName){
	try
	{
		xmlArray = xmlDoc.getElementsByTagName("*");
		for (x=0;x<xmlArray.length ;x++ )
		{
			if (xmlArray[x].getAttribute("id")==idName)
			{
				//alert(xmlArray[x].getAttribute("id"));
				return xmlArray[x];
			}
		}
		//alert(idName+":null");
		return null;
	}
	catch (myerror)
	{
		return null;
		//alert("error:"+idName+":null");
	}

}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function keywordReady(tempkeyword){
	tempkeyword = escape(tempkeyword)
	return tempkeyword;
}