function processBlogRSS(rssxml,noOfItems,module)
{
    try
	{

    //alert("rssxml:"+rssxml);
	//alert("noOfItems:"+noOfItems);
	//alert("module:"+module);

	var randomnumberNew=Math.floor(Math.random()*11);
	var completeLiTag="";
	if(module=='blogsModule') {
		completeLiTag = new Element('div',{'id':'tempNasaBlogRss'});
	} else if (module== 'twitterModule'){		
	    completeLiTag = new Element('ul',{'id':'tempNasaTwitterRss','className':'small_gray_scroll'});
	}

    var chanElement = rssxml.getElementsByTagName("channel")[0];
    var itemElements = rssxml.getElementsByTagName("item");
	var mainTags	=	'';
	 
	if (itemElements.length < 1)
	{
	  throw err;
	} 
	
    if(noOfItems=='' || noOfItems=='undefined' || noOfItems==null || noOfItems>itemElements.length){ 
		noOfItems = itemElements.length;
	}
	
		
	   	if(itemElements.length>0){
		
     		for (var i=0; i<noOfItems; i++)
			{
                
		    
                   		
	            var tmpTitle = null;
	            var tmpDesc	=	null;
	            var tmpPubDate	=null;
	            var tmpComments	=null;
	            var tmpLink= null;
	            var tmpLinkChild;

                      if (module=='blogsModule'){
	                
	               tmpTitle = itemElements[i].getElementsByTagName("title")[0];
		        tmpLink = itemElements[i].getElementsByTagName("link")[0];
		        tmpDesc = itemElements[i].getElementsByTagName("description")[0];
		        tmpPubDate = itemElements[i].getElementsByTagName("pubDate")[0];
 	    
	            
	   	        var liTag = new Element('li',{});
		        var divTag = new Element('div',{});
		        var spanTag	= new Element('span',{'className':'datefield'});
		        var pTag	= new Element('p',{});
		
     	         var tmpTitleChild = tmpTitle.childNodes[0].nodeValue;
		        //alert(tmpTitleChild.length);
		        /*if(tmpTitleChild.length > 44)
		        {
		           tmpTitleChild=tmpTitleChild.substring(0,38);
		           tmpTitleChild+=" ...";
		        }*/
		
		        if (tmpLink && tmpLink.childNodes[0])
		        {
		           tmpLinkChild = tmpLink.childNodes[0].nodeValue;
		        }
		        var tmpPubChild = tmpPubDate.childNodes[0].nodeValue;
		        var tmpDescChild = tmpDesc.childNodes[0].nodeValue;
		        var indexDot = tmpDescChild.indexOf('<br/>');
	
		        if(indexDot!=-1)
		        {
			        tmpDescChild = tmpDescChild.substring(0,indexDot);
		        }

	          	//alert(tmpDescChild.length);
		        if (tmpDescChild.length > 54)
		        {
		                  tmpDescChild=tmpDescChild.substring(0,50);
		                  if (tmpDescChild.lastIndexOf(" ") > -1)
		                  {tmpDescChild=tmpDescChild.substring(0,tmpDescChild.lastIndexOf(" "));}
		                   tmpDescChild+=" ...";
		        }
		
	   	         spanTag.update(timeDifference(tmpPubChild,'blogsModule'));
		         pTag.update(tmpDescChild);
		         
                       if (tmpLink && tmpLink.childNodes[0])
		         {
			
		             var anchorTag	=	new Element('a',{'className':'titlefield','href':tmpLinkChild});
		             var boldTag	=	new Element('b',{});
		             anchorTag.update(tmpTitleChild);
		             liTag.insert(divTag);
                           divTag.insert(boldTag);
		             boldTag.insert(anchorTag);
		             divTag.insert(spanTag);
			      liTag.insert(pTag);
			 
			  }
		         else
		         {
				var spanTitle	=	new Element('b',{'className':'titlefield'});
		              spanTitle.update(tmpTitleChild);
		              liTag.insert(divTag);
                            divTag.insert(spanTitle);
		              divTag.insert(spanTag);
		              liTag.insert(pTag);
			  }

	   	             completeLiTag.appendChild(liTag);
                       }

                       if (module=='twitterModule'){
	                
                      
	               
                      tmpTitle= itemElements[i].getElementsByTagName("title")[0];
                                           

		        tmpLink = itemElements[i].getElementsByTagName("link")[0];
		        tmpPubDate = itemElements[i].getElementsByTagName("pubdate")[0];
 	    
	            
	   	        var liTag = new Element('li',{});
		        var divTag = new Element('div',{});
		        var spanTag	= new Element('span',{'className':'datefield'});
		        
		
     	               var tmpTitleChild1 = tmpTitle.childNodes[0].nodeValue;
                      
                      


                     var tmpTitleChild;
                      


		        if (tmpLink && tmpLink.childNodes[0])
		        {
		           tmpLinkChild = tmpLink.childNodes[0].nodeValue;
		        }
		        var tmpPubChild = tmpPubDate.childNodes[0].nodeValue;
		        
	   	         if (tmpLink && tmpLink.childNodes[0])
		         {
			      
                           //tmpTitleChild = tmpTitleChild1.replace(/(f|ht)tps?:\/\/.+?(\s|$)/g,"<a href=\'"+tmpLinkChild+"\' class=\'titlefield link\'>(link)</a>");
						   tmpTitleChild = tmpTitleChild1.replace(/(f|ht)tps?:\/\/.+?(\s|$)/g,function(match){match=match.replace(/^\s+|\s+$/g, '');
if (((match.lastIndexOf('.')+1) == match.length) && (match.lastIndexOf('.') != -1)){match=match.substring(0,match.lastIndexOf('.'));}/*alert("match:"+match);*/var temp="<a href=\'"+match+"\' class=\'titlefield link\'>(link)</a>";return temp;});

                           //alert(tmpTitleChild);

                    liTag.insert(tmpTitleChild);
        		    divTag.update("about "+timeDifference(tmpPubChild));
		            liTag.insert(divTag);
			  }
		         else
		         {
			       var spanTitle	= new Element('div',{'className':'titlefield'});
                            tmpTitleChild=tmpTitleChild1;
		              spanTitle.update(tmpTitleChild);
		              liTag.insert(spanTitle);
                            divTag.update("about "+timeDifference(tmpPubChild,'twitterModule'));
		              liTag.insert(divTag);
			 }

                           //alert(liTag.innerHTML);
	   	             completeLiTag.appendChild(liTag);
                       }

              }
                       if (module=='twitterModule'){
                       var liTag1 = new Element('li',{});
                       var anchorTag1 = new Element('a',{'className':'titlefield','href':'http://twitter.com/nasa'});
                       anchorTag1.setStyle({'float':'right'});
                       anchorTag1.update('&rsaquo;&nbsp;More Updates&nbsp;&rarr;');
                       liTag1.insert(anchorTag1);
                       completeLiTag.appendChild(liTag1);}


		}

	
	var dummyParent = "";
	var tempDiv = "";

	if(module=='blogsModule') {
		dummyParent = $('nasablogs_recentpostings').parentNode;
		tempDiv = $('tempNASABlogRss');
	}
    else if (module=='twitterModule')
    {
		dummyParent = $('nasatwitter_recenttweets').parentNode;
		tempDiv = $('tempNASATwitterRss');
	}
	
	if(tempDiv!=null){
		tempDiv.remove();
	}
	
	dummyParent.appendChild(completeLiTag);

				
	
  	if(module=='blogsModule') {
		$('nasablogs_recentpostings').innerHTML='';
	}
    
    if(module=='twitterModule') {
		$('nasatwitter_recenttweets').innerHTML='';
	}
	
	}
	catch(err)
	{
	       if(module=='blogsModule'){
	       try
		   {
	       $('blog_dynamic_html').hide();
           document.getElementById('blog_static_html').style.display='block';
           document.getElementById('blog_static_html').style.visibility='visible';
	       }
		   catch (err)
		   {
		   }
		   }
		   else if (module=='twitterModule'){
	       try
		   {
	        $('nasa_ticker').hide();
            document.getElementById('nasa_ticker_static_msg').style.display='block';
            document.getElementById('nasa_ticker_static_msg').style.visibility='visible';
	       }
		   catch (err)
		   {
		   }
		   }
		   else {
		   }
	}
	
}

function timeDifference(tmpPubChild,module)
{

    try
	{

  	var date = new Date(tmpPubChild);
	var date1= new Date();
	//alert("date:"+date);
	//alert("date1:"+date1);
		

    var difference = date1.getTime() - date.getTime();
    var daysDifference = Math.floor(difference/1000/60/60/24);
    difference -= daysDifference*1000*60*60*24
    var hoursDifference = Math.floor(difference/1000/60/60);
    difference -= hoursDifference*1000*60*60
    var minutesDifference = Math.floor(difference/1000/60);
    difference -= minutesDifference*1000*60
    var secondsDifference = Math.floor(difference/1000);
	
	/*alert(32 - new Date (2008,1,32).getDate());*/

	if ( daysDifference > 0 )
     {
     	 if( daysDifference >= 365 )
          {
           var year = date1.getFullYear()-date.getFullYear();
           if(year==0)year=1;
           tmpPubChild = year + (year>1?" years":" year") + " ago";
          }
          else
          {
                  var month = 0;
		          if ( daysDifference >  (32 - new Date (date.getFullYear(),date.getMonth(),32).getDate()))
		          {
                      month = Math.abs(((date1.getFullYear()-date.getFullYear())*12)+(date1.getMonth()-date.getMonth()));
                  }
		  
                 if(month>0)
                 {
                      tmpPubChild = month + (month>1?" months":" month") + " ago";
                 }
                  else
                 {
                      tmpPubChild = daysDifference + (daysDifference>1?" days":" day") + " ago";
                 }
         
		   }
         
	 }
     else if(hoursDifference>0)
     {
        tmpPubChild = hoursDifference + (hoursDifference>1?" hours":" hour") + " ago";
     }
    else if(minutesDifference>0)
     {
        tmpPubChild = minutesDifference + (minutesDifference>1?" mins":" min") + " ago";
     }
    else if(secondsDifference>0)
     {
        tmpPubChild = secondsDifference + (secondsDifference>1?" secs":" sec") + " ago";
     }
    else
     {
        tmpPubChild = "just now";
     }

	//alert(tmpPubChild);
	return tmpPubChild;
	
	}
	catch(err)
	{
	       if(module=='blogsModule'){
	       try
		   {
	       $('blog_dynamic_html').hide();
           document.getElementById('blog_static_html').style.display='block';
           document.getElementById('blog_static_html').style.visibility='visible';
	       }
		   catch (err)
		   {
		   }
		   }
		   else if (module=='twitterModule'){
	       try
		   {
	        $('nasa_ticker').hide();
            document.getElementById('nasa_ticker_static_msg').style.display='block';
            document.getElementById('nasa_ticker_static_msg').style.visibility='visible';
	       }
		   catch (err)
		   {
		   }
		   }
		   else {
		   }
	}
	
}



