function SetCartTask(theTask)
{
	var theForm = document.ecart_form;
	
	theForm.task.value = theTask;
	theForm.submit();
}

var newwindow = '';

function popItUp(theURL,winName,features) 
{
	if (!newwindow.closed && newwindow.location) 
	{
		newwindow.location.href = theURL;
	} else 
	{
		newwindow=window.open(theURL,winName,features);
		if (!newwindow.opener) 
			newwindow.opener = self;
	}
	if (window.focus) 
	{
		newwindow.focus()
	}
	return false;
}


function confirmClearCart(){
	var answer = confirm("Are you sure? This will remove all items from your Shopping Cart.");
	if(answer){
		SetCartTask('clearCart');
	}
}
function confirmClearNotifyMe(){
	var answer = confirm("Are you sure? This will remove all items from your Notify Me section.");
	if(answer){
		SetCartTask('clearNotifyMe');
	}
}
function confirmClearWishList(){
	var answer = confirm("Are you sure? This will remove all items from your Wish List.");
	if(answer){
		SetCartTask('clearWishList');
	}
}
/* Toggle 'move to wish list' checkbox on image click */
var showUpdateChangesMsg = 1;
function checkCheckbox(checkboxName, imgUpName, imgDownName, divName) {
    document.getElementById(checkboxName).checked = true;
	document.getElementById(imgUpName).style.display = "none";
	document.getElementById(imgDownName).style.display = "";
	if(showUpdateChangesMsg==1){
	  document.getElementById(divName).innerHTML = "Select the items you wish to move and then click <b>Update Changes</b>";
	  document.getElementById(divName).style.display = "";
	  setTimeout('hideWishListMsg(\''+divName+'\')',4750);
	  showUpdateChangesMsg = 0;
	}
}
function uncheckCheckbox(checkboxName, imgUpName, imgDownName) {
	document.getElementById(checkboxName).checked = false;
	document.getElementById(imgUpName).style.display = "";
	document.getElementById(imgDownName).style.display = "none";
}
/* Toggle checkbox image */
function hideCheckbox(checkboxName, imgName) {
  if(document.getElementById(checkboxName).checked == true){
	document.getElementById(checkboxName).style.display = "none";
	document.getElementById(imgName).style.display = "";
  }
}
function showCheckbox(checkboxName, imgName) {
	document.getElementById(checkboxName).checked = false;
	document.getElementById(checkboxName).style.display = "";
	document.getElementById(imgName).style.display = "none";
}
/* If user tries to move item to wish list show login message */
function showWishListMsg(checkboxName, divName){
	document.getElementById(checkboxName).checked = false;
	document.getElementById(divName).innerHTML = "You must <br /><a href='/cfCart/login.cfm'>log in</a> to do this.";
	document.getElementById(divName).style.display = "";
	setTimeout('hideWishListMsg(\''+divName+'\')',4000);
}
function hideWishListMsg(divName){
	document.getElementById(divName).innerHTML = "";
	document.getElementById(divName).style.display = "none";
}
/* Omniture Data and Last Cart Tab Cookie */
function sendTabClick(tabname){
  //Send Omniture Data As Custom Link
  s.linkTrackVars='eVar27,events';
  s.linkTrackEvents='';
  s.eVar27=tabname;
  s.events='';
  s.tl(this,'o','Tab Clicks');
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+1);
  document.cookie="KNITPICKSCART_LASTTAB=" +escape(tabname)+ ";expires="+exdate.toGMTString()+";path=\/";
}


