﻿function changefontsize() {
    var x = document.getElementById("ctl00_col1"); 
    if (x.currentStyle) { 
    // IE
    var y = x.currentStyle['fontSize'];  
        } else if (window.getComputedStyle) { 
    // FF, Opera
        var y = document.defaultView.getComputedStyle(x, null).getPropertyValue('font-size');
    }
    
    if (y == '15px') {
        document.getElementById("ctl00_col1").style.fontSize = '11px';
        }
    else if (y == '11px') {
            document.getElementById("ctl00_col1").style.fontSize = '13px';
        }
        else {
            document.getElementById("ctl00_col1").style.fontSize = '15px';
    }
    setFooter();
    setLeftIcons();
    setRightIcons();
}

function dp() {
    document.getElementById("ctl00_Panel1").style.visibility = 'hidden';
}

function KeyDownHandler(btn) {
    // process only the Enter key
    if (event.keyCode == 13) {
        // cancel the default submit
        event.returnValue = false;
        event.cancel = true;
        // submit the form by programmatically clicking the specified button
        btn.click();
    }
}

var hex = 255;
var i = 1;
var j = 1;

function fadeintext(Obj) {
    if (hex > 0) {
        hex -= 6;
        document.getElementById(Obj).style.color = "rgb(" + hex + "," + hex + "," + hex + ")";
        setTimeout("fadeintext('" + Obj + "')", 20);
    }
    else {
        hex = 255;
        i++;
        if (document.getElementById("fit" + i)) {
            fadeintext("fit" + i);
        }
    }    
}

function fadeinallelements() {
    setFooter();
    setLeftIcons();
    setRightIcons();
    if (document.getElementById("ctl00_banner").src.indexOf('images/header-logo.jpg') >= 0) {
        initImage();
    }
    
// This code fades in the bullet points
//    var elli = document.getElementsByTagName("li");
//    if (elli.length > 6) {
//        fadeintagtext(6);
    //    }

    // This types in the call to action boxes

    if (document.getElementById("tt1")) {
        startTyping(document.getElementById("tt1").innerHTML, 40, "tt1");
    }
//    if (document.getElementById("tt2")) {
//        startTyping(document.getElementById("tt2").innerHTML, 40, "tt2");
//    }
    typeallelements();
}

function fadeintagtext(i) {
    if (hex > 0) {
        hex -= 6;
        var elli = document.getElementsByTagName("li");
        elli[i].style.color = "rgb(" + hex + "," + hex + "," + hex + ")";
        setTimeout("fadeintagtext(" + i + ")", 20); 
    }
    else {
        hex = 255;
        i++;
        if (document.body.getElementsByTagName("li")[i]) {
            fadeintagtext(i);
        } else {
            i = 0;
        }
    }
}

function typeallelements() {
    id = "fi" + i.toString()
    if (document.getElementById(id)) {
        setOpacity(document.getElementById(id), 0);
        document.getElementById(id).style.visibility = 'visible';
        fadeIn(id, 0);
    }
    id = "fit" + i.toString()
    if (document.getElementById(id)) {
        fadeintext(id, 0);
    }
    if (document.getElementById("ni1")) {
        w = 780;
        setTimeout("newsintro()",2000);
    }
}

var itemno = 0;
var currentChar = 1;
var endChar = 1;
var startChar = 0;

function newsintro() {
    if (w > 130) {
        w -= 10;
        document.getElementById("latestnews").style.width = w + "px";
        document.getElementById("latestnewsitems").style.left = (w) + "px";
        document.getElementById("latestnewsitems").style.width = (780 - w) + "px";
        setTimeout("newsintro(" + w + ")", 0);
    } else {
        destination = "ni1";
        setTimeout("nextnews()", 1000);
    }
}

function typenews() {
    document.getElementById("ni").innerHTML = text.substr(startChar, endChar);
    currentChar++;
    endChar++;
    if (currentChar > 80) {
        endChar = 80;
        startChar++;
    }
    if (currentChar > text.length) {
        setTimeout("nextnews()", 1000);
    } else {
        setTimeout("typenews()", 80);
    }
}

function nextnews() {
    currentChar = 1;
    endChar = 1;
    startChar = 0;
    itemno++;
    destination = "ni" + itemno;
    if (document.getElementById(destination)) {
        text = document.getElementById(destination).innerHTML;
        typenews();
    } else {
        destination = "ni1";
        itemno = 1;
        text = document.getElementById(destination).innerHTML;
        typenews();
    }
}

function type() {
    if (document.getElementById) {
        var dest = document.getElementById(destination);
        if (dest) {
            dest.innerHTML = text.substr(0, currentChar);
            currentChar++
            if (currentChar > text.length) {
                currentChar = 1;
                if (destination == "tt1") {
                    if (document.getElementById("tt2")) {
                        startTyping(document.getElementById("tt2").innerHTML, 40, "tt2");
                    }
                }
            }
            else {
                setTimeout("type()", delay);
            }
        }
    }
}

function startTyping(textParam, delayParam, destinationParam) {
    var txth = document.getElementById(destinationParam).offsetHeight;
    document.getElementById(destinationParam).style.height = txth + "px";
    text = textParam;
    delay = delayParam;
    currentChar = 1;
    destination = destinationParam;
    type();
}

function initImage() {
    imageId = 'banner1';
    image = document.getElementById(imageId);
    setOpacity(document.getElementById('banner1'), 100);
    setOpacity(document.getElementById('banner2'), 0);
    setOpacity(document.getElementById('banner3'), 0);
    setOpacity(document.getElementById('banner4'), 0);
    setOpacity(document.getElementById('banner5'), 0);
    document.getElementById('banner1').style.visibility = 'visible';
    document.getElementById('banner2').style.visibility = 'visible';
    document.getElementById('banner3').style.visibility = 'visible';
    document.getElementById('banner4').style.visibility = 'visible';
    document.getElementById('banner5').style.visibility = 'visible';
    fadeInBanner(imageId, 80);
}

function setOpacity(obj, opacity) {
    opacity = (opacity == 100) ? 99.999 : opacity;

    // IE/Win
    obj.style.filter = "alpha(opacity:" + opacity + ")";

    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacity / 100;

    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity / 100;

    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity / 100;
}

function fadeInBanner(objId, opacity) {
    if (document.getElementById(objId)) {
        obj = document.getElementById(objId);
        if (opacity <= 100) {
            setOpacity(obj, opacity);
            opacity += 5;
            window.setTimeout("fadeInBanner('" + objId + "'," + opacity + ")", 100);
        } else {
            window.clearTimeout;
            window.setTimeout("fadeSwap('" + objId + "',100,0)", 3000);
        }
    }
}

function fadeIn(objFadeId, opacity) {
    obj = document.getElementById(objFadeId);
    if (opacity <= 100) {
        setOpacity(obj, opacity);
        opacity += 10;
        window.setTimeout("fadeIn('" + objFadeId + "'," + opacity + ")", 100);
    } else {
    window.clearTimeout;
    j++
    objFadeId = 'fi' + j.toString();
    if (document.getElementById(objFadeId)) {
        setOpacity(document.getElementById(objFadeId), 0);
        document.getElementById(objFadeId).style.visibility = 'visible';
        fadeIn(objFadeId, 0);
    }
    }
}

function fadeSwap(objId, opacity, opacityIn) {
    var imageIn = ''
    var imgID = 0
    window.clearTimeout;
    if (document.getElementById(objId)) {
        obj = document.getElementById(objId);
        imgID = parseInt(objId.charAt(6)) + 1;
        if (imgID == 6) {
            imgID = 1;
        }
        imageIn = 'banner' + imgID
        objIn = document.getElementById(imageIn);
        if (opacity >= 0) {
            setOpacity(obj, opacity);
            opacity -= 5;
            setOpacity(objIn, opacityIn);
            opacityIn += 5;
            window.setTimeout("fadeSwap('" + objId + "'," + opacity + "," +opacityIn + ")", 100);
        } else {
        window.clearTimeout;
        imgID = parseInt(objId.charAt(6)) + 1;
        if (imgID == 6) {
            imgID = 1;
        }
        imageId = 'banner' + imgID
        image = document.getElementById(imageId);
        window.setTimeout("fadeSwap('" + imageId + "',100,0)", 3000);
    }
}
}

function setFooter() {
    var minh = 430;
    var maxh;
    maxh = document.getElementById("ctl00_col1").offsetHeight;
    if (document.getElementById("ctl00_col2").offsetHeight == 0) {
        maxh = maxh + 50;
    }
    if (maxh > minh) {
        minh = maxh;
    }

    maxh = document.getElementById("ctl00_col2").offsetHeight + 50;
    if (maxh > minh) {
        minh = maxh;
    }

    minh = minh + 240;
    document.getElementById("footer").style.top = minh + "px";
    document.getElementById("footer").style.visibility = 'visible';
}

function setLeftIcons() {
    var iconh;
    var footertop;
    footertop = document.getElementById("footer").offsetTop;
    iconh = document.getElementById("ctl00_iconsleft").offsetHeight + 5;
    document.getElementById("ctl00_iconsleft").style.top = (footertop - iconh) + "px";
}

function setRightIcons() {
    var iconh;
    var footertop;
    footertop = document.getElementById("footer").offsetTop;
    iconh = document.getElementById("ctl00_iconsright").offsetHeight + 5;
    document.getElementById("ctl00_iconsright").style.top = (footertop - iconh) + "px";
}

function wo(wtoo) {
    window.open(wtoo, "video", "scrollbars=no,resizable=no,left=50,top=50,screenX=50,screenY=50,width=350,height=350");
}

