﻿function cboRedirector(cboObj, sSecure, sDNSName, sType, sTrx, nSourceCatID, nSearchTree) {
	if (typeof(cboObj == 'object')) {
		if (cboObj.type == 'select-one') {
			if (cboObj.selectedIndex > 0) {
				var sProtocal = (sSecure == 'true')?'https://':'http://';
				var sScript;
				// TODO: Change these "asp" to "asp" when renaming file extensions.
				switch (sType) {
					case 'brand':
						sScript = '/brand.asp?brand=' + cboObj.options[cboObj.selectedIndex].value;break;
					case 'category':
						sScript = '/category.asp?catid=' + cboObj.options[cboObj.selectedIndex].value;break;
					case 'product':
						sScript = '/product.asp?pid=' + cboObj.options[cboObj.selectedIndex].value;break;
					case 'search':
						sScript = '/search/search.asp?search=' + cboObj.options[cboObj.selectedIndex].text;break;
					default:
						return;
				}
				sScript += '&srchtree=' + nSearchTree;
				sScript += '&trx=' + sTrx;
				sScript += '&trxP1=' + nSourceCatID;
				document.location = sProtocal + sDNSName + sScript;
			}
		}
	} else {
		return;
	}
}

function getObject(sNodeID) {
	var obj = document.getElementById(sNodeID);
	if (typeof(obj) == 'object') {
		return obj;
	} else {
		return;
	}
}

// Function to highlight the free sample items that user selected in Beauty.com 
function HighlightSample(chkObj, SourceId)   
{
	if(chkObj.checked)   
	{
		document.getElementById(SourceId).style.backgroundColor = 'f0e5f3';
	}
	else  
	{
		document.getElementById(SourceId).style.backgroundColor = 'white';
	}
}

function SubmitSamplesForm(sPostElementKey)
{
    if (!document.frmSampleItems)
        return;
        
	var hdnRedirect = document.frmSampleItems.hdnRedirect;
	if (hdnRedirect)
	{
		hdnRedirect.value = sPostElementKey;
	}
	document.frmSampleItems.submit();
}

function SubmitNewProductRequestForm()
{
    if (document.frmNewProductRequest)
	    document.frmNewProductRequest.submit();
}

function AddHandlers() {
	// add event handlers
}

// cross browser node text
function GetNodeText(o) {
	return (o.innerText) ? o.innerText : o.textContent;
}

function Initialize() {
	// from body onload
}

// helpers
function GetChildElementById(o,s) {
	var x = o.childNodes.length-1;
	for(var i=0; i<=x; i++) {
		if(o.childNodes[i].id == s)
			return o.childNodes[i];
	}
}

function GetSiblingElementById(o,s) {
	if(o) {
		while(o.id != s) {
			o = o.nextSibling;
		}
	}
	return o;
}
