function edgeInitialiseEdges() {
	jQuery('.edged').each(function(){
		edgeRecalculate(this);
	});
}
/*
function edgeInitialiseHeading() {
	var edgeObject = jQuery('#content_main > h1:first-child > div.edged.highlighted');
	if (edgeObject.length <= 0) {
		jQuery('#content_main > h1:first-child').prepend("<div class='edged highlighted'><div class='highlightedge' /></div>");
		edgeObject = jQuery('#content_main > h1:first-child > div.edged.highlighted');
		jQuery('#content_main > h1:first-child').css("padding-left","61px");
	} 
	var edgeRatio = 0.09680851063829787234042553191489; // Calculated from Design
	var edgeWidth = jQuery(edgeObject).innerWidth();
	var edgeHeight = Math.round(edgeWidth * edgeRatio);
	var highlightHeight = edgeHeight + jQuery(edgeObject).innerHeight();
	
	var highlightObject = jQuery(edgeObject).children('.highlightedge');
	jQuery(highlightObject).css({
		borderLeftWidth : ''+edgeWidth+'px',
		borderBottomWidth : ''+highlightHeight+'px'
	});
}
*/
function edgeInitialiseTitle() {
	var edgeObject = jQuery('#title_h1_wrapper');
	var highlightObject = jQuery(edgeObject).children('.highlightedge');
	if (highlightObject.length <= 0) {
		jQuery(edgeObject).append("<div class='highlightedge' cm_dont_save='true' />");
		highlightObject = jQuery(edgeObject).children('.highlightedge');
	}
	var edgeRatio = 0.09680851063829787234042553191489; // Calculated from Design
	var edgeWidth = jQuery(edgeObject).innerWidth();
	var edgeHeight = Math.round(edgeWidth * edgeRatio);
	var highlightWidth = 45;
	var highlightHeight = edgeHeight + jQuery(edgeObject).innerHeight();
	
	jQuery(highlightObject).css({
		borderLeftWidth : ''+highlightWidth+'px',
		borderBottomWidth : ''+highlightHeight+'px'
	});
}

function edgeInitialiseNavigation() {
	jQuery('#cm_navigation ul.cm_subnavigation > li:last-child').each(function(){
		jQuery(this).parent().parent().mouseenter(function(){
			edgeRecalculate(jQuery(this).children('ul.cm_subnavigation').children('li:last-child'));
		});
	});
}

function edgeRecalculate(object) {
	var ratio = 0.09680851063829787234042553191489; // Calculated from Design
	var width = jQuery(object).innerWidth();
	var height = Math.round(width * ratio);
	var edgeObject = jQuery(object).children(".simpleedge");
	if (edgeObject.length <= 0) {
		if (jQuery(object).hasClass('append')) {
			jQuery(object).append("<div class='simpleedge' cm_dont_save='true' />");
		} else {
			jQuery(object).prepend("<div class='simpleedge' cm_dont_save='true' />");
		}
		edgeObject = jQuery(object).children(".simpleedge");
	}
	jQuery(edgeObject).css("border-left-width", ""+width+"px");
	jQuery(edgeObject).css("border-bottom-width", ""+height+"px");
}

jQuery(window).resize(function(){
	edgeInitialiseEdges();
	edgeInitialiseNavigation();
});

jQuery(window).load(function(){
	/* if (!_isEditMode) {
		edgeInitialiseHeading();
	} */
	edgeInitialiseTitle();
	jQuery(window).resize();
});