/* existing finestationery.com function used to redirect user on change for footer brand select field */
function shopByBrand(thisValue) {
	manValue = thisValue.substring(0,thisValue.indexOf('|'));
	answerIdValue = thisValue.substring(thisValue.indexOf('|') + 1,thisValue.length);
	window.location.href = 'indexCelebros.cfm?manid='+manValue+'&action=4&AnswerID='+answerIdValue+'&shopbybrand=true&fss_id=180820060246500557244917665303';
}

// make sure forms initilizes (see onlaod.js)
if (initialize) { initialize.forms = true }

// forms object used to store global variables and functions for popup windows
var forms = new Object();

//document.write('<style type="text/css">#DC_RELATED .dcRelatedModule div.inputChk{display:none}</style>');

/**
* This function detects checkboxes that are replaced (visually) with images and wires everything up to make them still work as checkboxes.
*/
forms.ini = function()
{
	var dcRelated   = document.getElementById( 'DC_RELATED' );
	var pageContent = document.getElementById( 'pageContent' );
	
	if (!dcRelated || !pageContent) { return false; }
	
	var cInput = pageContent.getElementsByTagName( 'INPUT' );
	var oInput;
	var iInput = 0;
	var nInput = cInput.length;

	if ( nInput > 0 )
	{
		for ( iInput ; iInput < nInput ; iInput++ )
		{
			oInput = cInput[iInput];

			if ( oInput.type && ( oInput.type == 'checkbox' ) )
			{
				var oWrapper = oInput.parentNode.parentNode;
				
				oWrapper.oInput = oInput;
			
				if ( oInput.checked == true )
				{
					oWrapper.className += ' isChecked';
				}
				else
				{
					oWrapper.className += ' unChecked';
				}

				var cImg = oWrapper.getElementsByTagName( 'IMG' );
				var oImg_isChecked = cImg[0];
				var oImg_unChecked = cImg[1];

				oImg_isChecked.bChecked = true;
				oImg_unChecked.bChecked = false;
				
				oImg_isChecked.onclick = forms.toggleCheckboxState;
				oImg_unChecked.onclick = forms.toggleCheckboxState;
			}
		}
	}
}


/**
* This function toggles the state of the checkbox and the visual state of the checkbox image.
*/
forms.toggleCheckboxState = function()
{
	var oWrapper = this.parentNode;
	oWrapper.oInput.checked = this.bChecked;
	
	if (oWrapper.oInput.checked == true)
	{
		oWrapper.className = oWrapper.className.replace(" unChecked", " isChecked");
	}
	else
	{
	  if(oWrapper.oInput.name != null)
		  {
			 if(oWrapper.oInput.name == "ThankYouNote_CardCheck" && document.getElementsByName("tynenvtext_CardCheck")(0).checked == true)
			 {	 
				document.getElementsByName("tynenvtext_CardCheck")(0).checked=false;
				document.getElementsByName("tynenvtext_CardCheck")(0).parentNode.parentNode.className=document.getElementsByName("tynenvtext_CardCheck")(0).parentNode.parentNode.className.replace(" isChecked", " unChecked");
			 }
			 if(oWrapper.oInput.name == "MatchingThankYouNote_CardCheck" && document.getElementsByName("tynenvtext_CardCheck")(0).checked == true)
			 {
				document.getElementsByName("tynenvtext_CardCheck")(0).checked=false;
				document.getElementsByName("tynenvtext_CardCheck")(0).parentNode.parentNode.className=document.getElementsByName("tynenvtext_CardCheck")(0).parentNode.parentNode.className.replace(" isChecked", " unChecked");
			 }
		}
		else
		{
		}
		oWrapper.className = oWrapper.className.replace(" isChecked", " unChecked");
	}

}


function selectCheckbox(sInputId)
{
	var oInput = document.getElementById( sInputId );
	var oWrapper = oInput.parentNode.parentNode;
	oWrapper.oInput.checked = true;
	
	if (oWrapper.className.indexOf(' unChecked')>-1)
	{
		oWrapper.className = oWrapper.className.replace(" unChecked", " isChecked");
	}
}