/*
    DA BEAT GOES ON - Tabito Tei Webgraphy
    Copyright (C) 2002 Tabito Tei  All Rights Reserved.
*/

var colorval = 0;
var diff = 8;
var timerid;
var timerinterval = 100;

function gray(color)
{
    var s, hex = "0123456789ABCDEF";
    s  = hex.charAt(color / 16);
    s += hex.charAt(color % 16);
    return '#' + s + s + s;
}

function fade(action)
{
    var e = document.getElementById('photoofday');

    if (action == 'start') {
	e.style.color = gray(colorval);
	timerid = setTimeout("fade('continue')", timerinterval);
    }
    else if (action == 'stop') {
        clearTimeout(timerid);
	e.style.color = '#ff9933';
    }
    else {
	colorval += diff;
	if (colorval < 0 || 255 < colorval) {
	    diff *= -1;
	    colorval += diff * 2;
	}
	e.style.color = gray(colorval);
	timerid = setTimeout("fade('continue')", timerinterval);
    }
}

function getbackgroundcolor()
{
    return window.configframe.document.getElementById('backgroundcolor').style.color;
}

function getratiofromscreensize()
{
    if (screen.height > 768)
        ratio = '1';    // must be same as gRatio['xga'] in library.php
    else if (screen.height > 600)
        ratio = '1.2';  // must be same as gRatio['svga'] in library.php
    else
        ratio = '1.5';  // must be same as gRatio['vga'] in library.php
    return ratio;
}

function launchcarddialog(filename, credit)
{
    var feature = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=640,height=640';
    var url;
    if (location.host == "zelter.lunarpages.com")
        url = 'http://' + location.host + '/~dabeat2';
    else
        url = 'http://' + location.host;
    url += '/tegami.php?filename=' + filename + '&credit=' + credit;
    window.open(url, "POSTCARD", feature);
}

function savecolor(value)
{
    var expireDate = new Date ();
    expireDate.setTime( expireDate.getTime() + (365 * 24 * 3600 * 1000) );
    window.document.cookie = "color=" + escape(value) + "; expires=" + expireDate.toGMTString();
}

function launchcolordialog()
{
    var url;
    
    if (location.host == "zelter.lunarpages.com")
        url = 'http://' + location.host + '/~dabeat2/preference.php';
    else
        url = 'http://' + location.host + '/preference.php';
    var feature = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=200,height=260';
    window.open(url, "PREFERENCE", feature);
}

