function showCsgSource(){

	var csgSource = document.getElementById('divCsgSource');

	if (csgSource.innerHTML == '') {  	
		csgSource.innerHTML = document.all.csgSource.value;  
		csgSource.style.borderColor = "#6B6C5A";
		csgSource.style.borderWidth = "1px"
		csgSource.style.borderStyle = "dotted";
		csgSource.style.marginBottom = "10px"; 
		document.all.sourceLink.innerHTML = "[ hide source]";
	}else{ 
		
		csgSource.style.borderWidth = "0px"
		csgSource.style.borderStyle = "none";
		csgSource.style.marginBottom = "0px"; 
		csgSource.innerHTML = ''; 
		document.all.sourceLink.innerHTML = "[ csg source ]";
		
	}
		
}


function getTechEquip(workOrderId) {
	equipmentSelected = 0;
	//document.all.processIframe.src = "processWo.php?mode=showEquipment&workOrderId=<?php print $_REQUEST[workOrderId]?>&techId=" + document.forms.frmMain.techId.options[document.all.techId.selectedIndex].value + "&techId2=" + document.all.frmMain.techId2.value;
	document.all.processIframe.src = "processWo.php?mode=showEquipment&workOrderId=" + workOrderId + "&techId=" + document.forms.frmMain.techId.options[document.all.techId.selectedIndex].value;

	if (document.forms[0].workOrderId.value > 0) {
		document.all.transferEquip.src = "transferEquip.php?techId=" + document.all.techId.options[document.all.techId.selectedIndex].value + "&workOrderId=" + workOrderId;
	}

}

function resetCustomers() {

		document.all.first.value = "";
		document.all.last.value = "";
		document.all.address.value = "";
		document.all.city.value = "";
		document.all.state.value = "";
		document.all.zip.value = "";
		document.all.email.value = "";
		document.all.bridger.value = "";
		document.all.grid.value = "";
		document.all.phone1.value = "";
		document.all.phone2.value = "";
		document.all.phone3.value = "";
		document.all.apt.value = "";
		document.all.accountNo.value = "";


}

function searchCustomers() {
		
	var mode=$('mode').value;

	$('divCustomerResults').style.display = 'block';
	$('frmMain').mode.value = "searchCustomer";

	new Ajax.Updater('divCustomerResults', 'processWo.php', {asynchronous:true, evalScripts:true, parameters:Form.serialize(document.forms[0])}); 

	$('mode').value = mode;
	
	return false;

/*
	var mode=document.forms[0].mode.value;
	//alert($('divCustomerResults').style.display);
	document.forms[0].target = "processIframe";
	document.forms[0].mode.value = "searchCustomer";
	//alert(document.forms[0].mode.value);
	document.forms[0].submit();
	document.forms[0].target = "";
	
	document.forms[0].mode.value = mode;
	$('divCustomerResults').style.display = 'block';
*/
}

function copyWorkOrder() {
	
	//document.forms[0].target = "processIframe";
	document.forms[0].mode.value = "copyWorkOrder";
	//alert(document.all.mode.value);
	document.forms[0].submit();
	//document.forms[0].target = "";
	document.forms[0].mode.value = "edit";

}

function addEquipment() {
	if (document.forms.frmEquipPool.workOrderId.value == "") {
		addWorkOrderEquipment();

		return false;
	}else{
		return true;
	}

}

function addWorkOrderEquipment() {

	//alert('Please save work order prior to adding equipment');
	
	document.forms[0].mode.value = 'addWorkOrderEquipment';
	document.forms[0].target = "processIframe";
	document.forms[0].submit();


}

/*
function addBillingCode(form) {
	
	


	if (form.workOrderId.value == "") {
		

		form.billingCodeId.value =  document.frmBillingCodes.billingCodeId.options[document.frmBillingCodes.billingCodeId.selectedIndex].value;
		form.quantity.value =  document.frmBillingCodes.quantity.value;
		form.mode.value = 'addBillingCode';
		form.target = "processIframe";
		form.submit();

		return false;
	}else{

		return true;
	}

}
*/

function addBillingCode(form) {

	new Ajax.Updater('divBillingCodes', 'processWo.php', {asynchronous:true, evalScripts:true, parameters:Form.serialize(form)}); 
	$('selectBillingCodeId').value = 0; 
	$('selectBillingCodeId').focus(); 
	
	return false; 
}

function deleteBillingCode(billingCodeId) {
	
	new Ajax.Updater('divBillingCodes', 'processWo.php?mode=deleteBillingCode&billingCodeId=' + billingCodeId + '&workOrderId=' + document.forms.frmBillingCodes.workOrderId.value , {asynchronous:true, evalScripts:true });
	//document.all.processIframe.src = "processWo.php?mode=deleteBillingCode&billingCodeId=" + billingCodeId + "&workOrderId=" + document.forms.frmBillingCodes.workOrderId.value;
}

function changeBillingQuantity(billingCodeId, quantity, workOrderId) {

	document.all.processIframe.src = "processWo.php?mode=changeBillingQuantity&billingCodeId=" + billingCodeId + "&quantity=" + quantity + "&workOrderId=" + workOrderId;
}

function toggleCheckbox(serialCheckbox, serial) {
	var myRow;
	eval("myRow=document.all." + trim(serial) + ";");

	if (serialCheckbox.checked != true) {		
		myRow.bgColor = "#ffffff";
		equipmentSelected--;
		document.all.divItemsSelected.innerHTML = "Items Selected: " + equipmentSelected;
	}else{
		myRow.bgColor = "#cccccc";
		equipmentSelected++;
		document.all.divItemsSelected.innerHTML = "Items Selected: " + equipmentSelected;
	}

}

function trim(str)
{
   return str.replace(/ /g, "");
}

function showEquipmentHistory(ePoolId) {

var left = event.clientX + document.body.scrollLeft + 90; 
var top = event.clientY + document.body.scrollTop + 10; 

$('divEquipHistory').style.display='block'
$('divEquipHistory').style.top = top

new Ajax.Updater('divEquipHistory', 'processEquipment.php?mode=showEquipmentHistory&ePoolId=' + ePoolId, {asynchronous:true, evalScripts:true });

}

function submitWO() 
{

	// if(window.external) window.external.AutoCompleteSaveForm(frmMain);
	frmMain.submit();
	return false;

}


function checkForm()
{
	// if($j.browser.msie && window.external) { window.external.AutoCompleteSaveForm(frmMain); }; 

	new Ajax.Updater('divJobInfo', 'processWo.php?checkJobForm=1', { evalScripts:true, parameters:Form.serialize('frmMain')}); return false;

}


<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://members.xoom.com/cyanide_7 -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
//  End -->



function showWoNotes(workOrderId) {
	//alert(window.event.clientX);
	var left = event.clientX + document.body.scrollLeft + 90; 
	var top = event.clientY + document.body.scrollTop + 10; 

	document.all.iframe1.src = 'processWo.php?mode=showWoNotes&workOrderId=' + workOrderId + '&left=' + left + '&top=' + top;

}

function submitStatusSwitch(form)
{
	new Ajax.Updater('statusSwitch', 'processWo.php', {asynchronous:true, evalScripts:true, parameters:Form.serialize(form)}); 
	return false;
}

function doLastSearch()
{ 
	new Ajax.Updater ('divJobList', 'processWo.php', {asynchronous:true, evalScripts:true, method: 'get', parameters:Form.serialize($('lastSearch'))});	
	return false;
	
}

function refreshAging()
{  
	new Ajax.Updater('divJobListAging', 'processWo.php?mode=dispatchAging', {asynchronous:true, evalScripts:true});
}

function showUploadStatus() {

	$j('#iframeR2W').show();
	$j('#divJobListTitle').html('');
	$j('#uploadStatus').show();
	showSpinner('uploadStatus');
	showSpinner('divJobList');

	 return true;
}

function showTOAUploadStatus() {

	$j('#iframeR2W').show();
	$j('#divJobListTitle').html('');
	$j('#uploadStatus').show();
	showSpinner('toaUploadStatus');
	showSpinner('divJobList');
	
	return true;
}

function searchJobsByKW(form)
{

	new Ajax.Updater('divJobList', 'processWo.php', {
			onLoading: showSpinner('divJobList'), 
			asynchronous:true, 
			evalScripts:true, 
			parameters:Form.serialize(form)
		}); 
		
	return false;

}

function showWorkOrderSearch(link) {
	
	resetLinks('menu' , link); 
	$('div1').update(); 
	$('divSelectors').update(); 
	$('searchJobs').show();
	$('divJobSearch').show();

}


function showProjectSummary()
{
	new Ajax.Updater ('divJobList', 'processWo.php', {
					onLoading: showSpinner('divJobList'),
					asynchronous:true, 
					evalScripts:true, 
					method: 'post', 
					parameters: { mode: 'showProjectSummary'},
					onComplete: function() { 
						$('divJobListTitle').update('Project Summary');
					}
	});	

	return false;
}

function showR2WSummaryLink(div) {
	

	$j('#' + div).show();
	$j('#' + div).html('<a onclick="showR2wSummary();">View R2W Import Summary</a>');

}