// JavaScript Document

var imgarraycount = 0;
var arrayofimages = new Array(1100);

function swap_rollover(inid, inpos){
	if (document.getElementById(inid).src == arrayofimages[inpos][0].src){
		document.getElementById(inid).src = arrayofimages[inpos][1].src;
	} else document.getElementById(inid).src = arrayofimages[inpos][0].src;
}


function add_rollover(inid,inimagenorm,inimageroll, inalt){
	arrayofimages[imgarraycount] = new Array(2);
	arrayofimages[imgarraycount][0] = new Image();
	arrayofimages[imgarraycount][1] = new Image();
	arrayofimages[imgarraycount][0].src = inimagenorm;
	arrayofimages[imgarraycount][1].src = inimageroll;
	lretstr = ('<img src="'+arrayofimages[imgarraycount][0].src+'" id="'+inid+'" onMouseover="swap_rollover(\''+inid+'\','+imgarraycount+')" onMouseout="swap_rollover(\''+inid+'\','+imgarraycount+')" alt="'+inalt+'" />');
	imgarraycount++;
	return (lretstr);
}

function fshowhide(inid, inotherid){
	document.getElementById(inid).className = 'show_me';
	document.getElementById(inotherid).className = 'hide_me';
}

function CheckForm(theform) {
	if (EmptyField(theform.frm_email.value)) {
		alert("Please confirm your \"email\".");
		theform.frm_email.focus();
		return (false);		
	}
	if (EmptyField(theform.frm_password.value)) {
		alert("Please confirm your \"password\".");
		theform.frm_password.focus();
		return (false);		
	}
	return (true);
}

function fcheckvalue(inthis, invalue){
	if (inthis.value == invalue) {
		inthis.value = '';
	}
}

function fcheckvalue_out(inthis, invalue){
	if (inthis.value == '') {
		inthis.value = invalue;
	}
}

function swap_display(ina, inb){
	var lclass  = document.getElementById(ina).className;
	document.getElementById(ina).className = document.getElementById(inb).className;
	document.getElementById(inb).className = lclass;
	document.getElementById(ina).focus();
	return false;
}

function swap_display_image(ina, inb){
	if (document.getElementById(inb).value == '')  swap_display(ina, inb);
	return false;
}

function fCheckLoginForm(){
//	alert('lol'+document.getElementById('the_password').value);
	swap_display('the_password', 'password_image');
	if (document.getElementById('the_password').value == '') return false;
	return true;
}

function jump_menu(inthis){
	var lval = inthis.options[inthis.selectedIndex].value;
	if(lval != '') window.location =lval;

}

function fuuid(){
	var currentTime = new Date();
	var month = currentTime.getMonth() + 1;
	var day = currentTime.getDate();
	var year = currentTime.getFullYear();
	var hours = currentTime.getHours();
	var minutes = currentTime.getMinutes();
	var seconds = currentTime.getSeconds();
	var cu = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
	var uid = '';
	var tempn = 0;
	for(i=0;i<10;i++){
		tempn = Math.floor(Math.random()*(cu.length-1));
		uid = uid+cu.substring(tempn, (tempn+1));
	}
	return year+''+month+''+day+''+hours+''+minutes+''+seconds+'-'+uid;
}






/**************************************************************/
var gimg_array = new Array(10);
var gimg_count = 0;
var gimg_place = 0;

function changeOpac(opacity) { 
    var object = document.getElementById('front_image').style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

function fade_images(opacStart, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
    if(opacStart > 10) { 
        for(i = opacStart; i >= 1; i--) { 
            setTimeout("changeOpac(" + i + ")",(timer * speed)); 
            timer++; 
        } 
    }
}


function rotate_images(){
	var lplace = gimg_place+1;
	if(lplace == gimg_count){
		lplace = 0;
	}
	//alert(gimg_place+':'+gimg_array[gimg_place].src+'###'+lplace+':'+gimg_array[lplace].src);
	document.getElementById('front_image').style.backgroundImage = "url('"+gimg_array[gimg_place].src+"')";
	document.getElementById('back_image').style.backgroundImage = "url('"+gimg_array[lplace].src+"')";
//	setTimeout('document.getElementById(\'front_image\').style.backgroundImage = "url(\''+gimg_array[gimg_place].src+'\');"', 1000);
	fade_images(100, 1000);
	setTimeout('rotate_images()', 6000);
	gimg_place = lplace;
}


function init_images(in_images){
	for(var i=0;i<(in_images).length;i++){
		gimg_array[gimg_count] = new Image();
		gimg_array[gimg_count++].src = in_images[i];
	}
	document.getElementById('front_image').style.backgroundImage = "url('"+gimg_array[0].src+"')";
	if(gimg_count > 0){
		document.getElementById('back_image').style.backgroundImage = "url('"+gimg_array[1].src+"')";
		gimg_place = 0;
		setTimeout('rotate_images()', 6000);
	}
}