

function check_search() {

	// br - Added JS check of search

	frm = document.frmSearch;

	val = frm.srchQuery.value;
	obj = frm.srchQuery;

	if(val == '') {

		alert("A search term is required.");
		obj.focus();
		obj.select();
		return false;

	}

	if(val.length < 3) {

		alert("The search term must have more at least 3 characters.");
		obj.focus();
		obj.select();
		return false;

	}

	return true;

}

function check_newsletter()
{

	var email = document.getElementById('email');

	if(email.value == '')
	{

		alert('You forgot to enter your email address!');
		email.focus();
		return false;

	}

	return true;

}

	function setCookie(cookieName, cookieValue, cookiePath, cookieExpires)
      {
        cookieValue = escape(cookieValue);
        if (cookieExpires == "")
          {
            var nowDate = new Date();
            nowDate.setMonth(nowDate.getMonth() + 6);
            cookieExpires = nowDate.toGMTString();
          }

        if (cookiePath != "")
          {
            cookiePath = ";Path=" + cookiePath;
          }

       document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires + cookiePath;
      }

    function getCookieValue(name)
      {
        var cookieString = document.cookie;
        var index = cookieString.indexOf(name + "=");

        if (index == -1) return null;

        index = cookieString.indexOf("=", index) + 1;
        var endstr = cookieString.indexOf(";", index);

        if (endstr == -1) endstr = cookieString.length;

        return unescape(cookieString.substring(index, endstr));
      }

	function OpenWin(uri, winName, width, height, scroll)
	{
		winName = winName.replace(' ', '_');
		var winLeft = (screen.width - width) / 2;
		var winTop = (screen.height - height) / 2;
		
		winData = 'height='+height+',width='+width+',top='+winTop+',left='+winLeft+',scrollbars='+scroll+',resizable';
		var win = window.open(uri, winName, winData);
		
		if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	}


  function DoPopupNL()
    {
      var NL = getCookieValue('techbuy_newsletter');

      if(NL == null)
        {
          // Show the newsletter signup popup
          setCookie('techbuy_newsletter', 'true', '', '');
          OpenWin('popupnl.html', 'popupNL', 300, 250, 'no');
        }
    }


	function Start(page)
		{
			OpenWin = this.open(page,"popup","scrollbars=1,top=50,left=100,width=560,height=450");
		}
	function StartChat()
		{
			window.open('http://hc2.humanclick.com/hc/45572151/?cmd=file&file=visitorWantsToChat&site=45572151','chat45572151','width=419,height=320');
			return false;
		}
	function StartWiz()
		{
			window.open('orderreportwiz.asp','OrderReport','width=650,height=400,left=100,top=100,scrollbars=1,statusbar=0,toolbar=0')
		}


  function doPoll()
    {
      if(pollTd.style.display != 'none')
        {
          pollTd.style.display = 'none';
          pollImg.src = strImageRoot + 'layout/arrowno.gif';
        }
      else
        {
          pollTd.style.display = 'inline';
          pollImg.src = strImageRoot + 'layout/arrowgo.gif';
        }
    }

  function doBrandsMenu()
    {
      if(brandTd.style.display != 'none')
        {
          brandTd.style.display = 'none';
          brandImg.src = strImageRoot + 'layout/arrowno.gif';
        }
      else
        {
          brandTd.style.display = 'inline';
          brandImg.src = strImageRoot + 'layout/arrowgo.gif';
        }
    }

  function doCartMenu()
    {
      if(cartTbl.style.display != 'none')
        {
          cartTbl.style.display = 'none';
          cartImg.src = strImageRoot + 'layout/arrowno.gif';
        }
      else
        {
          cartTbl.style.display = 'inline';
          cartImg.src = strImageRoot + 'layout/arrowgo.gif';
        }
    }

  function doProdMenu()
    {
      if(prodTd.style.display != 'none')
        {
          prodTd.style.display = 'none';
          prodImg.src = strImageRoot + 'layout/arrowno.gif';
        }
      else
        {
          prodTd.style.display = 'inline';
          prodImg.src = strImageRoot + 'layout/arrowgo.gif';
        }
    }

   function doCustompcTable()
     {
       if(custompcTable.style.display != 'none')
         {
           custompcTable.style.display = 'none';
           pcImg.src = strImageRoot + 'layout/arrowno.gif';
         }
       else
         {
           custompcTable.style.display = 'inline';
           pcImg.src = strImageRoot + 'layout/arrowgo.gif';
         }
     }

     function IsCheckDigitThere()
     {
		if(document.frmPayment.ccType.value != 'NULL' && document.frmPayment.ccCheck.value == '')
		{
			alert('Please enter your check digit number. Your order canot be processed without it.');
			document.frmPayment.ccCheck.focus();
			return false;
		}
		return true;
     }
