/* preload HTPC images!! */

var promo_array = new Array();
var in_process = 0;

// hot swaping images!!
function htpcSwap(n) {

if (in_process) return;
else in_process=1;

t = document.getElementById('promo_show');

if (t.src == promo_array[n].src) { in_process=0; return; }

opacity('promo_show',100,0,300); // first 300ms

t1 = setTimeout("t.src = promo_array["+n+"].src;",300);
t2 = setTimeout("opacity('promo_show',0,100,850);",350); // another 900ms
t3 = setTimeout("in_process=0;",1300); // rezerve


}

function htpcHover1(n) {
h = document.getElementById('htpc'+n);
h.src = 'promo_sestavy_htpc/htpc_1' + n + '.gif';
}

function htpcHover0(n) {
h = document.getElementById('htpc'+n);
h.src = 'promo_sestavy_htpc/htpc_0' + n + '.gif';
}

/* code from 
* http://brainerror.net/scripts/javascript/blendtrans/
*/
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 + ")";
} 
