// Title: Timestamp picker
// Description: See the demo at url
// URL: http://us.geocities.com/tspicker/
// Script featured on: http://javascriptkit.com/script/script2/timestamp.shtml
// Version: 1.0
// Date: 12-05-2001 (mm-dd-yyyy)
// Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com>
// Notes: Permission given to use this script in any kind of applications if
//    header lines are left unchanged. Feel free to contact the author
//    for feature requests and/or donations
//
//
// I butchered the hell out of this code because I don't know javascript.  All I know is
// that now it takes a DATE ONLY in mm-dd-yyyy format and it works. CM
//


function show_calendar(str_target, str_datetime) {
	var arr_months = ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"];
	var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
	var n_weekstart = 0; // day week starts from (normally 0 or 1)

	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
	var dt_prev_month = new Date(dt_datetime);
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	
	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head>\n"+
		"	<title>HomeSTAR</title>\n"+
		"</head>\n"+
		"<body bgcolor=\"6699FF\">\n"+
		"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
		"<tr><td bgcolor=\"#4682B4\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"<tr>\n	<td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+
		str_target+"', '"+ dt2dtstr(dt_prev_month)+"'+document.cal.time.value);\">"+
		"<img src=\"prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"previous month\"></a></td>\n"+
		"	<td bgcolor=\"#4682B4\" colspan=\"5\" align=\"center\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
		"	<td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
		+str_target+"', '"+dt2dtstr(dt_next_month)+"'+document.cal.time.value);\">"+
		"<img src=\"next.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"next month\"></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#87CEFA\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row header
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() &&
					dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#FFB6C1\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#DBEAF5\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
					"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
	str_buffer +=
		"<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+
		"<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+
		" <input type=\"hidden\" name=\"time\" value=\""+
		"\" size=\"8\" maxlength=\"8\"></font></td></tr>\n</form>\n" +
		"</table>\n" +
		"</tr>\n</td>\n</table>\n" +
		"</body>\n" +
		"</html>\n";

	var vWinCal = window.open("", "Calendar", 
		"width=200,height=250,status=no,resizable=yes,top=200,left=200");
	vWinCal.opener = self;
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) {
	var re_date = /^(\d+)\/(\d+)\/(\d+)/;
	// if I comment out the next 2 lines, it will accept any format CM
	if (!re_date.exec(str_datetime))
		return alert("Invalid Date format: "+ str_datetime);
	return (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2, RegExp.$4, RegExp.$5, RegExp.$6));
}
function dt2dtstr (dt_datetime) {
	return (new String (
			(dt_datetime.getMonth()+1)+"/"+dt_datetime.getDate()+"/"+dt_datetime.getFullYear()+" "));
			//dt_datetime.getDate()+"-"+(dt_datetime.getMonth()+1)+"-"+dt_datetime.getFullYear()+" "));
}
function dt2tmstr (dt_datetime) {
	//return (new String (
			//dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}

function get_sr_date(str_target, str_datetime) {
// this function tests to see if the "survey required" check box is checked.
//If it is not checked, then we obviously do not have to select a survey date.
// We just display an alert box and then return. CM
if(!document.escrowtab.surveyreq.checked)
	{
	return alert("Survey is not required...  You may not enter in a survey date...");
	}

show_calendar(str_target, str_datetime);
}
function get_cr_date(str_target, str_datetime) {
// this function tests to see if the "survey required" check box is checked.
//If it is not checked, then we obviously do not have to select a survey date.
// We just display an alert box and then return. CM
if(!document.escrowtab.contingency.checked)
	{
	return alert("There is no contingency...  You may not enter in a release date...");
	}

show_calendar(str_target, str_datetime);
}
function get_ar_date(str_target, str_datetime) {
// this function tests to see if the "survey required" check box is checked.
//If it is not checked, then we obviously do not have to select a survey date.
// We just display an alert box and then return. CM
if(!document.escrowtab.apprreq.checked)
	{
	return alert("There is no appraisal required...  You may not enter in a date...");
	}

show_calendar(str_target, str_datetime);
}
function get_payment_date(str_target, str_datetime) {
// this function tests to see if the "survey required" check box is checked.
//If it is not checked, then we obviously do not have to select a survey date.
// We just display an alert box and then return. CM
if(document.escrowtab.lenders.value == "Cash")
	{
	show_calendar(str_target, str_datetime);
	}
else
	{
	return alert("This is not a cash buyer...  You may not enter in a payment date...");
	}
}

function get_mortgage_date(str_target, str_datetime) {
// this function tests to see if the "survey required" check box is checked.
//If it is not checked, then we obviously do not have to select a survey date.
// We just display an alert box and then return. CM
if(document.escrowtab.lenders.value == "Cash")
	{
	return alert("This is a cash buyer...  You may not enter in a mortgage related date...");
	}
else
	{
	show_calendar(str_target, str_datetime);
	}
}

function savecommunity() {

//alert(window.escrowtab.community.value);
}
function picklist(mwhichname, mfirstvar, mlastvar, mfirstval, mlastval, mbuyernosel) {
// this next line worked to reset the value of last2!!
//window.document.escrowtab.last2.value="hgjdfhgd";
//document.escrowtab.buyervar2.value
	if (mwhichname == "buyer1")
		{
		window.open ('picklist.php?mltype=buyer1&mfirstvar=+mfirstvar+&mlastvar=mlastvar&mfirstval=mfirstval&mlastval=mlastval', 'newwindow', config='height=340,width=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,top=240,left=380') 
		}
	if (mwhichname == "buyer2")
		{
		window.open ('picklist.php?mltype=buyer2&mfirstvar=mfirstvar&mlastvar=mlastvar&mfirstval=mfirstval&mlastval=mlastval', 'newwindow', config='height=340,width=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,top=320,left=310') 
		}
	if (mwhichname == "address")
		{
		if(document.escrowtab.community.value == "")
			{
			alert("Please Select a Community Before Selecting an Address...")
			}
		else
			{
			//alert(document.escrowtab.community.value);
			document.escrowtab.community2.value=document.escrowtab.community.value;
			document.escrowtab.community.disabled=true;
			window.open ('picklist.php?mltype=address&mfirstvar='+mfirstvar+'&mlastvar='+mlastvar+'&mfirstval='+mfirstval+'&mlastval='+mlastval+'', 'newwindow', config='height=340,width=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,top=320,left=310') 
			}
		}
	if (mwhichname == "pend_address")
		{
		if(document.escrowtab.community.value == "")
			{
			alert("Please Select a Community Before Selecting an Address...")
			}
		else
			{
			//alert(document.escrowtab.community.value);
			document.escrowtab.community2.value=document.escrowtab.community.value;
			document.escrowtab.community.disabled=true;
			window.open ('picklist.php?mltype=pend_address&mfirstvar='+mfirstvar+'&mlastvar='+mlastvar+'&mfirstval='+mfirstval+'&mlastval='+mlastval+'', 'newwindow', config='height=340,width=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,top=320,left=310') 
			}
		}
	if (mwhichname == "address3")
		{
		if(document.escrowtab.community.value == "")
			{
			alert("Please Select a Community Before Selecting an Address...")
			}
		else
			{
			//alert(document.escrowtab.community.value);
			document.escrowtab.community2.value=document.escrowtab.community.value;
			document.escrowtab.community.disabled=true;
			window.open ('picklist.php?mltype=address3&mfirstvar='+mfirstvar+'&mlastvar='+mlastvar+'&mfirstval='+mfirstval+'&mlastval='+mlastval+'', 'newwindow', config='height=340,width=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,top=320,left=310') 
			}
		}
	if (mwhichname == "community")
		{
		window.open ('picklist.php?mltype=community&mfirstvar=mfirstvar&mlastvar=mlastvar&mfirstval=mfirstval&mlastval=mlastval', 'newwindow', config='height=340,width=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,top=320,left=310') 
//document.escrowtab.address.value = "";
		}
}
function getpendprice(maddress22) {
	//alert("get price info for "+maddress22);
	mwindowstr = "getpendprice.php?maddress="+maddress22;
	window.open (mwindowstr, 'pendprice', config='height=2,width=2,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=no,top=9000,left=9000') 
//window.close () 
}


function mailto(mtovar, mtoval) {
	window.open ('maillist.php?mtovar=mtovar&mtoval=mtoval', 'newwindow', config='height=240,width=240,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,top=290,left=70') 
}

function new_lender(mltype) {
	if (mltype == "reg")
		{
		alert("After adding a new lender, save changes to re-populate lists...");
		window.open ('newlender.php?mltype=reg', 'newwindow', config='height=200,width=400,toolbar=no,menubar=no,srollbars=no,resizable=no,location=no,directories=no,status=no,top=380,left=440') 
		}
	else if (mltype == "const")
		{
		alert("After adding a new lender, save changes to re-populate lists...");
		window.open ('newlender.php?mltype=const', 'newwindow', config='height=200,width=400,toolbar=no,menubar=no,srollbars=no,resizable=no,location=no,directories=no,status=no,top=350,left=550') 
		}
	else // else if we are entering ina new community
		{
		alert("After adding a new community, save changes to re-populate lists...");
		window.open ('newlender.php?mltype=comm', 'newwindow', config='height=180,width=400,toolbar=no,menubar=no,srollbars=no,resizable=no,location=no,directories=no,status=no,top=240,left=240') 
		}
return;
}

function ttt(str_target, str_datetime) {
//return alert("Enter in a new lender...");

	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head>\n"+
		"	<title>Enter in new lender</title>\n"+
		"</head>\n"+
		"<body bgcolor=\"6699FF\">\n"+
		"\n"
	);

	str_buffer +=
		"<?php \n" +
		"echo 'kkk';\n" +
		"?>\n" +
		
		"</body>\n" +
		"</html>\n";

	var vWinCal = window.open("", "Calendar", 
		"width=330,height=200,status=no,resizable=yes,top=380,left=440");
	vWinCal.opener = self;
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();

	}
function relogin ()
{
window.opener=top;
window.close(); 
window.open ('index.php?relogin=true','','height=740, width=1024, left=0, top=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, directories=yes, status=yes');

}

function crdate() {
if(document.escrowtab.contingency.checked)
	{
	document.escrowtab.contreldt.disabled=false;
	}
else
	{
	document.escrowtab.contreldt.disabled=true;
	document.escrowtab.contreldt.value=""; // erase date
	}
}

function ardate() {
if(document.escrowtab.apprreq.checked)
	{
	document.escrowtab.apprrec.disabled=false;
	}
else
	{
	document.escrowtab.apprrec.disabled=true;
	document.escrowtab.apprrec.value=""; // erase date
	}
}
function srdate() {
if(document.escrowtab.surveyreq.checked)
	{
	document.escrowtab.surveydate.disabled=false;
	}
else
	{
	document.escrowtab.surveydate.disabled=true;
	document.escrowtab.surveydate.value=""; // erase date
	}
}
function brokerinfo() {
if(document.escrowtab.broker.checked)
	{
	document.escrowtab.brokername.disabled=false;
	document.escrowtab.brokeroffice.disabled=false;
	}
else
	{
	document.escrowtab.brokername.disabled=true;
	document.escrowtab.brokeroffice.disabled=true;
	document.escrowtab.brokername.value=""; // erase field
	document.escrowtab.brokeroffice.value=""; // erase field
	}
}
function nameinv() {
if(document.escrowtab.specstart.checked)
	{
	// If house is a spec, the 1st first name is set to "Inventory"
	document.escrowtab.first1.value="Inventory";
	document.escrowtab.last1.value="";
	document.escrowtab.first2.value="";
	document.escrowtab.last2.value="";
	}
}
function lenderfields() {
if(document.escrowtab.lenders.value == "Cash")
	{
	// if this is a cash buyer, enable cash deposit date fields and disable mortgage date fields
	// 1st lets enable the date cash payment date fields
	document.escrowtab.optionpmt.disabled=false;
	document.escrowtab.slabpmt.disabled=false;
	document.escrowtab.cabpmt.disabled=false;
	// now lets disable the mortgage related fields
	document.escrowtab.rating.disabled=true;
	document.escrowtab.loantype.disabled=true;
	document.escrowtab.loanoffname.disabled=true;
	document.escrowtab.loanappdt.disabled=true;
	//document.escrowtab.loanappr.disabled=true;
	//document.escrowtab.rel2const.disabled=true;
	// and finally, lets reset the mortgage related fields to their default values
	document.escrowtab.rating.value="Select Loan Rating";
	document.escrowtab.loantype.value="Select Loan Type";
	document.escrowtab.loanoffname.value="";
	document.escrowtab.loanappdt.value="";
	//document.escrowtab.loanappr.value="";
	//document.escrowtab.rel2const.value="";
	}
else // else if there is a mortgage company (not a cash buyer)
	{
	// else if this is NOT a cash buyer, enable mortgage date fields and disable cash deposit date fields
	// 1st lets disable the cash payment fields
	document.escrowtab.optionpmt.disabled=true;
	document.escrowtab.slabpmt.disabled=true;
	document.escrowtab.cabpmt.disabled=true;
	// now lets enable the mortgage related fields
	document.escrowtab.rating.disabled=false;
	document.escrowtab.loantype.disabled=false;
	document.escrowtab.loanoffname.disabled=false;
	document.escrowtab.loanappdt.disabled=false;
	//document.escrowtab.loanappr.disabled=false;
	//document.escrowtab.rel2const.disabled=false;
	// now lets set the cash payment dates to blank
	document.escrowtab.optionpmt.value="";
	document.escrowtab.slabpmt.value="";
	document.escrowtab.cabpmt.value="";
	}
}

function stagelist(jobno) {
	window.open ('stagelist.php?mjobno='+jobno, 'newwindow', config='height=500,width=440,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,top=140,left=420') 
return;
}
function dispinv() {
window.open ('invwarning.php','','height=400, width=760, left=35, top=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=yes, directories=yes, status=yes');
}

function dispcash() {
window.open ('cashwarning.php','','height=400, width=980, left=35, top=200, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=yes, directories=yes, status=yes');
}

function dispallied() {
window.open ('alliedwarning.php','','height=400, width=780, left=35, top=300, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=yes, directories=yes, status=yes');
}

function displotnotes(jobno) {
window.open ('lotnotes.php?mjobno='+jobno,'','height=300, width=690, left=85, top=150, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=yes');
// mwin = window.open();
// mwin.close();
}
function editnotes(jobno) {
window.open ('editnotes.php?mjobno='+jobno,'','height=300, width=690, left=85, top=150, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=yes');
}
function prnt_board() {
window.open ('prnt_board.php','','height=600, width=700, left=40, top=40, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=yes');
}
function setlot() {
alert("Customizing your lot report will allow you to select the fields you wish to include in your PRINTED lot report...   HomeSTAR will also remember your settings for future printed lot reports...");
window.open ('setlot.php','','height=520, width=740, left=85, top=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=yes');
// mwin = window.open();
// mwin.close();
}

function statusenable(mvalue, mvar, mine) { //v2.0
 // alert(mvalue);
var thing=document.getElementById? document.getElementById("status-"+mvar) : document.all? "document.all."+"status-"+mvar : ""
var orig=document.getElementById? document.getElementById("origstat_"+mvar) : document.all? "document.all."+"origstat_"+mvar : ""

if(mvalue==true) // if I just checked the box to "check out" the file
 	{
	thing.disabled=false;
	}
else
	{
	thing.value=orig.value;
	thing.disabled=true;
	thing.disabled=false;
	if (mine == "F") // if it is still mine, do not disable it
		{
		thing.disabled=true;
		}
	}
}

function prntlot(commno) {
window.open ('printlotrpt.php?mcomm='+commno,'','toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=yes');
}

function optionupdate(mcurrfield, mcurrcat, m1stoption, mlastoption, mnocats, mvartype, minitialvalue, unitprice) { //v2.0
var getquantity = window.document.getElementById("getquantity_"+mcurrfield);
var getnotes = window.document.getElementById("getnotes_"+mcurrfield);
var choicevar = window.document.getElementById("choice_"+mcurrfield);
var notesvar = window.document.getElementById("notes_"+mcurrfield);
var pricevar = window.document.getElementById("unitprice_"+mcurrfield);
var pricevar2 = window.document.getElementById("unitprice2_"+mcurrfield);
var extpricevar = window.document.getElementById("extprice_"+mcurrfield);
var extpricevar2 = window.document.getElementById("extprice2_"+mcurrfield);
var depositvar = window.document.getElementById("deposit_"+mcurrfield);
var depositvar2 = window.document.getElementById("deposit2_"+mcurrfield);
var quanvar = window.document.getElementById("quantity_"+mcurrfield);
var depositamount = window.document.getElementById("depositamount_"+mcurrfield);
var popupvalue1 = window.document.getElementById("popupvalue1_"+mcurrfield);
if (mvartype == "checkbox")
	{
	if (choicevar.checked == true) // if I just checked the box
		{
		if (getquantity.value == "T")
			{
			quanvar.disabled=false;
			var mtotal = quanvar.value * pricevar.value;
			var mdeptotal = quanvar.value * depositamount.value;
			extpricevar.value=mtotal.toFixed(2);
			extpricevar2.value=mtotal.toFixed(2);
			depositvar.value=mdeptotal.toFixed(2);
			depositvar2.value=mdeptotal.toFixed(2);
			}
		else // else no quantity
			{
			var mtotal = pricevar.value;
			var mdeptotal = depositamount.value;
			extpricevar.value=mtotal;
			extpricevar2.value=mtotal;
			depositvar.value=mdeptotal;
			depositvar2.value=mdeptotal;
			}
		if (getnotes.value == "T")
			{
			notesvar.disabled=false;
			}
		}
	else // else I un-checked it
		{
		if (getquantity.value == "T")
			{
			quanvar.value="0";
			quanvar.disabled=true;
			}
		if (getnotes.value == "T")
			{
			notesvar.disabled=true;
			notesvar.value="";
			}
		extpricevar.value = "0.00";
		extpricevar2.value = "0.00";
		depositvar.value = "0.00";
		depositvar2.value = "0.00";
		}
	}
else // else it must be a popup
	{
	var myindex  = choicevar.selectedIndex // returns the number of the selected element??
	var selection = choicevar.value;	 // the value of the selected element???
	mitemprice = window.document.getElementById("itemprice_"+mcurrfield+"_"+myindex);
	mdeposit = window.document.getElementById("deposit_"+mcurrfield+"_"+myindex);
	//alert("item selected="+choicevar.value+"AND popup1.value="+popupvalue1.value+"AND");
	if (choicevar.value == popupvalue1.value) // no choice selected
		{
		if (getquantity.value == "T")
			{
			quanvar.disabled=true;
			quanvar.value=0;
			}
		if (getnotes.value == "T")
			{
			notesvar.disabled=true;
			notesvar.value="";
			}
		pricevar.value="0.00";
		extpricevar2.value = "0.00";
		extpricevar.value = "0.00";
		depositvar.value = "0.00";
		depositvar2.value = "0.00";
		}
	else // else I have selected aomething from my popup
		{
		if (getquantity.value == "T") // if this choice has a quantity associated with it
			{
			quanvar.disabled=false;
			}
		if (getnotes.value == "T") // if this choice has a notes field associated with it
			{
			notesvar.disabled=false;
			}
		if (getquantity.value == "T") // if this choice has a quantity associated with it
			{
			pricevar.value = mitemprice.value;
			pricevar2.value = mitemprice.value;
			mtotal = quanvar.value * pricevar.value; // save to a var so I can make sure there are 2 decimal places
			extpricevar.value=mtotal.toFixed(2);
			extpricevar2.value=mtotal.toFixed(2);
			var mdeptotal = quanvar.value * mdeposit.value;
			depositvar.value=mdeptotal.toFixed(2);
			depositvar2.value=mdeptotal.toFixed(2);
			}
		else
			{
			pricevar.value = mitemprice.value;
			pricevar2.value = mitemprice.value;
			mtotal = pricevar.value; // save to a var so I can make sure there are 2 decimal places
			extpricevar.value=mtotal;//.toFixed(2);
			extpricevar2.value=mtotal;//.toFixed(2);
			var mdeptotal = mdeposit.value;
			depositvar.value=mdeptotal;
			depositvar2.value=mdeptotal;

			}
		}
	}
	// now get the category total
	//mcurrcat, m1stoption, mlastoption, mnocats
	var cattotal = window.document.getElementById("cattotal_"+mcurrcat);
	var catdeptotal = window.document.getElementById("catdeptotal_"+mcurrcat);
	mtotal = 0;
	mdeptotal = 0;
	for (optionno = eval(m1stoption); optionno <= eval(mlastoption); optionno++)
		{
		var extpricevartmp = window.document.getElementById("extprice_"+optionno);
		var depositvartmp = window.document.getElementById("deposit_"+optionno);
		mtotal = eval(mtotal) + eval(extpricevartmp.value);
		mdeptotal = eval(mdeptotal) + eval(depositvartmp.value);
		}
	cattotal.value=mtotal.toFixed(2);
	catdeptotal.value=mdeptotal.toFixed(2); // category deposit total
	// now get the grand total
	//mcurrcat, m1stoption, mlastoption, mnocats
	mtotal = 0;
	mdeptotal = 0;
	for (catno = 1; catno <= mnocats; catno++)
		{
		var cattotal2 = window.document.getElementById("cattotal_"+catno);
		var deptotal2 = window.document.getElementById("catdeptotal_"+catno);
		mtotal = eval(mtotal) + eval(cattotal2.value);
		mdeptotal = eval(mdeptotal) + eval(deptotal2.value);
		}
	//mtotal = mtotal - eval(window.document.optionsheet.adjustment.value);
	window.document.optionsheet.grandtotal.value=mtotal.toFixed(2);
	window.document.optionsheet.grandtotal2.value=mtotal.toFixed(2);
	window.document.optionsheet.totaldeposits.value=mdeptotal.toFixed(2);
	window.document.optionsheet.totaldeposits2.value=mdeptotal.toFixed(2);
}

function flooringupdate(mcurrfield, mcurrcat, mnocats) { //v2.0
var extpricevar = window.document.getElementById("fltotal_"+mcurrfield);
	// not get the category total
	//mcurrcat, m1stoption, mlastoption, mnocats
	var cattotal = window.document.getElementById("cattotal_"+mcurrcat);
	mtotal = 0;
	for (optionno = 1; optionno <= 22; optionno++)
		{
		var extpricevartmp = window.document.getElementById("fltotal_"+optionno);
		if (extpricevartmp.value == "")
			{
			extpricevartmp.value = "0.00";
			}
		mtotal = eval(mtotal) + eval(extpricevartmp.value);
		}
	cattotal.value=mtotal.toFixed(2);
	// now get the grand total
	//mcurrcat, m1stoption, mlastoption, mnocats
	mtotal = 0;
	for (catno = 1; catno <= mnocats; catno++)
		{
		var cattotal2 = window.document.getElementById("cattotal_"+catno);
		mtotal = eval(mtotal) + eval(cattotal2.value);
		}
	//mtotal = mtotal - eval(window.document.optionsheet.adjustment.value);
	window.document.optionsheet.grandtotal.value=mtotal.toFixed(2);
	window.document.optionsheet.grandtotal2.value=mtotal.toFixed(2);
}

function reloadpage()
{
// this function is used so that when I close an option sheet, my contract data tab will reload and the new option total will
//be reflected in the totals.  ALso if I have signed and closed an option sheet, my "edit Option Sheet" link will change to "View Option Sheet".
window.opener.location.reload()
}

function allcomms(boxvar) { //v2.0
if(boxvar.checked) // called by options01.php.  if I just checked the "Universal" check box.  Un-check all others
 	{
	var thing=document.getElementById? document.getElementById("community_all2") : document.all? "document.all."+"community_all2" : ""
	thing.checked=false;
	var totalcount = window.document.options01.communitycount.value; // this is the number of communities in the list
	for (var n=1; n<=totalcount ; n++)
		{
		//var thing=document.getElementById? document.getElementById("status-"+mvar) : document.all? "document.all."+"status-"+mvar : ""
		var thing=document.getElementById? document.getElementById("community_"+n) : document.all? "document.all."+"community_"+n : ""
		thing.checked=false;
		}
	//window.document.options01.community_1.checked=false;
	}
}

function checkallcomms(boxvar) { //v2.0
if(boxvar.checked) // Called by options01.php.  If I just checked the "All Communities" check box, check all the community boxes.
 	{
	var totalcount = window.document.options01.communitycount.value; // this is the number of communities in the list
	for (var n=1; n<=totalcount ; n++)
		{
		//var thing=document.getElementById? document.getElementById("status-"+mvar) : document.all? "document.all."+"status-"+mvar : ""
		var thing=document.getElementById? document.getElementById("community_"+n) : document.all? "document.all."+"community_"+n : ""
		thing.checked=true;
		}
	//window.document.options01.community_1.checked=false;
	}
else // else I just unchecked the "All" check box
 	{
	var totalcount = window.document.options01.communitycount.value; // this is the number of communities in the list
	for (var n=1; n<=totalcount ; n++)
		{
		//var thing=document.getElementById? document.getElementById("status-"+mvar) : document.all? "document.all."+"status-"+mvar : ""
		var thing=document.getElementById? document.getElementById("community_"+n) : document.all? "document.all."+"community_"+n : ""
		thing.checked=false;
		}
	//window.document.options01.community_1.checked=false;
	}
}

function commboxes(boxvar) { //v2.0
if(boxvar.checked)  // Called by options01.php.  If I just checked a community check box, un-check the "Universal" box.  If I just unchecked a community, then un-check the "All" check box.
 	{
	window.document.options01.community_all.checked=false;
	}
else // else I just un-checked this check box
 	{
	window.document.options01.community_all2.checked=false;
	}
}

function allplans(boxvar) { //v2.0
if(boxvar.checked) // called by options01.php.  if I just checked the "Universal" check box.  Un-check all others
 	{
	var thing=document.getElementById? document.getElementById("plans_all2") : document.all? "document.all."+"plans_all2" : ""
	thing.checked=false;
	var totalcount = window.document.options02.seriescount.value; // this is the number of series in the list
	for (var n=1; n<=totalcount ; n++)
		{
		var thing=document.getElementById? document.getElementById("checkseries_"+n) : document.all? "document.all."+"checkseries_"+n : ""
		thing.checked=false;
		}
	var totalcount = window.document.options02.planscount.value; // this is the number of plans in the list
	for (var n=1; n<=totalcount ; n++)
		{
		//var thing=document.getElementById? document.getElementById("status-"+mvar) : document.all? "document.all."+"status-"+mvar : ""
		var thing=document.getElementById? document.getElementById("plan_"+n) : document.all? "document.all."+"plan_"+n : ""
		thing.checked=false;
		}
	//window.document.options01.community_1.checked=false;
	}
}

function checkallplans(boxvar) { //v2.0
if(boxvar.checked) // Called by options02.php.  If I just checked the "All Plans" check box, check all the plan boxes.
 	{
	var totalcount = window.document.options02.planscount.value; // this is the number of communities in the list
	for (var n=1; n<=totalcount ; n++)
		{
		//var thing=document.getElementById? document.getElementById("status-"+mvar) : document.all? "document.all."+"status-"+mvar : ""
		var thing=document.getElementById? document.getElementById("plan_"+n) : document.all? "document.all."+"plan_"+n : ""
		thing.checked=true;
		}
	//window.document.options01.community_1.checked=false;
	var totalcount = window.document.options02.seriescount.value; // this is the number of series in the list
	for (var n=1; n<=totalcount ; n++)
		{
		var thing=document.getElementById? document.getElementById("checkseries_"+n) : document.all? "document.all."+"checkseries_"+n : ""
		thing.checked=false;
		}
	}
else // else I just unchecked the "All" check box
 	{
	var totalcount = window.document.options02.communitycount.value; // this is the number of communities in the list
	for (var n=1; n<=totalcount ; n++)
		{
		//var thing=document.getElementById? document.getElementById("status-"+mvar) : document.all? "document.all."+"status-"+mvar : ""
		var thing=document.getElementById? document.getElementById("plan_"+n) : document.all? "document.all."+"plan_"+n : ""
		thing.checked=false;
		}
	//window.document.options01.community_1.checked=false;
	}
}

function planboxes(boxvar) { //v2.0
if(boxvar.checked) // if I just checked the box to "check out" the file
 	{
	window.document.options02.plans_all.checked=false;
	var totalcount = window.document.options02.seriescount.value; // this is the number of series in the list
	for (var n=1; n<=totalcount ; n++)
		{
		var thing=document.getElementById? document.getElementById("checkseries_"+n) : document.all? "document.all."+"checkseries_"+n : ""
		thing.checked=false;
		}
	}
else // else I just un-checked this check box
 	{
	window.document.options02.plans_all2.checked=false;
	}
}

function seriesboxes(boxvar) { //v2.0
if(boxvar.checked) // if I just checked the box to "check out" the file
 	{
	window.document.options02.plans_all.checked=false;
	window.document.options02.plans_all2.checked=false;
	var totalcount = window.document.options02.planscount.value; // this is the number of plans in the list
	for (var n=1; n<=totalcount ; n++)
		{
		//var thing=document.getElementById? document.getElementById("status-"+mvar) : document.all? "document.all."+"status-"+mvar : ""
		var thing=document.getElementById? document.getElementById("plan_"+n) : document.all? "document.all."+"plan_"+n : ""
		thing.checked=false;
		}
	}
else // else I just un-checked this check box
 	{
	window.document.options02.plans_all2.checked=false;
	}
}

function killplans() {
// this function is called by optionedit01.php
// it is used to disable the plans popup when a series is selected
if (window.document.optionedit01.series.value == "All Home Series")
	{
	window.document.optionedit01.plan.disabled=false;
	}
else // else we selected a series
	{
	window.document.optionedit01.plan.value="All Plans";
	window.document.optionedit01.plan.disabled=true;
	}
}

function killseries() {
// this function is called by optionedit01.php
// it is used to disable the series popup when a plan is selected
if (window.document.optionedit01.plan.value == "All Plans")
	{
	window.document.optionedit01.series.disabled=false;
	}
else // else we selected a plan
	{
	//window.document.optionedit01.series.value="All Home Series";
	window.document.optionedit01.series.disabled=true;
	}
}

function activate() {
// this function is called by optionedit01.php
// it is used to enable the buttons when a category is selected
if (window.document.optionedit01.category.value == "All Categories")
	{
	window.document.optionedit01.optionbutton01.disabled=true;
	window.document.optionedit01.optionbutton02.disabled=true;
	}
else // else we selected a plan
	{
	window.document.optionedit01.optionbutton01.disabled=false;
	window.document.optionedit01.optionbutton02.disabled=false;
	}
}

function killplans2() {
// this function is called by optionedit01.php
// it is used to disable the plans popup when a series is selected
//alert("plan = "+window.document.optionedit02.planno.value);
if (window.document.optionedit02.series.value == 0) // 0 = universal
	{
	window.document.optionedit02.planno.disabled=false;
	}
else // else we selected a series
	{
	window.document.optionedit02.planno.value=0; // 0 = universal
	window.document.optionedit02.planno.disabled=true;
	}
}

function killseries2() {
// this function is called by optionedit02.php
// it is used to disable the series popup when a plan is selected
if (window.document.optionedit02.planno.value == 0) // universal
	{
	window.document.optionedit02.series.disabled=false;
	}
else // else we selected a plan
	{
	window.document.optionedit02.series.disabled=true;
	}
}

function standard2(rowno) {
// this function is called by optionedit02.php
// it is used to uncheck all but the most recently checked "standard value" check box.  It makes them act like radio buttons.
var totalcount = document.optionedit02.nrows.value;
//alert("I just checked row number "+rowno+" out of "+totalcount);
for (var n=1; n<=totalcount ; n++)
	{
	if (n != rowno) // if this is not the box I just checked, uncheck it
		{
		var thing=document.getElementById? document.getElementById("standardchoice_"+n) : document.all? "document.all."+"standardchoice_"+n : ""
		thing.checked=false;
		}
	}
}

function setlists(catval, commval, seriesval, planval) {
// this function is called by optionedit01.php after returning from optionedit02
// it is used to reset the popups and the list.  now the list will reflect the changes we just might have made
if (catval != "") // if a category was selected
	{
	window.document.optionedit01.category.value = catval;
	}
if (commval != "") // if a community was selected
	{
	window.document.optionedit01.community.value = commval;
	}
if (seriesval != "") // if a series was selected
	{
	window.document.optionedit01.series.value = seriesval;
	}
if (planval != "") // if a plan was selected
	{
	window.document.optionedit01.plan.value = planval;
	}
}

function standard3(rowno) {
// this function is called by options05.php
// it is used to uncheck all but the most recently checked "standard value" check box.  It makes them act like radio buttons.
var totalcount = document.options05.rowcount.value;
//alert("I just checked row number "+rowno+" out of "+totalcount);
for (var n=1; n<=totalcount ; n++)
	{
	if (n != rowno) // if this is not the box I just checked, uncheck it
		{
		var thing=document.getElementById? document.getElementById("standardchoice_"+n) : document.all? "document.all."+"standardchoice_"+n : ""
		thing.checked=false;
		}
	}
}

function updategtotal(mnorows) { //v2.0
var $grandtotal = 0;
	mtotal = 0;
	for (rowno = 1; rowno <= mnorows; rowno++)
		{
		var rowtotal2 = window.document.getElementById("amount_"+rowno);
		mtotal = eval(mtotal) + eval(rowtotal2.value);
		}
	//mtotal = mtotal - eval(window.document.optionsheet.adjustment.value);
	window.document.changeorder.grandtotal.value=mtotal.toFixed(2);
	window.document.changeorder.grandtotal2.value=mtotal.toFixed(2);
}

function planchange() {
// this function is called by tabedit.php
// when a plan is changed, this function just alerts the user that saving a job with another plan will cause the option sheet,
//change orders & deposit data to be deleted.
var oldplancode = document.escrowtab.oldplancode.value;
var oldplanno = document.escrowtab.oldplanno.value;
var newplancode = document.escrowtab.plan.value;
if (oldplancode != "")
	{
	if (newplancode != oldplancode) // if plan changed
		{
		alert("The last saved plan for this job was "+oldplancode+"...  Changing it to "+newplancode+" and saving changes will cause the option sheet and any change orders to be deleted from the Home STAR database...");
		}
	}

}

function disable(mfield) {
// this function is called by gloptionedit02.php
// it is used to cause fields to be disabled and disregarded by the save routine
if (mfield == "quantity")
	{
	alert('Some of the selections in this global group allow for a quantity to be entered and some do not...  If this field is disabled, saving global edits will not overwrite the "quantity" fields.');
	document.optionedit02.quan_enabled.value = "F";
	document.optionedit02.quantity.disabled = true;
	}
if (mfield == "required")
	{
	alert('Some of the selections in this global group are marked as "required" and some are not...  If this field is disabled, saving global edits will not overwrite the "required" fields.');
	document.optionedit02.req_enabled.value = "F";
	document.optionedit02.required.disabled = true;
	}
if (mfield == "notes")
	{
	alert('Some of the selections in this global group allow for notes to be entered and some do not...  If this field is disabled, saving global edits will not overwrite the "notes" fields.');
	document.optionedit02.notes_enabled.value = "F";
	document.optionedit02.notes.disabled = true;
	}
if (mfield == "activationdate")
	{
	alert('Some of the selections in this global group have different activation dates than others...  If this field is disabled, saving global edits will not overwrite the "activation date" fields.');
	document.optionedit02.act_enabled.value = "F";
	document.optionedit02.activationdate.disabled = true;
	document.optionedit02.ppp.disabled = true;
	}
if (mfield == "deactivationdate")
	{
	alert('Some of the selections in this global group have different deactivation dates than others...  If this field is disabled, saving global edits will not overwrite the "deactivation date" fields.');
	document.optionedit02.de_act_enabled.value = "F";
	document.optionedit02.deactivationdate.disabled = true;
	document.optionedit02.ppp.disabled = true;
	}
}

function enable(mfield) {
// this function is called by gloptionedit02.php
// it is used to cause fields to be disabled and disregarded by the save routine
if (mfield == "quantity")
	{
	alert('Some of the selections in this global group allow for a quantity to be entered and some do not...  If this field is enabled, saving global edits will overwrite the "quantity" fields with whatever value you have entered here.');
	document.optionedit02.quan_enabled.value = "T";
	document.optionedit02.quantity.disabled = false;
	}
if (mfield == "required")
	{
	alert('Some of the selections in this global group are marked as "required" and some are not...  If this field is enabled, saving global edits will overwrite the "required" fields with whatever value you have entered here.');
	document.optionedit02.req_enabled.value = "T";
	document.optionedit02.required.disabled = false;
	}
if (mfield == "notes")
	{
	alert('Some of the selections in this global group allow for notes to be entered and some do not...  If this field is enabled, saving global edits will overwrite the "notes" fields with whatever value you have entered here.');
	document.optionedit02.notes_enabled.value = "T";
	document.optionedit02.notes.disabled = false;
	}
if (mfield == "activationdate")
	{
	alert('Some of the selections in this global group have different activation dates than others...  If this field is enabled, saving global edits will overwrite the "activation date" fields with whatever value you have entered here.');
	document.optionedit02.act_enabled.value = "T";
	document.optionedit02.activationdate.disabled = false;
	}
if (mfield == "deactivationdate")
	{
	alert('Some of the selections in this global group have different deactivation dates than others...  If this field is enabled, saving global edits will overwrite the "deactivation date" fields with whatever value you have entered here.');
	document.optionedit02.de_act_enabled.value = "T";
	document.optionedit02.deactivationdate.disabled = false;
	}
}

function get_ac_date(str_target, str_datetime) {
// this function tests to see if the "activation date" field is disabled.
// If it is, we just display an alert box and then return. CM
if(document.optionedit02.activationdate.disabled == true)
	{
	return alert("This field is disabled...  You may not enter in an activation date...");
	}
show_calendar(str_target, str_datetime);
}

function get_deac_date(str_target, str_datetime) {
// this function tests to see if the "activation date" field is disabled.
// If it is, we just display an alert box and then return. CM
if(document.optionedit02.deactivationdate.disabled == true)
	{
	return alert("This field is disabled...  You may not enter in a deactivation date...");
	}
show_calendar(str_target, str_datetime);
}

function addcharge() {
// this function is just for the multiple floor charge
if(document.optionsheet.multiplecharge.checked == true)
	{
	document.optionsheet.fltotal_22.value = "150.00";
	document.optionsheet.fltotal_22_2.value = "150.00";
	}
else
	{
	document.optionsheet.fltotal_22.value = "0.00";
	document.optionsheet.fltotal_22_2.value = "0.00";
	}
}

function realtorinfo() {
if(document.regcard.realtor.value == "Yes")
	{
	document.regcard.agentname.disabled=false;
	document.regcard.company.disabled=false;
	}
else
	{
	document.regcard.agentname.disabled=true;
	document.regcard.agentname.value=""; // erase text
	document.regcard.company.disabled=true;
	document.regcard.company.value=""; // erase text
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////
//
// function:	createnumber()
//
// description:	This function takes a number in string form (no commas or anything else).
//				If it really a number, it returns it, else returns 0.
//
// parameters:	mnumber is the number we are processing
//
//////////////////////////////////////////////////////////////////////////////////////////////
function createnumber(mnumber)
{
	mnumber = mnumber.replace(",","");
	
	while(mnumber.substr(0,1) == "0")
		{
		mnumber = mnumber.substr(1, mnumber.length-1)
		}
		
		
		
		
		
	if (IsNumeric(mnumber))
		{
		return eval(mnumber);
		}
	else
		{
		return 0;
		}
} // end of function
//////////////////////////////////////////////////////////////////////////////////////////////
//
// function:	lighton()
//
// description:	highlights the row our mouse cursor is over
//
//////////////////////////////////////////////////////////////////////////////////////////////
function lighton(rownum){
var color="orange";
var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-1") : document.all? "document.all."+"cell+"+rownum+"-1" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-2") : document.all? "document.all."+"cell+"+rownum+"-2" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-3") : document.all? "document.all."+"cell+"+rownum+"-3" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-4") : document.all? "document.all."+"cell+"+rownum+"-4" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-5") : document.all? "document.all."+"cell+"+rownum+"-5" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-6") : document.all? "document.all."+"cell+"+rownum+"-6" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-7") : document.all? "document.all."+"cell+"+rownum+"-7" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-8") : document.all? "document.all."+"cell+"+rownum+"-8" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-9") : document.all? "document.all."+"cell+"+rownum+"-9" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-10") : document.all? "document.all."+"cell+"+rownum+"-10" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-11") : document.all? "document.all."+"cell+"+rownum+"-11" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-12") : document.all? "document.all."+"cell+"+rownum+"-12" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-13") : document.all? "document.all."+"cell+"+rownum+"-13" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-14") : document.all? "document.all."+"cell+"+rownum+"-14" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-15") : document.all? "document.all."+"cell+"+rownum+"-15" : ""
crosstable.style.borderColor=color
}

//////////////////////////////////////////////////////////////////////////////////////////////
//
// function:	lightoff()
//
// description:	kills highlight on the row our mouse cursor is over
//
//////////////////////////////////////////////////////////////////////////////////////////////
function lightoff(rownum){
var color="black";
var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-1") : document.all? "document.all."+"cell+"+rownum+"-1" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-2") : document.all? "document.all."+"cell+"+rownum+"-2" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-3") : document.all? "document.all."+"cell+"+rownum+"-3" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-4") : document.all? "document.all."+"cell+"+rownum+"-4" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-5") : document.all? "document.all."+"cell+"+rownum+"-5" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-6") : document.all? "document.all."+"cell+"+rownum+"-6" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-7") : document.all? "document.all."+"cell+"+rownum+"-7" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-8") : document.all? "document.all."+"cell+"+rownum+"-8" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-9") : document.all? "document.all."+"cell+"+rownum+"-9" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-10") : document.all? "document.all."+"cell+"+rownum+"-10" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-11") : document.all? "document.all."+"cell+"+rownum+"-11" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-12") : document.all? "document.all."+"cell+"+rownum+"-12" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-13") : document.all? "document.all."+"cell+"+rownum+"-13" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-14") : document.all? "document.all."+"cell+"+rownum+"-14" : ""
crosstable.style.borderColor=color

var crosstable=document.getElementById? document.getElementById("cell"+rownum+"-15") : document.all? "document.all."+"cell+"+rownum+"-15" : ""
crosstable.style.borderColor=color

}

/////////////////////////////////////////////////////////////////////
// function:	setCookie
//
// description:	this function creates a cookie and sets the value
/////////////////////////////////////////////////////////////////////
function setCookie( name, value) 
{
var exdate=new Date();
//exdate.setDate(exdate.getDate()+expiredays);
//document.cookie=c_name+ "=" +escape(value)+
//((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
exdate.setDate(exdate.getDate()+10);

document.cookie = name+ "=" +escape(value)+";expires="+exdate.toGMTString();


//document.cookie = name + "=" +escape( value );
}
////////////////////////////////////////////////////////////////////////
// function:	getCookie
//
// description:	This function gets a cookie value
////////////////////////////////////////////////////////////////////////
function getCookie(name) {
	// this functino checks to see if the cookie named in the "name"
	// parameter exists.  If it does, this function returns the value.
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

////////////////////////////////////////////////////////////////////////////////////////
//
// function:	contractvalid
//
//
//
////////////////////////////////////////////////////////////////////////////////////////
function contractvalid()
{
if ((window.document.escrowtab.community2.value == "")||(window.document.escrowtab.address2.value == "")||(window.document.escrowtab.first1.value == "")||(window.document.escrowtab.rep1.value == "Select Sales Rep")||(window.document.escrowtab.date.value == "")||(window.document.escrowtab.buyers_address1.value == "")||(window.document.escrowtab.buyers_city.value == "")||(window.document.escrowtab.buyers_st.value == "No Answer")||(window.document.escrowtab.buyers_zip.value == "")||(window.document.escrowtab.totalpriceP.value == "")||((window.document.escrowtab.buyers_phone1.value == "")&&(window.document.escrowtab.buyers_phone2.value == "")&&(window.document.escrowtab.buyers_email1.value == "")&&(window.document.escrowtab.buyers_email2.value == ""))||((window.document.escrowtab.planP.value == "")&&(window.document.escrowtab.plan.value == "Select Plan")))
	{
	alert("One or more required fields was left blank...   Please fill out form completely...");
	return false;
	}
else
	{
	return true;
	}
}
////////////////////////////////////////////////////////////////////////////////////////
//
// function:	viewpdf
//
// description:	this function opens a window to view a pdf.
//
// parameters:	mfile2view = file to view (addendums, pendcontract, etc..)
//				mitemno = internal number for the item to view
//				no_type = jobno, pendingno, etc...
//
//
////////////////////////////////////////////////////////////////////////////////////////
function viewpdf(mfile2view, mitemno, no_type)
{
window.open ('viewpdf.php?mview='+mfile2view+'&mno='+mitemno+'&mtype='+no_type,'','toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=no, directories=no, status=yes');
}

////////////////////////////////////////////////////////////////////////////////////////
//
// function:	delvalid
//
//
//
////////////////////////////////////////////////////////////////////////////////////////
function delvalid()
{
	if (!confirm('Are You Sure?  Click "OK" to continue or "Cancel" to return to edit screen...'))
	return false;return true
	
}
////////////////////////////////////////////////////////////////////////////////////////
//
// function:	newsvalid
//
//
//
////////////////////////////////////////////////////////////////////////////////////////
function newsvalid()
{
	if (window.document.newsform1.type.value == "none") // no item type selected
		{
		alert("No item type has been selected...   Please select an item type before saving...");
		return false
		}
	if (window.document.newsform1.headline.value == "") // no headline selected
		{
		alert("No headline was entered...   Please select a headline before saving...");
		return false
		}
	if (window.document.newsform1.itemdate.value == "") // no item date selected
		{
		alert("No item date was entered...   Please select a date before saving...");
		return false
		}
	if ((window.document.newsform1.type.value == "news_en") || (window.document.newsform1.type.value == "pin_en")) // news item or PRO in the news
		{
		if ((window.document.newsform1.newsdispstart.value == "") || (window.document.newsform1.newsdispend.value == "")) // if missing a start or end date	
			{
			alert("All news items must have a start and end date...  Please make sure this item has both start and end dates...");
			return false;
			}
		}
	if (!confirm('Are You Sure?  Click "OK" to continue or "Cancel" to return to display item editing...'))
	return false;return true
}
////////////////////////////////////////////////////////////////////////////////////////
//
// function:	settype
//
//
//
////////////////////////////////////////////////////////////////////////////////////////
function settype()
{
if (window.document.newsform1.type.value == "none") // no item type selected
	{
	// un-check the `include in calendar` checkbox
	window.document.newsform1.dispincal.checked=false;
	// disable all fields - no item type selected
	window.document.newsform1.headline.disabled=true;
	window.document.newsform1.details.disabled=true;
	window.document.newsform1.linktext.disabled=true;
	window.document.newsform1.linkto.disabled=true;
	window.document.newsform1.newsdispstart.disabled=true;
	window.document.newsform1.newsdispend.disabled=true;
	window.document.newsform1.newsdispstart.value="";
	window.document.newsform1.newsdispend.value="";
	window.document.newsform1.dispincal.disabled=true;
	// make our calendar links disappear
	mgetid01 = window.document.getElementById("callink01"); 
	mgetid02 = window.document.getElementById("callink02"); 
	mgetid01.className="posthidden"; 
	mgetid02.className="posthidden"; 
	} // end if
if (window.document.newsform1.type.value == "news_en") // english news
	{
	// un-check the `include in calendar` checkbox
	window.document.newsform1.dispincal.checked=false;
	// enable all fields except `include in calendar`
	window.document.newsform1.headline.disabled=false;
	window.document.newsform1.details.disabled=false;
	window.document.newsform1.linktext.disabled=false;
	window.document.newsform1.linkto.disabled=false;
	window.document.newsform1.newsdispstart.disabled=false;
	window.document.newsform1.newsdispend.disabled=false;
	window.document.newsform1.newsdispstart.value=window.document.newsform1.today.value;
	window.document.newsform1.newsdispend.value=window.document.newsform1.nextmonth.value;
	window.document.newsform1.dispincal.disabled=true;	
	// make our calendar links appear
	mgetid01 = window.document.getElementById("callink01"); 
	mgetid02 = window.document.getElementById("callink02"); 
	mgetid01.className="postshown"; 
	mgetid02.className="postshown"; 
	} // end if
if (window.document.newsform1.type.value == "news_es") // english news
	{
	// un-check the `include in calendar` checkbox
	window.document.newsform1.dispincal.checked=false;
	// enable all fields except `include in calendar`
	window.document.newsform1.headline.disabled=false;
	window.document.newsform1.details.disabled=false;
	window.document.newsform1.linktext.disabled=false;
	window.document.newsform1.linkto.disabled=false;
	window.document.newsform1.newsdispstart.disabled=false;
	window.document.newsform1.newsdispend.disabled=false;
	window.document.newsform1.newsdispstart.value=window.document.newsform1.today.value;
	window.document.newsform1.newsdispend.value=window.document.newsform1.nextmonth.value;
	window.document.newsform1.dispincal.disabled=true;	
	// make our calendar links appear
	mgetid01 = window.document.getElementById("callink01"); 
	mgetid02 = window.document.getElementById("callink02"); 
	mgetid01.className="postshown"; 
	mgetid02.className="postshown"; 
	} // end if
if (window.document.newsform1.type.value == "pin_en") // english PRO in the news
	{
	// un-check the `include in calendar` checkbox
	window.document.newsform1.dispincal.checked=false;
	// enable all fields except date range & `include in calendar`
	window.document.newsform1.headline.disabled=false;
	window.document.newsform1.details.disabled=false;
	window.document.newsform1.linktext.disabled=false;
	window.document.newsform1.linkto.disabled=false;
	window.document.newsform1.newsdispstart.disabled=false;
	window.document.newsform1.newsdispend.disabled=false;
	window.document.newsform1.newsdispstart.value=window.document.newsform1.today.value;
	window.document.newsform1.newsdispend.value=window.document.newsform1.nextmonth.value;
	window.document.newsform1.dispincal.disabled=true;
	// make our calendar links appear
	mgetid01 = window.document.getElementById("callink01"); 
	mgetid02 = window.document.getElementById("callink02"); 
	mgetid01.className="postshown"; 
	mgetid02.className="postshown"; 
	} // end if
if (window.document.newsform1.type.value == "cal_en") // english calendar
	{
	// check the `include in calendar` checkbox
	window.document.newsform1.dispincal.checked=true;
	// enable all fields except date range
	window.document.newsform1.headline.disabled=false;
	window.document.newsform1.details.disabled=false;
	window.document.newsform1.linktext.disabled=false;
	window.document.newsform1.linkto.disabled=false;
	window.document.newsform1.newsdispstart.disabled=true;
	window.document.newsform1.newsdispend.disabled=true;
	window.document.newsform1.newsdispstart.value="";
	window.document.newsform1.newsdispend.value="";
	window.document.newsform1.dispincal.disabled=false;
	// make our calendar links disappear
	mgetid01 = window.document.getElementById("callink01"); 
	mgetid02 = window.document.getElementById("callink02"); 
	mgetid01.className="posthidden"; 
	mgetid02.className="posthidden"; 
	} // end if
if (window.document.newsform1.type.value == "ws_en") // english workshop
	{
	// enable all fields except date range & `include in calendar`
	window.document.newsform1.headline.disabled=false;
	window.document.newsform1.details.disabled=false;
	window.document.newsform1.linktext.disabled=false;
	window.document.newsform1.linkto.disabled=false;
	window.document.newsform1.newsdispstart.disabled=true;
	window.document.newsform1.newsdispend.disabled=true;
	window.document.newsform1.newsdispstart.value="";
	window.document.newsform1.newsdispend.value="";
	window.document.newsform1.dispincal.disabled=false;
	// make our calendar links disappear
	mgetid01 = window.document.getElementById("callink01"); 
	mgetid02 = window.document.getElementById("callink02"); 
	mgetid01.className="posthidden"; 
	mgetid02.className="posthidden"; 
	} // end if
if (window.document.newsform1.type.value == "cal_es") // spanish calendar
	{
	// check the `include in calendar` checkbox
	window.document.newsform1.dispincal.checked=true;
	// enable all fields except date range
	window.document.newsform1.headline.disabled=false;
	window.document.newsform1.details.disabled=false;
	window.document.newsform1.linktext.disabled=false;
	window.document.newsform1.linkto.disabled=false;
	window.document.newsform1.newsdispstart.disabled=true;
	window.document.newsform1.newsdispend.disabled=true;
	window.document.newsform1.newsdispstart.value="";
	window.document.newsform1.newsdispend.value="";
	window.document.newsform1.dispincal.disabled=false;
	// make our calendar links disappear
	mgetid01 = window.document.getElementById("callink01"); 
	mgetid02 = window.document.getElementById("callink02"); 
	mgetid01.className="posthidden"; 
	mgetid02.className="posthidden"; 
	} // end if
return true;
}

