                 
var showClass= "shown";
var hideClass = "hidden";
var counterObj = null;
var counterLast = null;
var timer = null;
var textObj = null;
var textLimit = null;

var commQueue = false;
var commExec = "http://app1.jax.usa4sale.net/ver5/ajax/relay.php?do=contactseller&site=6&fid=sch";
var commFwdQueue = false;
var commExecFwd = "http://app1.jax.usa4sale.net/ver5/ajax/relay.php?do=forwardad&site=6&fid=sch";
var commFlagQueue = false;
var commExecFlag = "http://app1.jax.usa4sale.net/ver5/ajax/relay.php?do=flagseller&site=6&fid=sch";
var commDlrQueue = false;
var commExecDlr = "http://app1.jax.usa4sale.net/ver5/ajax/relay.php?do=dealerlocate&s=6";
var commDlrMsgQueue = false;
var commDlrMsgVin = "";
var commDlrMsg = "http://app1.jax.usa4sale.net/ver5/ajax/relay.php?do=contactdealer&site=6";
var commQueueSimAd = false;
var commExecSimAd = "http://app1.jax.usa4sale.net/ver5/ajax/relay.php?do=similarads&s=6";
var mobile = false;

var commDo = "http://app1.jax.usa4sale.net/ver5/ajax/relay.php?do=do&site=6";

function jsonp(url, name, query)
{     
	if (query)
    	url += "&" + query + "&";

	url += new Date().getTime().toString(); // prevent caching 
	
	$(document).ready(function(){
		$.getJSON(url + "&jsoncallback=?", function(data){

		});
	});
}

function doContact()
{
	var container = document.getElementById("resultContainer");
	var mc = document.getElementById("msgContent");
	var s = document.getElementById("site");
	var sndr = document.getElementById("sender");
	var e = document.getElementById("email");
	var p1 = document.getElementById("phone1");
	var p2 = document.getElementById("phone2");
	var p3 = document.getElementById("phone3");
	var cps = document.getElementById("copySelf");
	var ms = document.getElementById("maskSelf");
	var a = document.getElementById("ad");
	
	if(cps.checked)
	{
		cps.value = "1";
	} else {
		cps.value = "";
	}
	
	if(ms.checked)
	{
		ms.value = "1";
	} else {
		ms.value = "";
	}
	
	if(!commQueue && mc.value != "" && s.value && sndr.value != "" && e.value != "" && p1.value != "" && p2.value != "" && p2.value != "" && a.value != "")
	{
		var qy = 	'mc=' + encodeURIComponent(mc.value) +
					'&s=' + encodeURIComponent(s.value) +
					'&sndr=' + encodeURIComponent(sndr.value) +
					'&e=' + encodeURIComponent(e.value) +
					'&p1=' + encodeURIComponent(p1.value) +
					'&p2=' + encodeURIComponent(p2.value) +
					'&p3=' + encodeURIComponent(p3.value) +
					'&cps=' + encodeURIComponent(cps.value) +
					'&ms=' + encodeURIComponent(ms.value) +
					'&ad=' + encodeURIComponent(a.value);
		var loadContent = "<h4><img class='pad15' src='/images/navi/ajax-loader-sm.gif' align='left'/> Your message is being transmitted... </h4>";
		container.innerHTML = loadContent;
		commQueue = true;
		jsonp(commExec, "contact",  qy);
	} else if (commQueue)
	{
		alert("Please wait momentarily while your previous message is being sent.");
	} else
	{
		alert("Please complete all fields to contact this seller.");
	}
	return false;
	
}

function doForward()
{
	var container = document.getElementById("fwd_resultContainer");
	var s = document.getElementById("fwd_site");
	var sndr = document.getElementById("fwd_sender");
	var e = document.getElementById("fwd_email");
	var a = document.getElementById("fwd_ad");
	
	if(s.value != "" && sndr.value && e.value != "" && a.value != "")
	{
		var qy = 	'&s=' + encodeURIComponent(s.value) +
					'&sndr=' + encodeURIComponent(sndr.value) +
					'&e=' + encodeURIComponent(e.value) +
					'&ad=' + encodeURIComponent(a.value);
		var loadContent = "<h4><img class='pad15' src='/images/navi/ajax-loader-sm.gif' align='left'/> Your request is being transmitted... </h4>";
		container.innerHTML = loadContent;
		commFwdQueue = true;
		jsonp(commExecFwd, "forwardad",  qy);
	} else
	{
		alert("Please provide your name and your friend's email address to forward.");
	}
	return false;
	
}

function doFlag()
{
	var container = document.getElementById("flag_resultContainer");
	var typ = document.getElementById("flag_type");
	var mc = document.getElementById("flag_msgContent");
	var s = document.getElementById("flag_site");
	var sndr = document.getElementById("flag_sender");
	var e = document.getElementById("flag_email");
	var a = document.getElementById("flag_ad");
	
	if(!commFlagQueue && typ.value != "" && mc.value != "" && s.value && sndr.value != "" && e.value != "" && a.value != "")
	{
		var qy = 	'mc=' + encodeURIComponent(mc.value) +
					'&typ=' + encodeURIComponent(typ.value) +
					'&s=' + encodeURIComponent(s.value) +
					'&sndr=' + encodeURIComponent(sndr.value) +
					'&e=' + encodeURIComponent(e.value) +
					'&ad=' + encodeURIComponent(a.value);
		var loadContent = "<h4><img class='pad15' src='/images/navi/ajax-loader-sm.gif' align='left'/> Your message is being transmitted... </h4>";
		container.innerHTML = loadContent;
		commFlagQueue = true;
		jsonp(commExecFlag, "flag",  qy);
	} else if (commFlagQueue)
	{
		alert("Please wait momentarily while your previous message is being sent.");
	} else
	{
		alert("Please complete all fields to flag this seller.");
	}
	return false;
	
}

function doResults(resp)
{
	var prepend = "";
	
	// Forwarding
	if(commFwdQueue)
	{
		prepend = "fwd_";
	}
	
	if(commFlagQueue)
	{
		prepend = "flag_";
	}
	var container = document.getElementById(prepend + "resultContainer");
	var containerFull = document.getElementById(prepend + "resultContainerFull");
	var containerStatus = document.getElementById(prepend + "statusContainer");
		
	var content = "";
	var errStatus = "";
	var err = false;
	
	if(resp.resultdata.length > 0)
	{
		if(!resp.resultdata[0] && resp.resultdata[2])
		{
			content = "<h4 class='green'>" + resp.resultdata[2] + "</h4>";
			content += "<b><a href='#' onClick='resetDisplay(1, \"" + prepend + "\"); return false;' class='buttonSuccess'>";
			if(commFwdQueue)
			{
				content += "Forward another ad";
			} else
			{
				content += "Send another message";
			}
			content += "</a></b>";
		} else
		{
			err = true;
			if(resp.resultdata[1]) { errStatus += resp.resultdata[1] + "<br>"; }
			if(resp.resultdata[2]) { errStatus += resp.resultdata[2] + "<br>"; }
		}
	} else
	{
		errStatus = "An unknown error occurred while transmitting your submission";
		err = true;
	}
	
	if(err)
	{
		content += 	"<br><br><b class='red'>" + errStatus + 
		"<a href='#' onClick='resetDisplay(0, \"" + prepend + "\"); return false;' class='buttonError'>Try Again</a>";
	}
	
	containerStatus.innerHTML = content;
	containerFull.className = hideClass;
	
	commQueue = false;
	commFwdQueue = false;
	commFlagQueue = false;
}

function doSimilarAds(adNum)
{
	
	var e = document.getElementById("resultContainer");
	
	if(e)
	{
		if (sitestatus.maintenance>0) {
			e.innerHTML = commMaintMsg;
		} else {
			e.innerHTML = "Please wait a moment while we locate similar listings...";
			var qy = "ad=" + adNum;
			jsonp(commExecSimAd, "similarads",  qy);
		}
	}
	return false;
	
}

function doSimilarAdResults(resp)
{
	var e = document.getElementById("resultContainer");
	var content = "";
	
	content += "<h3>View a similar active listing below:</h3>";
	content += "<div class='feature_encapsulation'>";
	
	for(var i = 0; i < resp.resultdata.length; i++)
	{
		
		var row = resp.resultdata[i];
		
		var adText = row.AdText;
		var pAdNum = row.AdNumber;
		
		if(row.InventoryNumber)
			pAdNum = row.InventoryNumber;
			
		if(adText.length > 100)
			adText = adText.substr(0, 100) + "...";
		
		content +=	"<div class='featured_listing'>" + 
					"<div id='feature_pic'><a href='/classifieds/" + row.AdNumber + ".php'>";
					
		if(row.ShowPhotos > 0)
		{

			if(row.ShowPhotosDefault)
				pAdNum += "_" + row.ShowPhotosDefault;
			else
				pAdNum += "_1";
			
			content += "<img border='0' src='http://images.usa4sale.net//95px_" + pAdNum + ".jpg' />";
		}
		
		content += 	"</a></div><div class='feature_text'>" + adText + "<br /></div>" +
					"<div id='featured_link'><a href='/classifieds/" + row.AdNumber + ".php'>Click for Details...</a></div>" +
					"</div>";
	}
	content += "<br class='clr'></div>";
	e.innerHTML = content;

}


function doDlrResults(fid, resp)
{

	var content = "";
	var err = false;
	var errStatus = "";
	
	var container = document.getElementById("dlr_resultContainer_" + fid);
	var containerStatus = document.getElementById("dlr_statusContainer_" + fid);
	
	if(resp.resultdata.length > 0)
	{
		if(!resp.resultdata[0] && resp.resultdata[2])
		{
			content = "<h4 class='green'>" + resp.resultdata[2] + "</h4>";
			//content += "<b><a href='#' onClick='resetDisplay(1, \"dlrRes\"); return false;' class='buttonSuccess'>";
			//content += "</a></b>";
		} else
		{
			err = true;
			if(resp.resultdata[1]) { errStatus += resp.resultdata[1] + "<br>"; }
			if(resp.resultdata[2]) { errStatus += resp.resultdata[2] + "<br>"; }
		}
	} else
	{
		errStatus = "An unknown error occurred while transmitting your submission";
		err = true;
	}
	
	if(err)
	{

		content += 	"<h4 class='red'>" + errStatus + "</h4>" + 
		"<a href='#' onClick='resetDlrDisplay(0, \"dlrRes\", \"" + fid + "\", \"" + commDlrMsgVin + "\"); return false;' class='buttonError'>Try Again</a>";
	}
	
	containerStatus.innerHTML = content;
	container.className = hideClass;
	
	commDlrMsgQueue = false;
	commDlrMsgVin = "";
}


function resetDlrDisplay(resetform, prepend, fid, vin)
{
	
	var container = document.getElementById("dlr_resultContainer_" + fid);
	var containerFull = document.getElementById("dlr_resultContainerFull_" + fid);
	var containerStatus = document.getElementById("dlr_statusContainer_" + fid);
	
	var content = "";
	if(resetform)
	{
		doDlrContact(fid);
	}
	
	if(!vin)
		var vin = "";
		
	content = "<p><input type=\"button\" class=\"buttonField\" onClick=\"doDlrContact(" + fid + ", '" + vin + "'); return false;\" value=\"Send Again\"></p>";		
	
		
	container.innerHTML = content;
	containerFull.className = showClass;
	containerStatus.innerHTML = "";
}

function resetDisplay(resetform, prepend)
{
	
	if(!prepend)
	{
		var prepend = "";
	}

	var container = document.getElementById(prepend + "resultContainer");
	var containerFull = document.getElementById(prepend + "resultContainerFull");
	var containerStatus = document.getElementById(prepend + "statusContainer");

	var content = "";
	
	if(prepend == "fwd_")
	{
		var frm = document.getElementById("fwdForm");
		if(resetform && frm)
		{
			frm.reset();
		}

		content = "<a href='#' onClick='return doForward();' id='fwdBut' class='buttonField'>Share Ad Again</a>";		
		
		
	} else if(prepend == "flag_")
	{
		var frm = document.getElementById("flagForm");
		if(resetform && frm)
		{
			frm.reset();
		}
		
		content = "<a href='#' onClick='doFlag(); return false;' class='buttonField'>Flag Ad Again</a>";
	} else 
	{
		var frm = document.getElementById("msgForm");
		if(resetform && frm)
		{
			frm.reset();
		}
		
		content = "<a href='#' onClick='return doContact();' class='buttonField'>Send Message Again</a>";
		
	}
	
	container.innerHTML = content;
	containerFull.className = showClass;
	containerStatus.innerHTML = "";
	

}

function doDlrContact(fid, vin)
{
	var container = document.getElementById("dlr_resultContainer_" + fid);
	var containerStatus = document.getElementById("dlr_statusContainer_" + fid);
	var mc = document.getElementById("msgContent_" + fid);
	var sndr = document.getElementById("sender");
	var e = document.getElementById("email");
	var p1 = document.getElementById("phone1_" + fid);
	var p2 = document.getElementById("phone2_" + fid);
	var p3 = document.getElementById("phone3_" + fid);
	var dlrid = document.getElementById("dlrid");

	if(containerStatus)
		containerStatus.innerHTML = "";

	if(!commDlrMsgQueue && mc.value != "" && sndr.value != "" && e.value != "" && p1.value != "" && p2.value != "" && p2.value != "" && dlrid.value != "")
	{
		commDlrMsgVin = "";
		
		var qy = 	'mc=' + encodeURIComponent(mc.value) +
					'&sndr=' + encodeURIComponent(sndr.value) +
					'&e=' + encodeURIComponent(e.value) +
					'&p1=' + encodeURIComponent(p1.value) +
					'&p2=' + encodeURIComponent(p2.value) +
					'&p3=' + encodeURIComponent(p3.value) +
					'&fid=' + encodeURIComponent(fid) +
					'&dlrid=' + encodeURIComponent(dlrid.value);
					if(vin)
					{
						qy += '&vin=' + encodeURIComponent(vin);
						commDlrMsgVin = vin;
					}
		var loadContent = "<h4><img class='pad15' src='/images/navi/ajax-loader-sm.gif' style='height: 16px; width: 16px; border: none;' align='left'/> Your message is being transmitted... </h4>";
		container.innerHTML = loadContent;
		jsonp(commDlrMsg, "contact",  qy);
		commDlrMsgQueue = true;
	} else if (commDlrMsgQueue)
	{
		alert("Please wait momentarily while your previous message is being sent.");
	} else
	{
		alert("Please complete all fields to contact this seller.");
	}
	return false;
	
}

function openDlrComm(dlr, id, site, vin)
{
	var e = document.getElementById('dlr_resultContainerFull_' + id);
	if(!vin)
	{
		vin = "none";
	}
	if(e)
	{
		if (sitestatus.maintenance>0) {
			e.innerHTML = commMaintMsg;
		} else {
															e.style.height = "270px";
			e.className = showClass;
			
			
			
			
			var content =	"<br><h4>Respond to this ad:</h4><form class=\"dlrForm\" onSubmit=\"return doDlrContact(" + id + ", '" + vin + "');\" name=\"fdcon\">" + 
							"<p><input type=\"text\" class=\"inputField\" name=\"sender\" id=\"sender\" value=\"Your Name...\" onClick=\"defaultTo(this, 'Your Name...', 0);\" onFocus=\"defaultTo(this, 'Your Name...', 0);\" onBlur=\"defaultTo(this, 'Your Name...', 1);\"></p>" +
							"<p><input type=\"text\" class=\"inputField\" name=\"email\" id=\"email\" value=\"Your E-mail Address...\" onClick=\"defaultTo(this, 'Your E-mail Address...', 0);\" onFocus=\"defaultTo(this, 'Your E-mail Address...', 0);\" onBlur=\"defaultTo(this, 'Your E-mail Address...', 1);\"></p>" +
							"<p><div class=\"pformLeft\">Phone:</div>" +
							"<div class=\"pformRight\"><input type=\"text\" class=\"inputFieldP3\" name=\"phone1\" id=\"phone1_" + id + "\" value=\"\" maxlength=\"3\" size=\"4\" onKeyUp=\"autotab(phone1_" + id + ",phone2_" + id + ");\"> - " + 
							"<input type=\"text\" class=\"inputFieldP3\" name=\"phone2\" id=\"phone2_" + id + "\" value=\"\" maxlength=\"3\" size=\"4\" onKeyUp=\"autotab(phone2_" + id + ",phone3_" + id + ");\"> - " + 
							"<input type=\"text\" class=\"inputFieldP4\" name=\"phone3\" id=\"phone3_" + id + "\" value=\"\" maxlength=\"4\" size=\"5\" onKeyUp=\"autotab(phone3_" + id + ",msgContent_" + id + ");\">" + 
							"</div><br class=\"clr\"></p>" +
							"<div id=\"charCount_" + id + "\" class=\"charCounter\">500 Chars Left</div>" +
							"<p><textarea id=\"msgContent_" + id + "\" name=\"msgContent\" onClick=\"defaultTo(this, 'Your Message...', 0);\" onFocus=\"defaultTo(this, 'Your Message...', 0);\" onBlur=\"defaultTo(this, 'Your Message...', 1); countChars(this, 'charCount_" + id + "', 500);\" onKeyUp=\"countChars(this, 'charCount_" + id + "', 500);\" onKeyDown=\"countChars(this, 'charCount_" + id + "', 500);\">Your Message...</textarea></p>" + 
							"<input type=\"hidden\" name=\"dlrid\" id=\"dlrid\" value='" + dlr + "' />" +
							"<div id=\"dlr_resultContainer_" + id + "\"><p><input type=\"button\" class=\"buttonField\" onClick=\"doDlrContact(" + id + ", '" + vin + "'); return false;\" value=\"Send\"></p></div>" +
							"</form>";
			
			e.innerHTML = content;
		}
	}
	return false;
}

function defaultTo(obj, defaultVal, blurred)
{
	if(blurred)
	{
		if(obj.value == '')
		{
			obj.value = defaultVal;
		}
	} else
	{
		if(obj.value == defaultVal)
		{
			obj.value = '';
		}
	}
	
}

function countChars(obj, counterName, limit)
{
	if(!counterObj || counterLast != counterName)
	{
		counterObj = document.getElementById(counterName);
		counterLast = counterName;
	}
	
	textObj = obj;
	textLimit = limit;
	
	if(timer)
	{
		clearTimeout(timer);
	}
	
	timer = setTimeout("updateCounter()", 300);
}

function updateCounter()
{
	clearTimeout(timer);
	timer = null;
	
	var counterText = " Chars Left";
	
	var counterLen = textObj.value.length;
	
	if(counterLen > textLimit)
	{
		textObj.value = textObj.value.substr(0,textLimit);
		textObj.scrollTop = 999999;
	}
	
	var pcnt = counterLen / textLimit;
	var useColor = "#444";
	var useWeight = "normal";
	
	
	switch(true)
	{
		case (pcnt > .98):
			useColor = "#f00";
			useWeight = "bold";
			break;
		case (pcnt > .90):
			useColor = "#ff5a00";
			useWeight = "bold";
			break;
		case (pcnt > .85):
			useColor = "#e06a01";
			break;
		default:
			useColor = "#444";
			break;
	}
	counterObj.style.fontWeight = useWeight;
	counterObj.style.color = useColor;

	
	counterObj.innerHTML = counterLen <= textLimit ? textLimit - counterLen + counterText : 0 + counterText;
}

function performAction(act, context, objRef)
{
	
	if(act != "" && context != "")
	{
		if (sitestatus.maintenance>0 && objRef) {
			objRef.innerHTML = commMaintMsg;
		} else {
			jsonp(commDo, "do", 'act=' + encodeURIComponent(act) + '&context=' + encodeURIComponent(context));
			if(objRef)
			{
				objRef.innerHTML = "<img src='/images/navi/ajax-loader-sm.gif' style='height: 16px; width: 16px; border: none; padding-right:5px;' align='left'/> Loading...";
			}
		}
	}
	return false;
}

function doWebOut(resp)
{
	if(resp && resp.resultdata)
	{
		top.location.href = "/site/?url=" + encodeURIComponent(resp.resultdata);
	}
}

function fetchDealer(dlrId)
{
	
	var e = document.getElementById("resultContainer");
	if(e)
	{
		if (sitestatus.maintenance > 0) {
			e.innerHTML = commMaintMsg;			
		} else {
			matches = dlrId.match(/((DLR|DL\-)[0-9]+)/);
			if(matches && matches[1])
			{
				e.innerHTML = "<img src='/images/navi/ajax-loader-sm.gif' style='height: 16px; width: 16px; border: none; padding-right:5px;' align='left'/> Please wait a moment while we locate this dealer's listings...";
				
				var qy = 	'ad=' + encodeURIComponent(matches[1]);
							
				jsonp(commExecDlr, "dealer", qy);
			}
		}		

	}
	return false;
	
}

function doLocateDealer(resp)
{
	var e = document.getElementById("resultContainer");
	var cInfo = "";
	var cDirHead = "";
	var cDirInner = "";
	var cDirFoot = "";
	var cListing = "";
	
	if(resp.dealer)
	{
		var d = resp.dealer;
		cInfo += 	"<div id='headings'>";
		cInfo += 	"<div class='dealerInfo'>";
		
		if(d.company) { cInfo += "<h1>" + d.company + "</h1>"; }
		if(d.phone) { cInfo += "<h2>" + d.phone + "</h2>"; }
		if(d.addr1) { cInfo += "" + d.addr1 + "<br/>"; }
		if(d.addr2) { cInfo += "" + d.addr2 + "<br/>"; }				
		if(d.city) { cInfo += "" + d.city + ""; }
		if(d.state) { cInfo += ", " + d.state; }
		if(d.zip) { cInfo += " " + d.zip; }
		cInfo += "<br />";
		
		cInfo += "</div></div>";

	}
	
	cDirHead += "<div class='dealerPageDir'>";
	
	cDirHead += "<div id='page_directory'><div width='100%' align='center'><b>PAGE DIRECTORY</b></div>";
	cDirHead += "<table id='pDir' class='pageDirectoryContainer' style='width: 100%; border: none; padding: 2px;'>";

	
	cDirFoot += "</table></div>";
	cDirFoot += "</div>";
	cDirFoot += "<br class='clr' />";
	
	cListing += "<div id='leftCol'>";
	cListing += "<div class='dealer_encapsulation'>";
	
	var cdirct = 0;
	var cdirmax = 2;
	
	var ads = 0;
	if(resp.resultdata)
	{

		for( var i in resp.resultdata)
		{
			
			if(resp.resultdata[i].inv.length)
			{
				cListing += "<h3><a name=\"" + resp.resultdata[i].cat + "\">" + resp.resultdata[i].cat + "</a></h3>";
				if(cdirct == 0) { cDirInner += "<tr>"; }
				cDirInner += "<td><a  href=\"#" + resp.resultdata[i].cat + "\">" + resp.resultdata[i].cat + "</a> (" + resp.resultdata[i].inv.length + ")</td>";
				cdirct++;
				if(cdirct == cdirmax) { cDirInner += "</tr>"; cdirct = 0; }
			}
			
			for(var j = 0; j < resp.resultdata[i].inv.length; j++)
			{
				ads++;
				var row = resp.resultdata[i].inv[j];

				var adText = row.AdText;
				var pAdNum = row.AdNumber;

				if(row.InventoryNumber)
					pAdNum = row.InventoryNumber;

				/*if(adText.length > 100)
					adText = adText.substr(0, 100) + "..."; */

				cListing +=	"<div class='dealer_listing'>" + 
							"<div class='dealer_pic'><a href='/classifieds/" + row.AdNumber + ".php'>";

				if(row.ShowPhotos > 0)
				{

					if(row.ShowPhotosDefault)
						pAdNum += "_" + row.ShowPhotosDefault;
					else
						pAdNum += "_1";

					cListing += "<img border='0' src='http://images.usa4sale.net//175px_" + pAdNum + ".jpg' /><br/><span class='lnk'>Contact Seller</span>";
				} else
				{
					cListing += "<span class='lnk'>Contact Seller</span>";
				}

				cListing += 	"</a></div><div class='dealer_text'>" + adText + "</div>" +
							"<br class='clr'></div>";
			}
		}

	}		
	
	if(cdirct < cdirmax) { cDirInner += "</tr>"; }
	
	
	
	if(!ads)
	{
		cListing = "<b>No dealer inventory available for this ad</b>";
		cDirInner += "<tr><td>No listings available</td></tr>";
	}
	
	cListing += "<br class='clr'></div></div>";
	
	
	var content = cInfo + cDirHead + cDirInner + cDirFoot + cListing;
	
	e.innerHTML = content;
	
}

function writeContactAction(adNum)
{var o = "<h2 class='contactIcon'>Contact Advertiser</h2>" +"<div id='statusContainer'>" +"</div><!--/statusContainer-->" +"<div id='resultContainerFull'>" +"<h4>To e-mail this advertiser of this listing, please fill out the information below:</h4>" +"<small><i>NOTE: Use of this form for commercial solicitation is a violation of our terms of service</i></small>" +"<br/><br/>" +"<form onSubmit='return doContact();' id='msgForm' name='msgForm'>" +"<input type='text' name='sender' id='sender' value='Your Name...' class='inputField' onClick='defaultTo(this, \"Your Name...\", 0);' onFocus='defaultTo(this, \"Your Name...\", 0);' onBlur='defaultTo(this, \"Your Name...\", 1);'>" +"<div class='panelLeft'>" +"<input type='text' name='email' id='email' value='Your E-mail Address...' class='inputField' onClick='defaultTo(this, \"Your E-mail Address...\", 0);' onFocus='defaultTo(this, \"Your E-mail Address...\", 0);' onBlur='defaultTo(this, \"Your E-mail Address...\", 1);'>" +"<br />" +"<div class='pLine'>Phone: <input type='text' name='phone1' id='phone1' value='' maxlength='3' size='4' onKeyUp='autotab(phone1,phone2);' class='inputFieldP3'> - " +"<input type='text' name='phone2' id='phone2' value='' maxlength='3' size='4' onKeyUp='autotab(phone2,phone3);' class='inputFieldP3'> - " +"<input type='text' name='phone3' id='phone3' value='' maxlength='4' size='5' onKeyUp='autotab(phone3,msgContent);' class='inputFieldP4'></div>" +"</div><!--/panelLeft-->" +"<div class='panelRight' id='charCount' style='margin-right: 15px; color: #444; font-size: 11px'>" +"500 Chars Left" +"</div><!--/panelRight-->" +"<br class='clr' />" +"<textarea class='tarea' id='msgContent' name='msgContent' onClick='defaultTo(this, \"Your Message...\", 0);' onFocus='defaultTo(this, \"Your Message...\", 0);' onBlur='defaultTo(this, \"Your Message...\", 1); countChars(this, \"charCount\", 500);' onKeyUp='countChars(this, \"charCount\", 500);' onKeyDown='countChars(this, \"charCount\", 500);'>Your Message...</textarea><br />" +"<input type='checkbox' name='copySelf' id='copySelf' value='1'> Please send me a copy of my message<br />" +"<input type='checkbox' name='maskSelf' id='maskSelf' value='1'> Don't share my contact info with advertiser<br />" +"<br />" +"<input type='hidden' name='site' id='site' value='6' />" +"<input type='hidden' name='ad' id='ad' value='" + adNum + "' />" +"<div id='resultContainer'>" +"<a href='#' onClick='doContact(); return false;' class='buttonField'>Send Message</a>" +"</div><!--/resultContainer-->" +"<br />" +"</form><!--/replyForm-->" +"</div><!--/resultContainerFull-->" +"<a href='javascript:void(0)' class='close'></a>";
	
	if (sitestatus.maintenance>0) {
		document.write(commMaintMsg);
	} else {
		document.write(o);
	}
}

function writeShareAction(adNum, pagePath, mobile)
{var o = "<h2 class='shareIcon'>Share Advertisement</h2>" +"<div id='fwd_statusContainer'>" +"</div><!--/fwd_statusContainer-->" +"<div id='fwd_resultContainerFull'>" +"<form onSubmit='return doForward();' id='fwdForm' name='fwdForm'>";if(!mobile){o += "<p>" +"<div class='addthis_toolbox addthis_32x32_style addthis_default_style'>" +"<a class='addthis_button_facebook'></a>" +"<a class='addthis_button_twitter'></a>" +"<a class='addthis_button_myspace'></a>" +"<a class='addthis_button_wordpress'></a>" +"</div>" +"</p><br />";}if(!mobile){o += "<p>" +"<h4>Link to This:</h4>" +"<input type='text' class='inputField' id='shareSelector' value='http://www.georgia4sale.com" + pagePath + "#" + adNum + "' readonly='readonly' onClick='this.focus();this.select()' /><br />" +"<small><b>To copy:</b> Click textbox above, then on your keyboard hold CTRL (Command on Mac) and press C. <b>To paste:</b> Navigate to where you would like to paste, then on your keyboard hold CTRL (Command on Mac) and press V.</small>" +"</p><br /><br />";} else{}o += "<h4>Forward this listing to a Friend:</h4>" +"<input type='text' name='fwd_sender' id='fwd_sender' value='Your Name...' class='inputField' onClick='this.value=this.value!=\"Your Name...\"?this.value:\"\"'  onFocus='this.value=this.value!=\"Your Name...\"?this.value:\"\"' onBlur='this.value=this.value?this.value:\"Your Name...\"'>" +"<input type='text' name='fwd_email' id='fwd_email' value='E-mail Address of your Friend...' class='inputField' onClick='this.value=this.value!=\"E-mail Address of your Friend...\"?this.value:\"\"' onFocus='this.value=this.value!=\"E-mail Address of your Friend...\"?this.value:\"\"' onBlur='this.value=this.value?this.value:\"E-mail Address of your Friend...\"'>" +"<br />" +"<input type='hidden' name='fwd_site' id='fwd_site' value='6' />" +"<input type='hidden' name='fwd_ad' id='fwd_ad' value='" + adNum + "' />" +"<div id='fwd_resultContainer'>" +"<a href='#' onClick='doForward(); return false;' class='buttonField'>Share Ad</a>" +"</div><!--/fwd_resultContainer-->" +"<br />" +"</form><!--/fwdForm-->" +"</div><!--/fwd_resultContainerFull-->" +"<a href='javascript:void(0)' class='close'></a>";
	
	if (sitestatus.maintenance>0) {
		document.write(commMaintMsg);
	} else {
		document.write(o);
	}
}

function writeFlagAction(adNum)
{var o = "<h2 class='flagIcon'>Flag Advertisement</h2>" +"<div id='flag_statusContainer'>" +"</div><!--/flag_statusContainer-->" +"<div id='flag_resultContainerFull'>" +"<form onSubmit='return doFlag();' id='flagForm' name='flagForm'>" +"<p>" +"<h4>Do you see a problem with this classified?</h4>" +"<div class='panelLeft'>" +"Help us improve our classifieds and share your issues which we may have overlooked with this seller's posting." +"<p><br>" +"<b>Flag as:</b> <select name='flag_type' id='flag_type' class='inputField'>" +"<option value=''>select type below... </option>" +"<option value='' class='selCat'>-- GENERAL --</option>" +"<option value='SOLDAD' class='selField'>Report item sold</option>" +"<option value='' class='selCat'>-- CATEGORY --</option>" +"<option value='MISCAT' class='selField'>Mis-Categorized classified</option>" +"<option value='DUPEAD' class='selField'>Duplicate or similar posting</option>" +"<option value='COMMAD' class='selField'>Business posing as private seller</option>" +"<option value='' class='selCat'>-- COMMUNICATION --</option>" +"<option value='NORESP' class='selField'>Seller unresponsive (over 1 week)</option>" +"<option value='THREAT' class='selField'>Seller response is abusive</option>" +"<option value='' class='selCat'>-- VALIDITY / FRAUD --</option>" +"<option value='FICTAD' class='selField'>Fictitious contact details</option>" +"<option value='FICCON' class='selField'>Fictitious classified details</option>" +"<option value='SCAMAD' class='selField'>Fraudulent or Scam</option>" +"<option value='' class='selCat'>-- OTHER --</option>" +"<option value='FAIRHS' class='selField'>Fair Housing Violation</option>" +"<option value='NOLIST' class='selField'>Other - Not listed above</option>" +"</select>" +"</p>" +"</div><!--/panelLeft-->" +"<div class='panelRight' id='flag_charCount' style='margin-right: 15px; color: #444; font-size: 11px'>" +"500 Chars Left" +"</div><!--/panelRight-->" +"<br class='clr' />" +"<textarea class='tarea' id='flag_msgContent' name='flag_msgContent' onClick='defaultTo(this, \"Additional Comments...\", 0);' onFocus='defaultTo(this, \"Additional Comments...\", 0);' onBlur='defaultTo(this, \"Additional Comments...\", 1); countChars(this, \"flag_charCount\", 500);' onKeyUp='countChars(this, \"flag_charCount\", 500);' onKeyDown='countChars(this, \"flag_charCount\", 500);'>Additional Comments...</textarea><br />" +"<input type='text' name='flag_sender' id='flag_sender' value='Your Name...' class='inputField' onClick='this.value=this.value!=\"Your Name...\"?this.value:\"\"' onFocus='this.value=this.value!=\"Your Name...\"?this.value:\"\"' onBlur='this.value=this.value?this.value:\"Your Name...\"'>" +"<input type='text' name='flag_email' id='flag_email' value='Your E-mail Address...' class='inputField' onClick='this.value=this.value!=\"Your E-mail Address...\"?this.value:\"\"' onFocus='this.value=this.value!=\"Your E-mail Address...\"?this.value:\"\"' onBlur='this.value=this.value?this.value:\"Your E-mail Address...\"'>" +"<br />" +"<input type='hidden' name='flag_site' id='flag_site' value='6' />" +"<input type='hidden' name='flag_ad' id='flag_ad' value='" + adNum + "' />" +"<div id='flag_resultContainer'>" +"<a href='#' onClick='doFlag(); return false;' class='buttonField'>Flag Ad</a>" +"</div><!--/flag_resultContainer-->" +"<br />" +"</form><!--/fwdForm-->" +"</div><!--/flag_resultContainerFull-->" +"<a href='javascript:void(0)' class='close'></a>";
	
	if (sitestatus.maintenance>0) {
		document.write(commMaintMsg);
	} else {
		document.write(o);
	}
}

