/*
Copyright Max Software Consultants, Inc.
(c) 2000-2005
All Rights Reserved
This software is the intellectual property
of Max Software Consultants, Inc. Any use 
of this software, in part or in whole, 
without written permission from Max Software 
Consultants, Inc. is strictly prohibited.
*/

if (dbdim=="") dbdim="pixel.gif";

function set_dbgim (img)
{
   if (img == "#") return;
   dbgim = '/images/backgrounds/'+img;
   select_backgnd();
   return;
}

function set_dbdim (img)
{
   if (img == "#") return;
   dbdim = '/dollmagic/images/scenes/'+img;
   select_backgnd();
   return;
}

var categs = new Array(
"-Misc",
"#Misc",
"Trash",
"Repair",
"Unknown",
"-Preps",
"#Boys",
"Heads",
"Shirts",
"Bodies",
"Tops",
"Bottoms",
"#Girls",
"Heads",
"Shirts",
"Bodies",
"Tops",
"Bottoms",
"-Goth",
"#Boys",
"Heads",
"Shirts",
"Bodies",
"Tops",
"Bottoms",
"#Girls",
"Heads",
"Shirts",
"Bodies",
"Tops",
"Bottoms"

);

var w;
var topcat = '';
var subcat = '';

function dollsorter(d)
{
   w=window.open('','dollsorter','location=0,status=0,toolbars=yes,scrollbars=yes,resizable=yes,width=900,height=600');
   if (w.dollpart == null) {
      w.document.writeln ('<scr' + 'ipt>');
      w.document.writeln ('function categorize(cat)');
      w.document.writeln ('{alert(dollpart.src + "=" + cat); window.close();}');
      w.document.writeln ('</scr' + 'ipt>');
      w.document.writeln ('<table width=900 bgcolor=#CCCCCC><tr><td valign=top><img id=dollpart src="'+d+'"></td><td valign=top>');
      for (i=0; i<categs.length; i++) {
	    if (categs[i].charAt(0) == '-') {
		   topcat = categs[i].substring(1);
		   if (i>0) w.document.writeln ('<br>');
		   w.document.writeln ('<b>'+categs[i]+'</b> ');
        }  
	    else if (categs[i].charAt(0) == '#') {
	   	   subcat = categs[i].substring(1);
	   	   if (i>0) w.document.writeln ('<br>');
	   	   w.document.writeln ('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>'+categs[i]+'</b> ');
        }  
        else w.document.writeln('<input type=radio onclick=categorize("'+topcat+'/'+subcat+'/'+categs[i]+'");>'+ categs[i]);
      }
      w.document.writeln ('</td></tr></table>');
   }
   else {
      w.dollpart.src = d;
   }
   w.focus();
}


function drawdoll()
{
    var txt = "";
    for (i=0; i<dl.length; i++) {
       txt = "";
       c = dl[i].substring(0,1);
       if (c != "#") {
          if (mgrinst) txt = '<a href=javascript:dollsorter("'+dollpath+dl[i]+'");>X</a>';
          txt += '<img dSize=9 bgColor="FFFFFF" filter1="none" filter2="none" filter3="none" filter4="none" class=doll id=' + i + ' style="z-index:' + zbase + ';border-width:1;" src=' + dollpath + dl[i]+' onmouseover="setHandlers1();">';
          // if (mgrinst) txt += '</a>';
          document.writeln(txt);
       }
    }
    nxtspareIM=document.images.length;
    for (i=dl.length;i<dl.length+sparecnt;i++) {
       document.writeln('<img dSize=9 class=doll id=' + i + ' style="position:absolute;z-index:' + zbase + ';border-width:1;" src=pixel.gif  onmouseover="setHandlers1();">');
    }
}

function txtStyle() {
  this.zIndex=tZIndex;
  this.borderStyle=tBorderStyle;
  this.borderWidth=tBorderWidth;
  this.borderColor=tBorderColor;
  this.color=tColor;
  this.backgroundColor=tBackgroundColor;
  this.fontFamily=tFontFamily;
  this.fontStyle=tFontStyle;
  this.fontWeight=tFontWeight;
  this.fontSize=tFontSize;
  this.width=tWidth;
  this.whiteSpace=tWhiteSpace;
  this.textAlign=tTextAlign;
  return this;
}

function txtSpan() {
  this.style = new txtStyle();
  this.bgColor=tBackgroundColor;
  setFilter(tFilter,this);
  this.filter=tFilter;
  return this;
}

function drawtext() {
  var chars ="ABCDEFGHIJKLMNOPQUSTUVWXYZ" +
             "abcdefghijklmnopqrstuvwxyz" +
             "1234567890`~!@#%^&*()_{}"
             ":\"\\|<>?-=[];\',./";
  var tid;
  var tsp = new txtSpan();
  for (i=0; i<tl.length; i++) {
     c = tl[i].substring(0,1);
     if (c != "#") {
      if (c == '=') {
         document.writeln('<hr>');
      }
      else {
         tid = "TX"+i;
         document.write('<span id='+ tid + ' class=text onmouseover="setHandlers2();" style="z-index:8;">');
       //  document.write('<table border=0 cellpadding=0 cellspacing=0 class=text><tr><td>'+tl[i]+'</td></tr></table>');
         document.write(tl[i]);
         document.writeln('</span>');
         dupTProps(tsp,document.all[tid]);
      }
    }
  }
  if (tAlphabet) {
     document.writeln('<br>');
     j=i;
     for (i=0; i<chars.length; i++) {
        c = chars.charAt(i);
        tid = "TX"+j;
        j++;
        document.write('<span id='+ tid + ' class=text onmouseover="setHandlers2();" style="z-index:8;">');
        document.write(c);
        document.writeln('</span>');
  //      dupTProps(document.all.tspan,document.all[tid]);
        dupTProps(tsp,document.all[tid]);
     }
     i=j;
  }
  document.writeln('<br>');
  nxtspareTX=i;
  for (j=i;j<i+sparecnt;j++) {
      tid = "TX"+j;
      document.write('<span id='+ tid + ' class=text onmouseover="setHandlers2();" style="z-index:8;">');
      document.writeln('</span>');
  }
}

function ad120X600()
{
//    document.writeln ('<script language="javascript"> ');
//    document.writeln ('var defaultAd = ""; ');
//    document.writeln ('</script> ');
//    document.writeln ('<script language="javascript" ');
//    document.writeln ('src="http://www6.bannerspace.com/asp/getad8os.asp?MID=11616&alt=off&f=FF0000&b=FFFFFF&w=_blank&s=120x600&ads=6&pop=1"> ');
//    document.writeln ('</script> ');
//    document.writeln ('<noscript> ');
    document.writeln ('<IFRAME name="bsadframe" ID="bsadframe" WIDTH=120 HEIGHT=600 SCROLLING="no" ');
    document.writeln ('FRAMEBORDER="0" FRAMESPACING="0" MARGINHEIGHT="0"  ');
    document.writeln ('MARGINWIDTH="0" BORDER="0" HSPACE="0" VSPACE="0" ALIGN="center" ');
    document.writeln ('SRC="http://www6.bannerspace.com/asp/getban_html.asp?MID=11616&alt=off&f=FF0000&b=FFFFFF&w=_blank&s=120x600&pop=1"> ');
    document.writeln ('<a href="http://www6.bannerspace.com/asp/gosite.asp?MID=11616&s=120x600" ');
    document.writeln ('target=_blank><img ');
    document.writeln ('src="http://www6.bannerspace.com/asp/getban.asp?MID=11616&s=120x600" width=120 ');
    document.writeln ('height=600 border=0></a> ');
    document.writeln ('</IFRAME> ');
//    document.writeln ('</noscript> ');
}

function dollhelp()
{
/**/
    document.writeln ('<table border=0 cellpadding=0 cellspacing=0><tr><td valign=top width=700>');
    document.writeln ('<font face=impact size=5 style="color:blue; background-color:yellow;"><center>How to Make Dolls using <b><i>Doll-Magic</i></center><b></font>');
    document.writeln ('<font face=arial size=1 color=#333333><center>The Ultimate Doll Maker / Doll Creator for Cartoon Dollz. Copyright 2002, 2003, 2004. All Rights Reserved.</font><br></font></center>');
    document.writeln ('<left><font face=arial size=3 color=Black><b>1) Select doll pieces from the dropdown lists below. <font color=#444444>Anything with a * is new!</font><br><b></font>');
    document.writeln ('<font face=arial size=3 color=darkblue><b>2) Left Mouse Button -- <i>DRAG</i> Doll Piece or Text Label into Design Box.<br><b></font>');
    document.writeln ('<font face=arial size=3 color=red><b>3) Double Click -- <i>COPY</i> Doll Piece or Text Label into Design Box.<br><b></font>');
    document.writeln ('<font face=arial size=3 color=darkmagenta><b>4) Right Mouse Button -- Set Properties for Doll Piece or Text Label.<br><b></font>');
    document.writeln ('<font face=arial size=3 color=brown><b>5) Make sure your Doll Pieces and Text Labels are contained within the Design Box.<br><b></font>');
//    document.writeln ('<font face=arial size=2><b><i>Doll Piece Position</i> determines how pieces stack on top of other pieces. Lower pieces go behind higher pieces.<br><b></font>')
    document.writeln ('<font face=arial size=3 color=darkgreen><b>6) Click <i>Save Doll</i> to save your doll.<br><b></font>');
    document.writeln ('</td></tr></table>');

    document.writeln ('<table cellpadding=0 cellspacing=0><tr><td align=center>');
    document.writeln ('<font face=arial size=2 color=red><br>Thanks to your uploads we have more than <b>20,000</b> new doll pieces. <a href=http://maxpages.com/dolls/upload>Click to Upload.</a>');
    document.writeln ('<br>But we need your help. <a href=http://maxpages.com/dollmaker>Click Here</a> to volunteer to help sort doll pieces.</font>');
    document.writeln ('<br><br>');
/**/

}


function draw(set) {
  BSR = sniffBrowser() ;
  if (BSR == NN4) {
    document.writeln ('You need Internet Explorer to look at the dollmaker!');
  }
  else {
  //  top.window.moveTo(0,0);
  //  top.window.resizeTo(screen.availWidth,screen.availHeight);
    document.onmousedown=IEmousedown;
    document.onmouseup=IEmouseup;
    document.ondblclick=IEdblclick;
    count = -1;

    document.writeln('<center>');
// Links 
   if (!embedded) {
      document.writeln ("<font face=arial size=2>");
      document.writeln("<b><a href=http://maxpages.com/maxpages/create_site>Create Free Web Site</a>");
      document.writeln("&nbsp;&nbsp;&nbsp;");
      document.writeln("<a href=http://maxpages.com/dollzvillage/upload>Upload Props</a>");
      document.writeln("&nbsp;&nbsp;&nbsp;");
      document.writeln("<a href=http://maxpages.com/dollguest?pg=Home&emb=10&formname=guestbook&a=Fill+Form>Sign Guestbook</a>");
      document.writeln("&nbsp;&nbsp;&nbsp;");
      document.writeln("<a href=http://maxpages.com/dollguest?pg=Home&emb=10&formname=guestbook&a=List+Data>View Guestbook</a>");
      document.writeln("&nbsp;&nbsp;&nbsp;");
      document.writeln("<a href=http://maxpages.com/dollzvillage>Old Doll Maker</a>");
      document.writeln("&nbsp;&nbsp;&nbsp;");
      document.writeln("<a href=http://maxpages.com/dollzvillage/gab_bag>Gab Bag</a></b>");
      document.writeln ("</font>");
   }
// newtech
    document.writeln('<STYLE>.suData {behavior:url(#default#userData);}</STYLE>');
    document.write('<FORM ID="oPF"><INPUT CLASS="suData" TYPE="hidden" ID="oPI"></FORM>');
    document.writeln ('<input type=button value="How to Make a Doll"');
    document.writeln ('onclick=showModelessDialog(\'http://maxpages.com/dollmagic/dollhelp.htm\')>');
   document.writeln ("<font face=arial size=1>");
   document.writeln ("<br>DollMagic -- The Ultimate Doll Maker / Doll Creator for Cartoon Dollz. Copyright 2000-2005. All Rights Reserved.</font>");


    document.writeln ('<table cellpadding=0 cellspacing=0><tr><td valign=top align=center XXX>');
//    ad120X600();
    document.writeln ('</td><td valign=top align=center>');

    document.writeln ('<script>show_sets();</script>');


    document.writeln ('<script language="javascript">');
    document.writeln ('  if (AdLoaded) {ShowAd();}');
    document.writeln ('</script>');
   
    document.writeln ('<table cellpadding=5 cellspacing=0><tr><td valign=top xxx>');
    document.writeln ('<script>mgr();</script>');
    document.writeln ('</td><td valign=top>');
    document.writeln ('<center><TABLE id=dollbox bgColor='+dback+' border=5 cellPadding=0 cellSpacing=0 width='+boxwidth+' height='+boxheight+' style="background-image: url(' + dbgim + '); background-repeat: repeat;">');
//    document.writeln ('<center><TABLE id=dollbox bgColor='+dback+' border=5 cellPadding=100 cellSpacing=1 width='+boxwidth+' height='+boxheight+'>');
    document.writeln ('<TBODY><TR><TD align=center valign=middle id=dollcell>');
    document.writeln ('<img class=anchor id=dolltab src='+dbdim+' height=100% width=100%>');
    document.writeln ('</TD></TR></TBODY></TABLE>');

    boxadj(0,0);

    document.writeln ('<center><table border=0 cellpadding=0 cellspacing=0><tr><td align=center>');
    document.writeln ('<center><table><tr>');
    document.writeln ('<td><font face="Arial" size=2><b>Width:</b></font>');
 
    document.writeln ('</td><td><input style="cursor:hand;" type=button name=fwidth value=\"+\" onclick=\"javascript:boxadj(boxdelta,0);\">');
    document.writeln ('</td><td><input style="cursor:hand;" type=button name=fwidth value=\"-\" onclick=\"javascript:boxadj(-boxdelta,0);\">');
    document.writeln ('</td><td><font face="Arial" size=2><b>Height:</b></font>');
    document.writeln ('</td><td><input style="cursor:hand;" type=button name=fheight value=\"+\" onclick=\"javascript:boxadj(0,boxdelta);\">');
    document.writeln ('</td><td><input style="cursor:hand;" type=button name=fheight value=\"-\" onclick=\"javascript:boxadj(0,-boxdelta);\">');

    document.writeln ('</td><td><table id="cbox" border=0 cellpadding=0 cellspacing=0 bgcolor='+dback+'><tr><td valign=middle>');
    document.writeln ('<font id=bgon face=arial size=2 color=000000><b>&nbsp;Background:&nbsp;</b></font></td><td>');
//    drawcbox2(cpast,32,2);
    document.writeln ('<table border=0 height=20 cellpadding=0 cellspacing=0><tr><td>');
    drawcbox2(cpast,32,2);
    document.writeln ('</td><td>');
    drawcbox();
    document.writeln ('</td></tr></table>');
    document.writeln ('</td><td valign=middle><font id=bgoff face=arial size=2 color=000000 bgcolor=yellow style="cursor:hand;">');
    document.writeln ('&nbsp;<a onclick="setbg(\'FFFFFF\');"><b>Off&nbsp;</b></a></font>');
    document.writeln ('</td></tr></table>');
    
    document.writeln ('</td><td>');
    draw_scenes();
    document.writeln ('</td><td>');
    draw_bkgnds();
    document.writeln ('</td><td><input type=button value="Clear Doll" onclick="javascript:clear_doll();">');

    document.writeln ('</td></tr></table>');

    document.writeln ('</td></tr><tr><td align=center>');
//    document.writeln ('<input type=button name=print value=\"Save Doll\" onclick=\"print_doll()\">');
/**/
    document.writeln('<form name="sdoll" method="POST"><table><tr><td align=center>');
    document.writeln('<font face="Arial" size=2><b>Doll Name:</b></font>');
    document.writeln('<input type="text" name="dname" size="10" maxlength="80" onBlur="this.value=cleanText(this.value);"><br></td><td>');
    document.writeln('<font face="Arial" size=2><b>Your Name:</b></font>');
    document.writeln('<input type="text" name="cname" size="10" maxlength="20" onBlur="this.value=cleanText(this.value);"><br></td><td>');
    document.writeln('<font face="Arial" size=2><b>Crop:</b></font>');
    document.writeln('<input type=checkbox name="dcrop" '+ischecked(dcrop)+'></td><td>');
    document.writeln('<font face="Arial" size=2><b>Frame:</b></font>');
    document.writeln('<input type=checkbox name="dframe" '+ischecked(dframe)+'></td><td>');
    document.writeln('<input type=button value="Save Doll" onclick="javascript:save_doll();">');
    document.writeln('</td></tr></table></form>');
/**/
//    document.writeln ('<font face="Arial" size=2>Click on the Rainbow Bar to set a background.<br>Click Off to remove the background.<br>Check Frame to save with a picture frame.<br>Check Crop to save with trimming.<br>Enter Doll Name and Your Name <i>before</i> you click Save Doll.</font>');
    document.writeln ('</td></tr></table>');
    document.writeln ('</center>');

    document.writeln ('</td><td valign=top yyy>');
    document.writeln ('</td></tr></table>');

    document.writeln ('</td><td valign=top align=center YYY>');
//    ad120X600();
    document.writeln ('</td></tr></table>');
 

    if (settext!='') document.writeln ('<center><font face=arial size=4 color=red><b>'+cattext+' / '+settext+'<br></b></font></center>');

    document.writeln (dHeader);    

    document.writeln ('<table bgcolor=lightgrey border=1><tr><td>');    
    if (isClone == 0) {
      showPieces();
      showLabels();
      drawdoll();
      drawtext();
    }
    document.writeln ('</td></tr></table>');
 /*
    for (i=0; i<dl.length; i++) {
       c = dl[i].substring(0,1);
       if (c != "#") {
          document.writeln('<img class=doll id=' + i + ' style="z-index:' + zbase + ';" src=' + dollpath + dl[i]+' onmouseover="setHandlers1();">');
       }
    }
    nxtspareIM=document.images.length;
    for (i=dl.length;i<dl.length+sparecnt;i++) {
       document.writeln('<img class=doll id=' + i + ' style="position:absolute;z-index:' + zbase + ';" src=pixel.gif  onmouseover="setHandlers1();">');
    }
 */
    document.writeln ('</td></tr><table>');

//document.writeln('<br><center><span style="background-color:#FFFF00">');
//document.writeln('<font size=3 face=arial>');
//document.writeln('<b>Help Keep Us Popup Free. Support Our Sponsors.</b>');
//document.writeln('</font>');
//document.writeln('</span><br>');
//document.writeln('<iframe src=http://bidclix.net/PopUps/Popup31.jsp?nl=5&p=1260&cat=36&opt=1&gId=9 height=100 width=500>');
//document.writeln('</iframe></center>');

    document.writeln('<table><tr><td align=center>');
    document.writeln (dFooter);    
//    document.writeln ('<br><br><font face="Arial" size=3><b>Visit a Doll Gallery</b></font><br><table cellspacing=5><tr>');
//    var rooms = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
//    for (i=0;i<26;i++) {
//       document.writeln ('<td width=20 align=center bgcolor=blue style="cursor:hand;"><a onclick="show_gallery(\''+rooms.charAt(i)+'\')">');
//       document.writeln ('<font face=Arial color=yellow size=3><b> ' + rooms.charAt(i) + ' </b></font></a></td>');
//    }

      uiVisitGallery();
      document.writeln ('</td></tr></table>');
    
//    document.writeln ('<a href=http://maxpages.com/dollmaker><br>Rate&nbsp;the&nbsp;New&nbsp;Save&nbsp;Doll&nbsp;Feature</a>');

//    document.writeln ('<script> adle(); </script>');
//    document.write ('<br><A HREF="http://web1.realtracker.com/netpoll/stat.asp?id'+id+'=&user=549558&pn=10053&offset=1000000&username=Dollmaker&userurl=http://maxpages.com/dollmaker" TARGET="_blank">');
//    document.write ('<IMG SRC="http://web1.realtracker.com/netpoll/ifree.asp?id'+id+'=&user=549558&pn=10053&offset=1000000&to=-360&js=1'+res+'" BORDER=0 WIDTH=32 HEIGHT=32 ALT=""></A>');
//    document.writeln ('</td></tr><table>');

  }
}
