var count;
var item;
var time_flag;

var colors = new Array();
colors[0] = "#666666";
colors[1] = "#748a93";
colors[2] = "#658c9b";
colors[3] = "#538ea5";
colors[4] = "#3f8faf";
colors[5] = "#2d93ba";
colors[6] = "#1a94c4";
colors[7] = "#008fd2";


var stripes = new Array();
stripes[0] = "/images/layout/stripes/stripey.gif";
stripes[1] = "/images/layout/stripes/stripey1.gif";
stripes[2] = "/images/layout/stripes/stripey2.gif";
stripes[3] = "/images/layout/stripes/stripey3.gif";
stripes[4] = "/images/layout/stripes/stripey4.gif";
stripes[5] = "/images/layout/stripes/stripey5.gif";
stripes[6] = "/images/layout/stripes/stripey6.gif";
stripes[7] = "/images/layout/stripes/stripey7.gif";


function product_on(id)
{
   if(time_flag)
   {
        clearTimeout(time_flag);
        kill_product(get_item());      
   }
   item = id;
   text = "text_" + id;
   text = document.getElementById(text);
   text.style["color"] = colors[0];
   
   stripe = "stripe_" + id;
   stripe = document.getElementById(stripe);
   stripe.src = stripes[0];
   
   start_fade_up();
}

function start_fade_up()
{
    count = 0;
    time_flag = setTimeout("fade_step_up()", 20);
}

function product_off(id)
{
    if(time_flag)
        clearTimeout(time_flag);
    //id = document.getElementById(id);
    item = id;
    text = "text_" + id;
    text = document.getElementById(text);
    text.style["color"] = colors[7];
    
    stripe = "stripe_" + id;
    stripe = document.getElementById(stripe);
    stripe.src = stripes[7];
     
    start_fade_down();
}

function fade_step_up()
{    
     num = add_count();
     if(num > 7)
        return;
     id = get_item();
     item = id;
     text = "text_" + id;
     text = document.getElementById(text);
     text.style["color"] = colors[num];
     
     stripe = "stripe_" + id;
     stripe = document.getElementById(stripe);
     stripe.src = stripes[num];
     
     //id.style["borderColor"] = colors[num];
     time_flag = setTimeout("fade_step_up()", 20);
}

function start_fade_down()
{
    count = 7;
    time_flag = setTimeout("fade_step_down()", 20);
}


function fade_step_down()
{
     num = minus_count();
     if(num < 0)
     {
        kill_product(get_item());
        return;
     }    
     id = get_item();
     text = "text_" + id;
     text = document.getElementById(text);
     text.style["color"] = colors[num];
     
     stripe = "stripe_" + id;
     stripe = document.getElementById(stripe);
     stripe.src = stripes[num];

     time_flag = setTimeout("fade_step_down()", 20);
}

function kill_product(id)
{
    item = id;
    text = "text_" + id;
    text = document.getElementById(text);
    text.style["color"] = colors[0];
    
    stripe = "stripe_" + id;
    stripe = document.getElementById(stripe);
    stripe.src = stripes[0];
}

function get_item()
{
    return item;
}

function add_count()
{
    count++;
    return count;
}


function minus_count()
{
    count--;
    return count;
}



