function getLeadInfo(){
	
	global $DB;
	
	// mark as read
	$r = $DB->queryUniqueObject("SELECT * FROM leads WHERE id = ".$_REQUEST['leadid']);
	$ret = '{			 
								"jobname":"'.$r->jobname.'",
								"company":"'.$r->company.'",
								"customer":"'.$r->customer.'",
								"repid":"'.$r->rep.'",
								"rep":"'.getRep($r->rep).'",
								"created by":"'.getRep($r->createdby_repid).'",
								"est. $":"$'.$r->estimated.'",
								"joanlead":"'.$r->joanload.'",
								"comments":"'.nonl($r->comments).'",
								"targetdate":"'.dateFix($r->targetdate).'",
								"dateclosed":"'.dateFix($r->dateclosed).'",
								"status":"'.$r->status.'",
								"reason":"'.nonl($r->reason).'",
								"reason given by":"'.getRep($r->reason_repid).'",
								"createdon":"'.dateFix($r->createdon).'",
								"lastupdated":"'.dateFix($r->lastupdated).'",
								"last updated by":"'.getRep($r->lastupdatedby_repid).'",
								"quotefilestr":"'.checkQuoteFile($r->quotefile).'",
								"quotefile":"'.checkQuoteFile($r->quotefile, true).'",
								"id":"'.$r->id.'"
					}';
									 
	
	print $ret;
}
function saveCorr($torepid, $cccorrid = 0){
	global $DB;
	
	$message = nonl($_REQUEST['message']);
	
	$sql = "INSERT INTO corr SET 
						message = '".$DB->safe($message)."',
						postdate = CURRENT_TIMESTAMP,
						fromrepid = ".$DB->safe($_SESSION['loggedin']).",
						torepid = ".$DB->safe($torepid).",
						leadid = ".$DB->safe($_REQUEST['leadid']).",
						cccorrid = ".$cccorrid;

	if($DB->query($sql)){
		print "1:saved";
	}else{
		print("0:Oops, there was an error saving this ".mysql_error());
	}

}