/* Blue River Digital API - Common **********************************
 *	
 *	This API contains all the common Javascript functions
 *	
 *********************************************************************/
 	
 	// Globals *************************************************
 
 	// Broswer Detection ****************
 	var IE = document.all?true:false; // determine which browser 
	var thisBrowser = navigator.userAgent;
	var thisBrowserVersion = null;
	
	if (thisBrowser.indexOf("MSIE") != -1)
	{
		thisBrowser = "IE";
		
		if (thisBrowser.indexOf("MSIE 8") != -1)
		{
			thisBrowserVersion = 8;	
		}
		
	}
	else if (thisBrowser.indexOf("Firefox") != -1)
	{
		thisBrowser = "Firefox";	
	}
	else if (thisBrowser.indexOf("Safari") != -1)
	{
		thisBrowser = "Safari";	
	}
	else
	{
		thisBrowser = "Other";	
	}
	
	
	var mousePositionX = "";
	var mousePositionY = "";
	
	
	// Current Date and Time *****************************
	var d = new Date();
	var yearValue = d.getYear();
	var hourValue = d.getHours();
	var amPmValue = "AM";
	
	if (!IE)
	{
		yearValue += 1900;	
	}
	
	if (hourValue > 11)
	{
		amPmValue = "PM";	
	}
	
	var now = (d.getMonth()+1) + "/" + d.getDate() + "/" + yearValue + " " + hourValue + ":" + d.getMinutes() + ":" + d.getSeconds() + " " + amPmValue;
			
/* Terms & Conditions Popups ******************************************************/

	function freeShippingELEConditions()
	{
		
		var contentTitle = "Terms and Conditions";
		var contentText = "<div style=\"width: 400px;\">";
		contentText = contentText + "<center><table cellpadding=\"0\" cellspacing=\"0\" width=\"250\"><tr><td><a href=\"/lightboxes/edgelyte-led/\">";
		contentText = contentText + "	<img border=\"0\" src=\"/images/edgeLyteEconoLedThumb.png\"/>";
		contentText = contentText + "</a></td><td style=\"padding-left: 20px;\">";
		contentText = contentText + "<a href=\"/lightboxes/edgelyte-led/\" class=\"mostPopular\">EdgeLyte Econo LED lightbox</span></a>";
		contentText = contentText + "				<div style=\"margin-top: 5px;\"><span class=\"lightboxPrice\">starting at <span style=\"color: #000000\">$279.00</span></span></div>";
				
		contentText = contentText + "					<div style=\"padding-top: 10px;\">";
		contentText = contentText + "						<table cellpadding=\"0\" cellspacing=\"0\">";
		contentText = contentText + "						<tr valign=\"center\">";
		contentText = contentText + "							<td></td>";
		contentText = contentText + "							<td>";
		contentText = contentText + "								&nbsp;";
		contentText = contentText + "								<a href=\"/hardware/backlit/lightboxSameDayShipping.asp\" target=\"_blank\"alt=\"Click Here for Detail\"><img src=\"/images/shipsTodayIcon.jpg\"  border=\"0\" onMouseOver=\"altTextPopup('Ships Today!* Click for Details.');\" onMouseOut=\"hideElement('altTextPane');\"/></a>";
		contentText = contentText + "							</td>";
									
		contentText = contentText + "						</tr>";
		contentText = contentText + "						</table>";
						
		contentText = contentText + "					</div>";
                                                
        contentText = contentText + "<div class=\"lightboxDescr\">LED backlit graphics display frame, with 100,000 hours life expectancy! </div></td></tr></table><br><br>";
		contentText = contentText + "<div style=\"width: 400px; font-weight: bold; padding-bottom: 15px;\">Receive FREE shipping* on the EdgeLyte Econo LED lightbox!<br>(Certain restrictions apply.)</div></center>";
		contentText = contentText + "<div class=\"tiny_text\">*Terms & Conditions: Expires August 30, 2009. This offer is for Ground shipping  mode only, to the 48 contiguous United States. Upgrades to faster shipping mode not eligible for discounted rate. Maximum eligible ";
		contentText = contentText + "quantities may apply, depending on inventory. This promotion is only available for shipments made on Blue River Digital's shipper account and only via carriers specified by Blue River Digital. Qualifying orders must be placed directly by Customer through Blue River Digital's website, at <a href=\"http://www.blueriverdigital.com\">www.blueriverdigital.com</a>, and prepaid per Blue River Digital's standard payment terms. No other products or models or sizes of lightboxes are eligible for this offer; standard configuration only, no customizations. This offer does not include inside delivery, liftgate, call-ahead or other special handling. Applicable shipping charges for Duratrans or other products ordered, and handling charges still apply. Offer is for product from warehouse stock only, and is subject to termination without notice.</div>";
		contentText = contentText + "</div>";
		
		textPopup(contentTitle, contentText);
	}


/* *********************************************************************************** */
			
/*  Get Mouse Position * *******************************************************
 *
 *	TAKES:		Event Object
 * 	RETURNS:	NOTHING
 *	NOTES:		IE by default does not calculate the page scrolling in the
 *				mouse postion, but the screen position.  Since FF and NS include
 *				page scroll in the mouse position, we're adding to IE as well.
 *
 *************************************************************************/
	
	function getMousePosition(e)
	{
		var posX = "";
		var posY = "";
		
		if (IE)
		{ 
			// grab the y pos.s if browser is IE
			posX = event.clientX - 2 + getPageXOffset();
			posY = event.clientY - 2 + getPageYOffset();
	  	}
		else
		{ 
			// grab the y pos.s if browser is NS
			posX = e.pageX;
			posY = e.pageY;
		}  
	  
	   // catch possible negative values in NS4
	   if ((posX < 0)||(posY < 0))
	   {
		  posX = 0;
		  posY = 0;
	   }  
	  
	 	mousePositionX = posX;
	 	mousePositionY = posY;
		
	}
	
 
 /* Is Array * *******************************************************
 *
 *	TAKES:		Array Object
 * 	RETURNS:	True if the array object is actually an array. False if the 
 *				array object is not an array.
 *	NOTES:		Usage: [Array Obj].isArray();
 *
 *************************************************************************/
 
 	Object.prototype.isArray = function()
	{
		return this.constructor == Array;
	}
	
/* Data Is Valid **********************************************************
*
*	TAKES:		Data, Data Type
*	RETURNS:	True if the data is valid, False if the data is not valid
*				based on the data type. Data types include:
*
*					1. String	- Ex: "abc123"
*					2. Integer	- Ex: 123
*					3. Float	- Ex: 25.99
*					4. Email	- Ex: test@email.com
*					5. Password - Ex: *******
*					6. Phone	- Ex: 123-444-5555
*
*	NOTES:		This function genreally doesn't enforce the maximum number
*				of characters for given data, this should be handled with 
*				character limits using HTML forms.
*
**************************************************************************/

	function dataIsValid(data, dataType)
	{
		var regExp;
		var errorMessage
		data = String(data);
		
		switch(dataType)
		{
			case "string":
				
				regExp = /^(\w|\s)+$/;
				errorMessage = "Invalid characters were used. (Ex: <, >, %, \", ', #).";
				break;
				
			case "integer":
				
				regExp = /^\d+$/;
				errorMessage = "This field can only contain whole numbers (Ex: 1, 23, 675).";
				break;
				
			case "float":
			
				regExp = /^\d+(.\d+|)$/;
				errorMessage = "This field can only contain decimal numbers (Ex: 51, 1.0, 23.5, 67.5).";
				break;
				
			case "fraction":
			
				regExp = /^(|[0-9]+ )[0-9]+\/[0-9]+$/;
				errorMessage = "This field can only contain fractions (Ex: 12 3/4, 1/2).";
				break;
				
			case "email":
			
				regExp = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
				errorMessage = "This field can only contain valid email addresses (Ex: johndoe@emailexample.com).";
				break;
				
			case "password":
			
				regExp = /^.{6}/
				errorMessage = "This field must be at least six characters long and not contain any invalid characters. (Ex: <, >, %, \", ', #)";
				break;
			
			case "phone":
			
				regExp = /^((\(\d{3}\)( |))|(\d{3}( |-|.|)))\d{3}( |-|.|)\d{4}(,| |x|e)*/;
				errorMessage = "This field can only contain phone numbers (Ex: 111-555-4444).";
				break;
			
			case "zip":
			
				regExp = /^\d{5}([\-]\d{4})?$/;
				errorMessage = "This field can only contain zip codes (Ex: 12345-5555).";
				break;
			
			case "text":
				
				// Omitt <br /> tags *********
				data = data.replace(/<br \/>/g, "");
				regExp = /^.*$/;
				errorMessage = "Invalid characters were used. (Ex: <, >, %, \", ', #).";
				break;
			
			case "projectNo":
			
				regExp = /^P[A-Z][0-9]{4}-[A-Z]{2}$/;
				errorMessage = "Invalid Project No., please use the format: PA0000-AA";
				break;
				
			case "date":
			
				regExp = /^([0-1][0-9]|[0-9])\/([0-3][0-9]|[0-9])\/[0-9]{4}$/;
				errorMessage = "Invalid Date, please use the format: MM/DD/YYYY";
				break;
				
			default:
				
				return false;
		}
		
		if ( (data.search(regExp) != -1) & isValid(data) )
		{
			return true;	
		}
		else
		{
			return errorMessage;	
		}
	}
	
/* Is Valid **********************************************************
*
*	TAKES:		Data
*	RETURNS:	True if the data is valid, False if the data is not valid
*				based on the data type. Data types include:
*
**************************************************************************/

	function isValid(data)
	{
		var regExp = /(<|>|"|%|'|#)/;
		
		if (data.search(regExp) != -1)
		{
			return false;	
		}
		else
		{
			return true;	
		}
		
	}
	
/*  Encode Query String * *******************************************************
 *
 *	TAKES:		Query String
 * 	RETURNS:	Encrypyed Query String
 *	NOTE:		Special characters that need to be encrypted:
 *
 *					- ;	%3B
 *					- ?	%3F
 *					- /	%2F
 *	 				- :	%3A
 *					- #	%23
 *					- &	%26
 *					- =	%3D
 * 					- +	%2B
 *					- $	%24
 *					- ,	%2C
 *					- <space>	%20
 *					- %	%25
 *					- <	%3C
 *					- >	%3E
 *					- ~	%7E
 *
 *************************************************************************/
 
	function encodeQueryString(queryString)
	{
		if (queryString == null)
		{
			queryString = "";
		}
		
		queryString = queryString.replace(/%/g, "%25");
		queryString = queryString.replace(/;/g, "%3B");
		queryString = queryString.replace(/\?/g, "%3F");
		queryString = queryString.replace(/\//g, "%2F");
		queryString = queryString.replace(/:/g, "%3A");
		queryString = queryString.replace(/#/g, "%23");
		queryString = queryString.replace(/ /g, "%20");
		queryString = queryString.replace(/&/g, "%26");
		queryString = queryString.replace(/=/g, "%3D");
		queryString = queryString.replace(/\+/g, "%2B");
		queryString = queryString.replace(/\$/g, "%24");
		queryString = queryString.replace(/,/g, "%2C");
		queryString = queryString.replace(/</g, "%3C");
		queryString = queryString.replace(/>/g, "%3E");
		queryString = queryString.replace(/~/g, "%7E");
		
		return queryString;

	}


/* Get Dimension Width **********************************************************
*
*	TAKES:		Dimension Data in the format W x H OR WWHH
*	RETURNS:	The width dimension from the dimension data
*
**************************************************************************/

	function getDimWidth(dimData)
	{
		var widthValue = "";
		var dimHolder = "";
		
		if (dimData.indexOf(" x ") != -1)
		{
			dimHolder = Left(dimData, dimData.indexOf(" x "));
			widthValue = Trim(dimHolder);
		}
		else
		{
			dimHolder = Right(dimData, dimData.length - 6);
			widthValue = Left(dimHolder, Math.floor(dimHolder.length/2));
		}
	
		return widthValue;
	
	}
	
/* Get Dimension Height **********************************************************
*
*	TAKES:		Dimension Data in the format W x H OR 5XXXXXWWHH
*	RETURNS:	The height dimension from the dimension data
*
**************************************************************************/

	function getDimHeight(dimData)
	{
		var heightValue = "";
		var dimHolder = "";
		
		if (dimData.indexOf(" x ") != -1)
		{
			dimHolder = Right(dimData, dimData.length - (dimData.indexOf(" x ")+3));
			heightValue = Trim(dimHolder);
		}
		else
		{
			dimHolder = Right(dimData, dimData.length - 6);
			heightValue = Right(dimHolder, Math.ceil(dimHolder.length/2));
		}
		return heightValue;
	
	}

/* Right **********************************************************
*
*	TAKES:		str - the string we are RIGHTing
*               n - the number of characters we want to return
*	RETURNS:	n characters from the right side of the string
*
**************************************************************************/

	function Right(str, n)
    {
		if (n <= 0)     // Invalid bound, return blank string
		{
			return "";
		}
		else if (n > String(str).length)   // Invalid bound, return
		{
			return str;                     // entire string
		}
		else
		{ 
		   // Valid bound, return appropriate substring
		   var iLen = String(str).length;
		   return String(str).substring(iLen, iLen - n);
		}
    }
	
/* Left **********************************************************
*
*	TAKES:		str - the string we are LEFTing
*               n - the number of characters we want to return
*	RETURNS:	n characters from the left side of the string
*
**************************************************************************/
		
	function Left(str, n)
	{
			if (n <= 0)     // Invalid bound, return blank string
			{
				return "";
			}
			else if (n > String(str).length)   // Invalid bound, return
			{
				return str;                // entire string
			}
			else // Valid bound, return appropriate substring
			{
				return String(str).substring(0,n);
			}
	}

	
/* Trim **********************************************************
*
*	TAKES:		String
*	RETURNS:	String with the whitespaces on the left and right sides trimmed.
*
**************************************************************************/

	function Trim(stringToTrim)
	{
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	

	
/* Fraction To Decimal **********************************************************
*
*	TAKES:		Fraction Data string
*	RETURNS:	Decimal representation of the fraction
*
**************************************************************************/

	function fractionToDecimal(data)
	{
		if (dataIsValid(data, "fraction") == true)
		{
			// Convert fractions to decimal
			var wholeNum 	= 0;
			var fraction	= 0;
			var numerator 	= 0;
			var denominator	= 0;
			var decimalValue = 0;
			
			var fractionValues = data.split(" ");
			
			if (fractionValues.length > 1)
			{
				wholeNum = fractionValues[0];
				fraction = fractionValues[1];
			}
			else
			{
				fraction = fractionValues[0];
			}
			
			if (fraction.search(/\//) != -1)
			{
				fractionValues 	= fraction.split("/");
				numerator  		= fractionValues[0];
				denominator  	= fractionValues[1];
				
				if (denominator > 0)
				{
					decimalValue = (numerator/denominator);
				}
				else
				{
					decimalValue = 0;
				}
			}
			
			data = Number(wholeNum) + Number(decimalValue);
		}
		
		return data;
	}

/* BRD Button Actions **********************************************************
*
*	TAKES:		NOTHING
*	RETURNS:	NOTHING
*	NOTES:		Sets the button actions for the BRD Buttons with tag: "brdButton"
*
*********************************************************************************/

	function setBrdButtonActions()
	{
		var buttonElements = getTagGroup("div", "brdButton");	
		
		if (buttonElements.length > 0)
		{
			var buttonElement;
			
			for(ctr=0; ctr<buttonElements.length; ctr++)
			{
				buttonElement = buttonElements[ctr];
				
				// Style Class --------------------------------
				buttonElement.className = "brdButton";
				
				// Mouse Over Actions -------------------------
				buttonElement.onmouseover = function()
				{
					this.className 		= "brdButtonHover";
					this.style.cursor	= "pointer";
				}
				
				// Mouse Over Actions -------------------------
				buttonElement.onmouseout = function()
				{
					this.className 		= "brdButton";
					this.style.cursor	= "";
				}
					
			}
			
		}
	}
	
/* Round Float **********************************************************
*
*	TAKES:		Float Value, Number of Significant Digits
*	RETURNS:	Truncated Float Value
*	NOTES:		
*
*********************************************************************************/

	function roundFloat(floatValue, numDigits)
	{
		if (numDigits == "")
		{
			numDigits = 0;	
		}
		
		var digitPosition;
		var multiplier = Math.pow(10, numDigits);
		
		floatValue = parseFloat(floatValue);
		floatValue = parseFloat(floatValue * multiplier);
		floatValue = Math.round(floatValue) / multiplier;
		
		if (String(floatValue).indexOf(".") > -1)
		{
			digitPosition = Right(String(floatValue), String(floatValue).length - (String(floatValue).indexOf(".") + 1));
			digitPosition = digitPosition.length;
		}
		else
		{
			digitPosition = 0;
			floatValue += ".";
		}
		
		if (digitPosition < numDigits)
		{
			for(var zeroCtr=digitPosition; zeroCtr<numDigits; zeroCtr++)
			{
				floatValue += "0";
			}
		}
		
		return floatValue;
	
	}

/* Set Department Cookie **********************************************************
*
*	TAKES:		Cookie Name, Cookie Value
*	RETURNS:	NOTHING
*	NOTES:		
*
*********************************************************************************/

	function setCookie(cookieName, cookieValue)
	{
		if (cookieName)
		{
			
			var expireDays 	= 365; // one year
			var expDate		= new Date();
			
			expDate.setDate(expDate.getDate() + expireDays);
			document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expDate.toGMTString();
			
		}
		
	}
	
/* Get Department Cookie **********************************************************
*
*	TAKES:		NOTHING
*	RETURNS:	Cookie Value
*	NOTES:		
*
*********************************************************************************/

	function getCookieValue(cookieName)
	{
		var cookieElements 	= document.cookie.split(";");
		var cookieElement 	= "";
		var cookieData		= "";
		var thisCookieName	= "";
		var thisCookieValue	= "";
		
		if (cookieElements.length > 0)
		{
			for(var ctr=0; ctr<cookieElements.length; ctr++)
			{
				cookieElement = cookieElements[ctr];
				
				cookieData = cookieElement.split("=");
				
				thisCookieName = cookieData[0];
				thisCookieValue = cookieData[1];
				
				if (thisCookieName == cookieName)
				{
					return (unescape(thisCookieValue));
				}
			}
		}
		
	}
	
 /* Email This Product Page ********************************************************
 *
 *	TAKES:		Product Name
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *	
 ************************************************************************************/
 
	function emailThisProductPage(productName)
	{
		var graphicContainer 	= document.createElement("div");
		graphicContainer.style.backgroundImage = "url(/images/emailGraphic.jpg)";
		graphicContainer.style.backgroundRepeat = "no-repeat";
		graphicContainer.style.backgroundColor= "#FFFFFF";
		graphicContainer.style.marginTop = "0px";
		
		var productNameElement 		= document.createElement("input");
		productNameElement.type 	= "hidden";
		productNameElement.id 		= "productName";
		productNameElement.value 	= productName;
		
		graphicContainer.appendChild(productNameElement);
		
		var productLinkElement 		= document.createElement("input");
		productLinkElement.type 	= "hidden";
		productLinkElement.id 		= "productLink";
		productLinkElement.value 	= location.href;
		
		graphicContainer.appendChild(productLinkElement);
		
		var contentElement 		= document.createElement("div");
		contentElement.style.padding = "15px";
		
		var fieldContainer 	= document.createElement("div");
		var fieldTable		= document.createElement("table");
		var fieldTableBody	= document.createElement("tbody");
		
			var fieldToRow		= document.createElement("tr");
			fieldToRow.vAlign	= "top";
			
				var fieldToCol1		= document.createElement("td");
				var fieldToCol2		= document.createElement("td");
				
				fieldToCol1.innerHTML = "<b>To E-mail*: ";
				fieldToCol2.innerHTML = "<input type=\"text\" size=\"35\" id=\"emailTo\">";
				fieldToCol2.style.paddingLeft = "20px"; 
					
					// Error Pane *******************************
					var errorContainer			= document.createElement("div");
					errorContainer.id			= "emailToError";
					errorContainer.className 	= "errorContainer";
					errorContainer.style.display 	= "none";
					errorContainer.style.margin		= "0px";
					errorContainer.style.marginTop	= "5px";
					errorContainer.style.marginBottom = "10px";
					
					errorContainer.style.padding 	= "5px"; 
					
					fieldToCol2.appendChild(errorContainer);
				
				fieldToRow.appendChild(fieldToCol1);
				fieldToRow.appendChild(fieldToCol2);
			
			fieldTableBody.appendChild(fieldToRow);
			
			var fieldFromRow		= document.createElement("tr");
			fieldFromRow.vAlign		= "top";
			
				var fieldFromCol1		= document.createElement("td");
				var fieldFromCol2		= document.createElement("td");
				
				fieldFromCol1.innerHTML = "<b>From E-mail:</b><br><span style=\"#666666\">(optional)</span> ";
				fieldFromCol2.innerHTML = "<input type=\"text\" size=\"35\" id=\"emailFrom\">";
				fieldFromCol2.style.paddingLeft = "20px"; 
				
				// Error Pane *******************************
					var errorContainerAlt			= document.createElement("div");
					errorContainerAlt.id			= "emailFromError";
					errorContainerAlt.className 	= "errorContainer";
					errorContainerAlt.style.display = "none";
					errorContainerAlt.style.margin		= "0px";
					errorContainerAlt.style.marginTop	= "5px";
					errorContainerAlt.style.marginBottom = "10px";
					
					errorContainerAlt.style.padding 	= "5px"; 
					
					fieldFromCol2.appendChild(errorContainerAlt);
				
				fieldFromRow.appendChild(fieldFromCol1);
				fieldFromRow.appendChild(fieldFromCol2);
				
			fieldTableBody.appendChild(fieldFromRow);
		
		fieldTable.appendChild(fieldTableBody);
		contentElement.appendChild(fieldTable);
		
		var commentsContainer 	= document.createElement("div");
		commentsContainer.style.paddingTop = "20px";
		
		var commentsText		= document.createElement("div");
		commentsText.innerHTML	= "If you would like to include a message, please type it here:";
		
		var commentsField		= document.createElement("textarea")
		commentsField.id		= "commentsField";
		commentsField.cols		= 40;
		commentsField.rows		= 5;
		
		commentsContainer.appendChild(commentsText);
		commentsContainer.appendChild(commentsField);
		
		contentElement.appendChild(commentsContainer);
		
		var buttonContainer					= document.createElement("div");
		buttonContainer.style.paddingTop 	= "20px";
		buttonContainer.align				= "center";
		buttonContainer.innerHTML 			= "<input type=\"button\" id=\"sendBtn\" value=\"Send E-mail\" onClick=\"sendProductPageEmail()\">";
		buttonContainer.innerHTML		   += "<input type=\"button\" id=\"cancelBtn\" value=\"Cancel\" onClick=\"restorePageBackground()\">";
		
		contentElement.appendChild(buttonContainer);
		graphicContainer.appendChild(contentElement);
		
		contentElementPopup(productName + "<span style=\"color: #666666;\"> | Email this Product Page </span>",  graphicContainer);
	}

 /* Email This Product Page ********************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *	
 ************************************************************************************/
 
	function sendProductPageEmail()
	{
		var emailToValue 	= getElement("emailTo").value;
		var emailFromValue 	= getElement("emailFrom").value;
		var commentsValue	= getElement("commentsField").value;
		
		var errorMessage	= "";
		var result			= "";
		
		result = dataIsValid(emailToValue, "email");
		if (result != true)
		{
			getElement("emailToError").innerHTML = "Please enter a valid e-mail address.";
			showElement("emailToError");
			errorMessage += result;
		}
		else
		{
			hideElement("emailToError");	
		}
		
		result = dataIsValid(emailFromValue, "email");
		if ((emailFromValue != "") & (result != true))
		{
			getElement("emailFromError").innerHTML = "Please enter a valid e-mail address.";
			showElement("emailFromError");
			errorMessage += result;
		}
		else
		{
			hideElement("emailFromError");	
		}
		
		if (errorMessage == "")
		{
			var productName	= getElement("productName").value;
			var productLink	= getElement("productLink").value;
			
			// Disable Buttons ******************
			getElement("sendBtn").disabled = true;
			getElement("cancelBtn").disabled = true;
			
			commentsValue = encodeQueryString(commentsValue);
			
			setAjaxUrl("updateData", "/includes/api/brdApiEmail.asp?action=sendProductPageEmail&productName=" + productName + "&productLink=" + productLink + "&emailTo=" + emailToValue + "&emailFrom=" + emailFromValue + "&comments=" + commentsValue, false, "alertShadedPopup('Email Product Page Status', 'E-mail Sent Successfully!');");
		}
		
	}
	
/*  Add Log Item  ********************************************************
 *
 *	TAKES:		Item Type, Item Id, Item Descr, Old Value, New Value
 * 	RETURNS:	NOTHING
 *	NOTE:		Log Action is determined based on the old and new values.
 *
 ********************************************************************************/
 
 	function addLogItem(itemType, itemId, itemDescr, oldValue, newValue)
	{
		var logAction = "";
		
		if (oldValue == " ")
		{
			oldValue = "";	
		}
		
		if (newValue == " ")
		{
			newValue = "";	
		}
		
		if ((oldValue != "") & (newValue != "") & (oldValue != newValue))
		{
			logAction = "CHANGED";	
		}
		else if ((oldValue != "") & (newValue == ""))
		{
			logAction = "REMOVED";	
		}
		else if ((oldValue == "") & (newValue != ""))
		{
			logAction = "ADDED";	
		}
		
		if (logAction != "")
		{
			var queryVars = "&itemType=" + encodeQueryString(itemType);
			queryVars += 	"&itemId=" + encodeQueryString(itemId);
			queryVars += 	"&itemDescr=" + encodeQueryString(itemDescr);
			queryVars += 	"&oldValue=" + encodeQueryString(oldValue);
			queryVars += 	"&newValue=" + encodeQueryString(newValue);
			queryVars += 	"&logAction=" + encodeQueryString(logAction);
			
			setAjaxUrl("dataPane", "/includes/api/brdApiQuery.asp?action=addLogItem" + queryVars, false, false);	
		}
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	
	
	
	
	