function dispatchinputs() {
	var inputs = document.getElementsByTagName('input');
	for (i in inputs) {
		if (inputs[i].type == 'text' || inputs[i].type == 'password') {
			inputs[i].onfocus = function() {
				//alert(this.style.backgroudColor);
				//this.style.bgColor = 'FFFFFF';
			}
		}
	}
}

/**
 * Ask and Redirect function
 * on question confirmation redirect to specified location
 */
function aar(question, location) {	
	if(confirm(question))
		window.location = location;
}

function $(id) {
	return document.getElementById(id);
}


function tableSort(that, action){
	var fID = that.id;
	var orderBy = $('orderby').value[0];
	var direction = "a";
	
	if(orderBy == "")
		direction = "a";
	else if(orderBy == "a")
		direction = "d";
	else if(orderBy == "d")
		direction = "a";
		
	window.location = 'index.php5?do='+action+'&orderby='+direction+fID;
}

function checkContact(){
	var errors = '';

	var myNameF = $('myName');
	var myEmailF = $('myEmail');
	var myMessageF = $('myMessage');
	
	if(myNameF && myEmailF && myMessageF){
		if(myNameF.value == ''){
			errors += " * 'Your name' field cannot be empty.\n";
		}
		if(myEmailF.value == ''){
			errors += " * 'Your e-mail' field must contain your valid e-mail.\n";
		}
		if(myMessageF.value == ''){
			errors += " * You must fill 'Message' field.\n";
		}
		
	}

	if(errors != ''){
		alert("Could not send your message:\n"+errors);
		return false;
	}else{
		$('contactFormRun').value = '1';
		return true;
	}
}

function settargetlinks() {
	var links = document.getElementsByTagName('a');
	var i = 0;
	for(i=0;i<links.length;i++) {
		if (links[i].className == 'blank')
			links[i].target='_blank'; 
	}
	
}