// JavaScript Document
var winWidth;
var winHeight;
var IsIe = false;

function GetWindowSize() {
 	var myWidth = 0, myHeight = 0;
 	
 	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
 	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		IsIe = true;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		IsIe = true;
	}
	//window.alert( 'Width = ' + myWidth );
	//window.alert( 'Height = ' + myHeight );
	winWidth = myWidth;
	winHeight = myHeight;
}

function SetFooterPos() {
	oContent = document.getElementById("PageContent");
	oContentT = document.getElementById("ContentTop");
	oContentM = document.getElementById("ContentMid");
	oContentB = document.getElementById("ContentBot");
	oFooter = document.getElementById("PageFooter");
	oPageHeader = document.getElementById("PageHeader");
	DefaultHeight = 602;
	
	ContentHeader = oPageHeader.offsetHeight;
	
    ContentPage = oContentT.offsetHeight + oContentM.offsetHeight + oContentB.offsetHeight;
    
    BodyHeight = ContentHeader + (ContentPage + 30);
	
	//if (BodyHeight > DefaultHeight)
	    //BodyHeight = DefaultHeight;
	oContent.style.height = ContentPage;
	//alert(DefaultHeight + " ::: " +  BodyHeight);
	/*if (BodyHeight < winHeight)	{
		//alert(DefaultHeight + " < " + BodyHeight);
		oContent.style.height = BodyHeight + "px";
	} else if (BodyHeight > winHeight) {
		oContent.style.height = BodyHeight + "px";
		
	} */
//alert(DefaultHeight + " > " + BodyHeight);
	/*
	//alert(BodyHeight);
 	if (winHeight < (BodyHeight + 30)) {
		 //alert(ContentPage + 30);
        // Position the footer at the bottom of the content to force scroll. 10 pixels are added for padding.
        oFooter.style.top = parseInt((winHeight - 30)) + "px";
	    
	} else if (winHeight > (BodyHeight + 30)) {	
	   
		
		//alert(oContent.offsetHeight);
		oFooter.style.top = (winHeight - 30) + "px";
	}
	*/
}

function Init() {
	//ValidateRequest();
	PreloadImages();
	GetWindowSize();
	SetFooterPos();
	//SetSideBoxPos();
	
	//Set handlers for window/mouse events
	window.onblur = register;
	window.oncontextmenu = register;
	window.onerror = register;
	window.onfocus = register;
	window.onscroll = register;
	window.onresize = register;
	window.onclick = register;
	window.onmousedown = register;
	window.onmouseup = register;
	//register(window.event);
}

function Resized() {
	GetWindowSize();
	SetFooterPos();
}

function register(e) {
	if(!e) e = window.event;
	if(e.type=='resize') {
		Resized();
	}
}

function PreloadImages() {
	MM_preloadImages('../images/navigation/bottommenu_bg.gif','../images/navigation/Menu_Background.gif','../images/navigation/bottommenu_left.gif','../images/navigation/bottommenu_right.gif','../images/navigation/item_hover.gif','../images/navigation/item_selected_left.gif','../images/navigation/item_selected_right.gif','../images/navigation/subitem_expanded_left.gif','../images/navigation/subitem_expanded_right.gif','../images/navigation/subitem_selected_left.gif','../images/navigation/subitem_selected_right.gif','../images/navigation/topmenu_bg.gif','../images/navigation/topmenu_left.gif','../images/navigation/topmenu_right.gif');
}

/* Dreamweaver functions */

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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function Show(strID) {
	document.getElementById(strID).style.display='block';
}

function Hide(strID) {
	document.getElementById(strID).style.display='none';
}

function ShowInfo() {
	Show('divInfo');
	Hide('divWait');
}

function SearchFocus(obj, searchDefault) {
    //alert(obj.value + " == " +  searchDefault);
    if (obj.value == searchDefault)
    {
        obj.value='';
        obj.style.fontStyle='normal';
        obj.style.color='#000';
    }
    else
    {
        obj.select();
    }
}

function SearchBlur(obj, searchDefault) {
    if (obj.value == '')
    {
        obj.value=searchDefault;
        obj.style.fontStyle='italic';
        obj.style.color = 'gray';
    }
}