﻿jQuery(document).ready(function(){
	AddCorners();
	// 3 recent posts
	EqualizeHeight();

	AlterHeader();

	TranslatePageParts();

	AdjustPageElements();


});


function AdjustPageElements(){

	jQuery("#content .postWithMenu:first").each(function(){

		jQuery("#content").addClass("postWithMenu");

		});



}


function AlterHeader(){
    jQuery("#blog-title").click(function(e){
	self.location = homeurl;
	});

}


function TranslatePageParts(){

	jQuery(".paginated-comments-links a.prev").each(function(){
		//this.innerHTML = this.innerHTML.replace("Previous","");
		this.innerHTML = "&#9658;";
		});

	jQuery(".paginated-comments-links a.next").each(function(){
		//.this.innerHTML = this.innerHTML.replace("Next","");
		this.innerHTML = "&#9668;";
		});

}

function AddCorners(){
	// add folded corner to every box in the layout
	var txtSelector = "";
	if (jQuery(document.body).hasClass("tag")){
	   txtSelector = "#content .p1,#content .p2,#content .p3, .posts_box";
	}else if (jQuery(document.body).hasClass("search")){
	    txtSelector = "#content .p1,#content .p2,#content .p3, .posts_box";
	}else if (jQuery(document.body).hasClass("slug-presentations")){
	    txtSelector = ".thumbnailWrap ";
	}else if (jQuery(document.body).hasClass("single")){
		txtSelector = "#container";
	}else if (jQuery(document.body).hasClass("archive")){
	    txtSelector = "#content .p1,#content .p2,#content .p3, .posts_box";
	}else if (jQuery(document.body).hasClass("category")){
	    txtSelector = "#content .p1,#content .p2,#content .p3, #container";
	}else if (jQuery(document.body).hasClass("page")){
	    txtSelector = "#container";
	}else if (jQuery(document.body).hasClass("blog")){
	    txtSelector = "#content .p1,#content .p2,#content .p3,#content .p4, .posts_box";
	}
	if (txtSelector=="")return;



	jQuery(txtSelector).each(function(){

		jQuery(this).append('<span class="paperFold"></span>');
		});

	jQuery("#primary").append('<br class="clearer" /><span class="paperFold"></span>');
	jQuery("#footer_bg").append('<span class="corner_right"></span>')
	jQuery("#footer_bg").append('<span class="corner_left"></span>')




}

function EqualizeHeight(){
	// make every post in the group the same height
	var maxHeight=0;

	var txtSelector = "";
	if (jQuery(document.body).hasClass("tag")){
	    txtSelector = "#content .p1,#content .p2,#content .p3";
	}else if (jQuery(document.body).hasClass("search")){
	    txtSelector = "#content .p1,#content .p2,#content .p3";
	}else if (jQuery(document.body).hasClass("slug-presentations")){
	    txtSelector = ".thumbnailWrap ";
	}else if (jQuery(document.body).hasClass("archive")){
	    txtSelector = "#content .p1,#content .p2,#content .p3";
	}else if (jQuery(document.body).hasClass("category")){
	    txtSelector = "#content .p1,#content .p2,#content .p3";
	}else if (jQuery(document.body).hasClass("blog")){
	    //txtSelector = "#container";
	    txtSelector = "#content .p2,#content .p3,#content .p4";
	}
	if (txtSelector=="")return;

	var group = jQuery(txtSelector);
	group.each(function(){
		if (jQuery(this).height()>maxHeight){
			maxHeight = jQuery(this).height();
		}
	});
	group.height(maxHeight);

}

