var ns4 = (document.layers)? true:false;
var nn6 = (!document.all && document.getElementById)? true:false;
var ie4 = (document.all)? true:false;

function posTop()
{
    return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

function getPageSize(){
	
	var arrayPageSize = new Array();
	var xScroll, yScroll;
	var pageWidth = 0;
      var pageHeight = 0;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}





function doResize()
{
    var arrayPageSize = new Array();
    arrayPageSize = getPageSize();
    if (ns4)
    {
        document.layers['disablePage'].width = '100%';
        document.layers['disablePage'].height = '100%';
        document.layers['disablePage'].height = (arrayPageSize[1] + arrayPageSize[3]);
    }
    if (nn6)
    {
        document.getElementById('disablePage').style.width = '100%';
        document.getElementById('disablePage').style.height = '100%';
        document.getElementById('disablePage').style.height = (arrayPageSize[1]) + 'px';
    }
    if (ie4)
    {
        document.getElementById('disablePage').style.width = '100%';
        document.getElementById('disablePage').style.height = '100%';
        document.getElementById('disablePage').style.height = (arrayPageSize[1]);
    }
}

window.onresize = function()
{
    doResize();
};

function enable_menues_for_ie()
{
    if (document.all)
    {
        uls = document.getElementsByTagName('UL');

        for(i = 0; i < uls.length; i++)
        {
            if (uls[i].className == 'dropdown')
            {
                var lis = uls[i].getElementsByTagName('li');

                for (j = 0; j < lis.length; j++)
                {
                    if(lis[j].lastChild.tagName == 'UL')
                    {
                        lis[j].onmouseover = function() { this.lastChild.style.display = 'block'; }
                        lis[j].onmouseout = function() { this.lastChild.style.display = 'none'; }
                        lis[j].onclick = function() { this.lastChild.style.display = 'none'; }
                    }
                }
            }
        }
    }
}


window.onload = enable_menues_for_ie;

function dialogImgLoad()
{
    var im = document.images['dialogImg'];
    var dl = document.getElementById('dialogLoading');
    var dc = document.getElementById('dialogContent');
    var dbg = document.getElementById('dialogBackground');
    var body = document.body;
    var top = 0;

    dl.style.display='none';
    dc.style.display='block';

    dbg.style.height=im.height + 6;

    if (ns4)
    {
        if((window.innerHeight / 2 - (im.height / 2)) <=0 ) top = 0;
        else top = (window.innerHeight / 2 - (im.height / 2));
        document.layers['dialogBox'].top = top;

        document.layers['dialogBox'].left = (body.offsetWidth / 2 - (im.width / 2));
        document.layers['dialogPanel'].width = (im.width + 6);
        document.layers['dialogBackground'].width = (im.width + 6);
        document.layers['dialogBackground'].height = (im.height + 6);
    }
    if (nn6)
    {
        if((window.innerHeight / 2 - (im.height / 2)) <=0) top = 0;
        else top = (window.innerHeight / 2 - (im.height / 2));
        document.getElementById('dialogBox').style.top = (top + posTop()) + 'px';

        document.getElementById('dialogBox').style.left = (body.offsetWidth / 2 - (im.width / 2)) + 'px';
        document.getElementById('dialogPanel').style.width = (im.width + 6) + 'px';
        document.getElementById('dialogBackground').style.width = (im.width + 6) + 'px';
        document.getElementById('dialogBackground').style.height = (im.height + 6) + 'px';
    }
    if (ie4)
    {
        if((document.body.offsetHeight/2 - (im.height / 2)) <= 0) top = 0;
        else top = (document.body.offsetHeight/2 - (im.height / 2));
        document.getElementById('dialogBox').style.top = top + posTop();

        document.getElementById('dialogBox').style.left = (body.offsetWidth / 2 - (im.width / 2));
        document.getElementById('dialogPanel').style.width = (im.width + 6);
        document.getElementById('dialogBackground').style.width = (im.width + 6);
        document.getElementById('dialogBackground').style.height = (im.height + 6);
    }
    doResize();
}


function dialogShow(imge)
{
    var d = document.getElementById('dialogBox');
    var dl = document.getElementById('dialogLoading');
    var dc = document.getElementById('dialogContent');
    var im = document.images['dialogImg'];
    var body = document.body;

    var top = 0;

    if (ns4)
    {
        if((window.innerHeight / 2 - 300) <=0 ) top = 0;
        else top = (window.innerHeight / 2 - 300);
        document.layers['dialogBox'].top = top;
        document.layers['dialogBox'].left = (body.offsetWidth / 2 - (400));
    }
    if (nn6)
    {
        if((window.innerHeight / 2 - 300) <=0) top = 0;
        else top = (window.innerHeight / 2 - 300);
        document.getElementById('dialogBox').style.top = (top + posTop()) + 'px';
        document.getElementById('dialogBox').style.left = (body.offsetWidth / 2 - (400)) + 'px';
    }
    if (ie4)
    {
        if((document.body.offsetHeight/2 - 300) <= 0) top = 0;
        else top = (document.body.offsetHeight/2 - 300);
        document.getElementById('dialogBox').style.top = top + posTop();
        document.getElementById('dialogBox').style.left = (body.offsetWidth / 2 - (400));
    }

    d.style.display='block';
    dl.style.display='block';
    dc.style.display='none';
    document.getElementById('disablePage').style.display='block';

    im.src='images/'+imge;

    doResize();
}

function dialogAbort()
{
    var d = document.getElementById('dialogBox');
    var im = document.images['dialogImg'];
    d.style.display='none';
    document.getElementById('disablePage').style.display='none';
    im.src='images/loading2.gif';

    if (ns4)
    {
        document.layers['dialogPanel'].width = 806;
        document.layers['dialogBackground'].width = 806;
        document.layers['dialogBackground'].height = 606;
    }
    if (nn6)
    {
        document.getElementById('dialogPanel').style.width = (800 + 6) + 'px';
        document.getElementById('dialogBackground').style.width = (800 + 6) + 'px';
        document.getElementById('dialogBackground').style.height = (600 + 6) + 'px';
    }
    if (ie4)
    {
        document.getElementById('dialogPanel').style.width = (800 + 6);
        document.getElementById('dialogBackground').style.width = (800 + 6);
        document.getElementById('dialogBackground').style.height = (600 + 6);
    }
}

/********************************************************************************************************************/


function dialogLoading()
{
    var d = document.getElementById('dialogBox');
    var dl = document.getElementById('dialogLoading');
    var dc = document.getElementById('dialogContent');
    var im = document.images['dialogImg'];
    var body = document.body;

    var top = 0;

    if (ns4)
    {
        if((window.innerHeight / 2 - 300) <=0 ) top = 0;
        else top = (window.innerHeight / 2 - 300);
        document.layers['dialogBox'].top = top;
        document.layers['dialogBox'].left = (body.offsetWidth / 2 - (400));
    }
    if (nn6)
    {
        if((window.innerHeight / 2 - 300) <=0) top = 0;
        else top = (window.innerHeight / 2 - 300);
        document.getElementById('dialogBox').style.top = (top + posTop()) + 'px';
        document.getElementById('dialogBox').style.left = (body.offsetWidth / 2 - (400)) + 'px';
    }
    if (ie4)
    {
        if((document.body.offsetHeight/2 - 300) <= 0) top = 0;
        else top = (document.body.offsetHeight/2 - 300);
        document.getElementById('dialogBox').style.top = top + posTop();
        document.getElementById('dialogBox').style.left = (body.offsetWidth / 2 - (400));
    }

    d.style.display='block';
    dl.style.display='block';
    dc.style.display='none';
    document.getElementById('disablePage').style.display='block';

    doResize();
}



function mover(im,fl)
{
    im.src="images/"+fl;
}


function mout(im,fl)
{
    im.src="images/"+fl;
}

function slideshow()
{
   document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH=532 HEIGHT=80>\n');
   document.write('<PARAM NAME=menu VALUE=false>\n');
   document.write('<param name="wmode" value="opaque">\n');
   document.write('<PARAM NAME=movie VALUE="slideshow.swf">\n');
   document.write('<PARAM NAME=quality VALUE=high>\n');
   document.write('<EMBED src="slideshow.swf" quality=high  WIDTH=532 HEIGHT=80 menu=false TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="opaque"></EMBED>\n');
   document.write('</object>\n');
}

