var AjaxObj = false; // make global variables
var objHTML = false
//

function PageTracker(PathOffset, pFilename) {
	sReferrer = GetReferringURL();
	sURL  = PathOffset + 'Admin/UpdatePageViews.php';
	sURL += '?page=' + pFilename;
	sURL += '&referrer=' + sReferrer;
//alert(sURL );
	AjaxObj = GetAjaxObj();
	if(AjaxObj)	{
		AjaxObj.onreadystatechange = function()
			{
				if (AjaxObj.readyState == 4 && AjaxObj.status == 200) {
//alert(AjaxObj.responseText);
				}
			}
		AjaxObj.open("GET", sURL, true);
		AjaxObj.send(null);
	}

}
//End PageTracker


function GetReferringURL(){
	sStr = document.referrer.replace('http://','');
	if (sStr.indexOf('/')) {
		nOffset = sStr.indexOf('/');
		sStr = sStr.substring(0,nOffset);
	}
	return sStr;
}
// End GetReferringURL

function GetAjaxObj (){
	var AjaxObj = false;
	if (window.XMLHttpRequest)
	{
		AjaxObj = new XMLHttpRequest();
	}
		else if (window.ActiveXObject)
		{
		AjaxObj = new ActiveXObject("Microsoft.XMLHTTP");
		}
	return AjaxObj;
}
// End GetAjaxObj

function DownloadInstructions(sPlanName) {

	sMsg  = '<p style="font-style: italic; color:red; font-weight:bold">';
	sMsg += 'Please Note: <br /><p>';
	sMsg += '<p style="font-style: italic;  color:red; margin: -15 0 0 0">';
	sMsg += 'These plans are provided as downloadable PDF files. ';
	sMsg += 'After your order has been completed by Paypal, you will receive instructions ';
	sMsg += 'for downloading your ' + sPlanName + ' plans';
	sMsg += '</p>';

document.getElementById('download_instructions').innerHTML = sMsg ;
}
// End DownloadInstructions

function LargeImage(imgFile) {
	document.getElementById('Div-LargeImage').style.display = 'inline';
	if (imgFile=='Hide') {
		document.getElementById('Div-LargeImage').style.display = 'none';
		return;
	}
}

// End LargeImage

function DownloadButton(PathOffset, PlanName, PdfFile){
// This function displays a download button for the PDF file
	sDownloadURL = PathOffset + 'FreeDownloads/' + PdfFile;
	sEvent = 'onclick=\'DownLoadPDF("'+PathOffset + '","' + sDownloadURL + '", "' + PdfFile + '")\' ';
	sStr  = '<div class="download">'
	sStr += '<p class="color_bold_center_italic">';
	sStr += 'Click the Download button for your free '+ PlanName +' plans.</p>';
	sStr += '<input type="button" name="download" value="Download"';
	sStr += sEvent  + '><br /><br />';
	sStr += 'When the plans open in your PDF viewer, be sure to save the file to your hard drive. ';
	sStr += '</div>	';
	document.write(sStr);
//	alert(sDownloadURL);
}
//End DownloadButton

function DownloadPreview(PathOffset, PlanName, PdfFile){
// This function displays a download button for the PDF file
	sDownloadURL = PathOffset + 'FreeDownloads/' + PdfFile;
	sEvent = 'onclick=\'DownLoadPDF("'+PathOffset + '","' + sDownloadURL + '", "' + PdfFile + '")\' ';
	sStr  = '<div class="download">'
	sStr += '<p class="color_bold_center_italic">';
	sStr += 'Click the Download button for your free Preview.</p>';
	sStr += '<input type="button" name="download" value="Download"';
	sStr += sEvent  + '><br /><br />';
	sStr += 'When the plans open in your PDF viewer, be sure to save the file to your hard drive. ';
	sStr += '</div>	';
	document.write(sStr);
//	alert(sDownloadURL);
}
//End DownloadButton


function DownLoadPDF(PathOffset, DownloadURL, PdfFile) {
	// This function updates the PdfViews table, then implements downloading of the pdf file.
	sTrackingURL  = PathOffset + 'Admin/UpdatePageViews.php?PdfFile=' + PdfFile;
//	alert(sTrackingURL);
	// The following code sends the above URL to the php script which updates the PdfViews table.
	AjaxObj = GetAjaxObj();
	if(AjaxObj)	{
		AjaxObj.onreadystatechange = function()
			{
				if (AjaxObj.readyState == 4 && AjaxObj.status == 200) {
//		alert(AjaxObj.responseText);
				}
			}
		AjaxObj.open("GET", sTrackingURL, true);
		AjaxObj.send(null);
	}
	// The following line implements the download using the URL passed to the function the
	window.open(DownloadURL,"Download");
}
//End DownLoadPDF

 function BuyNowInstructions() {
	Str  = '<p class="Paypal_Instructions">';
	Str += '	<b>Please Read!</b><br />';
	Str += '	You will receive an	order confirmation email with download instructions as soon as we receive your order from PayPal.';
	Str += '	If you do not receive the download instructions, please check the spam folder on your email program. </font></p>';
	Str += '</p>';
	
	Str += '<p class="Guarantee">';
	Str += '	<b>30 Day Satisfaction Guarantee:</b>&nbsp;<br />';
	Str += '	If you are not satisfied with your plans for any reason, you may email us within 30 days <br />';
	Str += '	of purchase. We will promptly refund your full purchase price. <br /><br />';

	Str += '	If you successfully placed your order, but did not receive <br />';
	Str += '	download instructions, please email us (with your phone number).<br />';
	Str += '	<a href="mailto:webmaster@bobsplans.com">webmaster@bobsplans.com</a></font>';
	Str += '</p>';
	document.write(Str);
 }
 
 
 
 
 
 
 
 
 
 
 
