$(document).ready(function() {
	$counterInterval = setInterval("vhqRotator('')", 10000);
	$('#boardBar > a').click(function(e) {
		clearInterval($counterInterval);
		vhqRotator($(this));
		e.preventDefault();
	});
	$('.switch').click(function(e) {
		$s = $(this).attr('rel');
		/*$('#linksBoard').animate({opacity: 'toggle'}, function() {
			$(this).animate({opacity: 'toggle'});
		});*/
		$('body').removeClass($('body').attr('class')).addClass($s);
		e.preventDefault();
	})
});
function vhqRotator(e) {
	if (!e) {
		e = $('.counterActive');
		if (e.next('a').length > 0) {
			e = e.next('a');
		} else {
			e = $('#boardBar').children('a:first');
		}
	}
	$('.counterActive').removeClass('counterActive');
	u = e.attr('href');
	e.addClass('counterActive');
	$('#board').animate({opacity: 'toggle'}, function() {$(this).css("background-image", "url(\"" + u + "\")").animate({opacity: 'toggle'})});
}
function ModFunction(Main, Modulus)
{
    var ModFunction = Main - (Math.floor((Main/Modulus)) * Modulus);
    return ModFunction;
}
function Mult(x, p, m)
{
    var y = 1;
    var i = 0;
    for (i = p; i > 0; i--)
    {
        while ( (i/2) == (Math.floor((i/2))) )
        {
            x = ModFunction((x * x), m);
            i = (i/2);
        }
        y = ModFunction((x * y), m);
    }
    return y;
}
function Encode(TheForm)
{
    // define variables
    var encoded_field = "";
    var original_field = TheForm.field.value;
    var Enc = 56259383;
    var Mod = 71355029;
    // loop through all single letter of field
    for (i = 0; i <= original_field.length - 1; i++)
    {
        // charCodeAt gives the ASC value of character in position i
        encoded_field = encoded_field + Mult( (original_field.charCodeAt(i)) , Enc , Mod ) + ","
    }
    TheForm.field.value = "";
    TheForm.my_encoded_field.value = encoded_field;
}


