// ###############################################################################//	SelectShade(fieldobject)	// 	Called by: Clicking Checkbox//    Aden Roper// ###############################################################################function SelectShade(fieldvalue , fieldchecked) {		// One or more shades were selected - create/update cookie containing the user's selections:	//alert(fieldvalue)	//alert(fieldchecked)				SampleRequestCookie = getCookie("SampleRequestCookie");		     	if (SampleRequestCookie =='' | SampleRequestCookie ==null )					{		// Cookie does not exist			// Prepend start marker to cookie content to enable LotusScript agents to identify where this cookie starts and end as all cookies 		SampleRequestCookieContent ="?#?";		SampleRequestCookieContent += fieldvalue +"-1#"		SampleRequestCookieContent += "#?#";					var NextYear=new Date();		NextYear.setFullYear(NextYear.getFullYear() + 1);				setCookie("SampleRequestCookie", SampleRequestCookieContent , null , "/" );		return;		}			// SampleRequests Cookie DOES exist:	SampleRequestCookie = rightString(leftString(SampleRequestCookie,"#?#"),"?#?");		// Make sure that if we get the value "?" back from the above code (meaning there is no values left) we need to remove it as it messes up the start of the array.	if(SampleRequestCookie.length == 1)	{	SampleRequestCookie = ""	}			// Check we have enough room to store these selections:	// ==============================================	// Actual max size of cookie = 4000 characters, but subtract the number of characters in the SampleRequestCookie from 3600, to allow 	// for Domino inserted labels and other cookie content etc	if ((3600 - SampleRequestCookie.length) < fieldvalue.length)	{				alert("The maximum number of samples possible has been reached.\n Before you can add these samples to your basket,\n it will be necessary for you unselect some of your existing selections");			return;	}		if(fieldchecked == true)	{	SampleRequestCookie= "?#?" + SampleRequestCookie+fieldvalue+"-1#" + "#?#" 	}		else	{		// Remove start and end markers from the cookie:	SampleRequestCookieArray = SampleRequestCookie.split("#");		var theNewCookieArray = removeItems(SampleRequestCookieArray , fieldvalue);	SampleRequestCookie= "?#?" + trim(theNewCookieArray.join("#")) + "#?#" 	}		// Delete the existing cookie:	delCookie("SampleRequestCookie","<Computed Value>");	// Write the updated cookie	var NextYear=new Date();	NextYear.setFullYear(NextYear.getFullYear() + 1);	setCookie("SampleRequestCookie",SampleRequestCookie,null,"/");	return;			}// ###############################################################################//	removeItems(array,value)	//    Aden Roper// ###############################################################################	function removeItems(array, item) {	var i = 0;	while (i < array.length) 	{		if (leftString( array[i] ,"-") == item) {		array.splice(i, 1);		} 		else		 {i++;}	}	return array;	}// ###############################################################################////	PrimeSamplePicker(ShadeDoc) //// 	Called from onLoad event of Product Home Page//// 	Takes the user selected shade indexes  from the cookie and uses them to populate //	appropriate shade check boxes// // ###############################################################################function PrimeSamplePicker(ShadeDoc) {			CookieShadesIDsString = getCookie("SampleRequestCookie");	if (CookieShadesIDsString == '' | CookieShadesIDsString == null ) 			{		// alert("PrimeSamplePicker - No cookie found");			return;		}	// Remove start and end markers from the cookie:	CookieShadesIDsString = rightString(leftString( CookieShadesIDsString ,"#?#"),"?#?");	// alert("SelectedShadeIndexesString =" +SelectedShadeIndexesString);	// Convert cookie content to an array:	CookieShadesIDsArray = CookieShadesIDsString.split("#");		CookieShadesIDsArray.length = CookieShadesIDsArray.length-1		//check if it is one checkbox instead of an array of the same AR	if( isObject( ShadeDoc.prod_shades1) && ShadeDoc.prod_shades1.length ){	//if( isCheckboxArray(ShadeDoc.prod_shades1) == true ){	//if(ShadeDoc.prod_shades1.length){	//process through the list (meaning it is the Range page with multiple swatches		for ( i=0; i<ShadeDoc.prod_shades1.length; i++) 		{				for ( y=0 ; y < CookieShadesIDsArray.length ; y++) 				{				//alert(trim(ShadeDoc.prod_shades1[i].value) + "-" + trim(leftString(CookieShadesIDsArray[y],"-") ));				//alert(CookieShadesIDsArray)				if( trim(ShadeDoc.prod_shades1[i].value) == trim(leftString(CookieShadesIDsArray[y] ,"-"))  ) 						{ShadeDoc.prod_shades1[i].checked=true; }				}		}	}	else	{	//process on the one swatch as we must be on the single swatch only page				for (y=0; y < CookieShadesIDsArray.length; y++) 				{				//alert(CookieShadesIDsArray[y])				if( trim(ShadeDoc.prod_shades1.value) == trim(leftString(CookieShadesIDsArray[y],"-")) ) 						{ShadeDoc.prod_shades1.checked=true; }				}	}}
