function URLencode(sStr) 
{
  sStr= escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27');
  sStr= sStr.replace(/[/]/g,'%2F');
  return sStr.replace(/-/g,'%2D');
}

function go(merchant_id, coupon_id )
{
  var merchant_only;
  if(coupon_id =='-1')
    merchant_only=true;
  else
    merchant_only = false;
    
  var go_back_url = location.href;
  /*
  if(merchant_only)
    go_back_url = go_back_url+"#M"+merchant_id;
  else
    go_back_url = go_back_url+"#C"+coupon_id;
    */
   
  this.href="redir.asp?m="+merchant_id+"&c="+coupon_id;
  url="toolbar.asp?m="+merchant_id+"&c="+coupon_id+"&g="+URLencode(go_back_url);
  //window.open(url,'d','menubar=yes;location=yes;resizable=yes,scrollable=yes,height=250,width=500');
  return false;
}

function goTopCoupons(merchant_id, coupon_id )
{
  var merchant_only;
  if(coupon_id =='-1')
    merchant_only=true;
  else
    merchant_only = false;
    
  var go_back_url = location.href;
  /*
  if(merchant_only)
    go_back_url = go_back_url+"#M"+merchant_id;
  else
    go_back_url = go_back_url+"#C"+coupon_id;
    */
   
  this.href="redir.asp?m="+merchant_id+"&c="+coupon_id;
  url="toolbar.asp?m="+merchant_id+"&c="+coupon_id+"&g="+URLencode(go_back_url);
  window.open(url,'d','menubar=yes;location=yes;resizable=yes,scrollable=yes,height=250,width=500');
  return false;
}



function removeFrames() 
{
  if (top != self)
    top.location = self.location
}

function contact_onSubmit()
{
  var valid=true;
  var msg="There was an error with the data you entered\n";
  if(document.contact.name.value.length<1)
  {
    msg=msg+"\tPlease enter your name.\n";
    valid=false;
  }
  if(document.contact.email.value.length<1)
  {
    msg=msg+"\tPlease enter your email address.\n";
    valid=false;
  }
  if(document.contact.comments.value.length<1)
  {
   msg=msg+"\tPlease enter something in the Questions/Comments field.\n";
    valid= false;
  }
  
  if(!valid)
    alert(msg);
  return valid;
}

function search_onSubmit()
{
  var valid=true;
  var msg;
  if(document.search.search_word.value.length<1)
  {
    msg="Please enter a search term in the search box before pressing submit.\n";
    valid=false;
  }

  if(!valid)
    alert(msg);
  return valid;
}

function Bookmark()
{
	if ((navigator.appName == 'Microsoft Internet Explorer') && (window.clientInformation.javaEnabled() == true ))
    {
 		window.external.AddFavorite(location.href,document.title);
	}
}
function check_email_address(email)
{
  if (email.indexOf("@")<0 )
    return false;
  else
    return true;
}
function newsletter_onsubmit(f)
{
 var result=check_email_address(f.email.value);
 if(!result)
   alert("Please enter a valid e-mail address to subscribe to the newsletter");
 
 return result;
}