﻿// JScript File
var Veidan = {

    _Last:null,
    _Length:0,
    _T:null,
    _Total:0,
    _TotalHidden:0,

    ShowFirst: function(id) {
        if(Veidan._Last != null && Veidan._Last != id) {
	        $('product_'+Veidan._Last).hide(); $('r_'+Veidan._Last).style.fontWeight = "normal";
	    }
	    Veidan._Last = id;
	    if($('product_'+id).visible() == false) {
	        Effect.Appear('product_'+id);
	         //$('product_'+id).show();
	         $('r_'+id).style.fontWeight = "bold";
	    }
	},

//    Total: function(total) {
//        Veidan._Total = total;
//            for(var x = 1; x < Veidan._Total+1; x++) {
//                if(x > 8) {
//                    $('anchor_'+x).hide();
//                    Veidan._TotalHidden++;
//                }
//            }
//            if(Veidan._Total > 8) { $('next').show(); }
//    },

    PrevRecord: function(i) {
        Veidan.StopTimer();
        var x = 1;
        var loop=new Array(Veidan._Total);
        var n = loop.length - Veidan._TotalHidden + i;
        //Veidan._Last = n;

        $('r_'+i).show();

        $('r_'+Veidan._Last).hide();
        $('prev').hide();
    },

    NextRecord: function(i) {
        Veidan.StopTimer();
        var x = 1;
        var loop=new Array(Veidan._Total);
        var n = loop.length - Veidan._TotalHidden;
        Veidan._Last = n;

        $('r_'+x).hide();
        alert(Veidan._Last+1);
        $('r_'+(Veidan._Last+1)).show();
        $('prev').show();
    },

    Random: function(length) {
        Veidan._Length = length;
        if(length != 0) {
            var increment = Math.floor(Math.random() * length+1);
            Veidan.ShowFirst(increment);
            Veidan.StartTimer();
        }
    },

    StartTimer: function() {
        Veidan._T=setTimeout("Veidan.TimerLoader()",5000);
    },

    StopTimer: function() {
        clearTimeout(Veidan._T);
        Veidan.Random(0);
    },

    TimerLoader: function() {
        Veidan.Random(Veidan._Length);
    }
}
