var exclude=1;
var agt=navigator.userAgent.toLowerCase();
var win=0;var mac=0;var lin=1;
if(agt.indexOf('win')!=-1){win=1;lin=0;}
if(agt.indexOf('mac')!=-1){mac=1;lin=0;}
var lnx=0;if(lin){lnx=1;}
var ice=0;
var ie=0;var ie4=0;var ie5=0;var ie6=0;var ie7=0;var com=0;var dcm;
var op5=0;var op6=0;var op7=0;
var ns4=0;var ns6=0;var ns7=0;var mz7=0;var kde=0;var saf=0;
if(typeof navigator.vendor!="undefined" && navigator.vendor=="KDE"){
	var thisKDE=agt;
	var splitKDE=thisKDE.split("konqueror/");
	var aKDE=splitKDE[1].split("; ");
	var KDEn=parseFloat(aKDE[0]);
	if(KDEn>=2.2){
		kde=1;
		ns6=1;
		exclude=0;
		}
	}
else if(agt.indexOf('webtv')!=-1){exclude=1;}
else if(typeof window.opera!="undefined"){
	exclude=0;
	if(/opera[\/ ][5]/.test(agt)){op5=1;}
	if(/opera[\/ ][6]/.test(agt)){op6=1;}
	if(/opera[\/ ][7-9]/.test(agt)){op7=1;}
	}
else if(typeof document.all!="undefined"&&!kde){
	exclude=0;
	ie=1;
	if(document.documentElement && typeof document.documentElement.style.maxHeight!="undefined"){
        ie7=1;
	}
	else if(typeof document.getElementById!="undefined"){
		ie5=1;
		if(agt.indexOf("msie 6")!=-1){
			ie6=1;
			dcm=document.compatMode;
			if(dcm!="BackCompat"){com=1;}
			}
		}
	else{ie4=1;}
	}
else if(typeof document.getElementById!="undefined"){
	exclude=0;
	if(agt.indexOf("netscape/6")!=-1||agt.indexOf("netscape6")!=-1){ns6=1;}
	else if(agt.indexOf("netscape/7")!=-1||agt.indexOf("netscape7")!=-1){ns6=1;ns7=1;}
	else if(agt.indexOf("gecko")!=-1){ns6=1;mz7=1;}
	if(agt.indexOf("safari")!=-1 || (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined")){mz7=0;ns6=1;saf=1;}
	}
else if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)){
	exclude=0;
	ns4=1;
	if(typeof navigator.mimeTypes['*']=="undefined"){
		exclude=1;
		ns4=0;
		}
	}
if(agt.indexOf('escape')!=-1){exclude=1;ns4=0;}
if(typeof navigator.__ice_version!="undefined"){exclude=1;ie4=0;}

var menuLocation = "";
var strMainMenuOver = "";
var strMainMenuSet = "";
var intMenuOnCounter = 0;
var bolCanHideMenu = true;
var rolloutMenuWidth = 132;
var menuInitialized = false;

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  if(strMainMenuOver != "" && document.MM_sr) {x=document.MM_sr[0];x.src=x.oSrc;}
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  MM_menuRollover(x.name);
}

function getElementSafe(id)
{
	var retval;
	if(document.getElementById){
		retval = document.getElementById(id);
	}
	else if(document.all){
		retval = document.all[id];
	}
	else if(document.layers)
	{
		retval = document.layers[id];
	}
	return retval;
}

function MM_menuRollover(strMenu)
{
	if(menuInitialized)
	{
		bolCanHideMenu = false;
		strMainMenuSet = strMenu;
		
		if(strMainMenuOver != "" && strMainMenuOver != strMenu) {
			mainMenuOff(strMainMenuOver);
		}

		var objDiv;
		objDiv = getElementSafe('navigation_menu_rollover_SUBMENU_'+ strMenu);
		if (objDiv && objDiv.style)	{
			objDiv.style.visibility = "visible";
			strMainMenuOver = strMenu; // set the main menu over
		} else {
			strMainMenuOver = "";
		}
	}
}

function MM_menuRollout(strMenu)
{
	if(strMainMenuOver == "")
		MM_swapImgRestore();
	bolCanHideMenu = true;
}

function mainMenuOff(menuOff)
{
	var objDiv;
	objDiv = getElementSafe('navigation_menu_rollover_SUBMENU_'+ menuOff);
	if (objDiv && objDiv.style)
	{
		objDiv.style.visibility="hidden";
	}
	strMainMenuOver = "";
	intMenuOnCounter = 0;
}


function subMenuRollOver(intMenuItem)
{
	bolCanHideMenu = false;
}

function subMenuRollOut(intMenuItem)
{
	bolCanHideMenu = true;
	intMenuOnCounter = 0;
}

function checkMenus()
{
	if((strMainMenuOver != "") && (bolCanHideMenu == true))
	{
		intMenuOnCounter = intMenuOnCounter + 1;
		if(intMenuOnCounter > 15)
		{
			mainMenuOff(strMainMenuOver);
			var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
		}
	}
}

window.setInterval("checkMenus()", 50);

function resetMenuCoordinates()
{
	if(typeof(menunames) != 'undefined')
	{
		for(i=0;i<menunames.length;i++)
		{
		    var alignRight = false;
			if(i == menunames.length - 1) {
				alignRight = true;
			}
			var rolloutMenuDiv = getElementSafe('navigation_menu_rollover_SUBMENU_' + menunames[i]);
			var imageThing = getElementSafe('navigation_' + menunames[i]);
			if(imageThing != null && rolloutMenuDiv != null)
			{
				rolloutMenuDiv.style.top = (imageThing.offsetTop + imageThing.offsetHeight) + 'px';
				if(alignRight == false)
					rolloutMenuDiv.style.left = (imageThing.offsetLeft) + 'px';
				else
					rolloutMenuDiv.style.left = ((imageThing.offsetLeft + imageThing.offsetWidth) - rolloutMenuDiv.offsetWidth) + 'px';
			}
		}
		if(resizeFunc != null)
			resizeFunc.call();
	}
}

var resizeFunc = null;
function setupMenuPositioning()
{
	if(window.onresize != null)
		resizeFunc = window.onresize;
	
	window.onresize = resetMenuCoordinates;
	resetMenuCoordinates();
	menuInitialized = true;
}

/* Gets the window position for IE and Firefox, at least */
function windowLeft() {return typeof window.screenLeft != 'undefined' ? window.screenLeft : typeof window.screenX != 'undefined' ?  window.screenX : 0;} 
function windowTop() {return typeof window.screenTop != 'undefined' ? window.screenTop : typeof window.screenY != 'undefined' ?  window.screenY : 0;} 

function popUp(url, width, height, menubar, name, top, left) 
{
	var strName;
	if(!top)
	{
		if(height)
		{
			top = (screen.height / 2 - height / 2);
			if(document.body.offsetHeight == height)
			{
			    top += 50;
			    if(Math.abs(windowTop() - top) < 50)
			    {
			        top += 50;
			    }
			}
		}
		else
			top = 50;
	}
	if(!left)
	{
		if(width)
		{
			left = (screen.width / 2 - width / 2);
			if(document.body.offsetWidth == width)
			{
			    left += 50;
			    if(Math.abs(windowLeft() - left) < 50)
			    {
			        left += 50;
			    }
			}
		}
		else
			left = 100;
	}
	if(name) strName = name; else strName = "popup"
	if(menubar)
		window.open(url,strName,'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
	else
	{
		window.open(url,strName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
	}
}

function popUpDrilldown(url,name, width, height)
{
	if (width == null)
		width = 800;
	if (height == null)
		height = 600;
	popUp(url, width, height, false, name);
}

function popUpConfirmation(url,name)
{
	popUp(url, 360, 240, false, name);
}

function popUpLookup(url,hiddenName)
{
	var retVal = false;
	var returnId = "";
	returnId = window.showModalDialog(url,'','dialogHeight:400px;dialogWidth:500px');
	if(returnId != "" && returnId != undefined)
	{
		var hiddenField = document.getElementById(hiddenName);
		hiddenField.value = returnId;
		retVal = true;
	}
	return(retVal);
}

var ctrlPressed=0;
var altPressed=0;
var shiftPressed=0;
function mouseDown(e)
{
	if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName=="Netscape") 
		{
			if(parseInt(navigator.appVersion) < 5)
			{
				var mString = (e.modifiers+32).toString(2).substring(3,6);
				shiftPressed = (mString.charAt(0)=="1");
				ctrlPressed = (mString.charAt(1)=="1");
				altPressed  = (mString.charAt(2)=="1");
			}
			else
			{
				shiftPressed = e.shiftKey;
				altPressed = e.altKey;
				ctrlPressed = e.ctrlKey;
			}
		}
		else
		{
			shiftPressed = event.shiftKey;
			altPressed  = event.altKey;
			ctrlPressed = event.ctrlKey;
		}
	}
	return true;
}

if (parseInt(navigator.appVersion)>3)
{
	document.onmousedown = mouseDown;
	if (navigator.appName=="Netscape") 
		document.captureEvents(Event.MOUSEDOWN);
}

function resetDivHeight(divName, lessHeight)
{
	var divElement = getElementSafe(divName);
	if(!divElement)
		alert('could not find ' + divName);
	var divHeight = document.body.clientHeight - lessHeight;
	if(divHeight > 0)
	    divElement.style.height = divHeight + 'px';
}

function resetDivWidth(divName, lessWidth)
{
	var divElement = getElementSafe(divName);
	if(!divElement)
		alert('could not find ' + divName);
	var divWidth = document.body.clientWidth - lessWidth;
	if(divWidth > 0)
	    divElement.style.width = divWidth + 'px';
}

function resetDivAbsoluteWidth(divName, absWidth)
{
    var divElement = getElementSafe(divName);
	if(!divElement)
		alert('could not find ' + divName);	
	if(absWidth > 0)
	    divElement.style.width = absWidth + 'px';
}

function addEvent(obj, evType, fn)
{ 
    if (obj.addEventListener)
    { 
      obj.addEventListener(evType, fn, false); 
      return true; 
    }
    else if (obj.attachEvent)
    { 
      var r = obj.attachEvent("on"+evType, fn); 
      return r; 
    }
    else
    { 
      return false; 
    } 
}

/* for Dev purposes */
function showWidth(control)
{
	alert(control.id + '\'s width = ' + control.offsetWidth);
}
function showHeight(control)
{
	alert(control.id + '\'s height  = ' + control.offsetHeight);
}

var pageHeaderHeight = 63;
var gutterCurveTopHeight = 30;
var searchBarAreaHeight = 33;
var listToolbarHeaderHeight = 38;
var listToolbarHeight = 34;
var listColumnHeight = 21;
var listPageTable = 21;
var gridFooterHeight = 20;
var listFooterHeight = 12;
var pageFooterHeight = 46;
var bottomMargin = 17; // offset by 7 for firefox

/* Fix IE Background Image Flicker */
if (ie) {
    try {
        document.execCommand("BackgroundImageCache", false, true);
    } catch(e) {}
}

/* BEGIN CUSTOMER FOOTER */
var gridFooterTimeoutDelay = 200;

function buildPagerHtml(grid,footerId)
{
    var htmlPager = "";
    var mid = Math.floor(maxPagerSpan / 2);
    var startPage = grid.PageCount <= maxPagerSpan ? 0 : Math.max(0, grid.CurrentPageIndex - mid);
    // adjust range for last few pages
    if (grid.PageCount > maxPagerSpan)
    {
      startPage = grid.CurrentPageIndex < (grid.PageCount - mid) ? startPage : grid.PageCount - maxPagerSpan;
    }
    
    var endPage = grid.PageCount <= maxPagerSpan ? grid.PageCount : Math.min(startPage + maxPagerSpan, grid.PageCount);
    
    var buildCustomFooterScript2 = "buildCustomFooter(" + grid.Id + ",\\'" + footerId + "\\');";
    var buildCustomFooterScript = "buildCustomFooter(" + grid.Id + ",'" + footerId + "');";

    if (grid.PageCount > maxPagerSpan && grid.CurrentPageIndex > mid)
    {
      htmlPager += "<a href=\"#\" onclick=\"" + grid.Id + ".Page(0);" + buildCustomFooterScript + "return false;\">&laquo;&nbsp;First</a>&nbsp;...&nbsp;";
      htmlPager += "<a href=\"#\" onclick=\"" + grid.Id + ".PreviousPage();" + buildCustomFooterScript + "return false;\">&lt;</a>&nbsp;";
    }
    
    for (var page = startPage; page < endPage; page++)
    {
        var showPage = page + 1;
        if (page == grid.CurrentPageIndex)
        {
            htmlPager += showPage + '&nbsp;';
        }
        else
        {
            htmlPager += "<a href=\"#\" onclick=\"" + grid.Id + ".Page(" + page + ");" + buildCustomFooterScript + "return false;\">" + showPage + "</a>&nbsp;";
        }
    }
    
    if (grid.PageCount > maxPagerSpan && grid.CurrentPageIndex < grid.PageCount - mid)
    {
        htmlPager += "<a href=\"#\" onclick=\"" + grid.Id + ".NextPage();" + buildCustomFooterScript + "return false;\">></a>&nbsp;...&nbsp;";
        htmlPager += "<a href=\"#\" onclick=\"" + grid.Id + ".Page(" + (grid.PageCount - 1) + ");" + buildCustomFooterScript + "return false;\">Last&nbsp;&raquo;</a>&nbsp;";
    }
    
    return htmlPager;
}

function buildPageXofYHtml(grid)
{
    var htmlPageXofY;

    if(grid.PageCount == 0)
        htmlPageXofY = '0 items';
    else
        htmlPageXofY = "Page&nbsp;<strong>" + (grid.CurrentPageIndex + 1) + "</strong>&nbsp;of&nbsp;<strong>" + (grid.PageCount) + "</strong>&nbsp;(" + grid.RecordCount + '&nbsp;items)';

    return htmlPageXofY;
}

function onPage(newPage,grid,gridId)
{
    // delay call so that Grid's client properties have their new values
    setTimeout("showCustomFooter();",gridFooterTimeoutDelay);
    return true;
}

var grids = new Array();
var gridIds = new Array();
var tableIds = new Array();
var maxPagerSpan = 5; // should be at least 2

function AddItemToCart(cmsRootPath, cartItemId)
{
    redirectLocation = window.location;
	membershipType = 0;
	donorType = 0;
	radioButtons = document.getElementsByName("membershipType");
	donorTypeRadioButtons = document.getElementsByName("donorType");
	membershipTypeSelected = false;
	donorTypeSelected = false;
	
	if (radioButtons != null)
	{
		i = 0;
		while (i < radioButtons.length)
		{
			if (radioButtons[i].checked)
			{
				membershipType = radioButtons[i].value;
				redirectLocation = cmsRootPath + "/Cart/PayInvoice.aspx";
				membershipTypeSelected = true;
			}
			i++;
		}
		
		if (membershipTypeSelected == false && radioButtons.length > 0)
		{
		    alert('Please select a membership option: Join, Upgrade or Renew');
		    return;
		}
	}
	
	if (donorTypeRadioButtons != null)
	{
		i = 0;
		while (i < donorTypeRadioButtons.length)
		{
			if (donorTypeRadioButtons[i].checked)
			{
				donorType = donorTypeRadioButtons[i].value;
				redirectLocation = cmsRootPath + "/Cart/PayInvoice.aspx";
				donorTypeSelected = true;
			}
			i++;
		}
		
		if (donorTypeSelected == false && donorTypeRadioButtons.length > 0)
		{
		    alert('Please select your entity type: "Individual" or "Firm or Organization"');
		    return;
		}
	}
	
	monthlyOption = 0;
	//radioButtons = document.getElementsByName("priceSelectionRadio_" + cartItemId);
	radioButtons = document.getElementsByName("priceSelectionRadio");
	priceSelected = false;
	if (radioButtons != null)
	{
		i = 0;
		while (i < radioButtons.length)
		{
			if (radioButtons[i].checked)
			{
				monthlyOption = radioButtons[i].value;
				if ((radioButtons[i].id == "priceSelectionRadio_" + cartItemId) || 
				    (radioButtons[i].id == "priceSelectionRadio_Monthly_" + cartItemId))
				{
				    priceSelected = true;
				}
			}
			i++;
		}
		
		if (priceSelected == false && radioButtons.length > 0)
		{
		    alert('Please select a payment option.');
		    return;
		}
	}
	
	sponsorshipComments = document.getElementById("sponsorshipComments");
	sponsorshipCommentsText = '';
	if (sponsorshipComments != null)
	{
	    if (sponsorshipComments.value != null && sponsorshipComments.value != '')
	    {
	        sponsorshipCommentsText = sponsorshipComments.value;
	    }
	}
	
    additionalInfo = document.getElementById("additionalInfo_" + cartItemId);
	additionalInfoProvided = true;
	
	proceedWithRedirect = true;
	alertMessage = '';
	
	
	
	redirectString = cmsRootPath + "/Cart/AddToCart.aspx?itemToAdd=" + cartItemId + "&monthlyOption=" + monthlyOption  + "&option=" + membershipType + "&membershipType=1" + "&donorType=" + donorType + "&sponsorshipComments=" + sponsorshipCommentsText + "&returnUrl=" + redirectLocation;
	
	if (additionalInfo != null)
	{
		if (additionalInfo.value != null && additionalInfo.value != '')
		{
			redirectString += "&additionalInfo=" + additionalInfo.value;	
		}
		else
		{
		    additionalInfoProvided = false;
		    alert('Please provided additional information requested for the item selected');
		    return;
		}
	}
	
	
	
	if (proceedWithRedirect)
		window.location = redirectString;
}

function buildCustomFooter(grid, footerId)
{
    if (typeof(grid) != 'undefined')
    {
        var pagerCellId = footerId + '_pagerCell';
        var pagerCell = document.getElementById(pagerCellId);
        var pagerHtml = buildPagerHtml(grid,footerId);
        pagerCell.innerHTML = pagerHtml;
        
        var indexCellId = footerId + '_indexCell';
        var indexCell = document.getElementById(indexCellId);
        var pageXofYHtml = buildPageXofYHtml(grid);
        indexCell.innerHTML = pageXofYHtml;
    }
    else
    {
        setTimeout('buildCustomFooter(' + grid.Id + '\'' + footerId + '\');', gridFooterTimeoutDelay);
    }
}
/* END CUSTOMER FOOTER */

function fredBaronGiftAmtUrl(cmsRootPath, cartItemId)
{
	cartAmt = document.getElementById("cartItemAmt_" + cartItemId).value;
    
    if (cartAmt != null && cartAmt != '' && cartAmt != '0' && cartAmt.length != 0)
	{
		re = /^\$|,/g;
		cartAmt = cartAmt.replace(re, "");
		fieldamount = parseFloat(cartAmt);
		if (fieldamount > 0)
			window.location = cmsRootPath + "/Cart/AddToCart.aspx?itemToAdd=" + cartItemId + "&giftAmt=" + fieldamount + "&returnUrl=" + cmsRootPath + "/Cart/PayInvoice.aspx";	
		else
			alert('Please enter a valid Gift Amount');
	}
	else
	{
		alert('Please enter a valid Gift Amount');
	}
}

function fredBaronSpecialGiftAmtUrl(cmsRootPath, cartItemId, price)
{
	fieldamount = parseFloat(price);
	if (fieldamount > 0)
		window.location = cmsRootPath + "/Cart/AddToCart.aspx?itemToAdd=" + cartItemId + "&giftAmt=" + fieldamount + "&returnUrl=" + cmsRootPath + "/Cart/PayInvoice.aspx";	
	else
		alert('Please enter a valid Gift Amount');
}

function giftAmtUrl(cmsRootPath, cartItemId, cartItemType)
{
	
	cartAmt = document.getElementById("cartItemAmt_" + cartItemId).value;
    
    if (cartAmt != null && cartAmt != '' && cartAmt != '0' && cartAmt.length != 0)
	{
		re = /^\$|,/g;
		cartAmt = cartAmt.replace(re, "");
		fieldamount = parseFloat(cartAmt);
		if (fieldamount > 0) {

			if (cartItemType != 5) { //5 is the type for honor or memory cart items. We have to save the user message on those ones.
				window.location = cmsRootPath + "/Cart/AddToCart.aspx?itemToAdd=" + cartItemId + "&giftAmt=" + fieldamount + "&returnUrl=" + window.location;
			}
			else {
				var cartMessage;
				var alertMessage = 'Please select whether and for whom this gift is in honor or in memory of';

				if (document.getElementById("honorRadioButton_" + cartItemId).checked) {
					cartMessage = "In Honor Of " + document.getElementById("honorTextBox_" + cartItemId).value;
				}
				else if (document.getElementById("memoryRadioButton_" + cartItemId).checked) {
					cartMessage = "In Memory Of " + document.getElementById("memoryTextBox_" + cartItemId).value;
				}
				else {
					alert(alertMessage);
				}

				if (cartMessage != undefined && cartMessage != '') {
					window.location = cmsRootPath + "/Cart/AddToCart.aspx?itemToAdd=" + cartItemId + "&giftAmt=" + fieldamount + "&additionalInfo=" + escape(cartMessage) + "&returnUrl=" + window.location;
				}
				else {
					alert(alertMessage);
				}

			}
		}
		else
			alert('Please enter a valid Gift Amount');
	}
	else
	{
		alert('Please enter a valid Gift Amount');
	}
	
}

function specialGiftAmtUrl(cmsRootPath, cartItemId, price)
{
	fieldamount = parseFloat(price);
	if (fieldamount > 0)
		window.location = cmsRootPath + "/Cart/AddToCart.aspx?itemToAdd=" + cartItemId + "&giftAmt=" + fieldamount + "&returnUrl=" + window.location;	
	else
		alert('Please enter a valid Gift Amount');
}

function optionsAddToCartUrl(cmsRootPath, cartItemId)
{
	size = document.getElementById("sizeSelect_" + cartItemId);
	color = document.getElementById("colorSelect_" + cartItemId);
	quantity = document.getElementById("quantity_" + cartItemId);
	proceedWithRedirect = true;
	alertMessage = '';
	
	redirectString = cmsRootPath + "/Cart/AddToCart.aspx?itemToAdd=" + cartItemId + "&returnUrl=" + window.location;
	
	if (size != null)
	{
		if (size.value != null && size.value != '' && size.value != '0' && size.length.value != 0)
		{
			if (size.value != 'Size')
				redirectString += "&option=" + size.value;	
			else
			{
				proceedWithRedirect = false;
				alertMessage += 'Please select a size.  ';
			}
		
		}
	}
	
	if (color != null)
	{
		if (color.value != null && color.value != '' && color.value != '0' && color.value.length != 0)
		{
			if (color.value != 'Color')
				redirectString += "&color=" + color.value;	
			else
			{
				alertMessage += 'Please select a color.  ';
				proceedWithRedirect = false;
			}
		}
	}
	
	if (quantity != null)
	{
		if (quantity.value == null || quantity.value == '' || quantity.value == '0' || quantity.value.length == 0)
		{
			quantity.value = 1;
		}
	}
	else
	{
		quantity.value = 1;
	}
	qtyVal = parseInt(quantity.value);
	if (qtyVal > 1)
	{
		redirectString += "&quantity=" + qtyVal;
	}
	else
	{
		qtyVal = 1;
		redirectString += "&quantity=" + qtyVal;
	}

	if (proceedWithRedirect)
		window.location = redirectString;
	else
		alert(alertMessage);

}

function payInvoiceRedirect(cmsRootPath)
{
	membershipType = 0;
	radioButtons = document.getElementsByName("membershipType");
	if (radioButtons != null)
	{
		i = 0;
		while (i < radioButtons.length)
		{
			if (radioButtons[i].checked)
			{
				membershipType = radioButtons[i].value;
			}
			i++;
		}
	}

	window.location = cmsRootPath + "/Cart/PayInvoice.aspx?returnUrl=" + window.location + "&membershipType=" + membershipType;
		
}

function createCookie(name,value,minutes) {
	if (minutes) {
		var date = new Date();
		date.setTime(date.getTime()+(minutes*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

