
function cpClientSideInclude(url, appendQs) {
	if (typeof appendQs == "undefined")
		cpLoadInto(url);
	else
		cpLoadInto(url, appendQs);
}

function cpLoadInto(url, appendQs, destId, genDiv, async) {
	if (typeof destId == "undefined") destId = "cpLoadInto" + Math.floor(Math.random() * 1000);
	if (typeof appendQs == "undefined") appendQs = true;
	if (typeof genDiv == "undefined") genDiv = true;
	if (typeof async == "undefined") async = true;
	
	// append the current page query string to the url
	var qs = ''; var beginQs = 0;
	if (appendQs) {
		var href = document.location.href;
		beginQs = href.lastIndexOf('?');
		if (beginQs > 0) qs = href.substring(beginQs + 1);
	}
	if (qs.length > 0)
	{
		beginQs = url.lastIndexOf('?');
		if (beginQs > 0) qs = "&" + qs; else qs = "?" + qs;
	}
	// generate the div on demand
    //alert(destId);
	if (genDiv)  document.write ("<div id='" + destId + "' style='display: none;'></div>");

	// load the document into the specified or generated div
	var dest = document.getElementById(destId);
	var ok = httpgetpage(url + qs, destId, async);
	//alert(ok);
	if (ok) {
		dest.contentLoaded = true;
		dest.style.display = 'block';
	}
	
	return true;	// this was added for marketplace categories conditional tiered loads
}
