//      function addMoreClick(){
//				$("#moreToggle").click(function(){
//					// by calling sibling, we can use same div for all demos
//					$(this).siblings("#moreContent").slideToggle();
//					// $("#moreContent").slideToggle(); 
//					// confirm( $(this).text() );
//					if( $(this).text().match("show more") ) {
//						$(this).text("[show less]");
//					} else {
//						$(this).text("[show more]");
//					}
//					confirm("toggle! $(this).siblings('#moreContent'): " + $(this).siblings("#moreContent").size() );
//					return false;
//				});
//      }
      function toggleMore(oLink){
//					// by calling sibling, we can use same div for all demos
				// confirm($(oLink).text());
				// alert( $(this).text() );
				$(oLink).siblings("#moreContent").slideToggle();
//					// $("#moreContent").slideToggle(); 
//					// confirm( $(this).text() );
				if( $(oLink).text().match("show more") ) {
						$(oLink).text("[show less]");
					} else {
						$(oLink).text("[show more]");
					}
//					confirm("toggle! $(this).siblings('#moreContent'): " + $(this).siblings("#moreContent").size() );
				return false;
      }
      function doAjax(url,msg,container){
       // if the URL starts with http
       if(url.match('^http')){
         // assemble the YQL call
         msg.removeClass('error');
         msg.html(' (loading...)');
         $.getJSON("http://query.yahooapis.com/v1/public/yql?"+
            "q=select%20*%20from%20html%20where%20url%3D%22"+
            encodeURIComponent(url)+
            "%22&format=xml'&callback=?",
           function(data){
             if(data.results[0]){
               //alert(data.results[0]);
               var data = filterData(data.results[0]);
               msg.html(' (ready.)');
               // alert(data);
               container.
                 html(data);
               // addMoreClick();
             } else {
               msg.html(' (error!)');
               msg.addClass('error');
               var errormsg = 'Error: could not load the page.';
               container.
                 html(errormsg).
                   focus().
                     effect('highlight',{color:'#c00'},1000);
             }
           }
         );
       } else {
       	 // alert("hello from the else");
         $.ajax({
           url: url,
           cache: false,
           timeout:5000,
           success: function(data){
             msg.html(" (ready.)");
             container.
               html(data);
						 // addMoreClick();
             // confirm("finished with ajax call");
           },
           error: function(req,error){
           	 confirm("ERROR LOADING DATA");
             msg.html(' (error!)');
             msg.addClass('error');
             if(error === 'error'){error = req.statusText;}
             var errormsg = 'There was a communication error: '+error;
               container.
                 html(errormsg).
                   focus().
                     effect('highlight',{color:'#c00'},1000);
           },
           beforeSend: function(data){
             msg.removeClass('error');
             msg.html(' (loading...)');
           }
         });
       }
     }
     function filterData(data){
       // filter all the nasties out
       // no body tags
       data = data.replace(/<?\/body[^>]*>/g,'');
       // no linebreaks
       data = data.replace(/[\r|\n]+/g,'');
       // no comments
       data = data.replace(/<--[\S\s]*?-->/g,'');
       // no noscript blocks
       data = data.replace(/<noscript[^>]*>[\S\s]*?<\/noscript>/g,'');
       // no script blocks
       data = data.replace(/<script[^>]*>[\S\s]*?<\/script>/g,'');
       // no self closing scripts
       data = data.replace(/<script.*\/>/,'');
       // [... add as needed ...]
       return data;
     }
