		var thecontent='';
		var excerptsxml='';
		var mystuff='';
		var stripped = '';
		var theExcerpt= new Array(postsPerPage); 
		var thecontent= new Array(postsPerPage); 
		var theTitle= new Array(postsPerPage);
		var comments= new Array(postsPerPage); 
		var postMeta= new Array(postsPerPage); 
		var i;
		var mynum=0;
		
function rnd(){ return String((new Date()).getTime()).replace(/\D/gi,'') }

function resetPosts(elem){
	//reset everything
	jQuery(".minimize").remove();
	jQuery(".comment-content").hide();
	jQuery("#articles").find(".posts").removeClass("maximized");
	
	jQuery("#top-stories .posts .full-content").show();
	for(i=1;i<postsPerPage;i++){
		jQuery(".post-num-" + i + " .full-content").html(theExcerpt[i]);
	}
	jQuery("#top-stories .posts").css("opacity","1");

	jQuery(".maximized").remove();
}

function getPostNum(elem){
	str = elem.parents(".posts").attr("class").toString();
	var num = str.match(/\d+/);
	//alert (str + " " + num);
	return num;
}

function minimize(elem){
	str = elem.parents(".posts").attr("class").toString();
	var num = str.match(/\d+/);
	
}


function smallSize(){
	
	jQuery(".sidebar-left").css({
				"position":"inherit",
		"float":"left",
		"position":"fixed",
		"-moz-border-radius":"0",
"background-color":"#E9ECEB",
"background-image":"none",
"margin":"0",
"padding":"0",
"top":"70px",
"width":"120px"});
	jQuery(".sidebar-left ul").css({"width":"116px","padding":"0 18px 18px"});
	jQuery(".sidebar-left ul li a").css({"color":"#909090","display":"block","background":"none","border":"0"});
	jQuery(".sidebar-left ul li").css({"position":"relative","display":"block", "margin":"0px","float":"none","background":"none","border":"0"});
	jQuery(".rightwrap").css({"position":"inherit","float":"right", "margin":"0", "width":"635px","padding":"0"});
	jQuery(".content").css({"width":"590px","float":"left", "margin":"0 0 0 30px"});
	jQuery("#wrapper").css({"width":"770px", "margin":"0 auto"});
	jQuery(".sidebar-left ul .home").css({"margin-bottom":"14px"});
	jQuery(".sidebar-left ul .current-cat").css({"background":"#fff","background":"#fff","font-weight":"bold","border":"1px solid #ddd","border-right":"0","-moz-border-radius-topleft":"6px","-moz-border-radius-bottomleft":"6px","-webkit-border-top-left-radius":"6px","-webkit-border-bottom-left-radius":"6px","margin-left":"-16px"});
	jQuery(".sidebar-left ul .current-cat a").css({"color":"#444444","display":"block","margin":"5px 16px"});
	jQuery(".sidebar-right").css({"display":"none"});
	jQuery("#top-stories .posts").css({"width":"29%"});
}

function mediumSize(){
	jQuery(".sidebar-left").css({"position":"relative","margin":"10px auto","width":"100%","top":"0","float":"none","clear":"both","background":"#000000","padding":"5px 0","color":"#ffffff","-moz-border-radius":"6px","-webkit-border-radius":"6px"});
	jQuery(".sidebar-left ul").css({"position":"relative","width":"100%","padding":"0px"});
	jQuery(".sidebar-left ul li a").css({"color":"#ffffff","display":"inline","background":"none","border":"0"});
	jQuery(".sidebar-left ul li").css({"position":"relative","display":"inline", "margin-left":"35px","float":"none","background":"none","border":"0"});
	jQuery(".rightwrap").css({"position":"relative","float":"none", "margin":"0 auto", "width":"950px","padding":"0px"});
	jQuery(".content").css({"width":"650px","margin-left":"30px"});
	jQuery("#wrapper").css({"width":"950px", "margin":"0 auto"});
	jQuery(".sidebar-left ul .home").css({"margin-bottom":"0"});
	jQuery(".sidebar-right").css({"display":"block"});
	jQuery("#top-stories .posts").css({"width":"29%"});
}

function largeSize(){
	
	jQuery(".sidebar-left").css({
				"position":"inherit",

		"float":"left",
		"position":"fixed",
		"-moz-border-radius":"0",
"background-color":"#000",
"background-image":"none",

"margin":"0",
"padding":"0",

"top":"70px",
"width":"120px"});
	jQuery(".sidebar-left ul").css({"width":"116px","padding":"0 18px 18px"});
	jQuery(".sidebar-left ul li a").css({"color":"#fff","display":"block","background":"none","border":"0"});
	jQuery(".sidebar-left ul li").css({"position":"relative","display":"block", "margin":"0px","float":"none","background":"none","border":"0"});
	jQuery(".rightwrap").css({"position":"inherit","float":"right", "margin":"0", "width":"1035px","padding":"20px 0 20px 30px"});
	jQuery(".content").css({"width":"750px","float":"left", "margin":"0"});
	jQuery("#wrapper").css({"width":"1200px", "margin":"0 auto"});
	jQuery(".sidebar-left ul .home").css({"margin-bottom":"14px"});
	jQuery(".sidebar-left ul .current-cat").css({"background":"#fff","background":"#fff","font-weight":"bold","border":"1px solid #ddd","border-right":"0","-moz-border-radius-topleft":"6px","-moz-border-radius-bottomleft":"6px","-webkit-border-top-left-radius":"6px","-webkit-border-bottom-left-radius":"6px","margin-left":"-16px"});
	jQuery(".sidebar-left ul .current-cat a").css({"color":"#000","display":"block","margin":"5px 16px"});
	jQuery(".sidebar-right").css({"display":"block"});
	jQuery("#top-stories .posts").css({"width":"29%"});
}


function vSmallSize(){
	
	jQuery(".sidebar-left").css({"position":"relative","margin":"10px auto","width":"100%","top":"0","float":"none","clear":"both","background":"#000000","padding":"5px 0","color":"#ffffff","-moz-border-radius":"6px","-webkit-border-radius":"6px"});
	jQuery(".sidebar-left ul").css({"position":"relative","width":"100%","padding":"0px"});
	jQuery(".sidebar-left ul li a").css({"color":"#ffffff","display":"inline","background":"none","border":"0"});
	jQuery(".sidebar-left ul li").css({"position":"relative","display":"inline", "margin-left":"35px","float":"none","background":"none","border":"0"});
	jQuery(".rightwrap").css({"position":"relative","float":"none", "margin":"0 auto", "width":"570px","padding":"0px"});
	jQuery(".content").css({"width":"540px","margin-left":"30px"});
	jQuery("#wrapper").css({"width":"570px", "margin":"0 auto"});
	jQuery(".sidebar-left ul .home").css({"margin-bottom":"0"});
	jQuery(".sidebar-right").css({"display":"none"});
	jQuery("#top-stories .posts").css({"width":"29%"});
}
function xSmallSize(){
	
	jQuery(".sidebar-left").css({"position":"relative","margin":"10px auto","width":"100%","top":"0","float":"none","clear":"both","background":"#000000","padding":"5px 0","color":"#ffffff","-moz-border-radius":"6px","-webkit-border-radius":"6px"});
	jQuery(".sidebar-left ul").css({"position":"relative","width":"100%","padding":"0px"});
	jQuery(".sidebar-left ul li a").css({"color":"#ffffff","display":"inline","background":"none","border":"0"});
	jQuery(".sidebar-left ul li").css({"position":"relative","display":"inline", "margin-left":"5px","float":"none","background":"none","border":"0"});
	jQuery(".rightwrap").css({"position":"relative","float":"none", "margin":"0 auto", "width":"100%","padding":"0px"});
	jQuery(".content").css({"width":"98%","margin-left":"2%"});
	jQuery("#wrapper").css({"width":"98%", "margin":"0 auto"});
	jQuery(".sidebar-left ul .home").css({"margin-bottom":"0"});
	jQuery(".sidebar-right").css({"display":"none"});

	jQuery("#top-stories .posts").css({"width":"90%"});
}
function init() {
		//jQuery(".comment-content").hide();
		jQuery(".minimize").hide();
		jQuery("#top-stories .posts .full-content").show();
		jQuery(".comment-content").hide();
		jQuery("#single .comment-content").show();
		for(i=1;i<postsPerPage;i++){
		thecontent[i]=jQuery(".post-num-" + i + " .full-content").html();
		theTitle[i]=jQuery(".post-num-" + i + " h2 a[rel]").html();
		//comments[i]=jQuery(".post-num-" + i + " .comment-content").html();
		postMeta[i]=jQuery(".post-num-" + i + " .postmetadata-top").html();
		jQuery(".post-num-" + i + " .full-content").html(theExcerpt[i]);
		}
		jQuery(".posts .full-content").show();
		
     				jQuery("#top-stories .posts h2 a").live("click",function(max){
     					//get this post number (NOT it's Wordpress ID)//
     					var num = getPostNum(jQuery(this));
     					
     					//open adequate box//
     					var alreadyMaximizedClass = '';
     					var alreadyMaximizedNum = 0;
     					if (alreadyMaximizedClass = jQuery(".maximized").attr("class")){
     						
     						alreadyMaximizedNum = Number(alreadyMaximizedClass.match(/\d+/));
     						
						}
						num = Number(num);
     					if (num == alreadyMaximizedNum){ //This post is maximized. shrinking//
     					num = String(num);
							jQuery(".maximized").remove();
							resetPosts(jQuery(this));
						}else{ //this post is not maxed, doing it now
     						//reset everything//
     						resetPosts(jQuery(this));
     						var maxDiv = '<div class="maximized orig' + num + '"><div class="minimize"><a href="#">minimize</a></div><h2><a href="#">' + theTitle[num] + '</a></h2><div class="postmetadata-top">' + postMeta[num] + '</div><div class="full-content">' + thecontent[num] + '</div><div class="comment-content"><a href="#"class="show-comments comments-num' + num + '">Show comments</a></div><div class="minimize"><a href="#">minimize</a></div></div>';
     						jQuery("#top-stories").after(maxDiv);
     						jQuery(".maximized .top-story-thumbnail").hide();
     						jQuery(this).parents(".posts").css("opacity","0.4");
     						jQuery(this).css("color","#000000");
     						jQuery(this).parent().css("color","#000000");
						}
						
     					max.preventDefault();
						return false;
					});
					
					jQuery(".maximized .minimize").live("click",function(minim){
						resetPosts(jQuery(this));
     					minim.preventDefault();
						return false;
     				});
	
	
		/**********
		 * Click on the regular posts title
		 * */
		     	jQuery("#articles .posts h2 a").live("click",function(max){
		     				if (jQuery(".maximized").attr("class")){
		     				var str=jQuery(".maximized").attr("class").toString()
							//var str="posts post-num-0 maximized";
							var mynum=str.match("[0-9][0-9]?[0-9]?");
		     				}
		     				//alert(mynum);
					resetPosts(jQuery(this));
     						
		     		for(i=4;i<postsPerPage;i++){
     					if(jQuery(this).parents(".post-num-" + i).find(".full-content").html()!=thecontent[i]){

     						jQuery(this).parents(".post-num-" + i).find(".full-content").html(thecontent[i]);
     						if (!jQuery(".post-num-" + i + " .minimize").html()){
     							jQuery(this).parents(".post-num-" + i).prepend('<div class="minimize"><a href="http://jfoucher/">minimize</a></div>');
     			
     							jQuery(this).parents(".post-num-" + i).append('<div class="minimize"><a href="http://jfoucher/">minimize</a></div>');
     							
							}
							jQuery(this).parents(".post-num-" + i).addClass("maximized");
							jQuery(this).parents(".post-num-" + i).find(".minimize").show();
							jQuery(this).parents(".post-num-" + i).find(".comment-content").show();

						}else{
							jQuery(this).parents(".post-num-" + i).find(".full-content").html(theExcerpt[i]);
						}
     				}
     				
     				
     				
 
     				max.preventDefault();
					return false;
				});

			
				
				jQuery("#articles .posts .minimize").live("click",function(minimizing){
							//jQuery(".minimize").show();
		     		for(i=4;i<postsPerPage;i++){
		     		//if(jQuery(this).parents(".post-num-" + i).find(".full-content").html()==thecontent[i]){
		     		//alert(theExcerpt[i]);
     					jQuery(this).parents(".post-num-" + i).find(".full-content").html(theExcerpt[i]);
     					jQuery(this).parents(".post-num-" + i).find(".minimize").hide();
     					jQuery(this).parents(".post-num-" + i).find(".comment-content").hide();
     					jQuery(".posts").removeClass("maximized");
     				//}
     				}

     				minimizing.preventDefault();
					return false;
				});
	/**********
		 * End Click on the regular posts title
		 * */
		
		
		
		
		
		
		
		//AJAX Comments *************
		jQuery(".commentform .sub-button").live("click",function(subm){
		var scripts = jQuery(document).find("script[src]");
		for ( i = 0; i < scripts.length; i++ ) {
			var scriptSrc = jQuery(scripts[i]).attr("src");
			//alert(scriptSrc);
			var result = scriptSrc.match("main.js");
			if ( result ) break;
		}
		ajaxURL = scriptSrc.replace(/main.js/, "jquery-ajax.php");
			//ajaxURL = "http://" + top.location.host + "/wp-content/themes/wp-feedly/script/jquery-ajax.php";
			//alert(ajaxURL);
			//Change this before release

			if ( jQuery(this).parents(".comment-content").find(".commentlist").html()==null){
				//alert(jQuery(this).parent().find(".commentlist").html());
				jQuery(this).parents(".comment-content").find("h2.postcomment").before('<ol class="commentlist"></ol>');
			}
				
			jQuery(this).parents(".comment-content").find(".comments").remove();
			jQuery(this).parents(".comment-content").find(".nocom").remove();
			jQuery(this).parents(".comment-content").find(".commentlist").before('<h2 id="ajaxheader" class="comments">Comments</h2>');
	
			jQuery(this).parents(".comment-content").find("#loading").remove();
			jQuery(this).parents(".comment-content").find(".commentlist").append('<li id="loading"><p>Loading...</p></li>');
			jQuery(this).parents(".comment-content").find("#loading").hide();
			jQuery(this).parents(".comment-content").find("#loading").show("slow");
			var commentAuthor  = '';
			var commentAuthorEmail  = '';
			var commentAuthorurl = '';
			var commentContent  = '';
			var commentID  = 0;
			commentAuthor  = jQuery(this).parents(".comment-content").find(".commentform .author").attr("value");
			commentAuthorEmail  = jQuery(this).parents(".comment-content").find(".commentform .email").attr("value");
			commentAuthorurl = jQuery(this).parents(".comment-content").find(".commentform .url").attr("value");
			commentContent  = escape(jQuery(this).parents(".comment-content").find(".commentform textarea").attr("value"));
			commentID  = jQuery(this).parents(".comment-content").find(".commentform .comment_post_ID").attr("value");
			commentparent  = jQuery(this).parents(".comment-content").find(".commentform .comment_parent").attr("value");
			var command = "author=" + commentAuthor + "&email=" + commentAuthorEmail + "&url=" + commentAuthorurl + "&comment=" + commentContent + "&comment_post_ID=" + commentID + "comment_parent=" + commentparent;
			//alert(command);
			jQuery(this).parents(".comment-content").find(".commentlist").load(ajaxURL,command,function(response,status){
				jQuery(this).parents(".comment-content").find("#loading").remove();
				if (status == "error"){
					jQuery(this).parents(".comment-content").find(".commentlist").append(response);
					//alert("test" + response + status);
				}
				jQuery(".ajaxsuccess").hide();
				jQuery(".ajaxsuccess").show("slow",function(){
				jQuery(".ajaxsuccess").animate( { backgroundColor:"#ffffff" }, 2000);
				});

			});
			
			subm.preventDefault();
			return false;

		});
	
		
		
		jQuery(".commentform").submit(function(sub){
			sub.preventDefault();
			return false;
		});
		//End AJAX Comments *************
		
		
		
		//Resize document///
		//jQuery(".cats-left").append('<li id="cat-left-top"></li>');
		
		var viewportWidth = jQuery(window).width();  
		if (Number(viewportWidth) <= 600){
			xSmallSize();
		}else if (Number(viewportWidth) <= 800){
			vSmallSize()
		}else if (Number(viewportWidth) <= 950){ //Sidebar coming off the screen
			
			smallSize();
		}else if (Number(viewportWidth) <= 1205){
			mediumSize();
		
		}else{
			largeSize();
		}
		jQuery(window).resize(function(){
			var viewportWidth = jQuery(window).width();  
			//var viewportHeight = jQuery(window).height();  
			//pos = jQuery(".sidebar-left").offset();
			if (Number(viewportWidth) <= 600){
				xSmallSize();
			}else if (Number(viewportWidth) <= 800){
				vSmallSize()
			}else if (Number(viewportWidth) <= 950){ //Sidebar coming off the screen
				smallSize();
			}else if (Number(viewportWidth) <= 1205){
				mediumSize();
				
			}else{
				largeSize();
			}
			//jQuery("#cat-left-top").html(pos.left);
		});
		//End resize document
		jQuery(".show-comments").live("click",function(showcom){
			
			if (jQuery(this).attr("class")){
		    var str=jQuery(this).attr("class").toString();
		    //alert (str);
			//var str="posts post-num-0 maximized";
			var mynum=str.match("[0-9][0-9]?[0-9]?");
		    }
		    //alert(str + " " + mynum + " " + comments[mynum]);
		    if (jQuery(this).parent().find("h2.comments").html()==null){
				jQuery(this).parent().append('<div class="dyngencomments">' + comments[mynum] + '</div>');
				jQuery(this).html("Hide comments");
			}else{
				jQuery(this).parent().find(".dyngencomments").remove();
				jQuery(this).html("Show comments");
			}
			showcom.preventDefault();
			return false;
		});
		
		jQuery(".comment-reply-link").live("click",function(replycom){
			if (jQuery(this).attr("href")){
		    var str=jQuery(this).attr("href").toString();
		    //alert (str);
			//var str="posts post-num-0 maximized";
			var mynum=str.match("[0-9]+");
			//alert(mynum);
		    }
			
			jQuery('textarea.comment').focus();
			jQuery('.comment_parent').attr('value',mynum);
			replycom.preventDefault();
			return false;
		});
		
}


jQuery(document).ready(init);

