/* *******************************************************
J  a  v  a  c  a  t  z
Filename:   bodyOnLoader.js
Purpose:    This file is created to hold the function used
            in the onload="..." attribute of <body> tag.
            Please do not put other codes in this file.
Created by: KY 2007.11.30
Modified by KY 2007.12.06
******************************************************* */

var noresize = true;

function bodyOnLoader(currentTopnav, currentLeftnav) {
	fixPNG();
	if($$('body.fullbackground') && $$('body.fullbackground').length>0) noresize = false;
	// else if($$('body#index') && $$('body#index').length>0) noresize = false;
	if($$('body#index') && $$('body#index').length>0) $$('html').each( function(node) { $(node).style.backgroundColor = "#FFF"; } );
	if(!noresize) renderPageResize();
	var elemTodays = $$('#header_midlink .today');
	var today = new Date();
	today = formatTime(today);
	if(elemTodays && elemTodays.length > 0) elemTodays.each( function(node) { $(node).innerHTML = today; } );
	if($('topnav_'+currentTopnav)) $('topnav_'+currentTopnav).className += ' current';
	if($('leftnav_'+currentLeftnav)) $('leftnav_'+currentLeftnav).className += ' current';
	printbar_init();
	ky_slidemenu_init();

	/* screenmode */
	var screenmode = getParameter("screenmode");
	if(screenmode != null && screenmode != "") {
		if(screenmode.toLowerCase()=="print") printPage2();
	}
	if(getParameter("screenmode")=="print") {
		$$('select').each( function(node) { $(node).disabled=true; } );
		$$('input').each( function(node) { $(node).disabled=true; } );
	}
	/* ie flash object focus */
	ieupdate();
	
	ky_backTop_init();
	
	if($$('body#index').length > 0) {
		setTimeout("renderIndex();",0);
	}
}

window.onresize = function() {
	if(!noresize) setTimeout('renderPageResize();',10);
}

function renderPageResize() {
	if(!noresize) {
		try {
			if(document.getElementById('mainContent')) {
				document.getElementById('mainContent').style.height = "";
				var targetHeight = displaySize('height') - parseInt(getElementStyle("page_top","height","height")) - parseInt(getElementStyle("footer","height","height"));
				if(parseInt(getElementStyle2(document.getElementById('mainContent'),'height','height')) < parseInt(targetHeight) ) {
					document.getElementById('mainContent').style.height = targetHeight + 'px';
				}
			}
		} catch(e) {
		}
	}
}

function renderIndex() {
	setTimeout("if($('page_top_inner')) new Effect.Fade( $('page_top_inner'), { duration: 0, afterFinish: function() { $('page_top_inner').style.marginTop = 0; new Effect.Appear( $('page_top_inner'), { duration: 3.0 } ); } } );",1000);
	setTimeout("if($('header_logo')) new Effect.Fade( $('header_logo'), { duration: 0, afterFinish: function() { $('header_logo').style.marginTop = 0; new Effect.BlindDown( $('header_logo'), { duration: 3.0 } ); } } );",1000);
	setTimeout("if($('topnav')) new Effect.Fade( $('topnav'), { duration: 0, afterFinish: function() { $('topnav').style.marginTop = 0; new Effect.Appear( $('topnav'), { duration: 2.5 } ); } } );",3000);
	setTimeout("if($('header_midlink_tabs')) new Effect.Fade( $('header_midlink_tabs'), { duration: 0, afterFinish: function() { $('header_midlink_tabs').style.marginTop = 0; new Effect.Pulsate( $('header_midlink_tabs') ); new Effect.Appear( $('header_midlink_tabs'), { duration: 2.0 } ); } } );",4000);
	// setTimeout("if($('header_midlink_tabs')) new Effect.Pulsate( $('header_midlink_tabs'), { duration: 3.0, pulses: 5, from: 0.5 } );",4000);
}
