// JavaScript Document
// background changer
function change_td_bg( td_id, bg_color )
{
	document.getElementById( td_id ).bgColor = bg_color;
}

// open a new window
function open_window( link, id, width, height )
{
	window.open(link,id,"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width="+width+", height="+height );
}

// check for empty fields
function check_fields()
{
	var status = true;
	var error_text = "";
	var fullname_field = document.query_form.fullname.value;
	var email_field = document.query_form.email.value;
	var query_field = document.query_form.query.value;
	
	if ( fullname_field == "" )
	{
		error_text += "Name field cannot be empty\n";
		status = false;
	}
		
	if ( email_field == "" )
	{
		error_text += "Email field cannot be empty\n";
		status = false;
	}
	else // if email field is not empty
	{
		if ( ( email_field.indexOf(".") > 2 ) && ( email_field.indexOf("@") > 0 ) )
		{
			;	
		}
		else
		{
			error_text += "Invalid email format\n";
			status = false;
		}
	}
		
	if ( query_field == "" )
	{
		error_text += "Query field cannot be empty\n";
		status = false;
	}
	
	if ( status == false )
	{
		alert( error_text );
		return false;
	}
	
	return true;
}