var imgTrashFullOn = new Image();
var imgTrashFull = new Image();
var imgTrashOn = new Image();
var imgTrash = new Image();
var imgSmallTrashFullOn = new Image();
var imgSmallTrashFull = new Image();
var imgSmallTrashOn = new Image();
var imgSmallTrash = new Image();
imgTrashFullOn.src = "../img/itinerary/icon_trash_full.jpg";
imgTrashFull.src = "../img/itinerary/icon_trash.jpg";
imgTrashOn.src = "../img/itinerary/icon_trash_full.jpg";
imgTrash.src = "../img/itinerary/icon_trash.jpg";
imgSmallTrashFullOn.src = "../img/itinerary/icon_small_trash_full.jpg";
imgSmallTrashFull.src = "../img/itinerary/icon_small_trash.jpg";
imgSmallTrashOn.src = "../img/itinerary/icon_small_trash_full.jpg";
imgSmallTrash.src = "../img/itinerary/icon_small_trash.jpg";

txtCustomerID = "";
txtItineraryID = "";

function fHideDiv(strID) {
	document.getElementById(strID).style.display = 'none';
	document.getElementById(strID).style.visibility = 'hidden';
}

function fShowDiv(strID) {
	document.getElementById(strID).style.display = 'block';
	document.getElementById(strID).style.visibility = 'visible';
}

function showDetail(strID) {
	fShowDiv(strID);
	//var myloc = window.location.href;
	//var locarray = myloc.split("/");
	//var counterPath = "<?=$strCounterBase?>" + "/inc/asset_counter.php?id=" + strID;
	//document.getElementById("counter").src = counterPath;
}

function hideDetail(strID) {
	fHideDiv(strID);
}

function fAddEvent(strID) {
	var oItin = document.getElementById('divItinerary');
	var strURL = fLinkBuild("../../../itinerary/addToItinerary.php?txtID=" + strID);
	oItin.style.display = "block";
	oItin.style.visibility = "visible";
	//if(txtItineraryID == "") {
		//strURL += "&nextURL=" + window.location.href;
		//strURL += "&nextURL=";
		//location.href = strURL;
		//alert(strURL + "&nextURL=" + location.href);
		//document.title = strURL + "&nextURL=" + location.href;
	//} else {
		document.getElementById('frmItinerary').src = strURL;
	//}
}

function fAddBusiness(strID) {
	var oItin = document.getElementById('divItinerary');
	var strURL = fLinkBuild("../../../itinerary/addToItinerary.php?txtType=business&txtID=" + strID);
	oItin.style.display = "block";
	oItin.style.visibility = "visible";
//	if(txtItineraryID == "") {
//		location.href = strURL + "&nextURL=" + location.href;
//		document.title = strURL + "&nextURL=" + location.href;
//		alert(strURL + "&nextURL=" + location.href);
//	} else {
		document.getElementById('frmItinerary').src = strURL;
//	}
}

// itinerary details
function fShowDetails(intDay, strDate, strDiv) {
	var strContent = "";
	var oDetails = document.getElementById('divItineraryDetails');
	oDetails.style.visibility = "visible";
	oDetails.style.display = "block";

	
	var oDiv = document.getElementById('day'+intDay);
	var re = /description=\".+?\"/g;
	//var re = /description=\".*?\"/g;

	var arrMatches = oDiv.innerHTML.match(re);
	if(arrMatches == null) {
		document.getElementById('divIDDate').innerHTML = strDate;
		document.getElementById('divIDContent').innerHTML = "You have no items in your itinerary for today.";
		return;
	}

	for(i=0; i<arrMatches.length; i++) {
		var strLink = arrMatches[i].substr(13,arrMatches[i].length-14);
		strContent += strLink + "<br />";
	}
	strContent = strContent.replace(/&lt;/g,		"<");
	strContent = strContent.replace(/&gt;/g,		">");
	strContent = strContent.replace(/&apos;/g,	"'");
	document.getElementById('divIDDate').innerHTML = strDate;
	document.getElementById('divIDContent').innerHTML = strContent;
}



function fHideDetails() {
	var oDetails = document.getElementById('divItineraryDetails');
	oDetails.style.visibility = "hidden";
	oDetails.style.display = "none";
	document.getElementById('divIDContent').innerHTML = "";
}
// end itinerary details

function fGoURL(strURL) {
	window.location = fLinkBuild(strURL);
}

function fLinkBuild(strURL) {
	if(strURL.indexOf("?") < 0) {
		strURL += "?";
	}
	if(txtCustomerID != "") {
		strURL += "&txtCustomerID=" + txtCustomerID;
	}
	if(txtItineraryID != "") {
		strURL += "&txtItineraryID=" + txtItineraryID;
	}
	return strURL;
}
