﻿//window.onresize = resize_window;

function resize_window()
{
    var obj = null;
    var img = null;
    var windowHeight = getWindowHeight();
    var imageHeight = windowHeight;
	var windowWidth = getWindowWidth();
    var imageWidth = windowWidth;
    
    obj = document.getElementById("bgImage");
    if (obj != null)
    {
        img = new Image();
        img.src = obj.src;
        var imgHeight = img.height;
        var imgWidth = img.width;
        if (windowHeight < imgHeight) imageHeight = imgHeight;
        if (windowWidth < imgWidth) imageWidth = imgWidth;
        
        if ((windowWidth - imgWidth) > (windowHeight - imgHeight))
        {
            if (windowWidth > 600)
            {
                imgWidth = imageWidth + "px";
                imgHeight = ""
            }
	    }
	    else
	    {
	        if (windowHeight > 400)
            {
                imgHeight = imageHeight + "px";
                imgWidth = "";
            }
	    }
	    
	    obj.style.width = imgWidth;
	    obj.style.height = imgHeight;
	}
	obj = document.getElementById("imgbg2");
    if (obj != null)
    {
        img = new Image();
        img.src = obj.src;
        var imgHeight = img.height;
        var imgWidth = img.width;
        if (windowHeight < imgHeight) imageHeight = imgHeight;
        if (windowWidth < imgWidth) imageWidth = imgWidth;
        
        if ((windowWidth - imgWidth) > (windowHeight - imgHeight))
        {
            if (windowWidth > 600)
            {
                imgWidth = imageWidth + "px";
                imgHeight = null;
            }
	    }
	    else
	    {
	        if (windowHeight > 400)
            {
                imgHeight = imageHeight + "px";
                imgWidth = null;
            }
	    }
	    
	    obj.style.width = imgWidth;
	    obj.style.height = imgHeight;
	}
	obj = document.getElementById("bg1");
    if  (obj != null)
    {
        obj.style.width = imageWidth + "px";
        obj.style.height = imageHeight + "px";
    }
	obj = document.getElementById("bg2");
    if  (obj != null)
    {
        obj.style.width = imageWidth + "px";
        obj.style.height = imageHeight + "px";
    }
	obj = document.getElementById("bg3");
    if  (obj != null)
    {
        obj.style.width = imageWidth + "px";
        obj.style.height = (imageHeight - 20) + "px";
    }

//    var obj = null;
//    var img = null;
//    var imageHeight = null;
//    var imageWidth = null;
//    var windowHeight = getWindowHeight();
//	var windowWidth = getWindowWidth();
//    
//    obj = document.getElementById("imgbg1");
//    if (obj != null)
//    {
//        img = new Image();
//        img.src = obj.src;
//        imageHeight = img.height;
//        imageWidth = img.width;
//        
//        if (windowWidth > 0)
//        {
//            if ((windowWidth - imageWidth) > (windowHeight - imageHeight))
//            {
//                obj.style.width = windowWidth + "px";
//            }
//            else
//            {
//                obj.style.height = windowHeight + "px";
//                
//            }
//	    }
//        document.getElementById("bg2").innerHTML = windowWidth + "x" + windowHeight;
//	}
	
//	obj = document.getElementById("imgbg2");
//	if (img != null)
//    {
//        var img = new Image();
//        if (windowWidth > 800)
//        {
//	        img.style.width = windowWidth + "px";
//	        //obj.style.height = windowHeight + "px";
//	    }
//    }
}

function getWindowHeight()
{
    var height = window.innerHeight;
	
	if (document.documentElement.clientHeight)
	{
		height = document.documentElement.clientHeight;
	}
	return height;
}
function getWindowWidth()
{
    var width = window.innerWidth;
	
	if (document.documentElement.clientWidth)
	{
		width = document.documentElement.clientWidth;
	}
	return width;
}
function getWidth()
{
    var obj = null;
    var img = null;
    var imageHeight = null;
    var imageWidth = null;
    var windowHeight = getWindowHeight();
	var windowWidth = getWindowWidth();
    
    obj = document.getElementById("bgImage");
    if (obj != null)
    {
        img = new Image();
        img.src = obj.src;
        imageHeight = img.height;
        imageWidth = img.width;
        
        if (windowWidth > 600)
        {
            if ((windowWidth - imageWidth) > (windowHeight - imageHeight))
            {
                imageWidth = windowWidth + "px";
            }
            else
            {
                imageWidth = null;
                //obj.style.height = windowHeight + "px";
                
            }
	    }
	}
	return imageWidth;
}
function getHeight()
{
    var obj = null;
    var img = null;
    var imageHeight = null;
    var imageWidth = null;
    var windowHeight = getWindowHeight();
	var windowWidth = getWindowWidth();
    
    obj = document.getElementById("bgImage");
    if (obj != null)
    {
        img = new Image();
        img.src = obj.src;
        imageHeight = img.height;
        imageWidth = img.width;
        
        if (windowWidth > 600)
        {
            if ((windowWidth - imageWidth) > (windowHeight - imageHeight))
            {
                //imageWidth = windowWidth + "px";
                imageHeight = null;
            }
            else
            {
                imageHeight = windowHeight + "px";
                
            }
	    }
	}
	return imageHeight;
}
function PageLoad()
{
    //resize_window();
    //runSlideShow();
    if (typeof change_scrollbar == "function")
    {
        change_scrollbar();
    }
}
//window.onload = function()
//{
//    //resize_window();
//	//imageLine();
//	alert('function onload');
//}

// Reference
var obj;
function SetTextVisible(id)
{
    _obj = document.getElementById(id);
    if (_obj != null)
    {
        _obj.style.visibility = 'visible';
    }
}
function SetTextHidden(id)
{
    _obj = document.getElementById(id);
    if (_obj != null)
    {
        var _call = "document.getElementById('" + id + "').style.visibility = 'hidden'";
        setTimeout(_call, 1500);
    }
}

function ChangeClass(ref, name)
{
    document.getElementById(ref).className = name;
}

