//->

//->

var Home=".";
var SURL="https://www.absolutelypsychic.com/f1029/order.php";

var ref=parent.document.referrer;
if (ref.indexOf("http://www.absolutelypsychic.com/f1029/order.php",0)!=-1) self.location="http://www.absolutelypsychic.com/store/view.php?action=View";
function getCookieVal(offset) {
   var endstr=document.cookie.indexOf(";", offset);
   if (endstr==-1) endstr=document.cookie.length;
   return unescape(document.cookie.substring(offset,endstr)); }

function GetCookie(name) {
   var arg=name+"=";
   var alen=arg.length;
   var clen=document.cookie.length;
   var i=0;
   while(i<clen) {
      var j=i+alen;
      if (document.cookie.substring(i,j)==arg) return getCookieVal(j);
      i=document.cookie.indexOf(" ",i)+1;
      if (i==0) break; }
   return null; }

function SetCookie(name,value) {
   var argv=SetCookie.arguments;
   var argc=SetCookie.arguments.length;
   var expires=(argc>2) ? argv[2]:null;
   var path=(argc>3) ? argv[3]:null;
   var domain=(argc>4) ? argv[4]:null;
   var secure=(argc>5) ? argv[5]:false;
   document.cookie=name+"="+escape(value)+((expires==null) ? "" : ("; expires="+expires.toGMTString()))+((path==null) ? "" : ("; path="+path))+((domain==null) ? "" : ("; domain="+domain))+((secure==true) ? "; secure" : ""); }

function DeleteCookie(name,path,domain) {
  if (GetCookie(name)) {
    document.cookie=name+"="+((path) ? "; path="+path:"")+((domain) ? "; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT"; }}

var Num=GetCookie("number");
var Item_List=new String(GetCookie("items"));
var I=Item_List.split("!!");
var Price_List=new String(GetCookie("prices"));
var P=Price_List.split("!!");
var Q_List=new String(GetCookie("quantity"));
var Q=Q_List.split("!!");
var S_List=new String(GetCookie("shipping"));
var S=S_List.split("!!");
var Url_List=new String(GetCookie("urls"));
var U=Url_List.split("!!");
var ST=new Array(Num);
var expdate=new Date();
expdate.setTime(expdate.getTime()+(24*60*60*1000));

function Decimal(n) {
   ns=new String(n);
   nsi=ns.indexOf('.');
   if (nsi!=-1) {
      nsil=nsi+3;
      l=ns.charAt(nsil);
      ln=new Number(l);
      if (ln>=5) n=n+.01;
      nr=new String(n);
      n=nr.substring(0,nsil);
      if (n.length<nsil) n+="0"; }
   else {
      n=ns+".00"; }
   return n; }

function getInput() {
   if ((Num!=null) && (Num>=0)) {
	var Total=0;
	var SHT=0;
	var SHST=0;
      for (var i=0; i<=Num; i++) {
         P[i]=new Number(P[i])*new Number(Q[i]);
         S[i]=new Number(S[i])*new Number(Q[i]);
         SHT=SHT+(S[i]);
         if (S[i]==0) SHST=SHST+P[i];
         ST[i]=P[i]+S[i];
	   Total=Total+ST[i];
         P[i]=Decimal(P[i]);
         S[i]=Decimal(S[i]);
         ST[i]=Decimal(ST[i]);
         document.write('<input type="hidden" name="I[]" value="'+I[i]+'">\n');
         document.write('<input type="hidden" name="Q[]" value="'+Q[i]+'">\n');
         document.write('<input type="hidden" name="P[]" value="'+P[i]+'">\n');
         document.write('<input type="hidden" name="S[]" value="'+S[i]+'">\n');
         document.write('<input type="hidden" name="ST[]" value="'+ST[i]+'">\n');
         document.write('<input type="hidden" name="U[]" value="'+U[i]+'">\n'); }
      Total=Decimal(Total);
      document.write('<input type="hidden" name="Total" value="'+Total+'">\n');
      SHT=Decimal(SHT);
      document.write('<input type="hidden" name="SHT" value="'+SHT+'">\n');
      SHST=Decimal(SHST);
      document.write('<input type="hidden" name="SHST" value="'+SHST+'">\n'); }}

function Add(id,item,price,ship) {
   if (document.Catalog[id+"m"]) item=item+" ("+document.Catalog[id+"m"].options[document.Catalog[id+"m"].selectedIndex].text+")";
   if (document.Catalog[id+"m1"]) item=item+" ("+document.Catalog[id+"m1"].options[document.Catalog[id+"m1"].selectedIndex].text+")";
   if (document.Catalog[id+"c"]) item=item+" ("+document.Catalog[id+"c"].value+")";
   var q=document.Catalog[id].value;
   qCheck=parseInt(q, 10);
   if ((qCheck==0) || (isNaN(qCheck)) || (q=="")) q=1;
   Num=GetCookie("number");
   var Items=GetCookie("items");
   var Prices=GetCookie("prices");
   var Quantity=GetCookie("quantity");
   var Shipping=GetCookie("shipping");
   var Urls=GetCookie("urls");
   var loc=new String(location);
   var ll=loc.length;
   var li=loc.lastIndexOf("/");
   var lbi=loc.lastIndexOf("#");
   if (lbi==-1) loc=loc.substring(li+1,ll);
   else loc=loc.substring(li+1,lbi);
   if (Num==null) {
      SetCookie("number",0,expdate);
      SetCookie("items",item+"!!",expdate);
      SetCookie("prices",price+"!!",expdate);
      SetCookie("quantity",q+"!!",expdate);
      SetCookie("shipping",ship+"!!",expdate);
      SetCookie("urls",loc+"#"+id+"!!",expdate); }
   else {
	var ix="f";
	I=Items.split("!!");
      for (var j=0; j<=Num; j++) {
	   if (I[j]==item) var ix=j; }
	if (ix!="f") {
	   Q=Quantity.split("!!");
	   Q[ix]=new Number(Q[ix])+new Number(q);
         var eq=Q.join("!!");
         rq=/!!!!/
         var Quantity=eq.replace(rq,"!!");
         SetCookie("quantity",Quantity,expdate); }
	else {
	   var newN=++Num;
         SetCookie("number",newN,expdate);
         SetCookie("items",item+"!!"+Items,expdate);
         SetCookie("prices",price+"!!"+Prices,expdate);
         SetCookie("quantity",q+"!!"+Quantity,expdate);
         SetCookie("shipping",ship+"!!"+Shipping,expdate);
         SetCookie("urls",loc+"#"+id+"!!"+Urls,expdate); }}
	self.location="http://www.absolutelypsychic.com/store/add.php?item="+escape(item)+"&q="+q+"&loc="+loc+"&id="+id; }

function Empty() {
   if ((Num==null) || (Num<0)) {
      alert("Sorry, your shopping cart is already empty!"); }
   else {
      if(confirm("Are you sure you want to delete all items from your shopping cart?")) {
         DeleteCookie("number");
         DeleteCookie("items");
         DeleteCookie("prices");
         DeleteCookie("quantity");
         DeleteCookie("shipping");
         DeleteCookie("urls");
	   self.location=location; }}}

function View() {
   if ((Num==null) || (Num<0)) {
      alert("Sorry, you do not have any items in your shopping cart!"); }
   else {
      document.View.action.value="View";
      document.View.submit(); }}

function Check_Out() {
   if ((Num==null) || (Num<0)) {
      alert("Sorry, you do not have any items in your shopping cart!"); }
   else {
      document.Order.action.value="Order";
      document.Order.submit(); }}

function Validate(theForm) {
   if (theForm.input.value=="") {
      alert("Please enter a single or multiple keywords to search our product catalog.");
      theForm.words.focus();
      return false; }
   return true; }

//