﻿function SessionExpired() {
    alert('Your session has expired. You will now be sent back to the home page.');
    location.href = 'http://www.salsastore.net';
}
 function IsCartEmpty(ItemLabel)
            {
                if (document.getElementById(ItemLabel).innerHTML == 'Total Items: 0')
                    {
                        alert('There are no items in your shopping cart.');
                        return false;
                    }
                else
                    {
                        return true;
                    }
            }
         
    function OpenWindow(url,w,h)
        {
            var pos_left;
            var pos_top;
                    
            pos_left = (screen.width - w) / 2;
            pos_top = (screen.height - h) / 2;

            window.open(url, '', 'status=0,menubar=0,location=0,scrollbars=1,resizable=0,width=' + w + ',height=' + h + ',left=' + pos_left + ',top=' + pos_top + '');
            return false;
        }
    
    
    // Function retrieved from: http://cass- hacks.com/articles/code/js_url_encode_decode/   
function URLEncode (clearString) {   
  var output = '';   
  var x = 0;   
  clearString = clearString.toString();   
  var regex = /(^[a-zA-Z0-9_.]*)/;   
  while (x < clearString.length) {   
    var match = regex.exec(clearString.substr(x));   
    if (match != null && match.length > 1 && match[1] != '') {   
        output += match[1];   
      x += match[1].length;   
    } else {   
      if (clearString[x] == ' ')   
        output += '+';   
      else {   
        var charCode = clearString.charCodeAt(x);   
        var hexVal = charCode.toString(16);   
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();   
      }   
      x++;   
    }   
  }   
  return output;   
}   
// Retrieved from: http://www.htmlcodetutorial.com/forms/index_famsupp_157.html   

function SubmitOnEnter(submitbutton)   
{     
    if (window.event.keyCode == 13)
        {
            document.getElementById(submitbutton).click();
            return false;
        }
} 
function SearchSite(url,searchfield)   
{

    if (document.getElementById(searchfield).value == '')
        {
        alert('Please type in a search phrase.');
        }
    else
        {
        document.location.href=url + '?cx=' + URLEncode('000226531558823443968:40hcvh1sbzu') + '&cof=' + URLEncode('FORID:9') + '&ie=UTF-8&q=' + URLEncode(document.getElementById(searchfield).value) + '&sa=Search';   
        }
    
    return false;
}
function OpenGoogleSearch(tb) {
    var b = document.getElementById(tb);
    window.open('http://www.google.com/search?hl=en&source=hp&q=' + b.value + '&aq=f&oq=&aqi=g10', '_blank');

    return false;
}