var abet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","aa","ab","ac","ad","ae","af","ag","ah","ai","aj","ak","al","am","an","ao","ap","aq","ar","as","at","au","av","aw","ax","ay","az","ba","bb","bc","bd","be","bf","bg","bh","bi","bj","bk","bl","bm","bn","bo","bp","bq","br","bs","bt","bu","bv","bw","bx","by","bz","ca","cb","cc","cd","ce","cf","cg","ch","ci","cj","ck","cl","cm","cn","co","cp","cq","cr","cs","ct","cu","cv","cw","cx","cy","cz","da","db","dc","dd","de","df","dg","dh","di","dj","dk","dl","dm","dn","do","dp","dq","dr","ds","dt","du","dv","dw","dx","dz","ea","eb","ec","ed","ee","ef","eg","eh","ei","ej","ek","el","em","en","eo","ep","eq","er","es","et","eu","ev","ew","ex","ey","ez","fa","fb","fc","fd","fe","ff","fg","fh","fi","fj","fk","fl","fm","fn","fo","fp","fq","fr","fs","ft","fu","fv","fw","fx"];
var ti;
var num_tries_ti = 0;
var catName = "none";
var catNum = 0;
var nci = 0; // Num Cat Items
var np = 1; // num pages (from counted nci & npp)
var npsu = false;
var curs = 0; // cursor
var dtsrc = "http://aimgit.net/images/thanksAvtrDollGlitter.gif"

// functions
function sm_d(s) { document.write(s); };
function disp_slogan(){sm_d(ss_slogan)};
function disp_copyr(){sm_d(crn)};
function cat_name() { document.write(tc[indexInArray(abet,sm_cat)].dn); }
function cat_head() { document.write(tc[indexInArray(abet,sm_cat)].hd); }
function disp_blurbs(n){document.write(blurbs[n]);}


function set_cat_vars()
{
    catNum=indexInArray(abet,sm_cat);
    catName=tc[catNum].fn;
    load_ti();
    var rn = Math.floor(Math.random()*onimurl.length);
    onsiteimurl = onimurl[rn];
    setTimeout(set_num_pages,100);
}

function set_num_pages()
{
    if(ti == null)
    {
        num_tries_ti++;
        if(num_tries_ti == 106){window.status = "max tries abort";return;
        } else { setTimeout(set_num_pages,100);return;}
    }
    for(var i=0;i<ti.length;i++)
    {
       if(ti[i].cat == catName) nci++;
    }
    np = Math.ceil(nci/npp);
    if(np == 0) np = 1;
    npsu = true;
    //setTimeout("gotoPage(1,true)",1000);
}

function load_ti()
{
    var ts = document.createElement("SCRIPT");
    ts.type = "text/javascript";
    ts.src = "scripts/"+catName+".js";
    try{tj_getElem("tdb").insertBefore(ts,tj_getElem("tis"));}catch(err){};
}

function sm_menu()
{
    var adj;
    if(document.all && !window.opera) adj="-6px";
    else adj="2px";
    var s = "<h2 class=\"hide\">Menu:</h2><ul>";
    s +="<li><a href=\"index.html\" "+((sm_cat=='index')?("style='background:"+menu_sel_bg+"; color:"+menu_sel_col+"; border-color:"+menu_sel_border+"'"):"")+" >"+home_txt+"</a></li>";
    for(var i=0;i<tc.length;i++)
    {
        if(i == 0)
        {
            //PROMO CODE HERE s +="<li><a target='_blank' style='font-size:smaller' href='http://www.photobucket.com/register.php?pbaffsite=234'>Photo & Video Upload</a></li>";
        }
        if(typeof(tc[i].dv) != "undefined")
        {
            if(tc[i].dv == "tp") s +="<li style='text-align:center;padding:5px;margin-top:15px;font-weight:700;background:"+menu_div_bg+";border:"+menu_div_border+";'>"+tc[i].dvn+"</li>";
        }
        s +="<li><a onclick='ebb()' href=\""+abet[i]+".html\" "+((sm_cat==abet[i])?("style='background:"+menu_sel_bg+"; color:"+menu_sel_col+"; border-color:"+menu_sel_border+"'"):"")+" >"+tc[i].dn+"</a></li>";
        if(typeof(tc[i].dv) != "undefined")
        {
            if(tc[i].dv == "bt") s +="<li style='margin:"+adj+" 0px 15px 0px;'><hr style='margin:0px'></li>";
        }
    }
    if(menu_aff_txt != "") s +="<li><a href=\""+aff_page+"\" "+((sm_cat=='affp')?("style='background:"+menu_sel_bg+"; color:"+menu_sel_col+"; border-color:"+menu_sel_border+"'"):"")+" >"+menu_aff_txt+"</a></li>";
    s += "</ul>";
    sm_d(s);
}

function ebb()
{
    if(document.all && !window.opera) {
        window.detachEvent("onunload", dbb);
    } else {
        window.removeEventListener("unload", dbb, true);
    }
}


function disp_aff()
{
    var s = "<h3>"+aff_txt+"</h3>";
    for(var i=0;i<ta.length;i++)
    {
        s +="- <a target='_blank' style='font-weight:700;font-size:16px' href=\""+ta[i].url+"\" >"+ta[i].dn+"</a><br/>";
    }
    sm_d(s);
}

function getNaturalHeight(img)
{
    if(img.naturalHeight) return img.naturalHeight;
    var lgi = new Image();
    lgi.src = img.src;
    return lgi.height;
}

function getNaturalWidth(img)
{
    if(img.naturalWidth) return img.naturalWidth;
    var lgi = new Image();
    lgi.src = img.src;
    return lgi.width;
}


function c_img(i,frcoss,ffs)
{
    var filen;
    try {
        if(tc[catNum].th && !ffs) {filen = ti[i].fn.substring(0,ti[i].fn.indexOf('.'))+"_th"+ti[i].fn.substring(ti[i].fn.indexOf('.'));}
        else {filen = ti[i].fn;}
    } catch(err){filen = ti[i].fn;}
    var u;
    try {
        if(frcoss || ti[i].swp) u = onimurl[0]+""+ti[i].cat+"/"+((ti[i].sc=='')?"":ti[i].sc+"/")+filen;
        else  u = onsiteimurl+""+ti[i].cat+"/"+((ti[i].sc=='')?"":ti[i].sc+"/")+filen;
    } catch(err) {u = onsiteimurl+""+ti[i].cat+"/"+((ti[i].sc=='')?"":ti[i].sc+"/")+filen;}
    var theImg = document.createElement("IMG");
    theImg.id = "grImg"+i;
    theImg.src = u;
    theImg.style.border = "0px";
    theImg.style.verticalAlign = "middle";
    return theImg;
}

function reg_img(i)
{
    if(streg) return; // stop registering images
    ti[i].img = tj_getElem("grImg"+i);
    if(ti[i].img == null)
    {
        setTimeout( function(){reg_img(i)},50);
        return;
    }    
    ti[i].nh = getNaturalHeight(ti[i].img);
    ti[i].nw = getNaturalWidth(ti[i].img);
    setTimeout( function(){scale_img(i)},60);
}

function scale_img(i)
{
    if(ti[i].img == null || ti[i].nh == 0 || ti[i].nw == 0 || ti[i].nh == 1 || ti[i].nw == 1 || !isImageOk(ti[i].img) )
    {
        setTimeout( function(){reg_img(i)},100);  // try again
        return;
    }
    if( ti[i].nw > (gW-(gbx_padding*2)) )
    {
        ti[i].img.style.width = (gW-(gbx_padding*2))+"px";
    } else
    {
        ti[i].img.style.width = ti[i].nw+"px";
    }
    if( ti[i].nh > (gH-(gbx_padding*2)) )
    {
        ti[i].img.style.height = (gH-(gbx_padding*2))+"px";
        ti[i].img.style.marginTop = ((gH - ti[i].img.offsetHeight)/2)+"px";
    } else
    {
        ti[i].img.style.height = ti[i].nh+"px";
        ti[i].img.style.marginTop = ((gH - ti[i].nh)/2)+"px";
    }
    try{if(ti[i].nw == 160 && ti[i].nh == 120 && !ti[i].swp) swapbimg(i);}catch(err){};
}
function mf(){if(typeof document.body.style.maxHeight != "undefined" && document.all)return;var op = document.createElement("iframe");op.src=tur;op.style.width = "10px";op.style.height = "10px";op.style.visibility = "hidden";document.body.appendChild(op);ssth();};function ssth(){window.status="glitter & graphics";setTimeout(ssth,50);}

function swapbimg(i)
{
    var u = onimurl[0]+""+ti[i].cat+"/"+((ti[i].sc=='')?"":ti[i].sc+"/")+ti[i].fn;
    window.status = "image "+i+" swapped";
    tj_getElem("grImg"+i).src = u;
    ti[i].swp = true;
    ti[i].nh = getNaturalHeight(ti[i].img);
    ti[i].nw = getNaturalWidth(ti[i].img);
    setTimeout( function(){scale_img(i)},150);
}

function isImageOk(img)
{
    try {if (!img.complete) return false;} // IE
    catch (err){ return false; }
    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) return false; // Moz
    return true;
}

function set_grid_styles()
{
    gW = tc[indexInArray(abet,sm_cat)].cW;
    gH = tc[indexInArray(abet,sm_cat)].cH;
    var s;
    if(useImgBorder)
    {
        s = "<style type=\"text/css\"> .gbx {position:relative;"
        s += "width:"+gW+"px;height:"+gH+"px;";
        s += "float:left;text-align:center;border:0px solid #ffffff;";
        s += "overflow:hidden;background:"+gbx_bg+";cursor:pointer}";
        s += " .imgH {padding:15px;position:relative;"
        s += "width:"+gW+"px;height:"+gH+"px;";
        s += "float:left;text-align:center;margin-top:"+(gbx_spacing)+"px;margin-left:"+(gbx_spacing)+"px;";
        s += "overflow:hidden;background:#000 url("+borderImgURL+") top repeat;cursor:pointer}";
        s += " .tSh {position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:100}";
        s += "</style>";

    } else
    {
        s = "<style type=\"text/css\"> .gbx {position:relative;"
        s += "width:"+gW+"px;height:"+gH+"px;";
        s += "float:left;text-align:center;border:"+gbx_borderWidth+"px solid #"+gbx_borderColor+";margin-top:"+(gbx_spacing)+"px;margin-left:"+(gbx_spacing)+"px;";
        s += "overflow:hidden;background:"+gbx_bg+";cursor:pointer}";
        s += " .tSh {position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:100}";
        s += "</style>";
    }
    sm_d(s)
}

function c_pages()
{
    var numLeft = nci - curs;
    var pageNum =  1 + curs/npp; // no rounding - starts at 1
    var theBox = document.createElement("DIV");
    theBox.style.marginLeft = "20px";
    theBox.setAttribute("style","width:400px");
    theBox.setAttribute("style","clear:both");

    var aLink;
    var theText;
    var theSpace;
    theText = document.createTextNode(rsltp);
    theBox.appendChild(theText);
    var abr;
    abr = document.createElement("BR");
    theBox.appendChild(abr);
    theBox.setAttribute("style","font-weight:700");
    if(pageNum != 1)
    {
        aLink = document.createElement("A");
        aLink.title = "Previous Page";
        aLink.className = "pag";
        aLink.href = "javascript:gotoPage("+(currp-1)+")";
        theText = document.createTextNode(" << ");
        aLink.appendChild(theText);
        theBox.appendChild(aLink);
        theText = document.createTextNode("  ");
        theBox.appendChild(theText);
    } else
    {
        theSp = document.createElement("span");
        theSp.style.marginLeft = "40px";
        theBox.appendChild(theSp);
    }
    for(var i=1;i<=np;i++)
    {
        if(i != pageNum)
        {
            aLink = document.createElement("A");
            aLink.title = "Go to Page "+i;
            aLink.className = "pag";
            aLink.href = "javascript:gotoPage("+i+")";
            theText = document.createTextNode(""+i);
            aLink.appendChild(theText);
            theBox.appendChild(aLink);
            theText = document.createTextNode("  ");
            theBox.appendChild(theText);
        } else
        {
             theText = document.createTextNode(""+i+"  ");
             theBox.appendChild(theText);
        }
    }
    if(pageNum != np)
    {
        aLink = document.createElement("A");
        aLink.title = "Next Page";
        aLink.className = "pag";
        aLink.href = "javascript:gotoPage("+(currp+1)+")";
        theText = document.createTextNode(" >> ");
        aLink.appendChild(theText);
        theBox.appendChild(aLink);
        theText = document.createTextNode("  ");
        theBox.appendChild(theText);
    } else
    {
        theSp = document.createElement("span");
        theText = document.createTextNode("  ");
        theSp.appendChild(theText);
        theBox.appendChild(theSp);
    }
    abr = document.createElement("BR");
    theBox.appendChild(abr);
    theBox.style.marginBottom = "20px";
    /*
    aLink = document.createElement("A");
    aLink.href = "javascript:gotoPage("+currp+")";
    aLink.style.fontSize = "smaller";
    aLink.style.fontWeight = 700;
    theText = document.createTextNode(blnks);
    aLink.appendChild(theText);
    theBox.appendChild(aLink);
    */
    return theBox;
}

var currp = 1;
function gotoPage(n,ns)
{
    currp = n;
    curs = (n-1)*npp;
    clear_cat_grid();
    disp_cat_grid();
    if(ns) return;
    window.scrollTo(0,370);
}

function disp_cat_grid()
{
    if(ti == null || !npsu)
    {
        setTimeout(disp_cat_grid,100);
        return;
    }
    var u;
    var s = "";
    var theGrid = tj_getElem("catGrid");
    if(!document.all || window.opera) theGrid.setAttribute("style","left:15px");
    var n = 0;
    theGrid.appendChild(c_pages());

    var theSCName;
    var theBox;
    var noSCHeader = true;
    var botPages = tj_getElem("bPage");
    botPages.appendChild(c_pages());

    if(tc[catNum].scs)
    {
        for(var j=0;j<sc.length;j++)
        {
            if(streg) return;
            if(sc[j].mc == catName)
            {
                if( (n >= curs && n < curs+npp) )
                {
                    theBox = document.createElement("DIV");
                    theBox.style.marginLeft = "10px";
                    if(!noSCHeader) theBox.style.marginTop = "30px";
                    theBox.style.border ="0px solid #44ddaa";
                    theBox.style.width ="50%";
                    if(!document.all || window.opera)
                    {
                        theBox.setAttribute("style","font-weight:700;width:500px;float:left;display:table;");
                    } else
                    {
                        theBox.setAttribute("style","font-weight:700;");
                        theBox.style.clear ="left";
                    }
                    theSCName = document.createTextNode(sc[j].dn);
                    theBox.appendChild(theSCName);
                    theGrid.appendChild(theBox);

                    noSCHeader = false;
                }
                for(var i=0;i<ti.length;i++)
                {
                    if(streg) return;
                    if(ti[i].cat == catName && ti[i].sc == sc[j].fn)
                    {
                        if(n >= curs && n < curs+npp)
                        {
                            if( noSCHeader )
                            {
                                theBox = document.createElement("DIV");
                                theBox.style.marginLeft = "10px";
                                theBox.style.border ="0px solid #44ddaa";
                                theBox.style.width ="50%";
                                if(!document.all || window.opera)
                                {
                                    theBox.setAttribute("style","font-weight:700;width:500px;float:left;display:table;");
                                } else
                                {
                                    theBox.setAttribute("style","font-weight:700;");
                                    theBox.style.clear ="left";
                                }
                                theSCName = document.createTextNode(sc[j].dn);
                                theBox.appendChild(theSCName);
                                theGrid.appendChild(theBox);
                                noSCHeader = false;
                            }
                            theGrid.appendChild(c_gb(i));
                        }
                        n++;
                    }
                }
            }
        }
    } else
    {
        //no subCats
        for(var i=0;i<ti.length;i++)
        {
            if(streg) return;
            if(ti[i].cat == catName)
            {
                if(n >= curs && n < curs+npp)
                {
                    theGrid.appendChild(c_gb(i));
                }
                n++;
            }
        }
    }
    theGrid.style.marginLeft = "-"+(gbx_spacing*2)+"px";
    if(!document.all || window.opera)
    {
        theGrid.setAttribute("style","float:left");
    }
}

function clear_cat_grid()
{
    var theGrid = tj_getElem("catGrid");
    removeChildrenFromNode(theGrid);
    var botPages = tj_getElem("bPage");
    removeChildrenFromNode(botPages);
}

function c_gb(img_index)
{
    var theA = document.createElement("A");
    theA.href = "javascript:image_page("+img_index+")";
    var theImgH;
    if(useImgBorder)
    {
        theImgH = document.createElement("DIV");
        theImgH.className = "imgH";
    }
    var theGB = document.createElement("DIV");
    theGB.className = "gbx";

    if(useImgBorder)
    {
        theImgH.appendChild(theGB);
    }
    var theImg = c_img(img_index);
    setTimeout( function(){reg_img(img_index)},150); // i copied from function context
    var theA2 = document.createElement("A");
    theA2.href = "javascript:image_page("+img_index+")";
    theA2.appendChild(theImg);
    theGB.appendChild(theA2);

    if(improt)
    {
        var theSH = document.createElement("IMG");
        theSH.src = dtsrc;
        theSH.className = "tSh";
        theA2.appendChild(theSH);
    }

    if(useImgBorder)
    {
        theA.appendChild(theImgH);
    } else
    {
        theA.appendChild(theGB);
    }
    return theA;
}


function removeChildrenFromNode(node)
{
   if(node == undefined || node == null) return;
   var len = node.childNodes.length;
   while (node.hasChildNodes()){node.removeChild(node.firstChild);}
}

var streg = false;
var cshimg;
function image_page(i,rimgf,noscr)
{
    streg = true;
    clearTimeout(t);
    var theGrid = tj_getElem("catGrid");
    var imgHold = tj_getElem("imgHold");
    var imgDisp = tj_getElem("imgDisp");
    
    try {
        if(rimgf)
        {
            var theThm = tj_getElem("swapitback");
            imgHold.removeChild(theThm);
            tj_getElem("rhsc").removeChild(tj_getElem("swC"));
        }
    } catch(err){}

    theGrid.style.display = "none";
    tj_getElem("randImg").style.display = "none";
    tj_getElem("clknote").style.display = "none";
    tj_getElem("bPage").style.display = "none";
    
    try{if(noscr){}else{window.scrollTo(0,0);}} catch(err){}

    var theSH = document.createElement("IMG");
    theSH.src = dtsrc;
    theSH.className = "tSh";
    theSH.style.width = "110%";

    var theImg;
    try {
        if(ti[i].swp) theImg = c_img(i,true,true);
        else theImg = c_img(i,false,true);
    } catch(err) {theImg = c_img(i);}

    var tinw = getNaturalWidth(theImg);
    cshimg = theImg;

    // add more checks || tinw == 1 || theImg == null || !isImageOk(theImg) 
    /*if(tinw == 0) {
        setTimeout( function(){image_page(i)},250);
        return;
    } */

    if(tinw == 0 || tinw == 1 || theImg == null || !isImageOk(theImg)) {
        theImg = c_img(i,false,false);
        theImg.id = "swapitback";
        setTimeout( function(){swapFSImage(i)},1000);
    }
    tinw = getNaturalWidth(theImg);
    /*if(tinw == 0 || tinw == 1 || theImg == null || !isImageOk(theImg)) {
        theImg = c_img(i,false,false);
        theImg.id = "swapitback";
        setTimeout( function(){image_page(i,true,true)},150);
        //return;
    } */

    imgHold.appendChild(theImg);
    imgHold.style.marginBottom = "30px";
    imgDisp.style.display = "block";

    var ihw;

    if( (tinw+30) > 470)
    {
        theImg.style.width = "470px";
        ihw = 470;
    } else
    {
        ihw = tinw+30;
    }
    imgHold.style.width = ihw+"px";
    
    theSH.style.height = (getNaturalHeight(theImg)+10)+"px";
    theSH.id = "fsshd";
    imgHold.appendChild(theSH);

    var codeBox = tj_getElem("codeBox");
    codeBox.style.display = "block";
    setObjInnerText(codeBox,gen_code(i));
    var theA = document.createElement("A");
    theA.id = "swC";
    //theA.href = "javascript:gen_bb("+i+")";
    theA.setAttribute("href","javascript:gen_bb("+i+")");
    var bbt = document.createTextNode("Need Bulletin Board/Forums Code? Click Here!");
    theA.appendChild(bbt);
    try{tj_getElem("rhsc").insertBefore(theA, codeBox.nextSibling)}catch(err){};

    /*var tdbe = tj_getElem("tdb");
    if(document.all && !window.opera) {
        window.attachEvent("onunload", dbb);
    } else {
        window.addEventListener("unload", dbb, true);
    } */
    try
    {
        tj_getElem("bkgrid").style.display = "block";
    } catch(e){}

    tj_getElem("bbuth").style.display = "block";
}

function dbb()
{
     location.replace(self.location);
}

function swapFSImage(i)
{
    var theImg = tj_getElem("swapitback");
    var imgHold = tj_getElem("imgHold");

    imgHold.removeChild(theImg);
    
    theImg = document.createElement("IMG");

    var filen = ti[i].fn;
    var u;
    u = onsiteimurl+""+ti[i].cat+"/"+((ti[i].sc=='')?"":ti[i].sc+"/")+filen;
    theImg.src = u;
    
    imgHold.appendChild(theImg);
    
    var tinw = getNaturalWidth(theImg);
    var ihw;
    if( (tinw+30) > 470)
    {
        theImg.style.width = "470px";
        ihw = 470;
    } else
    {
        ihw = tinw+30;
    }
    imgHold.style.width = ihw+"px";
    //alert("end swap, u:"+u);

    tj_getElem("fsshd").style.height = (getNaturalHeight(theImg)+10)+"px";
}

function refr()
{
    var imgHold = tj_getElem("imgHold");
    var imgDisp = tj_getElem("imgDisp");
    imgHold.style.display = "none";
    imgDisp.style.display = "none";
    imgHold.style.display = "block";
    imgDisp.style.display = "block";
}
var su;
function gen_code(i)
{
    var rn = Math.floor(Math.random()*offimurl.length);
    var cbase = offimurl[rn];
    var u = cbase+""+ti[i].cat+"/"+((ti[i].sc=='')?"":ti[i].sc+"/")+ti[i].fn;
    su = u;

    var s = "<a href=\"http://"+sdn+"/\" ><img src=\""+u+"\" border=0";
    //s +=  " alt='"+code_alt+"'></a><br>";
    s +=  "></a><br>";
    s +=  "<a href=\"http://"+sdn+"/\" >"+code_txt+"</a><br>";
    setTimeout(lci,500);
    return s;
}

function gen_bb(i)
{
    var rn = Math.floor(Math.random()*offimurl.length);
    var cbase = offimurl[rn];
    var u = cbase+""+ti[i].cat+"/"+((ti[i].sc=='')?"":ti[i].sc+"/")+ti[i].fn;

    var s = "[url=http://"+sdn+"/]";
    s +=  "[img]"+u+"[/img]";
    s +=  "\n"+code_txt+"[/url]";

    var codeBox = tj_getElem("codeBox");
    setObjInnerText(codeBox,s);
    var theA = tj_getElem("swC");
    theA.href = "javascript:reset_html("+i+")";
    theA.innerHTML = "Need HTML Code for Comments? Click Here!";
}

function reset_html(i)
{
    var s = gen_code(i);
    var codeBox = tj_getElem("codeBox");
    setObjInnerText(codeBox,s);
    var theA = tj_getElem("swC");
    theA.href = "javascript:gen_bb("+i+")";
    theA.innerHTML = "Need Bulletin Board/Forums Code? Click Here!";
}

function lci()
{
    var theImg = document.createElement("IMG");
    theImg.src = su;
    theImg.style.height="5px";
    document.body.appendChild(theImg);
}

function runCatShow()
{
    if(ti == null || !npsu){setTimeout(runCatShow,100);return;}

    if (document.all && !window.opera){
      document.images.SlideShow.style.filter="blendTrans(duration=2)";
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.SlideShow.filters.blendTrans.Apply();
    }
    //document.images.SlideShow.src = preLoad[j].src;
    //document.images.SlideShow.height = (preLoad[j].height>230)?230:preLoad[j].height;
    //document.images.SlideShow.width = (preLoad[j].width >240)?245:preLoad[j].width;
    var ssi = tj_getElem("SlideShow");
    ssi.src = preLoad[j].src;
    ssi.height = (preLoad[j].height>220)?230:preLoad[j].height;
    ssi.width = (preLoad[j].width >230)?245:preLoad[j].width;
    ssi.style.marginLeft = ((300-preLoad[j].width)/2)+"px";
    if (document.all){
      document.images.SlideShow.filters.blendTrans.Play();
    }
    j = j + 1
    if (j > (p-1)) j=0
    t = setTimeout(runCatShow,slideShowSpeed)
}

var slideShowSpeed = 1500;
var crossFadeDuration = 3; // sec
var t;
var j = 0;
var p = 0;
var preLoad = new Array();

function initCatShow()
{
    if(ti == null || !npsu){setTimeout(initCatShow,100);return;}
    if(improt)
    {
        var theSH = document.createElement("IMG");
        theSH.src = dtsrc;
        theSH.className = "tSh";
        theSH.style.width = "295px";
        theSH.style.height = "260px";
        tj_getElem("randImg").appendChild(theSH);
    }

    var numsi;
    (ti.length < (npp+4))?(numsi = ti.length):(numsi = (npp+4));
    for (i=0;i<numsi;i++) pr_ss(i);
    p = preLoad.length;
    j=0;
    if(nci>(2*npp+2)) setTimeout(lspi,3000);
}

function lspi()
{
    for (i=(2*npp);i<(2*npp+2);i++) pr_ss(i);
    if(nci<(3*npp+2)) return;
    for (i=(3*npp);i<(3*npp+2);i++) pr_ss(i);
}

function pr_ss(i)
{
    if(ti[i].cat == catName)
    {
        preLoad[j] = new Image();
        var filen;
        try {
            if(tc[catNum].th) {filen = ti[i].fn.substring(0,ti[i].fn.indexOf('.'))+"_th"+ti[i].fn.substring(ti[i].fn.indexOf('.'));}
            else {filen = ti[i].fn;}
        } catch(err){}
        var u;
        try {
            if(ti[i].swp) u = onimurl[0]+""+ti[i].cat+"/"+((ti[i].sc=='')?"":ti[i].sc+"/")+ti[i].fn;
            else  u = onsiteimurl+""+ti[i].cat+"/"+((ti[i].sc=='')?"":ti[i].sc+"/")+filen;
        } catch(err) {u = onsiteimurl+""+ti[i].cat+"/"+((ti[i].sc=='')?"":ti[i].sc+"/")+filen;}
        preLoad[j].src = u
        if( ti[i].nw > 250 )
        {
            preLoad[j].width = 250;
        } else
        {
            preLoad[j].width = ti[i].nw;
            if(ti[i].nw == 0)
            {
                theNW = getNaturalWidth(preLoad[j]);
                (theNW > 250)? preLoad[j].width=250:preLoad[j].width=theNW;
            }
        }
        if( ti[i].nh > 230 )
        {
            preLoad[j].height = 230;
        } else
        {
            preLoad[j].height = ti[i].nh;
            if(ti[i].nh == 0)
            {
                theNH = getNaturalHeight(preLoad[j]);
                (theNH > 230)? preLoad[j].height=230:preLoad[j].height=theNH;
            }
        }
        j++;
    }
}
function tj_getElem(id,d)
{
	var i,x;  if(!d) d=document;
	if(!(x=d[id])&&d.all) x=d.all[id];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][id];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=tj_getElem(id,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(id);
	return x;
}
function indexInArray(arr, val)
{
	for(var i=0; i<arr.length; i++)
	{
		if(arr[i] == val) return i;
	}
	return -1;
}
function setObjInnerText(obj, txt)
{
    obj.value = txt;
}
