var oMonth = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
function DoRSSBlogs_Posting(xml,id,name,profile){
	var oHTML = "";
	$('#right #contributorinformation').fadeOut('fast',function(){
		$('.loader').fadeIn('fast');
	});
	$.ajax({
		url: '/XMLReader.ashx?url=' + xml,
		cache: false,
		beforeSend: function(){
			//$('#right #contributorinformation').html("loading..");
		},
		success: function(xml){
			var oDescripton = "";
			var oTitle = "";
			var oDate = "";	
			
			if($('entry:eq('+id+') > title', xml).text() == ""){
				oDescripton = $('item:eq('+id+') > description', xml).text();
				oTitle = $('item:eq('+id+') > title', xml).text();
				oDate = $('item:eq('+id+') > pubDate', xml).text();
				oEncodedTitle = encodeURI(""+oTitle+"");
			}else{
				oDescripton = $('entry:eq('+id+') > content', xml).text();
				oTitle = $('entry:eq('+id+') > title', xml).text();
				oDate = $('entry:eq('+id+') > published', xml).text();
				oEncodedTitle = encodeURI(""+oTitle+"");
			}
			var listDate = new Date(oDate);
			
			oHTML = "<div class=\"subheading left\">"+oMonth[listDate.getMonth()] + " " + listDate.getDay() + ", " + listDate.getFullYear()+"</div>";
			oHTML += "<h1 class=\"clear blog\">"+oTitle+"</h1>";
			oHTML += "<h2 class=\"small\">By: <a href=\""+profile+"\">"+name+"</a> | <a href=\""+profile+"\">View "+name+"'s Contributor Profile</a></h2>";
			oHTML += "<div class=\"copy\">"+oDescripton+"</div>";
			$('.loader').fadeOut(250,function(){
				$('#right #contributorinformation').html(oHTML, function(){
					$('#right #contributorinformation').fadeIn('slow');
				});
			});
		}
	})
}
function DoRSSBlogs(xml, name, profile){
	var oHTML = "";
	var oXML = xml;
	$('#blogs .section').fadeOut('fast',function(){
		$('#blogs .loader').fadeIn('fast');
	});
	$.ajax({
		url: '/XMLReader.ashx?url=' + xml,
        cache: false,
        beforeSend: function(){
        	//$('.loader').fadeIn('fast');
		},
        success: function(xml){
			oHTML ="<ul id=\"bloglist\">";
			for(var i=0;i<parseInt(blogNumber);i++){
				var oDescripton = "";
				var oTitle = "";
				var oDate = "";	
				
				if($('entry:eq('+i+') > title', xml).text() == ""){
					oDescripton = $('item:eq('+i+') > description', xml).text();
					oTitle = $('item:eq('+i+') > title', xml).text();
					oDate = $('item:eq('+i+') > pubDate', xml).text();
					oEncodedTitle = encodeURI(""+oTitle+"");
				}else{
					oDescripton = $('entry:eq('+i+') > summary', xml).text();
					oTitle = $('entry:eq('+i+') > title', xml).text();
					oDate = $('entry:eq('+i+') > published', xml).text();
					oEncodedTitle = encodeURI(""+oTitle+"");
				}
				var listDate = new Date(oDate);
				
				oHTML +="<li class=\"clearfix\">";
				oHTML +="    <div class=\"bloglistcontent\">";
				oHTML +="        <div class=\"bloglistinfo\">";
				oHTML +="            <div class=\"subheading runtime\">"+oMonth[listDate.getMonth()] + " " + listDate.getDay() + ", " + listDate.getFullYear()+"</div>";
				oHTML +="            <h2 class=\"green\"><a title=\""+oTitle+"\" href=\"/Blog+Pages/Contributor+Blog+Posting?XML="+oXML+"&Id="+i+"&Title="+oEncodedTitle+"&Name="+name+"&Profile="+profile+"\" rel=\"no-follow\">"+oTitle+"</a></h2>";
				oHTML +="            <span>"+oDescripton.replace('[...]','...')+"</span></span>";
				oHTML +="        </div>";
				oHTML +="        <a class=\"btngreen selected\" href=\"/Blog+Pages/Contributor+Blog+Posting?XML="+oXML+"&Id="+i+"&Title="+oEncodedTitle+"&Name="+name+"&Profile="+profile+"\" rel=\"no-follow\"><span class=\"left\"></span><span class=\"copy\">READ MORE</span><span class=\"right\"></span></a>";
				oHTML +="    </div>";
				oHTML +="</li>";
			}
			oHTML +="</ul>";
			$('#blogs .loader').fadeOut(250,function(){
				$('#blogs .section').html(oHTML, function(){
					$('#blogs .section').fadeIn('slow');
				});
			});
		}
	})
}
function DoRSSVideos_CategoryPage(xml, name, profile, category, videoAmount){
	var oHTML = "";
	var oXML = xml;
	var entryList = "";
	$.ajax({
		url: '/XMLReader.ashx?url=' + xml,
        cache: false,
        beforeSend: function(){
        	//$('.loader').fadeIn('fast');
		},
        success: function(xml){
			for(var i=0;i<parseInt($('item', xml).length);i++){
				if($('item:eq('+i+') > category',xml).text() == category){
					entryList+=i+",";
				}
			}
			entryList = entryList.slice(0,entryList.length-1);
			entryList = entryList.split(",",entryList.length-1);
			for(var i=0;i<parseInt(entryList.length);i++){
				var oTitle = $('item:eq('+entryList[i]+') > title', xml).text();
				if(oTitle != ""){
					var oImage = $('item:eq('+entryList[i]+') > thumbnail', xml).text();
					var oCategory = $('item:eq('+entryList[i]+') > category',xml).text();
					var oEncodedTitle = encodeURI(""+oTitle+"");
					
					var oCatId="";
					var oCatIdHTML="";
					for(var a=0;a<oCategoryNames.length;a++){
						if(oCategoryNames[a].replace(" ","") == oCategory.replace(" ","")){
							oCatId = oCategoryIds[a];
						}
					}
					if(oCatId!="")
						oCatIdHTML = "&CId="+oCatId;

					if(i%2==0)
						oHTML +="<li class=\"clear\">";
					else
						oHTML +="<li>";
					oHTML +="	<div class=\"image\"><a title=\""+oTitle+"\" href=\"/Contributor+Videos/Video?XML="+encodeURI(oXML)+oCatIdHTML+"&Category="+oCategory+"&Id="+entryList[i]+"&Title="+oEncodedTitle+"&Name="+name+"&Profile="+profile+"\"><img width=\"229\" alt=\""+oTitle+"\" src=\""+oImage+"\"></a></div>";
					oHTML += "	<h2 class=\"green\"><a title=\""+oTitle+"\" href=\"/Contributor+Videos/Video?XML="+encodeURI(oXML)+oCatIdHTML+"&Category="+oCategory+"&Id="+entryList[i]+"&Title="+oEncodedTitle+"&Name="+name+"&Profile="+profile+"\">"+oTitle+"</a></h2>";
					oHTML +="</li>";
				}
				$('#contributorvideolist').html(oHTML);
			}
			
		}
	})
}
function DoRSSVideos(xml, name, profile){
	var oHTML = "";
	var oXML = xml;
	
	$('#videos .section').fadeOut('fast',function(){
		$('#videos .loader').fadeIn('fast');
	});
	$.ajax({
		url: '/XMLReader.ashx?url=' + xml,
        cache: false,
        beforeSend: function(){
        	//$('.loader').fadeIn('fast');
		},
        success: function(xml){
			oHTML ="<ul class=\"videolist\">";
			for(var i=0;i<parseInt(videoNumberProfile);i++){
				
				var oTitle = $('item:eq('+i+') > title', xml).text();
				if(oTitle != ""){
					var oImage = $('item:eq('+i+') > thumbnail', xml).text();
					var oCategory = $('item:eq('+i+') > category',xml).text();
					var oEncodedTitle = encodeURI(""+oTitle+"");
					
					var oCatId="";
					var oCatIdHTML="";
					for(var a=0;a<oCategoryNames.length;a++){
						if(oCategoryNames[a].replace(" ","") == oCategory.replace(" ","")){
							oCatId = oCategoryIds[a];
							//alert(oCategoryNames[a] + "::"+oCategory+"::"+oCategoryIds[a]+"::");
							//break;
						}
					}
					if(oCatId!=""){
						oCatIdHTML = "&CId="+oCatId;
					}
					
					if(i%2==0)
						oHTML +="<li class=\"clear\">";
					else
						oHTML +="<li>";
					oHTML +="	<div class=\"image\"><a title=\""+oTitle+"\" href=\"/Contributor+Videos/Video?XML="+encodeURI(oXML)+oCatIdHTML+"&Category="+oCategory+"&Id="+i+"&Title="+oEncodedTitle+"&Name="+name+"&Profile="+profile+"\"><img width=\"229\" alt=\""+oTitle+"\" src=\""+oImage+"\"></a></div>";
					oHTML += "	<h2 class=\"green\"><a title=\""+oTitle+"\" href=\"/Contributor+Videos/Video?XML="+encodeURI(oXML)+oCatIdHTML+"&Category="+oCategory+"&Id="+i+"&Title="+oEncodedTitle+"&Name="+name+"&Profile="+profile+"\">"+oTitle+"</a></h2>";
					oHTML +="</li>";
					if(i%2==0 && i > 0)
						oHTML +="<li class=\"spacer\">&nbsp;</li>";
				}
			}
			oHTML +="</ul>";
			$('#videos .loader').fadeOut(250,function(){
				$('#videos .section').html(oHTML, function(){
					$('#videos .section').fadeIn('slow');
				});
			});
		}
	})
}
