

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame 
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens 
    if (opacStart > opacEnd) {
        for (i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
            timer++;
        }
    } else if (opacStart < opacEnd) {
        for (i = opacStart; i <= opacEnd; i++) {
            setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers 
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function blendimage(headerDivId, contentDivId, contentBgDivId, imagefile, newHeaderColor, newPageBg, newPageSideBg, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //make divs transparent to show backgrounds
    changeOpac(0, headerDivId);
    changeOpac(0, contentDivId);
    changeOpac(0, contentBgDivId);
    

    //set new image
    document.getElementById(headerDivId).style.backgroundImage = "url(" + imagefile + ")";
    document.getElementById(contentDivId).style.backgroundImage = "url(" + newPageBg + ")";
    document.getElementById(contentBgDivId).style.backgroundImage = "url(" + newPageSideBg + ")";

    //set background color
    document.getElementById(headerDivId).style.backgroundColor = newHeaderColor;

    //fade in new images
    for (i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + headerDivId + "')", (timer * speed));
        setTimeout("changeOpac(" + i + ",'" + contentDivId + "')", (timer * speed));
        setTimeout("changeOpac(" + i + ",'" + contentBgDivId + "')", (timer * speed));
        
        timer++;
    }
}

var imageIndex = 0;

function rotateImages(imageFolder) {
        
    var Images = new Array(11);

    Images[0] = ["banner9.jpg", "#47627E", "contentBg9.jpg", "contentSideBg9.jpg", "/about-us/microsoft-worldwide-partner-of-the-year-2009.aspx",
                    "<h2>Microsoft Worldwide Partner of the Year 2009</h2><p>Kiandra has been awarded the Microsoft Worldwide Partner of the Year 2009 in the category of Custom Development Solutions, Application Infrastructure Development.</p><p>The Microsoft Worldwide Partner Conference Awards recognise Microsoft partners that have developed and delivered exceptional Microsoft-based solutions.</p>"]; //kiandra wins 2009
    Images[1] = ["banner9.jpg", "#47627E", "contentBg9.jpg", "contentSideBg9.jpg", "/about-us/microsoft-worldwide-partner-of-the-year-2009.aspx",
                    "<h2>Microsoft Worldwide Partner of the Year 2009</h2><p>Kiandra has been awarded the Microsoft Worldwide Partner of the Year 2009 in the category of Custom Development Solutions, Application Infrastructure Development.</p><p>The Microsoft Worldwide Partner Conference Awards recognise Microsoft partners that have developed and delivered exceptional Microsoft-based solutions.</p>"]; //kiandra wins 2009]; //kiandra wins 2009
    Images[2] = ["banner10.jpg", "#47627E", "contentBg10.jpg", "contentSideBg10.jpg", "/business-perspectives/radically-boost-your-bottom-line.aspx",
                    "<h2>Custom software</h2><p>The last piece of the IT puzzle that radically boosts your bottom line.</p>"]; //custom software
    Images[3] = ["banner11.jpg", "#9f9f9f", "contentBg11.jpg", "contentSideBg11.jpg", "/products-and-technologies/apple-solutions.aspx",
                    "<h2>Got Mac? Want Mac? We have it covered.</h2><p>Kiandra are experts at Mac and Windows integration and deliver quality, cross-platform solutions.</p>"]; //apple-mac
    
    Images[4] = ["banner1.jpg", "#4C75A7", "contentBg1.jpg", "contentSideBg1.jpg", "/LinkClick.aspx?link=115&tabid=115",    
                    "<h2>Get a fresh change</h2><p>The right IT people looking after the right IT solutions</p>"];//fresh change
    Images[5] = ["banner4.jpg", "#9BADD6", "contentBg4.jpg", "contentSideBg4.jpg", "/LinkClick.aspx?link=114&tabid=114",
                    "<h2>Got a bright idea?</h2><p>Kiandra specialises in green field start-up and venture capital fuelled websites and software development</p>"]; //bright idea
    Images[6] = ["banner3.jpg", "#728E00", "contentBg3.jpg", "contentSideBg3.jpg", "/LinkClick.aspx?link=93&tabid=36",
                    "<h2>Thinking of green IT?</h2><p>Talk to us about virtualisation and environmentally responsible technology</p>"];//green it
    Images[7] = ["banner5.jpg", "#A7865D", "contentBg5.jpg", "contentSideBg5.jpg", "/LinkClick.aspx?link=113&tabid=113",
                    "<h2>Certified</h2><p>We hold certifications and extensive experience in all leading technologies and solutions</p>"];//certified
    Images[8] = ["banner6.jpg", "#728E00", "contentBg6.jpg", "contentSideBg6.jpg", "/LinkClick.aspx?link=92&tabid=36",
                    "<h2>Out of the office?</h2><p>Kiandra's secure remote access solutions enable you to work easily from anywhere</p>"];//out of office
    Images[9] = ["banner7.jpg", "#47627E", "contentBg7.jpg", "contentSideBg7.jpg", "/LinkClick.aspx?link=86&tabid=36",
                    "<h2>Email Archiving</h2><p>Kiandra partners with Symantec to provide industry leading email and content archiving</p>"];//email archive
    Images[10] = ["banner8.jpg", "#A5906D", "contentBg8.jpg", "contentSideBg8.jpg", "/LinkClick.aspx?link=73&tabid=36",
                    "<h2>Development project gone off the rails?</h2><p>Kiandra's emergency project recovery services will get you back on track</p>"]; //development off rails
    Images[11] = ["banner2.jpg", "#090F16", "contentBg2.jpg", "contentSideBg2.jpg", "/LinkClick.aspx?link=55&tabid=36",
                "<h2>Impressive Lineup</h2><p>Kiandra's product knowledge and experience ensures you get the right solution.</p>"]; //impressive lineup


    //set background div styles to the current styles in use (cant access ones set from css via javascript so use array)
    document.getElementById('headerBannerWrapperBack').style.backgroundImage = "url('" + imageFolder + Images[imageIndex][0] + "')";
    document.getElementById('headerBannerWrapperBack').style.backgroundColor = Images[imageIndex][1];
    document.getElementById('pageContentBGBack').style.backgroundImage = "url('" + imageFolder + Images[imageIndex][2] + "')";
    document.getElementById('pageContentBGWrapperBack').style.backgroundImage = "url('" + imageFolder + Images[imageIndex][3] + "')";
  
    //get next image
    imageIndex++;
    
    if (imageIndex >= Images.length)
    {
        //reset array
        imageIndex = 0;
    }

    //set onclick
    setBannerOnClick(Images[imageIndex][4]);

    //set text
    setText(Images[imageIndex][5]);

    //swap images
    blendimage('headerBannerWrapper', 'pageContentBG', 'pageContentBGWrapper', imageFolder + Images[imageIndex][0], Images[imageIndex][1], imageFolder + Images[imageIndex][2], imageFolder + Images[imageIndex][3], 500)



    setRotation(imageFolder);
}

function setText(text) {
    
    document.getElementById('headerBannerContent').innerHTML = text;
}

function setBannerOnClick(url) {

    document.getElementById('headerBannerWrapperBack').onclick = function() {
        if (url != '') {
            document.location = url;
        }
    };
    
}

function setRotation(imageFolder) {

    //run again in 10 seconds
    setTimeout("rotateImages('" + imageFolder + "')", 6000);
}