﻿// JScript File

function escString(searchString)
{
	//var newString = searchString.replace(/\+/g,"%2B");
	var newString = escape(searchString);
	return newString;
}

function siteSearch(searchString)
{
 
	if (searchString != "")
	{
	    if (document.all) {
	        window.location='http://knitting-yarn.knitpicks.com/search?w=' + escString(searchString);
	    } else if (document.getElementById) {
	        location.href='http://knitting-yarn.knitpicks.com/search?w=' + escString(searchString);
	    }		
	
	}
	
	return false;
}

function fyarnline(yarnid)
{
 
	if (yarnid != "")
	{
	    if (document.all) {
	        window.location='/yarns/yarn_list.aspx?id=' + yarnid;
	    } else if (document.getElementById) {
	        location.href='/yarns/yarn_list.aspx?id=' + yarnid;
	    }
	
	}else {
	    alert("Please select a Yarn from the list.");
	}
	
	return false;
}

function addCartItem(itemID)
{
    var loc = '/cart/add2cart.asp?SKU_0=' + escString(itemID) + '&QTY_0=1&CQ=1';
    if (document.all) {
        window.location = loc;
    } else if (document.getElementById) {
        location.href = loc;
    }


}
