// JavaScript Document for pulling the customer data
// show the services
var xmlHttp
var strDashMatrix

var checkflag = "false";
function check(field) {
  if (checkflag == "false") {
    transferBilling()
	checkflag = "true";
    return "Uncheck All";
  } else {
    document.getElementById("ShipToFName").value = '';
	document.getElementById("ShipToLName").value = '';
	document.getElementById("ShipToAddress").value = '';
	document.getElementById("ShipToCity").value = '';
	document.getElementById("ShipToState").value = '';
	document.getElementById("ShipToZip").value = '';
	document.getElementById("ShipToCountry").value = '';
	
    checkflag = "false";
    return "Check All";
  }
}
function transferBilling()
{
	document.getElementById("ShipToFName").value = document.getElementById("BillToFName").value;
	document.getElementById("ShipToLName").value = document.getElementById("BillToLName").value;
	document.getElementById("ShipToAddress").value = document.getElementById("BillToAddress").value;
	document.getElementById("ShipToCity").value = document.getElementById("BillToCity").value;
	document.getElementById("ShipToState").value = document.getElementById("BillToState").value;
	document.getElementById("ShipToZip").value = document.getElementById("BillToZip").value;
	document.getElementById("ShipToCountry").value = document.getElementById("BillToCountry").value;
}
function handleBilling() 
{
	if (TheForm.BillToName.value == "") {
		alert("You must enter a billing name.");
		return false;
	}
	else if(TheForm.BillToAddress.value == "") {
		alert("You must enter a billing address.");
		return false;
	}
	else {
		return true;
	}
}

function removeCartItem(DashMatrix, ItemID)
{
var url= DashMatrix + "includes/ajax/RemoveFromCart.asp?sid=" + Math.random() + "&DashMatrix=" + DashMatrix + "&ItemID=" + ItemID;
strDashMatrix = DashMatrix
xmlHttp=GetXmlHttpObject(UpdateCartCount)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function AddToCart(ItemName, strSize, DashMatrix, SystemID, Quantity, UnitCost, RateFormula)
{
var url= DashMatrix + "includes/ajax/UpdateCart.asp?Size=" + strSize + "&ItemName=" + ItemName + "&Type=Product&systemID=" + SystemID + "&Qty=" + Quantity + "&sid=" + Math.random() + "&UnitCost=" + UnitCost + "&RateFormula=" + RateFormula + "&DashMatrix=" + DashMatrix;
strDashMatrix = DashMatrix
xmlHttp=GetXmlHttpObject(UpdateCartCount)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function AddTripToCart(ItemName, DashMatrix, TripID, xTripDate, Count, PmtType, PayAmount, TotalAmount, InsAmount)
{
var url= DashMatrix + "includes/ajax/UpdateCart.asp?ItemName=" + ItemName + "&tripDate=" + xTripDate + "&Type=Trip&TripID=" + TripID + "&Count=" + Count + "&sid=" + Math.random() + "&PmtType=" + PmtType + "&Amount=" + PayAmount + "&TotalAmount=" + TotalAmount + "&InsAmount=" + InsAmount + "&DashMatrix=" + DashMatrix;
strDashMatrix = DashMatrix
xmlHttp=GetXmlHttpObject(UpdateCartCount)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
	function UpdateCartCount() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("CartContentNum").innerHTML=xmlHttp.responseText; 
			visShoppingCart(strDashMatrix);
		}
	}



function getCalendarMonth(DashMatrix, Month, TripID, PeopleCount)
{
var url= DashMatrix + "includes/ajax/BookingCalendar.asp?PeopleCount=" + PeopleCount + "&Month=" + Month + "&sid=" + Math.random() + "&TripID=" + TripID + "&DashMatrix=" + DashMatrix;
document.getElementById("BookingCalendar").innerHTML="<img src='" + DashMatrix + "images/Loading.jpg' align='absmiddle'>";
xmlHttp=GetXmlHttpObject(PullCalendar)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
				function PullCalendar() 
				{ 
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
					{ 
						document.getElementById("BookingCalendar").innerHTML=xmlHttp.responseText 
					}
				}
function BookTrip(DashMatrix, TripID, PeopleCount, TripDate)
{
var url= DashMatrix + "includes/ajax/BookTripDate.asp?PeopleCount=" + PeopleCount + "&TripDate=" + TripDate + "&sid=" + Math.random() + "&TripID=" + TripID + "&DashMatrix=" + DashMatrix;
document.getElementById("TripBooking").innerHTML="Calculating Trip Details...";
xmlHttp=GetXmlHttpObject(PopulateSubTotal)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
				function PopulateSubTotal() 
				{ 
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
					{ 
						document.getElementById("TripBooking").innerHTML=xmlHttp.responseText 
					}
				}

function UpdateTripCost(strDashMatrix,RatePerPerson,PeopleCount,taxrate)
{
var url = strDashMatrix + "includes/ajax/CalculateTripCost.asp?Rate=" + RatePerPerson + "&sid=" + Math.random() + "&Count=" + PeopleCount + "&taxrate=" + taxrate;
xmlHttp=GetXmlHttpObject(getTripCostEval)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
function getTripCostEval() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("TripCostEval").innerHTML=xmlHttp.responseText 
		}
	}



function visShoppingCart(strDashMatrix)
{
var url= strDashMatrix + "includes/ajax/ShoppingCart.asp?DashMatrix=" + strDashMatrix + "&sid=" + Math.random();
xmlHttp=GetXmlHttpObject(CartFunction)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
	function CartFunction() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("ShoppingCart").style.display = 'inline';
			document.getElementById("ShoppingCart").innerHTML=xmlHttp.responseText 
		}
	}

function closeCart()
{
	document.getElementById("ShoppingCart").style.display = 'none';
}



function removeService(ModuleID)
{
var url="../includes/ajax/AJAX_Components.asp?action=remove&sid=" + Math.random() + "&ModuleID=" + ModuleID;
xmlHttp=GetXmlHttpObject(removeComponent)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
				function removeComponent() 
				{ 
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
					{ 
						document.getElementById("components").innerHTML=xmlHttp.responseText 
					}
				}
// show the services
function showServices()
{
	document.getElementById("allServices").style.display = 'inline';
}
// hide the services
function hideServices()
{
	document.getElementById("allServices").style.display = 'none';
}

function addService(ModuleID)
{
var url="../includes/ajax/AJAX_Components.asp?action=add&sid=" + Math.random() + "&ModuleID=" + ModuleID;
xmlHttp=GetXmlHttpObject(addComponent)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
				function addComponent() 
				{ 
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
					{ 
						document.getElementById("components").innerHTML=xmlHttp.responseText 
					}
				}


function evalCompanyType(TypeString)
{
var url="../includes/ajax/AJAX_CompType.asp?sid=" + Math.random() + "&CompType=" + TypeString;
xmlHttp=GetXmlHttpObject(writeOther)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)	
}
function writeOther() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("otherctype").innerHTML=xmlHttp.responseText;
		document.getElementById("otherctype").style.display = 'inline';
	}
}



function AJAX_Example(add1,add2)
{ 
var url="../includes/ajax/AJAX_Add_Function.asp?sid=" + Math.random() + "&add1=" + add1 + "&add2=" + add2;
xmlHttp=GetXmlHttpObject(addNums)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function addNums() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("thesum").innerHTML=xmlHttp.responseText 
	}
}

var xmlHttp
function getEmailPage(pageid)
{ 
var url="../includes/ajax/AJAX_EmailPage.asp?sid=" + Math.random() + "&pageid=" + pageid;
xmlHttp=GetXmlHttpObject(formemail)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function formemail() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("pullcontent").innerHTML=xmlHttp.responseText ;
		document.getElementById("pullcontent").style.display='block';
	}
}


function getReqInfo(ModuleID)
{ 
var url="../includes/ajax/AJAX_AddToReqInfo.asp?sid=" + Math.random() + "&moduleid=" + ModuleID;
xmlHttp=GetXmlHttpObject(AddModule)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function AddModule() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("pullcontent").innerHTML=xmlHttp.responseText ;
		document.getElementById("pullcontent").style.display='block';
	}
}


function getExplanation(ABC)
{ 
var url="../includes/ajax/AJAX_DisplayInformation.asp?sid=" + Math.random() + "&infoString=" + ABC;
xmlHttp=GetXmlHttpObject(xrsInfo)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function xrsInfo() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("pullcontent").innerHTML=xmlHttp.responseText ;
		document.getElementById("pullcontent").style.display='block';
	}
}

function MSAJAX_newobject(pageref,strVar,strValue)
{ 
var url=pageref + "?sid=" + Math.random() + "&" + strVar + "=" + strValue;
xmlHttp=GetXmlHttpObject(newobj_stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function newobj_stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("newobject").innerHTML=xmlHttp.responseText 
	}
} 

function MSAJAX_saveinfo(pageref,strDatabase,strVars,strValues)
{ 
var url=pageref + "?sid=" + Math.random() + "&db=" + strDatabase + "&Vars=" + strVars + "&Values=" + strValues;
xmlHttp=GetXmlHttpObject(saveinfo_submit)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function saveinfo_submit() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("saveinfo").innerHTML=xmlHttp.responseText 
	}
} 

function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null
if (navigator.userAgent.indexOf("Opera")>=0)
{	alert("This example doesn't work in Opera") 
return 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 	var strName="Msxml2.XMLHTTP"
	if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
		strName="Microsoft.XMLHTTP"
		} 
	try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
} 