﻿// JScript File

// to implement onbeforeunload processing, add a control named submitClicked to the form
// and change it's value to 1 when it is clicked
//var _splitter = null;  
//var _splitterContainer = null; 

window.onload = function() { 
	setMyFooter();
}
window.onresize = function() {
	setMyFooter();
}
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function setMyFooter() {
	if (document.getElementById) {
		var windowHeight=getWindowHeight();
		var windowWidth=getWindowWidth();
		if (windowHeight>0) {
			var headerElement = document.getElementById('header-container');
			var headerHeight= headerElement.offsetHeight;
			var footerElement= document.getElementById('footer-container');
			var footerHeight=footerElement.offsetHeight;
			footerElement.style.position='absolute';
			footerElement.style.bottom = 0;
			var contentHeight = windowHeight-headerHeight-footerHeight
			var leftElement = document.getElementById('left-container');
			var leftWidth = leftElement.offsetWidth
			var rightElement = document.getElementById('right-container');
			var contentElement = document.getElementById('content-container');
			if (contentElement != null) {
				contentElement.style.height = contentHeight-1
			}
			leftElement.style.height = contentHeight
			rightElement.style.height = contentHeight-1
			rightElement.style.width = windowWidth-leftWidth
		}
	}
}



function makeDirty(){
	document.forms[0].dirtyFlag.value = 1;
}

function isDirty(){
	if(document.forms[0].dirtyFlag.value == 1)
	{return true;}
	else
	{return false;}
}

function sf() {
	var fld = findElement(document.forms[0],"focusControl");
	if (fld !=  null){
		var focusControl = findVisibleElement(document.forms[0],fld.value);
		if (focusControl != null){
			focusControl.focus();
			focusControl.select();
		}
	}
}

function setFocus(focusControl) {
	if (focusControl != null){
		focusControl.focus();
		focusControl.select();
	}
}

function getClientElement(form,elem) {
	for(i=0; i<form.elements.length; i++){
		if(form.elements[i].id = elem)  {
			return form.elements[i];
		}
	}
}

function findElement(form,elem) {
	for(i=0; i<form.elements.length; i++){
		if(form.elements[i].id.indexOf(elem) >= 0) 
			return form.elements[i];
	}
}

function findVisibleElement(form,elem) {
	for(i=0; i<form.elements.length; i++){
		if(form.elements[i].id.indexOf(elem) >= 0) {
			if(form.elements[i].type != "hidden"){
				return form.elements[i];
			}
		}
	}
}

function findRadioElement(form,elem,v) {
	for(i=0; i<form.elements.length; i++){
		if(form.elements[i].id.indexOf(elem) >= 0) {
			if(form.elements[i].type == "radio"){
				if(form.elements[i].value == v){
					return form.elements[i];
				}
			}
		}
	}
}

function findHiddenElement(form,elem) {
	for(i=0; i<form.elements.length; i++){
		if(form.elements[i].id.indexOf(elem) >= 0) {
			if(form.elements[i].type == "hidden"){
				return form.elements[i];
			}
		}
	}
}
