									/*  simple-complex tinySimple CMS v. 0.9.51 - www.tinysimple.net  */
/*///// template tp_ts200803 ///////////////////////////////////////////////////////////////////////////////*/

//  settings ---------------------------------------------------------
template_contentBoxWidth["normal_max"] = 580;  template_contentBoxWidth["normal_min"] = 360;
template_contentBoxWidth["wide_max"] = 780;  template_contentBoxWidth["wide_min"] = 560;
/*  final properties(are established at onload in system.js):
    template_contentBoxWidth["maximum"]
    template_contentBoxWidth["minimum"]
*/

var contentArea_topMargin;

function fixAnchorScroll() {
	try {
		if(USERAGENT == "ie")  window.detachEvent("onscroll", fixAnchorScroll);
		else  window.removeEventListener("scroll", fixAnchorScroll, false);
	} catch(noListener) { }
	scroll_by(-contentArea_topMargin);
}

function all_template_resizing(at_onLoad) {
    //  stuff that only should be done the first time ------------------------------------
    if(at_onLoad !== undefined && at_onLoad == true) {
        //
    }
    //  set element refs -----------------------------------------------------------------
	var docElm_header = getDocElm("header");
	var docElm_subheader = getDocElm("subheader", null, true);
	var docElm_contentArea = getDocElm("contentArea");
	var docElm_contentBox = getDocElm("contentBox");
	//  set width of contentArea and header-----------------------------------------------  
    browserDimensions();
    var contentArea_width;
    if(globals["browserWidth"] >= globals["browsers"]["ideal_minWidth"]) { // >= 1024x768 
        contentArea_width = template_contentBoxWidth["maximum"];
    }
    else if(globals["browserWidth"] >= globals["browsers"]["minimal_minWidth"]) { // >= 800x600
        contentArea_width = globals["browserWidth"]
                - (globals["browsers"]["ideal_minWidth"] - template_contentBoxWidth["maximum"]);
    }
    else { // < 800x600
        contentArea_width = template_contentBoxWidth["minimum"];
    }
    docElm_contentArea.style.width = "" + contentArea_width + "px";
    //  make sure that header is as wide as content (header has to hide content in all its width)
    docElm_header.style.width = "" + contentArea_width + "px";     
    //  find height of elements above content area ----------------------------------------
	var header_height = docElm_header.offsetHeight;
	contentArea_topMargin = getDocElm("topBar").offsetHeight + header_height;
	//  fix scrolling (doesnt work naturally because the whole body scrolls,
	//  but the top of body is hidden by elements above content area)
	if(at_onLoad) {
		if(location.href.search(/#/) != -1) {
			if(USERAGENT == "ie") {
				window.attachEvent("onscroll", fixAnchorScroll);
			}
			else {
				window.addEventListener("scroll", fixAnchorScroll, false);
			}
		}
	}
    //  fix shading on contentArea -------------------------------------------------------
    if(USERAGENT == "ie" && USERAGENTversion < 7) { } // dont, grading is done by png-24
    else {
        //  headers graded background
        docElm_headerBg = getDocElm("headerBg");
        docElm_headerBg.style.width = "" + contentArea_width + "px";
        getDocElm("headerBg_opaque").style.height = "" 
                + (header_height - getStyle("headerBg_gradedtransp", "height", 1)) + "px";
        var header_left = getStyle(docElm_header, "left", 1);
        docElm_headerBg.style.left = "" + header_left + "px";
        docElm_headerBg.style.top = "" + getStyle(docElm_header, "top", 1) + "px";
        docElm_headerBg.style.visibility = "visible";
        docElm_header.style.backgroundColor = "transparent"; // hide original header background
        //  bottom        
        docElm_contentArea_bottomShader = getDocElm("contentArea_bottomShader");
        docElm_contentArea_bottomShader.style.width = "" + contentArea_width + "px"; 
        docElm_contentArea_bottomShader.style.left = "" + header_left + "px"; 
        docElm_contentArea_bottomShader.style.top = "" + (globals["browserHeight"]
                - getStyle(docElm_contentArea_bottomShader, "height", 1)) + "px"; 
        docElm_contentArea_bottomShader.style.visibility = "visible"; 
    }   
	//	set position contentArea ---------------------------------------------------------
	docElm_contentArea.style.top = "" + contentArea_topMargin + "px";
	//	establish height of contentArea (for content editor) -----------------------------
	var contentArea_height = globals["browserHeight"] - contentArea_topMargin;
	//  for content editor: establish dimentions of contentBox ---------------------------
    if(docElm_subheader != null) var contentBox_height = contentArea_height - docElm_subheader.offsetHeight;
    else  var contentBox_height = contentArea_height;
	//  these values will be used by PHP for setting dimensions of contentEditor
	//	and the values will be cleared again at onload (see top of this function)
	setCookie("contentBox_innerWidth__when_sysEditors_contentEditor", contentArea_width, "session");
	setCookie("contentBox_innerHeight__when_sysEditors_contentEditor", (contentBox_height - 10), "session");

	//	if in content editor, ------------------------------------------------------------
	//	give contentArea height, make content boxes overflow hidden, and hide bottom spacer
	if(globals["sysEditorsState"] !== undefined && globals["sysEditorsState"] == "content") {
		docElm_contentArea.style.height = "" + contentArea_height + "px";
		docElm_contentArea.style.overflow = "hidden";
		getDocElm("contentBox").style.overflow = "hidden";
		getDocElm("contentEditor").style.overflow = "hidden";
	}
	/*
	if(globals["force_fixed_absolute"] == 1) {
	    docElm_tinySimpleLink = getDocElm("tinySimpleLink");
	    docElm_tinySimpleLink.style.position = "absolute";
	    docElm_tinySimpleLink.style.top = "" + (document.body.scrollHeight
	           - getStyle_effectiveHeight(docElm_tinySimpleLink, 1)) + "px";
	    alert(contentArea_topMargin + docElm_contentBox.offsetHeight
               - getStyle_effectiveHeight(docElm_tinySimpleLink, 1));
	}*/
}

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////*/