﻿// JScript File
function LoadPage()
{
timeout2 = setTimeout("CheckImages();", 10)
timeout3 = setTimeout("CheckImages();", 50)
timeout4 = setTimeout("CheckImages();", 100)
timeout5 = setTimeout("CheckImages();", 500)
timeout6 = setTimeout("CheckImages();", 1000)
timeout7 = setTimeout("CheckImages();", 1500)
timeout8 = setTimeout("CheckImages();", 2000)
timeout9 = setTimeout("CheckImages();", 2500)
timeout10 = setTimeout("CheckImages();", 3000)
timeout11 = setTimeout("CheckImages();", 3500)
timeout12 = setTimeout("CheckImages();", 5000)
timeout13 = setTimeout("CheckImages();", 7500)
timeout14 = setTimeout("CheckImages();", 10000)

SubMenu_Last = ""
LastParent = ""
Timeout1=setTimeout("ClearMenu()",1)
//DrawSidePanel()
ItemID = ""
}


function change(x){
document.getElementById(x).style.background="#ACE9FC"
document.getElementById(x + "1").style.background="#ACE9FC"
document.getElementById(x + "2").style.background="#ACE9FC"
}

/*function change2(x){
document.getElementById(x).style.background="FFFFFF"
document.getElementById(x + "1").style.background="FFFFFF"
document.getElementById(x + "2").style.background="FFFFFF"
}*/

function change2(x){
document.getElementById(x).style.background=document.getElementById(x + "hdn").value
document.getElementById(x + "1").style.background=document.getElementById(x + "hdn").value
document.getElementById(x + "2").style.background=document.getElementById(x + "hdn").value
}


function GetSubMenu(name)
{
    if(Timeout1){
        clearTimeout(Timeout1)
        }
        
    if (SubMenu_Last != "")
    {
        document.getElementById(SubMenu_Last).style.display = 'none';
        SubMenu_Last = "";

    }
    if (LastParent != name){
        if (LastParent != "") {
    document.getElementById(LastParent).className = 'Default'
    LastParent = ""
        }
        }
LastParent = name
document.getElementById(name + '_sub').style.display = 'block';
document.getElementById(name + '_sub').style.position = 'absolute';
document.getElementById(name + '_sub').style.zindex = '99999';
var CurPosAr = findCPos(document.getElementById(name))
document.getElementById(name + '_sub').style.top= CurPosAr[1] +25 + 'px'
document.getElementById(name + '_sub').style.left= CurPosAr[0]  - 100 + 'px'
SubMenu_Last = name + '_sub';
LastParent = name
}
function findCPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function findCPos_bottom(obj) {
	var curleft = curtop = 0;
	var top = obj.offsetHeight
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	curtop += top
	
	return [curleft,curtop];
}


function HoldMenu(Parent)
{
    if (Parent) {
    LastParent = Parent.id
    }
    if (LastParent != ""){
    Timeout1 = setTimeout("document.getElementById('" + LastParent + "').className='Default';ClearMenu()",1500)
    }
}
function HoldMenuBySub()
{
    clearTimeout(Timeout1)
}
function ClearMenu()
{    
    clearTimeout(Timeout1)
    if (LastParent != "") {
    document.getElementById(LastParent).className='Default'
    LastParent = ""
        }
    if (SubMenu_Last != "")
    {
        document.getElementById(SubMenu_Last).style.display = 'none';
        SubMenu_Last = ""
    }

}
function DrawTopBG(){
str = ""
var v = 0
for(i=0;i<56;i++){
str += "<b class='r1'></b><b class='r2'></b>"
v = v+1
if (v == 10){
document.getElementById("TopBG").innerHTML += str
str = ""
v = 0
}
}
document.getElementById("TopBG").innerHTML += str
}
function DrawSidePanel()
{
var sidepanel = ""
for(a=0;a<400;a++)
{
sidepanel += "<b class='r1'></b><b class='r2'></b>"
}

//document.getElementById("SidePanel").innerHTML = sidepanel
}

function drawsidepanel(){
//document.getElementById("SidePanel").innerHTML = ""
//sidepanel = ""
//sh = 0
//if (document.getElementById("SideMenuContent").scrollHeight > document.getElementById("MainContent").scrollHeight){
//sh = document.getElementById("SideMenuContent").scrollHeight
//}else{
//sh = document.getElementById("MainContent").scrollHeight
//}
//for(a=0;a< (sh/2);a++)
//{
//sidepanel += "<b class='r1'></b><b class='r2'></b>"
//}
//document.getElementById("SidePanel").innerHTML += sidepanel

//window.scrollTo(0,0)
}
//timout = setTimeout("drawsidepanel();GetSideMenuData()",0)

var ImagesLoaded = true
var AdjComplete = false
function CheckImages() {
    if(!AdjComplete){
    for (var i = 0; i < document.images.length; i++) {
        if (!IsImageOk(document.images[i])) {
            ImagesLoaded = false
        }
    }
    if (ImagesLoaded == true) {
    //DisplayPage();
    AdjComplete = true;
    }else{
    ImagesLoaded = true;
    }
    }
    
}
function ResizeTop(){
//if(document.getElementById("TopBG").scrollWidth /16 >= document.getElementById("WidthGetter").style.width){
//document.getElementById("TopBGContainer").style.width = document.getElementById("TopBG").scrollWidth /16 + "em"
//}else{
//document.getElementById("TopBGContainer").style.width = "100%";
//}
document.getElementById("TopBGContainer").style.width = "100%";
//document.scrollWidth

}
var TopDrawn = 0
function DisplayPage(){
//GetSideMenuData();
//document.getElementById("HiddenContentLayer").style.display = "block";
// if(document.getElementById('LoadingInfo')){
//    document.getElementById('LoadingInfo').innerHTML+='<br><b>Page Load Complete</b>'
//}
//document.getElementById("HiddenLoadingLayer").style.display = "None";
    //if (TopDrawn == 0){
    //DrawTopBG()
    //TopDrawn = 1
  //  }
    //ResizeTop()
    //drawsidepanel();
   
             
        
    //}
  //  if(document.getElementById('LoadingInfo')){
  //  document.getElementById('LoadingInfo').innerHTML=''
  //  window.onresize = ResizeTop
    }

function IsImageOk(img) {
    // During the onload event, IE correctly identifies any images that
    // weren't downloaded as not complete. Others should too. Gecko-based
    // browsers act like NS4 in that they report this incorrectly.
    if (!img.complete) {
        return false;
    }

    // However, they do have two very useful properties: naturalWidth and
    // naturalHeight. These give the true size of the image. If it failed
    // to load, either of these should be zero.
    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        return false;
    }

    // No other way of checking: assume it's ok.
    return true;
}
