/*  JavaScripts for TimeCard54 */

/*

Copyright (C) 2005 - Chris Alexander, aim54 Digital Solutions, http://www.aim54.com

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    If you have downloaded the program, you should have received a
    copy of the GNU General Public License along with this program;
    if not, write to the Free Software Foundation, Inc., 51 Franklin St,
    Fifth Floor, Boston, MA  02110-1301 USA, or contact aim54 Digital Solutions
    via email to 'support@aim54.com' to receive a copy of the GNU
    General Public License via email.

*/


function proj_formWin() {

	window.open('', 'projInfo', 'location=no, toolbar=no, scrollbars=yes, width=750,height=400,left=80,top=80');
	return true;
	
}

function type_formWin() {

	window.open('', 'typeInfo', 'location=no, toolbar=no, scrollbars=yes, width=750,height=600,left=80,top=80');
	return true;
	
}

function rate_formWin() {

	window.open('', 'rateInfo', 'location=no, toolbar=no, scrollbars=yes, width=750,height=600,left=80,top=80');
	return true;
	
}


function proj_formWin2() {

	window.open('', 'projDelete', 'location=no, toolbar=no, scrollbars=yes, width=750,height=500,left=50,top=70');
	return true;
	
}

function proj_formWin3() {
var myform = document.forms.changes.proj_name2;
	if (myform.value == "") {
		alert('You did not enter a new Project Name. The Project Name cannot be empty.');
	myform.focus();
	myform.select();
	return false;
	}
	else {
	window.open('', 'changeInfo', 'location=no, toolbar=no, scrollbars=yes, width=750,height=600,left=70,top=50');
	return true;
	}
}

function type_formWin3() {
var myform = document.forms.changes.type_name2;
	if (myform.value == "") {
		alert('You did not enter a new Type Name. The Type Name cannot be empty.');
	myform.focus();
	myform.select();
	return false;
	}
	else {
	window.open('', 'typeInfo', 'location=no, toolbar=no, scrollbars=yes, width=750,height=600,left=70,top=50');
	return true;
	}
}

function rate_formWin3() {
var myform1 = document.forms.changes.rate_amount2;
var myform2 = document.forms.changes.rate_cycle2;
	if (myform1.value == "") {
		alert('You did not enter a new Rate Amount. The Rate Amount cannot be empty.');
	myform1.focus();
	myform1.select();
	return false;
	}
	else if (myform2.value == "") {
		alert('You did not choose a new Rate Cycle. The Rate Cycle cannot be empty.');
	myform2.focus();
	return false;
	}
	else {
	window.open('', 'rateInfo', 'location=no, toolbar=no, scrollbars=yes, width=750,height=600,left=70,top=50');
	return true;
	}
}


function pers_formWin3() {
var myform = document.forms.change_info;
	if (myform.first_name2.value == "") {
		alert('You did not enter a First Name. The First Name cannot be empty.');
	myform.first_name.focus();
	myform.first_name.select();
	return false;
	}
	else if (myform.last_name2.value == "") {
		alert('You did not enter a Last Name. The Last Name cannot be empty.');
	myform.last_name.focus();
	myform.last_name.select();
	return false;
	}
	else if ((myform.phone1_2.value == "") && (myform.phone2_2.value == "") && (myform.email2.value == "")) {
		alert('You did not enter a method of contact. You must enter either a Phone Number, Email Address, or both.');
	myform.phone_1.focus();
	myform.phone_1.select();
	return false;
	}
	else {
	window.open('', 'persInfo', 'location=no, toolbar=no, scrollbars=yes, width=750,height=600,left=70,top=50');
	return true;
	}
}


function update_Parent(source) {
	opener.document.location = source;
}

function proj_delForm() {

	if (confirm('You are about to PERMANENTLY remove the selected Projects and their associated Billing Information from your account. Are you certain you want to do this?')) {
	setTimeout("update_Parent('projects.php')",500);
	return true;
	}
	else {
	return false;
	}
}

function type_delForm() {

	if (confirm('You are about to PERMANENTLY remove the selected Types from your account. Are you certain you want to do this?')) {
	setTimeout("update_Parent('types.php')",500);
	return true;
	}
	else {
	return false;
	}
}


function rate_delForm() {

	if (confirm('You are about to PERMANENTLY remove the selected Rates from your account. Are you certain you want to do this?')) {
	setTimeout("update_Parent('rates.php')",500);
	return true;
	}
	else {
	return false;
	}
}


function checkInput() {
var myform = document.forms.new_proj.proj_name;
	if (myform.value == "") {
		alert('You did not enter a new Project Name. The Project Name cannot be empty.');
	myform.focus();
	myform.select();
	return false;
	}
	else {
	return true;
	}
}


function check_typeInput() {
var myform = document.forms.new_type.type_name;
	if (myform.value == "") {
		alert('You did not enter a new Type Name. The Type Name cannot be empty.');
	myform.focus();
	myform.select();
	return false;
	}
	else {
	return true;
	}
}


function check_rateInput() {
var myform1 = document.forms.new_rate.rate_amount;
var myform2 = document.forms.new_rate.rate_cycle;
	if (myform1.value == "") {
		alert('You did not enter a new Rate Amount. The Rate Amount cannot be empty.');
	myform1.focus();
	myform1.select();
	return false;
	}
	else if (myform2.value == "") {
		alert('You did not select a new Rate Cycle. The Rate Cycle cannot be empty.');
	myform2.focus();
	return false;
	}
	else {
	return true;
	}
}


function check_persInput() {
var myform = document.forms.new_persInfo;
	if (myform.first_name.value == "") {
		alert('You did not enter a First Name. The First Name cannot be empty.');
	myform.first_name.focus();
	myform.first_name.select();
	return false;
	}
	else if (myform.last_name.value == "") {
		alert('You did not enter a Last Name. The Last Name cannot be empty.');
	myform.last_name.focus();
	myform.last_name.select();
	return false;
	}
	else if ((myform.phone_1.value == "") && (myform.phone_2.value == "") && (myform.email.value == "")) {
		alert('You did not enter a method for contact (Phone or Email). You must enter either a Phone Number, Email Address, or both.');
	myform.phone_1.focus();
	myform.phone_1.select();
	return false;
	}
	else {
	return true;
	}
}

function check_reportWin() {

	window.open('', 'reportWin', 'location=no, toolbar=no, scrollbars=yes, width=900,height=750,left=20,top=50');
	return true;

}