var idarray = new Array("d9c986b338760c23e1566fc7614a0a2d", "995713e837e1b328ed78754a0a19b5e1", "e878879896eca9264374d61f3ab4df99", "98f6df19ee57f9f83fff3a7cbfaea2da", "22f8e8c22c22dfd39ff9624b4dd7187b");
var interval = 0;

var id, num, oldnum, timer_id;
oldnum = -1;
random_pet();
if (interval > 0) {
    timer_id = setInterval('random_pet()', interval);
}

function random_pet()
{
    do {
        num = Math.floor(Math.random() * idarray.length);
    } while (num == oldnum)
    oldnum = num;
    show_pet();
}

function next_pet()
{
    num++;
    if (num == idarray.length) num = 0;
    if (interval > 0) {
        clearInterval(timer_id);
        timer_id = setInterval('random_pet()', interval);
    }
    show_pet();
}

function prev_pet()
{
    num--;
    if (num == -1) num = idarray.length - 1;
    if (interval > 0) {
        clearInterval(timer_id);
        timer_id = setInterval('random_pet()', interval);
    }
    show_pet();
}

function select_pet(pet_no)
{
    num = pet_no;
    if (interval > 0) {
        clearInterval(timer_id);
        timer_id = setInterval('random_pet()', interval);
    }
    show_pet();
}

function show_pet()
{
    var today=new Date();
    var tseconds=today.getSeconds();
    var id = idarray[num];

    pethtml = "<object id='usa' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='130' height='200' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='http://www.blogpet.net/usa.swf' /><param name='play' value='true' /><param name='loop' value='false' /><param name='menu' value='false' /><param name='wmode' value='transparent' /><param name='quality' value='high' /><param name='FlashVars' value='username=" + id + "&tseconds="+tseconds+"' /><embed src='http://www.blogpet.net/usa.swf' loop='false' menu='false' quality='high' wmode='transparent' bgcolor='#ffffff' width='130' height='200' name='usa' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' FlashVars='username=" + id + "&tseconds="+tseconds+"' /></object>\n";
    pethtml += "<img src='http://www.blogpet.net/add_log.php?username=" + id + "&url="+document.URL+"&referrer="+document.referrer+"'>";
    document.getElementById('blogpet').innerHTML = pethtml;
}
