// Copyright 2007 Armorlogic. All rights reserved.

function exp_box(box) {
	
	element = document.getElementById(box);
	
	if (!element) return;
	
	if (element.className == 'box_o') {
		element.className = 'box_c'
	}
	else {
		element.className = 'box_o';
	}
}

function toggle(obj, t1, t2) {
	if (obj.innerHTML == t1) {
		obj.innerHTML = t2;
	} else {
		obj.innerHTML = t1;
	}
}

function UnCryptMailto( s )
{
    var n = 0;
    var r = "";
    for( var i = 0; i < s.length; i++)
    {
        n = s.charCodeAt( i );
        if( n >= 8364 )
        {
            n = 128;
        }
        r += String.fromCharCode( n - 1 );
    }
    return r;
}

function linkTo_UnCryptMailto( s )
{
    location.href=UnCryptMailto( s );
}

function rotate_text_rand(text_array, target_id, target_source_id, seconds) {
	var f = function () {
	    var which = Math.round(Math.random()*(text_array.length - 1));
	    document.getElementById(target_id).innerHTML = text_array[which][0];
	    document.getElementById(target_source_id).innerHTML = (text_array[which][1]) ? text_array[which][1] : '';
	};
	
	setInterval(f, seconds*1000);
}

function rotate_text(text_array, target_id, target_source_id, seconds, next_quote) {
	var f = function () {
	    document.getElementById(target_id).innerHTML = text_array[next_quote][0];
	    document.getElementById(target_source_id).innerHTML = (text_array[next_quote][1]) ? text_array[next_quote][1] : '';
	    next_quote = (next_quote + 1 <= text_array.length - 1) ? next_quote + 1 : 0;
	};
	
	setInterval(f, seconds*1000);
}
