﻿//********************************************************************
//	Core JavaScript - CSI Auto Repair (CSIAutoRepair.com)
//********************************************************************
var IE = (document.all) ? 1 : 0;

function __DoCallBack(strPageUrl, pAsync) 
{
	if (strPageUrl.indexOf(".aspx") < 0)
		strPageUrl = CSIGlobalCallbackPage + strPageUrl;
	if (strPageUrl.indexOf("?") > 0)
		strPageUrl += "&callback=true";
	else
		strPageUrl += "?callback=true";

    var strObject	= "Microsoft.XMLHTTP";
    var strApp		= "application/x-www-form-urlencode";
	var xmlRequest	= null;
	
	if (window.XMLHttpRequest)
	{
		xmlRequest = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		try
		{
			xmlRequest = new ActiveXObject("MSXML2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
			}
		}
	}
	
	if (pAsync == null) pAsync = true;
	
	if (xmlRequest != null)
	{
		xmlRequest.open("GET", strPageUrl, pAsync);	
		xmlRequest.setRequestHeader("Content-Type", strApp);
		xmlRequest.send(null);

		if (pAsync == false)
		{
			return xmlRequest.responseText;
		}
	}

}
    
function EscapeValue(pValue)
{
	while (pValue.indexOf("\n") > -1)
	{
		pValue = pValue.replace("\n", "[N]")
	}
	while (pValue.indexOf("&") > -1)
	{
		pValue = pValue.replace("&", "[AMP]")
	}
	while (pValue.indexOf("<") > -1)
	{
		pValue = pValue.replace("<", "[LT]")
	}
	while (pValue.indexOf(">") > -1)
	{
		pValue = pValue.replace(">", "[GT]")
	}
		
	return pValue;
}
	
function printCoupon(CoupId)
{
	var strPageUrl = "../App_Pages/Coupons.aspx?cid=" + CoupId + "&callback=true";
	var Options = "status=0,toolbar=0,scrollbars=0,menubar=0,directories=0,resizable=0,width=380,height=620";
	var Coupon = window.open(strPageUrl, "CSICoupon", Options);
	
	//Coupon.print();
	//Coupon.close();
}
