function replaceAll(txt, replace, with_this) {		       
       if (txt.indexOf(replace)!=-1) {			     
          return txt.replace(new RegExp(replace, "g"),with_this);
	} 
	return txt;
}		

function runMyFunction(title,description) { 
	title = replaceAll(title,"---replace1---","'");
	description = replaceAll(description,"---replace1---","'");
	title = replaceAll(title,"---replace2---","\"");
	description = replaceAll(description,"---replace2---","\"");
					
       myWindow=window.open('','','width=400,height=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes')		
		
		myWindow.document.write("<html><body><h4 style='color:green;'>");			
		myWindow.document.write("Question:&nbsp;"+title+"<br></h4><h4 style='color:blue;'>");
		myWindow.document.write("Answer:&nbsp;"+description+"<br>");
		myWindow.document.write("</h4></body></html>");
			
		return true;
}	
	
function processSuccess(data, status, req) {
	var txt="";
       if (status == "success") {
//		alert("RSSFeed:"+req.responseXML);	
	       var i = 1; 
		$(req.responseXML).find('item').each(function(){
			          
			var title = $(this).find('title').text();
			var description = $(this).find('description').text();	
//          var newTitle = replaceAll(title,"'","---replace1---");  					 
//			var newDescription = replaceAll(description,"'","---replace1---"); 
//			newTitle = replaceAll(newTitle,"\"","---replace2---");  					 
//			newDescription = replaceAll(newDescription,"\"","---replace2---");		 
//     		txt += "<li><a onClick='runMyFunction(\""+newTitle+"\",\""+newDescription+"\");'>"
//			txt += "<li><a href=\"#\" data-faq-question=" +title+ "\ data-faq-answer=" +description+ ">"
 //           txt += title;
//			txt += "</a></li>";	
            txt += '<li><a href="#" data-faq-question="' + title + '"data-faq-answer="' + description + '">';	
            txt += title;
			txt +='</a></li>';					   					 
                     if(i==3) {
                       return false;
                     }
                     i++;					
	       });              			  
		document.getElementById('response').innerHTML=txt;
	}            
}

function processError(data, status, req) {
//     alert("RSSFeed error"); 
//     alert(req+ " " + status);
}  


