﻿
// function to reset the top margin to whatever the current height of the ribbon is 
function setTopPadding() {
	var myElem = document.getElementById('s4-workspace'), newHeight = document.getElementById('s4-ribbonrow').offsetHeight;
	myElem.style.paddingTop = newHeight + 'px';
	//$('#s4-leftpanel').css({ width: 157 + 'px' });
}

function setTopPos() {
	$('.ms-cui-menu, .ms-cui-tooltip').each(function () {
		var newTop = $(this).data('origTop') || $(this).position().top;
		$(this).data('origTop', newTop);
		newTop += $('#s4-ribbonrow').position().top;
		$(this).css({ top: newTop });
	});

	//$('#s4-leftpanel').css({ width: 157 });
	//$('#MSO_ContentTable').css({ left: 2 });
}

// bind top padding reset to ribbon resize event so that the page always lays out correctly. 
ExecuteOrDelayUntilScriptLoaded(function () { SP.UI.Workspace.add_resized(setTopPadding); }, "init.js");

$(document).ready(function () {
	setInterval(setTopPos, 300);
});

function dli_Onload() {
	//alert('Pil af MS');
	//alert($('#s4-leftpanel').css('width'));



	//alert($($('.ms-bodyareacell').find('table').get(1)).attr('style'));

	//$($('.ms-bodyareacell').find('table').get(1)).removeAttr('style'); .css('border', 'solid 1px #d00')
	$('.ms-bodyareacell').find('#MSO_ContentTable').attr('cellpadding', '0').css('width', '1056').css('padding', '0').find('table:first').css('padding', '0');
	$($('.ms-bodyareacell').find('table').get(2)).css('padding', '0').css('width', '655'); //.css('border', 'solid 1px #00d');

	//$($('.ms-bodyareacell').find('table').get(1)).css('width', '707');


	//$($('.ms-bodyareacell').find('table').get(2)).find('*');

	$($($('.ms-bodyareacell').find('table').get(2)).find('*')).each(function (index) {

		//var aStr = '';
		//if ($(this).attr('width') != 'undefined') {
		//	aStr = $(this).attr('width');
		//}
		//if ($(this).css('width') != 'undefined') {
		//	aStr += ' - ' + $(this).css('width');
		//}
		//aStr = 'Width: ' + aStr;

		//alert(index + '\n' + $(this).get(0).nodeName + '\n' + aStr + '\n\n' + $(this).text());




//		if ($(this).css('width') == '1056px') {
//			//alert($(this).attr('id'));
//			$(this).css('width', '707px');
//		}
//		if ($(this).css('width') == '775px') {
//			//alert($(this).attr('id'));
//			$(this).css('width', '707px');
//		}
//		if ($(this).css('width') == '773px') {
//			//alert($(this).attr('id'));
//			$(this).css('width', '707px');
//		}


	});



	//$($('.ms-bodyareacell').find('table').get(2)).find('td').css('border', 'solid 1px #0d0');
	//$($('.ms-bodyareacell').find('table').get(1)).find('table').css('border', 'solid 1px #d00').css('width', '200');




	//ms-commentsWrapper
	//s4-wpTopTable
	//$($('.ms-bodyareacell').find('table').get(1)).find('ms-commentsWrapper').css('border', 'solid 1px #d00').css('width', '700');
	//$($('.ms-bodyareacell').find('table').get(1)).find('s4-wpTopTable').css('border', 'solid 1px #d00').css('width', '700');



	//s4-wpTopTable
	//ms-blogRightZone
	$('.ms-blogRightZone').css('width', '260').css('padding', '0').prev('td:first').css('width', '260').css('padding', '0');



	//$('.ms-blogpostdatecol').parents('.s4-wpTopTable').parents('table:first').css('border', 'solid 1px #d00').css('width', '707').parents('table:first').css('border', 'solid 1px #0d0').css('width', '1056').css('padding', '0');
	//$('.ms-blogRightZone').css('width', '260').css('padding', '0').prev('td:first').css('width', '260').css('padding', '0');
	//$('.s4-wpcell-plain').css('width', '707').css('padding', '0');
}




//function searchConfiguration() {
//	$("input[id^='<%= SearchBoxExMain.ClientID %>']").watermark('Type your Keyword here...', { className: 'searchBox-watermark' });
//	$("input[id^='<%= SearchBoxExMain.ClientID %>']").attr("title", "Type your Keyword here...");
//	$("input[id^='<%= SearchBoxExMain.ClientID %>']").css("color", "#000000");
//}
//_spBodyOnLoadFunctionNames.push("searchConfiguration");


