// JavaScript Document for pulling the customer data
// show the services
var xmlHttp
var strDashMatrix
var workElement;
var currentNum;
var leftNum;
var thisChecked

function loadSecCode(DashMatrix) {
	var url= DashMatrix + "includes/ajax/functions/getSecCode.asp?sid=" + Math.random() + "&DashMatrix=" + DashMatrix;
	strDashMatrix = DashMatrix
	workElement = "SecCode";
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)	
}


function selectUserRights(userPerms)
{
	if (userPerms == "3") {
		document.getElementById("userRights").style.display = "block";
	} else {
		document.getElementById("userRights").style.display = "none";
	}
}


function doProcessFeedback() {
	if(document.FeedbackForm.fbName.value == "") {
		alert("Please enter your name.");
		document.FeedbackForm.fbName.focus();
	} else if(document.FeedbackForm.fbEmail.value == "") {
		alert("Please enter your email.");	
		document.FeedbackForm.fbEmail.focus();
	} else if(document.FeedbackForm.fbComments.value == "") {
		alert("Please enter your comments/feedback.");	
		document.FeedbackForm.fbComments.focus();
	} else {
		document.FeedbackForm.submit();
	}
}

function doProcessRequest() {
	if(document.RequestForm.estName.value == "") {
		alert("Please enter your name.");
		document.RequestForm.estName.focus();
	} else if(document.RequestForm.estPhone.value == "" && document.RequestForm.estEmail.value == "") {
		alert("Please enter your phone or email.");	
		document.RequestForm.estPhone.focus();
	} else {
		document.RequestForm.submit();
	}
}


/* ==================================================================
// Site-wide Sale Functions -----------------------------------------
=====================================================================
*/
function driveSaleMinimum(DashMatrix, fSaleApply, postback)
{
	var url= DashMatrix + "includes/functions/sitewide_sale/SaleMinimum.asp?SaleApplyID=" + fSaleApply + "&sid=" + Math.random() + "&DashMatrix=" + DashMatrix;
	strDashMatrix = DashMatrix
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)		
}

/* ================================================================== */

function driveSaleAmount(DashMatrix, fSaleAmount, postback)
{
	var url= DashMatrix + "includes/functions/sitewide_sale/SaleAmount.asp?SaleAmount=" + fSaleAmount + "&sid=" + Math.random() + "&DashMatrix=" + DashMatrix;
	strDashMatrix = DashMatrix
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)		
}
/* ==================================================================
// End Site-wide Sale Functions -------------------------------------
=====================================================================
*/

function editCMSPage(thePageID, DashMatrix, postback) {
	var url= DashMatrix + "includes/ajax/functions/pullCMSPage.asp?PageID=" + thePageID + "&sid=" + Math.random() + "&DashMatrix=" + DashMatrix;
	strDashMatrix = DashMatrix
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function previewPage(DashMatrix,pageContent) {
	window.open(DashMatrix + "includes/ajax/CMSPage.asp?content=" + pageContent);
}

// =======================================================================================================
// 	Calendar Functions

	function showMiniCalendar(DashMatrix, theMonth, theYear, postback, clickedObject)
	{
		var url = DashMatrix + "includes/components/Calendar/miniCalendar.asp?sid=" + Math.random() + "&theMonth=" + theMonth + "&DashMatrix=" + DashMatrix + "&theYear=" + theYear + "&DivID=" + postback;
		workElement = "miniCalendarDiv"
		document.getElementById(workElement).innerHTML="Loading...";
		xmlHttp=GetXmlHttpObject(postbackDisplay)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
		objElement = "miniCalendarDiv";
		obj = clickedObject;
		postbackHoverDate(obj, objElement)
	}
	function showMiniCalendarNext(DashMatrix, theMonth, theYear, postback)
	{
		var url = DashMatrix + "includes/components/Calendar/miniCalendar.asp?sid=" + Math.random() + "&theMonth=" + theMonth + "&DashMatrix=" + DashMatrix + "&theYear=" + theYear + "&DivID=" + postback;
		workElement = "miniCalendarDiv"
		xmlHttp=GetXmlHttpObject(postbackDisplay)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
	function selectThisDate(TheDate, postback)
	{
		workElement = postback;
		document.getElementById(workElement).value = TheDate;
		document.getElementById('miniCalendarDiv').style.display = 'none';
	}
	
// =======================================================================================================



/* MESSAGE FUNCTIONS ========================================================== */
function DeletePress(DashMatrix, postback, PressID) {
	var url= DashMatrix + "includes/ajax/functions/deletePress.asp?PressID=" + PressID + "&sid=" + Math.random();
	strDashMatrix = DashMatrix
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function openReplyField() {
	document.getElementById("ReplyField").style.display='block';
}

function RequestMessageAssistance(DashMatrix, Checked, postback) {
	if (Checked == true) { thisChecked = "true"; } else { thisChecked = "false"; }
	var url= DashMatrix + "includes/ajax/functions/reqMsgAssistance.asp?Checked=" + thisChecked + "&sid=" + Math.random();
	strDashMatrix = DashMatrix
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function postbackDisplay() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById(workElement).innerHTML=xmlHttp.responseText; 
	}
}
function postbackDisplayToValue() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById(workElement).value=xmlHttp.responseText; 
	}
}



function setVideoStill(DashMatrix, FeatureID, StillID, postback) {
	var url= DashMatrix + "includes/ajax/functions/setVidStill.asp?sid=" + Math.random() + "&DashMatrix=" + DashMatrix + "&FeatureID=" + FeatureID + "&DivID=" + postback + "&StillID=" + StillID;
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function setThumbRel(DashMatrix, FeatureID, postback) {
	var url= DashMatrix + "includes/ajax/functions/setVideoThumbnail.asp?sid=" + Math.random() + "&DashMatrix=" + DashMatrix + "&FeatureID=" + FeatureID + "&DivID=" + postback;
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function showhideDivReverse(Checked, postback) {
	workElement = postback;
	if (Checked == true) {
		thisChecked = "true";
		document.getElementById(workElement).style.display="none"; 
	} else { 
		thisChecked = "false";
		document.getElementById(workElement).style.display="block"; 
	}
}

function showhideDiv(Checked, postback) {
	workElement = postback;
	if (Checked == true) {
		thisChecked = "true";
		document.getElementById(workElement).style.display="block"; 
	} else { 
		thisChecked = "false";
		document.getElementById(workElement).style.display="none"; 
	}
}

/* SITE FEATURE FUNCTIONS // ======================================================================================= */
function setSiteFeature(DashMatrix,FeatureID,Thumbnail,URLink,SiteID,SlotNum,postback) {
	var url= DashMatrix + "includes/ajax/functions/setSiteFeatures.asp?URL=" + URLink + "&sid=" + Math.random() + "&DashMatrix=" + DashMatrix + "&SiteID=" + SiteID + "&SlotNum=" + SlotNum + "&FeatureID=" + FeatureID + "&DivID=" + postback + "&Thumbnail=" + Thumbnail;
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function editSiteFeature(DashMatrix,SiteID,SlotNum,URLink,postback,FeatureID) {
	var url= DashMatrix + "includes/ajax/functions/editSiteFeatures.asp?URL=" + URLink + "&sid=" + Math.random() + "&DashMatrix=" + DashMatrix + "&SiteID=" + SiteID + "&SlotNum=" + SlotNum + "&FeatureID=" + FeatureID + "&DivID=" + postback;
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function previewFeature(DashMatrix,FeatureID,postback) {
	var url= DashMatrix + "includes/ajax/functions/previewFeature.asp?sid=" + Math.random() + "&DashMatrix=" + DashMatrix + "&FeatureID=" + FeatureID;
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
/* END SITE FEATURE FUNCTIONS // ======================================================================================= */




/* MEMBERS & QUICK LINK  FUNCTIONS // ======================================================================================= */
function removeQuickLink(DashMatrix,ListItemID) {
	var url= DashMatrix + "includes/ajax/functions/removeQuickLink.asp?sid=" + Math.random() + "&DashMatrix=" + DashMatrix + "&ListItemID=" + ListItemID;
	strDashMatrix = DashMatrix;
	workElement = "ListItem_" + ListItemID;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function addQuickLink(DashMatrix, LinkURL, LinkName, postback) {
	var url= DashMatrix + "includes/ajax/functions/addQuickLink.asp?sid=" + Math.random() + "&DashMatrix=" + DashMatrix + "&ListItemName=" + LinkName + "&ListURL=" + LinkURL;
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
/* END MEMBERS & QUICK LINK  FUNCTIONS // ======================================================================================= */



function postbackHoverDate(obj, Element)
{ 
// Position the div next to the object
	objElement = Element;
	var x = 0;
	var y = 0;
	while (obj) { 
			x += obj.offsetLeft 
			y += obj.offsetTop
			obj = obj.offsetParent; 
			//x = x + 1;
			y = y - 8;
		} 
		document.getElementById(objElement).style.display = 'inline';
		document.getElementById(objElement).style.left = x+"px";
		document.getElementById(objElement).style.top = y+"px";
	//	document.getElementById("hoverpopup").moveTo(x,y);
// Write the content of the Div
} 




/* SITE DISPLAY & UPDATE  FUNCTIONS // ======================================================================================= */
function saveSiteSale(DashMatrix, SiteID, ProdID, SalePrice, SaleStart, SaleEnd, postback) {
	var url= DashMatrix + "includes/ajax/functions/saveSiteSalePrice.asp?sid=" + Math.random() + "&DashMatrix=" + DashMatrix + "&SiteID=" + SiteID + "&ProdID=" + ProdID + "&SalePrice=" + SalePrice + "&SaleStart=" + SaleStart + "&SaleEnd=" + SaleEnd + "&DivID=" + postback;
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function lockdownConfirm(theAction)
{
	 var where_to= confirm("Locking down the system will kill all current user sessions and kick everyone out of the system. Are you sure you want to do this?");
	 if (where_to== true)
	 {
	   window.location=theAction;
	 }
}

function deleteConfirm(theAction)
{
	 var where_to= confirm("This action cannot be undone. Are you sure you want to delete?");
	 if (where_to== true)
	 {
	   window.location=theAction;
	 }
}

function confirmBlacklist(theAction)
{
	 var where_to= confirm("Are you sure you want to blacklist this Message / IP Address?");
	 if (where_to== true)
	 {
	   window.location=theAction;
	 }
}

function addMorePress(DashMatrix, TheNumber, postback)
{
	var url= DashMatrix + "includes/ajax/functions/addMorePress.asp?sid=" + Math.random() + "&DashMatrix=" + DashMatrix + "&PressNum=" + TheNumber;
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function ajaxadd(Preset, DashMatrix, postback)  {
		var url= DashMatrix + "includes/ajax/functions/addPresets.asp?DashMatrix=" + DashMatrix + "&Preset=" + Preset + "&sid=" + Math.random();
		strDashMatrix = DashMatrix;
		workElement = postback;
		xmlHttp=GetXmlHttpObject(postbackDisplay)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
}
/* END SITE DISPLAY & UPDATE  FUNCTIONS // ======================================================================================= */



/* SEARCH & RECOMMEND FUNCTIONS // ======================================================================================= */
function TextAreaLimit(current, DivTag, Limit) 
{
	workElement = DivTag;
	currentNum = current.length;
	leftNum = Limit - currentNum;
	document.getElementById(workElement).innerHTML = leftNum + " of " + Limit + " total chars left";
}

function DoLetterForm(TheLetter)
{
	document.LetterForm.LetterValue.value = TheLetter;
	document.LetterForm.submit();
}

function pullProductResults(DashMatrix,ProdName,ProdType,Genre,Collection,postback)  {
	if (ProdName.length >= 3) {
		var url= DashMatrix + "includes/functions/search/autoRecProducts.asp?DashMatrix=" + DashMatrix + "&ProdName=" + ProdName + "&ProdType=" + ProdType + "&Genre=" + Genre + "&Collection=" + Collection + "&sid=" + Math.random();
		strDashMatrix = DashMatrix;
		workElement = postback;
		xmlHttp=GetXmlHttpObject(postbackDisplay)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
}

function formulateID(DashMatrix,postbackToValue,thisValue,totalChar) {
	var url= DashMatrix + "includes/ajax/functions/formulateID.asp?totalChar=" + totalChar + "&thisValue=" + thisValue + "&sid=" + Math.random();
	strDashMatrix = DashMatrix;
	workElement = postbackToValue;
	xmlHttp=GetXmlHttpObject(postbackDisplayToValue)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function focusIn(TheField) {
	workElement = TheField;
	document.getElementById(workElement).focus();
}
function moreDubbed(DashMatrix, postback, currentCheck) {
	var url= DashMatrix + "includes/functions/admin/DubbedLanguages.asp?currentDubbed=" + currentCheck + "&sid=" + Math.random();
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	
}


function loadProductPresets(DashMatrix, ProdTypeID, postback) {
	var url= DashMatrix + "includes/functions/admin/Products/LoadProductPresets.asp?ProdTypeID=" + ProdTypeID + "&sid=" + Math.random();
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	
}

function AddProductType(DashMatrix, ProductName, ProductTypeID, Active, postback) {
	var url= DashMatrix + "includes/functions/admin/ProductTypes/AJAXSave.asp?Active=" + Active + "&ProdName=" + ProductName + "&ProdTypeID=" + ProdTypeID + "&sid=" + Math.random();
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function AddWebsite(DashMatrix, SiteName, SiteURL, Active, DisplayOrder, postback) {
	var url= DashMatrix + "includes/functions/admin/ProductTypes/AJAXSave.asp?Active=" + Active + "&ProdName=" + ProductName + "&ProdTypeID=" + ProdTypeID + "&sid=" + Math.random();
	strDashMatrix = DashMatrix;
	workElement = postback;
	xmlHttp=GetXmlHttpObject(postbackDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}




var SiteDivTag
var checkflagsite = "false";
var thisChecked

function activateSiteContent(DashMatrix, Checked, SiteID, UnitCost) {
	if (Checked == true) { thisChecked = "true"; } else { thisChecked = "false"; }
	var url= DashMatrix + "includes/ajax/functions/activateSiteContent.asp?Checked=" + thisChecked + "&PresetUnitCost=" + UnitCost + "&SiteID=" + SiteID + "&sid=" + Math.random();
	strDashMatrix = DashMatrix
	SiteDivTag = "divSite_" + SiteID;
	xmlHttp=GetXmlHttpObject(SiteContentDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function SiteContentDisplay() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById(SiteDivTag).innerHTML=xmlHttp.responseText; 
	}
}


function updateProdYear(DashMatrix,newYear,currentYear) {
	var url= DashMatrix + "includes/ajax/functions/ProdYear.asp?CurrentYear=" + currentYear + "&NewYear=" + newYear + "&sid=" + Math.random() + "&DashMatrix=" + DashMatrix;
	strDashMatrix = DashMatrix
	xmlHttp=GetXmlHttpObject(ProdYearDisplay)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function ProdYearDisplay() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("divProdYear").innerHTML=xmlHttp.responseText; 
	}
}

function showResultsDisplay(showtab) {
	var url= "../../includes/ajax/functions/SetDisplayPrefs.asp?showtab=" + showtab + "&sid=" + Math.random();
	xmlHttp=GetXmlHttpObject(doNothing)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)

	document.getElementById("List").style.display = 'none';
	document.getElementById("Thumbnails").style.display = 'none';
	document.getElementById("tab_List").style.backgroundColor = '#B2CDE1';
	document.getElementById("tab_Thumbnails").style.backgroundColor = '#B2CDE1';
	
	if (showtab == "List") {
		document.getElementById("List").style.display = 'inline';
		document.getElementById("tab_List").style.backgroundColor = '#FFFFFF';
	} else if (showtab == "Thumbnails") {
		document.getElementById("Thumbnails").style.display = 'inline';
		document.getElementById("tab_Thumbnails").style.backgroundColor = '#FFFFFF';
	}
}
function doNothing() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//document.getElementById("writeDisplayPrefs").innerHTML=xmlHttp.responseText; 
	}
}


function showTabEdit(showtab) {
	document.getElementById("Details").style.display = 'none';
	document.getElementById("Sites").style.display = 'none';
	document.getElementById("Assets").style.display = 'none';
	document.getElementById("Notes").style.display = 'none';
	document.getElementById("tab_Details").style.backgroundColor = '#B2CDE1';
	document.getElementById("tab_Sites").style.backgroundColor = '#B2CDE1';
	document.getElementById("tab_Assets").style.backgroundColor = '#B2CDE1';
	document.getElementById("tab_Notes").style.backgroundColor = '#B2CDE1';
	
	if (showtab == "details") {
		document.getElementById("Details").style.display = 'inline';
		document.getElementById("tab_Details").style.backgroundColor = '#FFFFFF';
	} else if (showtab == "sites") {
		document.getElementById("Sites").style.display = 'inline';
		document.getElementById("tab_Sites").style.backgroundColor = '#FFFFFF';
	} else if (showtab == "assets") {
		document.getElementById("Assets").style.display = 'inline';
		document.getElementById("tab_Assets").style.backgroundColor = '#FFFFFF';
	} else if (showtab == "notes") {
		document.getElementById("Notes").style.display = 'inline';
		document.getElementById("tab_Notes").style.backgroundColor = '#FFFFFF';
	}
}

function showTabEdit1(showtab) {
	document.getElementById("Details").style.display = 'none';
	document.getElementById("Sites").style.display = 'none';
	//document.getElementById("Assets").style.display = 'none';
	document.getElementById("Notes").style.display = 'none';
	document.getElementById("tab_Details").style.backgroundColor = '#B2CDE1';
	document.getElementById("tab_Sites").style.backgroundColor = '#B2CDE1';
	//document.getElementById("tab_Assets").style.backgroundColor = '#B2CDE1';
	document.getElementById("tab_Notes").style.backgroundColor = '#B2CDE1';
	
	if (showtab == "details") {
		document.getElementById("Details").style.display = 'inline';
		document.getElementById("tab_Details").style.backgroundColor = '#FFFFFF';
	} else if (showtab == "sites") {
		document.getElementById("Sites").style.display = 'inline';
		document.getElementById("tab_Sites").style.backgroundColor = '#FFFFFF';
	//} else if (showtab == "assets") {
	//	document.getElementById("Assets").style.display = 'inline';
	//	document.getElementById("tab_Assets").style.backgroundColor = '#FFFFFF';
	} else if (showtab == "notes") {
		document.getElementById("Notes").style.display = 'inline';
		document.getElementById("tab_Notes").style.backgroundColor = '#FFFFFF';
	}
}


var checkflag = "false";
function showMemberPanel() {
  if (checkflag == "false") {
	document.getElementById("MemberPanel").style.display = 'block';
	checkflag = "true";
  } else {
	document.getElementById("MemberPanel").style.display = 'none';
    checkflag = "false";
  }
}


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
	}
} 