function Rcertify() { 
popupWin = window.open('http://www.bbbonline.org/cks.asp?id=11000333', 
'Participant', 'location=yes,scrollbars=yes,resizable=yes,width=800,height=500') 
window.name = 'opener'; 
}
function openWindowReturnRef(url,winName,width,height){
	var winRef = window.open(url,winName, "height=" + height + ",width=" + width + ",status=yes,toolbar=no,menubar=no,location=no,directories=no,resizable=yes,scrollbars=yes,titlebar=no");
	return winRef;
}

function openWindow(url,winName,width,height){
	var winRef = openWindowReturnRef(url,winName,width,height);
}
function openLongWindow(url,winName,width,height,top,left){
	var winRef = openLongWindowReturnRef(url,winName,width,height,top,left)
}
function openLongWindowReturnRef(url,winName,width,height,top,left){
var winRef = window.open(url,winName, "height=" + height + ",width=" + width + ",top=" + top + ",left=" + left + ",status=yes,toolbar=no,menubar=no,location=no,directories=no,resizable=yes,scrollbars=yes,titlebar=no");
	return winRef;
}
/*function OpenEmailFriendWindow(url,prodName, categoryText){
	var urlqs = url + '?productName=' + prodName + "&productUrl=" + escape(location.href)+ "&categoryText=" + categoryText;
	var emailWin = openWindowReturnRef(urlqs,'Email',460,500);
}*/
function OpenEmailFriendWindow(url,prodName, categoryText, image){
	var urlqs = url + '?productName=' + prodName + "&productUrl=" + escape(location.href)+ "&categoryText=" + categoryText+ "&img=" + escape(image);
	var emailWin = openWindowReturnRef(urlqs,'Email',460,500)
}


function OpenLargeImageWindow(imgName,prodName){
	var win = openWindowReturnRef('','LargeImage',420,300);
	var docHtml = "<center><h3>" + prodName + "</h3><img src=/Crafters_assets/images/product/" + imgName + "><br><br><a href=javascript:window.close()><img src=/Crafters_assets/images/closewin.gif width=122 height=22 border=0></a></center>";
	win.document.write(docHtml);
	win.focus();
}

function OpenLargeImageSampleCheck(imgName){
	var win = openWindowReturnRef('','LargeImage',420,300);
	var docHtml = "<center><h3>Sample Check</h3><img src=/Crafters_assets/images/global/" + imgName + "><br><br><a href=javascript:window.close()><img src=/Crafters_assets/images/product/closewin.gif width=122 height=22 border=0></a></center>";
	win.document.write(docHtml);
	win.focus();
}


function ValidateCheckSearch(searchVal){
	if(searchVal.length > 0){
		return true;
	}else{
		alert("Please enter a keyword.");
		return false;		
	}
}


var iInitSelectedIndex;
var oLastFocusedSelect = null;

function SetInitialSelectedIndex(oSelect){
	if(oSelect){
		if(oSelect != oLastFocusedSelect){					
			iInitSelectedIndex = oSelect.selectedIndex;
			oLastFocusedSelect = oSelect;
		}
	}
}
var updating = false;
function checkUpdating(){
	if (updating)return false;
	else return true;}
function disableSubmit(){
         updating = true;}
	
    function UpdateQty(oSelect){
	if(oSelect){
	    updating = true;
	    
		var bUpdateQty = true;
		var oForm = oSelect.form;
		var sStartPattern = "_ctl";
		var sEndPattern = ":ddlQty";
		var iStartIndex = (oSelect.name).indexOf(sStartPattern) + sStartPattern.length;
		var iQtyStringLength = (oSelect.name).indexOf(sEndPattern) - iStartIndex;
		var iItemIndex = (oSelect.name).substr(iStartIndex, iQtyStringLength) - 1;
		var iNewQty = oSelect.options[oSelect.selectedIndex].value;
		
		if(oForm.valuePackDiscount){
			if(oForm.valuePackDiscount.value < 0){
				if(oSelect.selectedIndex < iInitSelectedIndex){
					bUpdateQty = window.confirm("Decreasing the quantity of this product could potentially make you ineligible for any Value Pack discount for which you currently qualify.  Would you like to proceed?");
				}	
			}
		}

		if(bUpdateQty){
			if(oForm.hasQtyChanged) oForm.hasQtyChanged.value = "yes";
			if(oForm.newLineItemQty) oForm.newLineItemQty.value = iNewQty;
			if(oForm.lineItemIndex) oForm.lineItemIndex.value = iItemIndex;
			oForm.submit();
		}else{
			oSelect.selectedIndex = iInitSelectedIndex;
			oLastFocusedSelect = null;
			oSelect.blur();
		}
	}			
}
function UpdateUnitQty(oSelect){
	if(oSelect){
		var bUpdateQty = true;
		var oForm = oSelect.form;
		var sStartPattern = "_ctl";
		var sEndPattern = ":ddlQty";
		var iStartIndex = (oSelect.name).indexOf(sStartPattern) + sStartPattern.length;
		var iQtyStringLength = (oSelect.name).indexOf(sEndPattern) - iStartIndex;
		var iItemIndex = (oSelect.name).substr(iStartIndex, iQtyStringLength) - 1;
		var iNewQty = oSelect.options[oSelect.selectedIndex].value;
		var iNewQtyText = oSelect.options[oSelect.selectedIndex].text;
		var iNewUnitQty = iNewQtyText/iNewQty;
		
		if(oForm.valuePackDiscount){
			if(oForm.valuePackDiscount.value < 0){
				if(oSelect.selectedIndex < iInitSelectedIndex){
					bUpdateQty = window.confirm("Decreasing the quantity of this product could potentially make you ineligible for any Value Pack discount for which you currently qualify.  Would you like to proceed?");
				}	
			}
		}

		if(bUpdateQty){
			if(oForm.hasQtyChanged) oForm.hasQtyChanged.value = "yes";
			if(oForm.newLineItemQty) oForm.newLineItemQty.value = iNewQty;
			if(oForm.newLineItemQty) oForm.newLineItemUnitQty.value = iNewUnitQty;
			if(oForm.lineItemIndex) oForm.lineItemIndex.value = iItemIndex;
			oForm.submit();
		}else{
			oSelect.selectedIndex = iInitSelectedIndex;
			oLastFocusedSelect = null;
			oSelect.blur();
		}
	}			
}
function newtab(id,myobject) {

	// define tab ID's
	var tabs = new Array("divmono","divcuts");
	
	// highlight selected
	var tabobj=document.getElementById("tablist")
	var tabobjlinks=tabobj.getElementsByTagName("li")
		if(id!="divmono")
		{
			tabobjlinks[0].className="normal"
			tabobjlinks[1].className="current"
		}else
		{
			tabobjlinks[1].className="normal"
			tabobjlinks[0].className="current"
		}

	// loop over tabs array to find out what to hide/unhide
	for (i=0; i<tabs.length; i++) {
		if(tabs[i]==id) {
			document.getElementById(id).style.display="block"
		} else {
			document.getElementById(tabs[i]).style.display="none"
		}
		
	}
	return false;
}

function showonetab(id)
{
	// define tab ID's
	var tabs = new Array("divmono","divcuts");
	
	// highlight selected
	var tabobj=document.getElementById("tablist")
	var tabobjlinks=tabobj.getElementsByTagName("li")
	if(id!="divmono")
	{
		tabobjlinks[0].className="normal"
		tabobjlinks[1].style.display="none"
	}else
	{
		tabobjlinks[0].style.display="none"
		tabobjlinks[1].className="normal"
	}
	
	// loop over tabs array to find out what to hide/unhide
	for (i=0; i<tabs.length; i++) {
		if(tabs[i]==id) {
			document.getElementById(id).style.display="block"
		} else {
			document.getElementById(tabs[i]).style.display="none"
		}
		
	}	
}

function checkOptOut(objSite,objPartner,objAction)
{
	if(objAction == "optout")
	{
		if(objSite.checked != true)
		{
			objPartner.checked = false;
		}
	}
	else
	{
		if(objPartner.checked == true)
		{
			objSite.checked = true;
		}
	}
}

/* For personal page                    */   		 
	function SetValue(fieldName,fieldValue)   		 
	{      		 
	   var cookieValue = getCookie("valuestr");                  		 
	   setCookie(fieldName,fieldValue,cookieValue);   		 
	}   		 
	  		 
	function resetCookie()   		 
	{                  		 
	   var expiredays = 0;   		 
	   var exdate=new Date();   		 
	   exdate.setDate(exdate.getDate()+expiredays);   		 
	   document.cookie="valuestr"+ "=" +escape("")+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());   		 
	}   		 
	  		 
	function setCookie(fieldName,newFieldValue,cookieValue)   		 
	{   		 
	   var cookieArray = cookieValue.split('+++');   		 
	   var arrayLength = cookieArray.length;      		 
	   if(cookieValue == "")   		 
	   arrayLength = 0;   		 
   var newCookieStr = "";      		 
	         		 
	   for(var i= 0; i< arrayLength; i++)   		 
	   {                      		 
	       var fieldvalue = cookieArray[i];   		 
	       var fieldArray = fieldvalue.split(':::');                      		 
	       if(fieldArray[0] != fieldName)   		 
	       {                          		 
	           if(newCookieStr == "")   		 
	           {   		 
	               newCookieStr = newCookieStr + fieldvalue;   		 
	           }   		 
	           else   		 
	           {   		 
	               newCookieStr = newCookieStr + "+++" + fieldvalue;   		 
	           }                          		 
	       }                      		 
	                 		 
	   }      		 
	     		 
	   cookieArray = newCookieStr.split('+++');   		 
	   arrayLength = cookieArray.length;   		 
	   if(newCookieStr == "")   		 
	   arrayLength = 0;                  		 
	     		 
	   if(arrayLength > 0)   		 
	   {   		 
	       newCookieStr = newCookieStr + "+++" + fieldName + ":::" + newFieldValue;   		 
	   }   		 
	   else   		 
	   {   		 
	       newCookieStr = fieldName + ":::" + newFieldValue;   		 
	   }   		 
	                 		 
	     		 
	   //setCookie("valuestr",newCookieStr,1);   		 
	   var expiredays = 1;   		 
	   var exdate=new Date();   		 
	   exdate.setDate(exdate.getDate()+expiredays);   		 
	   document.cookie="valuestr"+ "=" +escape(newCookieStr)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());   		 
	}   		 
	  		 
	function getCookie(c_name)   		 
	{   		 
	   if (document.cookie.length>0)   		 
	   {   		 
	       c_start=document.cookie.indexOf(c_name + "=");   		 
	       if (c_start!=-1)   		 
	       {   		 
	           c_start=c_start + c_name.length+1;   		 
	           c_end=document.cookie.indexOf(";",c_start);   		 
	           if (c_end==-1)   		 
	               c_end=document.cookie.length;   		 
	           return unescape(document.cookie.substring(c_start,c_end));   		 
	       }   		 
	   }   		 
	   return "";   		 
	}