
function formatCurrency(num) {num = num.toString().replace(/\$|\,/g,'');if(isNaN(num))num = "0";sign = (num == (num = Math.abs(num)));num = Math.floor(num*100+0.50000000001);cents = num%100;num = Math.floor(num/100).toString();if(cents<10)cents = "0" + cents;for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));return (((sign)?'':'-') + '$' + num + '.' + cents);}

Number.prototype.formatMoney = function(c, d, t){
	var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
	return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};

function bakeCookie(name, url, image, price, saleprice, orderable)
{

recent1=getCookie("eyRecently1");
recent2=getCookie("eyRecently2");
recent3=getCookie("eyRecently3");
recent4=getCookie("eyRecently4");
var split1 = recent1.split("|");
var split2 = recent2.split("|");
var split3 = recent3.split("|");
var split4 = recent4.split("|");


if(recent3.length==0)
{
  if(recent2.length==0){
  
    if(recent1.length==0){
    document.cookie="eyRecently1="+name+"|"+url+"|"+image+"|"+price+"|"+saleprice+"|"+orderable;
    }
    else{
  
        if(name==split1[0])
        {

        }
        else{
        document.cookie="eyRecently2="+recent1;
            document.cookie="eyRecently1="+name+"|"+url+"|"+image+"|"+price+"|"+saleprice+"|"+orderable;
        }    
    }
  }
   else{
       
         if(name==split1[0]){

         }
         else if(name==split2[0]){
         document.cookie="eyRecently1="+recent2;
         document.cookie="eyRecently2="+recent1;
         }
          else if(name==split3[0]){
         document.cookie="eyRecently1="+recent3;
         document.cookie="eyRecently3="+recent1;
         }
         else{
         document.cookie="eyRecently3="+recent2;
         document.cookie="eyRecently2="+recent1;
         document.cookie="eyRecently1="+name+"|"+url+"|"+image+"|"+price+"|"+saleprice+"|"+orderable;
         }
   }
  

}
else
{
if(name==split1[0]){

}
else if(name==split2[0]){
document.cookie="eyRecently1="+recent2;
document.cookie="eyRecently2="+recent1;
}
else if(name==split3[0]){
document.cookie="eyRecently1="+recent3;
document.cookie="eyRecently3="+recent1;
}
else if(name==split4[0]){
document.cookie="eyRecently1="+recent4;
document.cookie="eyRecently4="+recent1;
}



else{
document.cookie="eyRecently4="+recent3;
document.cookie="eyRecently3="+recent2;
document.cookie="eyRecently2="+recent1;
      document.cookie="eyRecently1="+name+"|"+url+"|"+image+"|"+price+"|"+saleprice+"|"+orderable;
}
}


recent2=getCookie("eyRecently2");
recent3=getCookie("eyRecently3");
recent4=getCookie("eyRecently4");
var split1 = recent1.split("|");
var split2 = recent2.split("|");
var split3 = recent3.split("|");
var split4 = recent4.split("|");

if(recent2.length!=0)
{
document.writeln("<img src='/lib/dragonballzcentral/recent.jpg'><br/>");

document.writeln("<table class='recentTable' align='center'><tr>");

document.writeln("<td class='recentTD'><a href='"+split2[1]+"'><img src='"+split2[2]+"'</a><div class=featuredItemName><a href='"+split2[1]+"'>"+split2[0]+"</a></div>");

if (split2[3]==split2[4])
{
document.writeln("<div class=price>Price: "+formatCurrency(split2[3])+"</div>");
}
else{
document.writeln("<div class=price>Price: "+formatCurrency(split2[3])+"</div><div class=sale-price>Sale Price: <font color=#FF0000>"+formatCurrency(split2[4])+"</font></div>");
}

if(split2[5]=="o")
{
var ide=split2[1].split(".");
document.writeln("<form action=http://order.store.yahoo.net/cgi-bin/wg-order?dragonballzcentral+"+ide[0]+" method=post><input type=hidden value="+ide[0]+" name=vwitem /><input type=hidden value=dragonballzcentral name=vwcatalog /><input type=image border=0 src=http://lib.store.yahoo.net/lib/dragonballzcentral/recentadd.jpg /><input type=hidden value=http://www.toywiz.com/ name=.autodone /></form></td>");
}
else{
document.writeln("</td>");
}

}

if(recent3.length!=0)
{
document.writeln("<td class='recentTD'><a href='"+split3[1]+"'><img src='"+split3[2]+"'</a><div class=featuredItemName><a href='"+split3[1]+"'>"+split3[0]+"</a></div>");

if (split3[3]==split3[4])
{
document.writeln("<div class=price>Price: "+formatCurrency(split3[3])+"</div>");
}
else{
document.writeln("<div class=price>Price: "+formatCurrency(split3[3])+"</div><div class=sale-price>Sale Price: <font color=#FF0000>"+formatCurrency(split3[4])+"</font></div>");
}


if(split3[5]=="o")
{
var ide=split3[1].split(".");
document.writeln("<form action=http://order.store.yahoo.net/cgi-bin/wg-order?dragonballzcentral+"+ide[0]+" method=post><input type=hidden value="+ide[0]+" name=vwitem /><input type=hidden value=dragonballzcentral name=vwcatalog /><input type=image border=0 src=http://lib.store.yahoo.net/lib/dragonballzcentral/recentadd.jpg /><input type=hidden value=http://www.toywiz.com/ name=.autodone /></form></td>");
}
else{
document.writeln("</td>");
}
}






if(recent3.length!=0 && recent4.length!=0)
{
document.writeln("<td class='recentTD'><a href='"+split4[1]+"'><img src='"+split4[2]+"'</a><div class=featuredItemName><a href='"+split4[1]+"'>"+split4[0]+"</div></a>");

if (split4[3]==split4[4])
{
document.writeln("<div class=price>Price: "+formatCurrency(split4[3])+"</div>");
}
else{
document.writeln("<div class=price>Price: "+formatCurrency(split4[3])+"</div><div class=sale-price>Sale Price: <font color=#FF0000>"+formatCurrency(split4[4])+"</font></div>");


}


if(split4[5]=="o")
{
var ide=split4[1].split(".");
document.writeln("<form action=http://order.store.yahoo.net/cgi-bin/wg-order?dragonballzcentral+"+ide[0]+" method=post><input type=hidden value="+ide[0]+" name=vwitem /><input type=hidden value=dragonballzcentral name=vwcatalog /><input type=image border=0 src=http://lib.store.yahoo.net/lib/dragonballzcentral/recentadd.jpg /><input type=hidden value=http://www.toywiz.com/ name=.autodone /></form></td>");
}
else{
document.writeln("</td>");
}


}






if(recent2.length!=0)
{
document.writeln("</tr></table>");
}
}
function getCookie(name){
var cookie,list,i,equals,match;
cookie=document.cookie;
if(cookie.length==0){
return '';
}
else{
list=cookie.split(';');
for(i=0;i<list.length;i=i+1){
equals=list[i].indexOf('=');
match=list[i].substring(0,equals);
if(match.substr(0,1)==' '){
match=match.substr(1);
}
if(match==name){
return list[i].substring(equals+1,list[i].length);
}
}
return '';
}
}




