document.write("<div id='treasurelicious'></div>");
var tlishDivId="treasurelicious";
 
var divTreasures=document.getElementById(tlishDivId);
while (divTreasures.firstChild)
    divTreasures.removeChild(divTreasures.firstChild);

divTreasures.style.position="relative";


var eMag=document.createElement("div");
eMag.id=tlishDivId+"-mag";
eMag.style.position="absolute";
eMag.style.display="none";
eMag.style.width="125px";
eMag.style.height="125px";
eMag.style.border="1px solid #888888";
eMag.style.backgroundColor="#ffffff";

eMag.onmouseover=function() {
    var eMag=this;
    if (eMag.timeoutId>0)
        window.clearTimeout(eMag.timeoutId);
} //onmouseover

eMag.onmouseout=function () {
    var eMag=this;
    if (eMag.timeoutId>0)
        window.clearTimeout(eMag.timeoutId);

    (function(obj) {
        eMag.timeoutId=window.setTimeout(function() {
            var eMag=obj;
            eMag.style.display="none";
        },250);
    })(eMag);
} //onmouseout


var divHeader=document.createElement("div");
divHeader.id=tlishDivId+"-header";
divHeader.style.padding="2px";
divHeader.style.marginBottom="5px";
divHeader.style.borderBottom="1px solid #cccccc";

var aTreasurelicious=document.createElement("a");
aTreasurelicious.className="tlish-title";
aTreasurelicious.href="http://www.treasurelicious.com/list?id=156";
aTreasurelicious.style.fontWeight="bold";
aTreasurelicious.appendChild(document.createTextNode("My Newest Treasures"));
aTreasurelicious.title="See my treasures";

divHeader.appendChild(aTreasurelicious);

var aFeed=document.createElement("a");
aFeed.className="tlish-feed";
aFeed.title="Subscribe to my feed";
aFeed.style.marginLeft="5px";
aFeed.href="http://www.treasurelicious.com/feed?id=156";

var imgFeed=document.createElement("img");
imgFeed.src="http://www.treasurelicious.com/media/feed.png";
imgFeed.alt="Subscribe to my feed";
imgFeed.style.border="none";
imgFeed.style.verticalAlign="middle";

aFeed.appendChild(imgFeed);

divHeader.appendChild(aFeed);


divTreasures.appendChild(divHeader);


var treasures=[
{ treasureId: 879, caption: 'impish horns', urlImage: 'http://twitpic.com/img/bmou-e1008e44a09efb7d1b9448d2280fbe51.48cda4ef.jpg', urlInfo: '', tsCreated: 1221437093 },{ treasureId: 730, caption: 'comfy lounge shorts', urlImage: 'http://www.oldnavy.com/Asset_Archive/ONWeb/Assets/Product/581/581510/big/on581510-00vliv01.jpg', urlInfo: '', tsCreated: 1219554837 },{ treasureId: 691, caption: 'new header', urlImage: 'http://bp1.blogger.com/_d9WS3IeY1TM/SJjl23D44iI/AAAAAAAABEs/plEKhbeB8W0/S1600-R/August+08+header+opt+3+smallest.jpg', urlInfo: 'http://www.camikaos.com', tsCreated: 1217980320 },{ treasureId: 690, caption: 'funny family memories', urlImage: 'http://farm4.static.flickr.com/3184/2736268496_6fa00dedb8.jpg?v=0', urlInfo: '', tsCreated: 1217959734 },{ treasureId: 689, caption: 'Eau des 4 Reines Eau de Toilette', urlImage: 'http://img.loccitane.com/P.aspx?l=en-US&s=265&e=jpg&id=24ET125RO', urlInfo: 'http://usa.loccitane.com/FO/Catalog/Product.aspx?prod=24ET125RO', tsCreated: 1217915368 },{ treasureId: 688, caption: 'my macbook', urlImage: 'http://images.apple.com/macbook/images/design_gal04_20080226.jpg', urlInfo: 'http://store.apple.com/us/browse/home/shop_mac/family/macbook', tsCreated: 1217486003 },{ treasureId: 677, caption: 'Hand Rolled Jasmine Pearls', urlImage: 'http://www.taooftea.com/thbnail.php3?img1-117.gif&w=230&h=200', urlInfo: 'http://www.taooftea.com/detail117-Jasmine_Pearls.html', tsCreated: 1216617872 },{ treasureId: 676, caption: 'Genmaicha (Brown Rice Tea)', urlImage: 'http://www.taooftea.com/thbnail.php3?img1-146.gif&w=230&h=200', urlInfo: 'http://www.taooftea.com/detail146-Brown_Rice_Tea.html', tsCreated: 1216617740 },{ treasureId: 675, caption: 'White Peony Tea', urlImage: 'http://www.taooftea.com/thbnail.php3?img1-127.gif&w=230&h=200', urlInfo: 'http://www.taooftea.com/detail127-White_Peony.html', tsCreated: 1216617678 },{ treasureId: 674, caption: 'Green Dragon Oolong Tea', urlImage: 'http://www.taooftea.com/thbnail.php3?img1-103.gif&w=230&h=200', urlInfo: 'http://www.taooftea.com/detail103-Green_Dragon.html', tsCreated: 1216617609 },{ treasureId: 673, caption: 'Rose Petal Black Tea', urlImage: 'http://www.taooftea.com/thbnail.php3?img1-155.gif&w=230&h=200', urlInfo: 'http://www.taooftea.com/detail155-Rose_Petal_Black.html', tsCreated: 1216617550 },{ treasureId: 672, caption: 'tea-zer clear', urlImage: 'http://ecx.images-amazon.com/images/I/61Zn9D77thL._SS500_.gif', urlInfo: 'http://www.amazon.com/Liquid-Solutions-Tea-zer-Brewing-Tumbler/dp/B00125JDNC/ref=sr_1_2?ie=UTF8&s=home-garden&qid=1216617425&sr=1-2', tsCreated: 1216617468 },{ treasureId: 670, caption: 'perfect purse', urlImage: 'http://bp3.blogger.com/_d9WS3IeY1TM/SHU_LGHAhgI/AAAAAAAABA0/g7LFT9U6HG4/s1600/purse.jpg', urlInfo: '', tsCreated: 1216139446 },{ treasureId: 610, caption: 'Strange Love messenger bag', urlImage: 'http://i67.photobucket.com/albums/h319/pdxcam/IMG_0694.jpg?t=1214698046', urlInfo: 'http://www.strangelovelive.com/', tsCreated: 1214698058 },{ treasureId: 609, caption: 'Strange Love Sticker', urlImage: 'http://i67.photobucket.com/albums/h319/pdxcam/IMG_0693.jpg?t=1214697932', urlInfo: 'http://www.strangelovelive.com/', tsCreated: 1214697995 }];
treasures.sort(function(a,b) {
    var tsCreatedA=a.tsCreated;
    var tsCreatedB=b.tsCreated;

    if (tsCreatedA<tsCreatedB)
        return 1;
    else if (tsCreatedA>tsCreatedB)
        return -1;
    else {
        if (a.treasureId<b.treasureId)
            return 1;
        else if (a.treasureId>b.treasureId)
            return -1;
        else
            return 0;
    }
});
var eList=document.createElement("div");
eList.id=tlishDivId+"-treasures";

function showMagImage(eMag) {
    var imgContainer=eMag.imgContainer;
    var imgObj=imgContainer.imgObj;

    while (eMag.firstChild)
        eMag.removeChild(eMag.firstChild);

    var imgMag=document.createElement("img");
    imgMag.src=imgObj.src;
    imgMag.alt="Image";

    var marginLeft=0;
    var marginTop=0;

    if (imgObj.origWidth>imgObj.origHeight) {
        imgMag.style.width="125px";
        imgMag.style.height="auto";

        marginLeft=0;
        marginTop=(125-(imgObj.origHeight*(125.0/imgObj.origWidth)))/2;
    } else {
        imgMag.style.width="auto";
        imgMag.style.height="125px";

        marginTop=0;
        marginLeft=(125-(imgObj.origWidth*(125.0/imgObj.origHeight)))/2;
    }

    imgMag.style.marginLeft=marginLeft+"px";
    imgMag.style.marginTop=marginTop+"px";

    eMag.appendChild(imgMag);

    var pLeft=imgContainer.offsetParent.offsetLeft+25;
    var pTop=imgContainer.offsetParent.offsetTop-25;

    eMag.style.left=pLeft+"px";
    eMag.style.top=pTop+"px";

    eMag.style.display="block";
} //showMagImage

for (var a=0;a<treasures.length;a++) {
    var treasure=treasures[a];

    var eDiv=document.createElement("div");
    eDiv.style.position="relative";
    eDiv.style.height="50px";
    eDiv.className="tlish-treasure";

    if (a>0)
        eDiv.style.paddingTop="3px";

    if (a<(treasures.length-1))
        eDiv.style.paddingBottom="3px";


    var eDivImg=document.createElement("div");
    eDivImg.style.height="50px";
    eDivImg.style.width="50px";
    eDivImg.style.position="absolute";
    eDivImg.style.left="0px";
    eDivImg.style.top="0px";
    eDivImg.style.border="1px solid #cccccc";
    eDivImg.className="tlish-image";


    var urlImage=treasure.urlImage;
    if (urlImage=="")
        urlImage="http://www.treasurelicious.com/media/treasureUnknown.png";

    var eImg=document.createElement("img");
    eImg.style.visibility="hidden";

    eDivImg.imgObj=eImg;

    eImg.onload=function() {
        var width=this.width;
        var height=this.height;

        this.origWidth=width;
        this.origHeight=height;

        var marginTop=0;
        var marginLeft=0;

        if (width>height) {
            this.style.width="50px";
            this.style.height="auto";

            marginLeft=0;
            marginTop=(50-(this.origHeight*(50.0/this.origWidth)))/2;
        } else {
            this.style.width="auto";
            this.style.height="50px";

            marginLeft=(50-(this.origWidth*(50.0/this.origHeight)))/2;
            marginTop=0;
        }

        this.style.marginLeft=marginLeft+"px";
        this.style.marginTop=marginTop+"px";

        this.style.visibility="visible";
    }; //onload

    (function(obj) {
        eDivImg.onmouseover=function(event) {
            var eMag=obj;

            if (eMag.timeoutId>0)
                window.clearTimeout(eMag.timeoutId);

            //if mag is already displayed, show the new image right away
            if (eMag.style.display=="block") {
                eMag.imgContainer=this;
                showMagImage(eMag);
            } else {
                eMag.imgContainer=this;

                (function(myObj) {
                    eMag.timeoutId=window.setTimeout(function() {
                        showMagImage(myObj);
                    },500);
                })(obj);
            }
        }; //onmouseover
    })(eMag);

    (function(obj) {
        eDivImg.onmouseout=function() {
            var eMag=obj;

            if (eMag.timeoutId>0) {
                window.clearTimeout(eMag.timeoutId);
                eMag.timeoutId=-1;
            }

            (function(myObj) {
                eMag.timeoutId=window.setTimeout(function() {
                    var eMag=myObj;
                    eMag.style.display="none";
                },250);
            })(obj);
        }; //onmouseout
    })(eMag);


    eImg.src=urlImage;
    eImg.alt="Treasure image";

    eDivImg.appendChild(eImg);

    eDiv.appendChild(eDivImg);


    var eDivCaption=document.createElement("div");
    eDivCaption.style.position="absolute";
    eDivCaption.style.left="60px";
    eDivCaption.style.top="16px";
    eDivCaption.style.height="34px";
    eDivCaption.style.right="0px";
    eDivCaption.style.lineHeight="34px";
    eDivCaption.style.overflow="hidden";
    eDivCaption.style.textAlign="left";
    eDivCaption.className="tlish-caption";
    eDivCaption.title=treasure.caption;

    if (treasure.urlInfo!="") {
        var eAnchor=document.createElement("a");
        eAnchor.href=treasure.urlInfo;
        eAnchor.appendChild(document.createTextNode(treasure.caption));

        eDivCaption.appendChild(eAnchor);
    } else
        eDivCaption.appendChild(document.createTextNode(treasure.caption));

    eDiv.appendChild(eDivCaption);


    var eDivIcons=document.createElement("div");
    eDivIcons.style.position="absolute";
    eDivIcons.style.left="60px";
    eDivIcons.style.top="0px";
    eDivIcons.style.height="16px";
    eDivIcons.style.right="0px";
    eDivIcons.style.overflow="hidden";
    eDivIcons.className="tlish-icons";


    var props=["w00t!","omg!","sexy!","sweet!","wicked awesome!","kickass!","wow!","groovy!","hot!","score!","woohoo!"];
var twitterStatus="\@camikaos "+props[Math.floor(Math.random()*props.length)]+" "+treasure.caption+" http://tlish.com/list?id=156&tid="+treasure.treasureId;

    var eTwitter=document.createElement("a");
    eTwitter.href="http://twitter.com/home?status="+encodeURIComponent(twitterStatus);
    eTwitter.style.display="none";
    eTwitter.onclick=function() {
        return openWindow(this,'Twitter');
    }

    var eTwitterImg=document.createElement("img");
    eTwitterImg.alt="Twitter";
    eTwitterImg.title="Talk about this treasure on Twitter";
    eTwitterImg.src="http://www.treasurelicious.com/media/twitter.png";
    eTwitterImg.style.border="0";
    eTwitterImg.style.marginRight="5px";

    eTwitter.appendChild(eTwitterImg);

    eDivIcons.appendChild(eTwitter);


    var dateNow=(new Date()).getTime();
    dateNow=dateNow/1000;

    if ((dateNow-treasure.tsCreated)<24*60*60) {
        var eNew=document.createElement("img");
        eNew.src="http://www.treasurelicious.com/media/new.png";
        eNew.alt="New";
        eNew.title="New";
        eNew.className="tlish-new";
        eNew.style.marginRight="5px";

        eDivIcons.appendChild(eNew);
    }

    eDiv.appendChild(eDivIcons);


    (function(wrapper,twitter) {
        wrapper.onmouseover=function() {
            if (wrapper.timeoutId>0)
                window.clearTimeout(wrapper.timeoutId);

            twitter.style.display="inline";
        };
    })(eDiv,eTwitter);

    (function(wrapper,twitter) {
        wrapper.onmouseout=function() {
            if (wrapper.timeoutId>0) {
                window.clearTimeout(wrapper.timeoutId);
                wrapper.timeoutId=-1;
            }

            wrapper.timeoutId=window.setTimeout(function() {
                twitter.style.display="none";
            },250);
        };
    })(eDiv,eTwitter);


    eList.appendChild(eDiv);
} //treasures

divTreasures.appendChild(eList);


var divFooter=document.createElement("div");
divFooter.id=tlishDivId+"-footer";
divFooter.style.padding="2px";
divFooter.style.marginTop="5px";
divFooter.style.borderTop="1px solid #cccccc";

var imgLogo=document.createElement("img");
imgLogo.src="http://www.treasurelicious.com/media/logoSmall.png";
imgLogo.alt="Treasurelicious";
imgLogo.style.border="none";
imgLogo.style.verticalAlign="middle";
imgLogo.style.marginRight="2px";

var aLogo=document.createElement("a");
aLogo.className="tlish-logo";
aLogo.href="http://www.treasurelicious.com";
aLogo.title="Treasurelicious : Expose your treasures";
aLogo.appendChild(imgLogo);

divFooter.appendChild(aLogo);

var aGetWidget=document.createElement("a");
aGetWidget.className="tlish-getwidget";
aGetWidget.title="Get Widget";
aGetWidget.href="http://www.treasurelicious.com/";
aGetWidget.appendChild(document.createTextNode("Get Widget"));

divFooter.appendChild(aGetWidget);

divTreasures.appendChild(divFooter);


function openWindow(obj,name) {
    if (name==null)
        name="_blank";

    window.open(obj.href,name);
    return false;
} //openWindow
divTreasures.appendChild(eMag);
