//hidden login link
function login() {
 window.location = "login.php";
}

//preload images
function preloadImages() {
  var d=document; if(d.images){ if(!d.pre) d.pre=new Array();
    var i,j=d.pre.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.pre[j]=new Image; d.pre[j++].src=a[i];}}
}

//shows image file in new window
function newWindow(file, width, height){
	window.open(file,'save_search_dialog','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+width+', height='+height);
}

//style change for menu rollover
function swap(id, bg_image){
	document.getElementById(id).style.backgroundImage = "url("+bg_image+")";
}

// field control //

//clear text from form field
function clear_text(id){
	document.getElementById(id).value = "";
	document.getElementById(id).style.color = "#000000";
}

//change text area size
function textarea_size(field_id, control_id){
	var field = document.getElementById(field_id);
	var control = document.getElementById(control_id);
	if (control.value=="bigger"){
		field.style.height = "500px";
		field.style.width = "600px";
		control.value = "smaller";
	}
	else if(control.value=="smaller"){
		field.style.height = "50px";
		field.style.width = "400px";
		control.value = "bigger";
	}
}
//generate a password	
function generate_password(field_id){
	var field = document.getElementById(field_id);
	var length = 8;
	var charSet = "0123456789" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var rc = "";
	for (var i = 1; i <= length; ++i) {
		rc = rc + charSet.charAt(Math.floor(Math.random() * charSet.length));
	}
	field.value = rc;
}

