
function  gopage(gopage)
{

if (gopage != '')
{ 
top.location.href="http://www.ranch2arena.com/"+gopage
}

}


function badcookie()
{
  alert("In order for the Secure Ordering System to work, your browser must Accept Cookies.  It appears that you have either disabled your browser's cookie function, or (if you have configured your browser to prompt for conformation of each cookie) you forgot to accept the last cookie.  In either case, the last action that you requested was unable to complete.  For more information, see the section entitled \"Secure Ordering\".")
}

function delete_cookie (name)
{
 var x_date = new Date();
 x_date.setFullYear(x_date.getFullYear() - 1);
 x_date = x_date.toGMTString();
 c_string = escape (name) + "=null" + "; expires=" +x_date;
 document.cookie = c_string;

  // reread 
      checker_string = escape(name)+ "=" + escape(read_cookie(name)) + "; expires=" +x_date

 // see if null was returned as an empty
 var nullx = checker_string.indexOf("=;")


 if (checker_string != c_string && nullx == -1)
 { 
 badcookie()
 } 

}

function read_cookie (key)
{
 // break whole cookie into sperate cookies
  ori_string = "" + document.cookie;
  var cookie_array = ori_string.split ("; ")

 // find the desired cookie:
  for (var i = 0; i < cookie_array.length; ++ i)
  {
  var s_cookie = cookie_array[i].split ("=");
  if (s_cookie.length != 2)
  {
  continue
  }

 // cookie found
 if (key == unescape (s_cookie [0]))
 return unescape (s_cookie [1])
 }

 // not found:
 return null
}

function addto_order (qty,d_string)
{

  agent = navigator.userAgent
  slash  =agent.indexOf("/") 
  period =agent.indexOf(".")
  verx = 0

   if (agent.indexOf("Mozilla/") != -1)
      {
      verx = agent.substring(slash+1,period)
      }
 
  verx = verx/1

  if (verx < 4)
  {
  alert("In order to place an order, you must be using one of the following Browsers:\n\n     Microsoft Internet Explorer (ver 4.0 or greater)\n\n     Netscape Navigator (version 4.0 or greater)\n\n     A browser compatiable with one of these\n\nYour browser does not appear to meet this requirement. It has the following identification:\n\n"+agent)
  }

  else
  {

 // split the d_string into description, price and special freight
 // the description is element 0 because it has no $ at front
    split_array=d_string.split("$");

 //get current cookie
   var name = "items"
   var ori =read_cookie(name);

// check the length of the current string
   if (ori == null)
   len = 0
   else
   len = ori.length

   if (len > 1800)
   alert("You Order Form is full!")

   else
        
{       
        
 // build the addon
 // *note is not used
    addon = '|*' + qty + '*' + split_array[0] + '*' + split_array[1]+ '*' + split_array[2]+ '*' + split_array[3]+ '*' + split_array[4]+ '*' + split_array[5]+ '*' + split_array[6]+ '*' + split_array[7]+ '*' + split_array[8] + '*' + split_array[9] + '*' + 'notex'
          
  var x_date = new Date();
  x_date.setFullYear(x_date.getFullYear() + 2);
  x_date = x_date.toGMTString();

 // build the string 
  if (ori != null)
  {
  c_string = escape (name) +"="+ escape (ori) + escape (addon)+"; expires=" +x_date  
  }
  else
  {
   c_string = escape (name) + "=" + escape (addon) + "; expires=" +x_date  
  }
      
  // set cookie:
    document.cookie = c_string

   // reread the cookie
   checker_string = escape(name)+ "=" + escape(read_cookie("items")) + "; expires=" +x_date 

   if (checker_string != c_string)
   { 
   badcookie()
   }
 
   else
   {
   alert(qty + "  --  " + split_array[0] + "   Added to Order.")
   }
}
}
}



