home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 June / comonline0602.iso / software / cogitum / CoTracker.exe / app.___ < prev    next >
Encoding:
Text File  |  2001-04-24  |  43.6 KB  |  1,648 lines

  1. <HTML>
  2. <HEAD> 
  3. <TITLE>Image Co-Tracker</TITLE>
  4. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
  5.   <HTA:APPLICATION ID="oMyApp" 
  6.     APPLICATIONNAME="{130C4DD1-7A96-11d4-BE19-00C0F0489117}"
  7.     BORDER="yes"
  8.     CAPTION="yes"
  9.     ICON=".\\bpad.ico"
  10.     SHOWINTASKBAR="yes"
  11.     SINGLEINSTANCE="yes"
  12.     SYSMENU="yes"
  13.     WINDOWSTATE="maximize">    
  14. </HTA:APPLICATION>    
  15. <OBJECT ID="Engine" CLASSID="CLSID:04AB20C2-D25A-11D3-A94C-00C0F048995B">
  16. </OBJECT>
  17.  
  18. <SCRIPT language="javascript">
  19.  
  20. // File2Tracker constants
  21. @set @NEW_XMLDB=0
  22. @set @OPEN_XMLDB=1
  23. @set @SAVE_XMLDB=2
  24.  
  25.  
  26. var gnImageNum = 0;
  27. var gIntId=null;
  28. var bOpenList = 0;
  29. var szPath, szProductPath;
  30. var bCallTPrint=0;
  31. var gnPicLoopCount = 0;          
  32. var idLoadPicIntv = 0;
  33. var bInsertOrRename = false;
  34. var bOk = false;
  35.  
  36.  
  37. szPath = new String (top.location.pathname);
  38. szPath = szPath.toLowerCase();
  39. if (szPath.charAt(0) == "/")
  40.  szPath = szPath.substring(1, szPath.length);
  41. nPos =  szPath.search ("app.hta");
  42. szProductPath = unescape(szPath.substring(0,nPos-1));
  43.  
  44. var    sz_XSLPath = szProductPath + "\\store.xsl";
  45.  
  46.  
  47. var    Source;
  48. var    Style;
  49. var    StyleFirst;
  50. //var    WshShell;
  51.  
  52. var sc_BeforeChange = "";
  53. var ChangeParent = null;
  54. var bNoRestore = 0;
  55. var idImgTimer = 0;
  56. var idTimeout = 0;
  57. var idDis = 0;
  58. var IEVersion;
  59.  
  60.  
  61. function SaveSource()
  62. {
  63.     var str; 
  64.  
  65.     // check XML base encoding         
  66.     if (Source.childNodes[0].attributes[1].nodeValue != "utf-8")
  67.      Source.childNodes[0].attributes[1].nodeValue ="utf-8";
  68.  
  69.     dbversion = Source.selectSingleNode ("root[@dbversion]");
  70.     if (dbversion == null)
  71.     {
  72.        Root = Source.selectSingleNode ("root");
  73.        Root.setAttribute ("dbversion", "1.0");
  74.     }
  75.  
  76.  
  77.     if (!Engine)
  78.      alert("Unable to create Image Co-Tracker object!");
  79.  
  80.     str = Engine.commitChanges(Source, 0);
  81.  
  82.     return str;
  83. }
  84.  
  85. function ChangeStringValue(ItemToChange)
  86. {   
  87.     
  88.     ChangeParent = ItemToChange.offsetParent; // BANNER
  89.     sc_BeforeChange = ChangeParent.innerHTML;
  90.     var sc_OldValue = ChangeParent.all.item("Value").innerText;
  91.     
  92.     ChangeParent.innerHTML = "<INPUT TYPE=TEXT CLASS=width80 onkeydown=top.ChangeOnKeyPress(this) id=TEXT1 name=TEXT1 onblur=top.MyClick()></INPUT>"
  93.     ChangeParent.firstChild.value = sc_OldValue;
  94.     ChangeParent.firstChild.select();
  95.     ChangeParent.firstChild.focus();
  96. }
  97.  
  98.  
  99. function GetSortMode ()
  100. {
  101.    var sz_Sort= top.frames[0].document.all.item("SortOrder").value;
  102.    switch (sz_Sort)
  103.    {
  104.     case "All categories":
  105.       return 0;
  106.     case "-@CreationDate":
  107.       return 1;
  108.     case "@Name; -@CreationDate":
  109.       return 2;
  110.     case "-@LastAccess":
  111.       return 3;
  112.     case "@Comment; -@CreationDate":
  113.       return 4;
  114.    case  "@ID_CATEGORY; -@CreationDate":
  115.       return 5;
  116.   }
  117.   return 0;
  118. }
  119.  
  120. function IsNeedSort (szSlotName)
  121. {
  122.  switch (szSlotName)
  123.  {
  124.   case "Name":
  125.    if (GetSortMode() == 2)
  126.     return 1;
  127.    else
  128.     return 0;
  129.     
  130.   case "Comment":
  131.    if (GetSortMode() == 4)
  132.     return 1;
  133.    else
  134.     return 0;
  135.     
  136.   case "Category":
  137.    if (GetSortMode() == 5)
  138.     return 1;
  139.    else
  140.     return 0;    
  141.  }
  142.  return 0;
  143. }
  144.  
  145. function OnListKeyDown (Select)
  146. {    
  147.     var Key=top.frames[1].event.keyCode;
  148.     if (Key == 27)    
  149.     {        
  150.         ChangeParent.innerHTML = sc_BeforeChange;
  151.         ChangeParent.focus();
  152.         bOpenList = 0;        
  153.         ChangeParent = null;
  154.     }
  155.     else
  156.      if (Key == 13)    
  157.      {       
  158.        ChangeBannerCategory(Select);
  159.        ChangeParent = null; 
  160.      }
  161. }
  162.  
  163.  
  164. function ChangeBannerCategory (Select)
  165.    var    Banner = Source.selectSingleNode("root\/BANNERBASE\/BANNER[@UIN="+ChangeParent.offsetParent.id+"]");
  166.    sc_NewValue = Select.options[Select.selectedIndex].value;
  167.    if (Banner != null)    
  168.    {
  169.      Banner.setAttribute("ID_CATEGORY", sc_NewValue);
  170.      szNewCTName = Select.options[Select.selectedIndex].text;
  171.      ChangeParent.innerHTML = sc_BeforeChange;         
  172.      ChangeParent.all.item("Value").innerText = szNewCTName;
  173.      ChangeParent.focus();         
  174.      Sort(1);          
  175.      ChangeParent = null; 
  176.    }       
  177.    bOpenList = 0;
  178. }
  179.  
  180.  
  181. // call XSL on category/change
  182. function ChangeCategoryValue(ItemToChange)
  183. {   
  184.   bOpenList = 1;
  185.  
  186.   var    CTListNames = Source.selectNodes("root\/CTLIST\/CATEGORY\/@Name");
  187.   var    CTListIDs =   Source.selectNodes("root\/CTLIST\/CATEGORY\/@CID");    
  188.   var   b_cat;
  189.   var    Banner;
  190.   var   k=0;
  191.   
  192.   if ((CTListNames == null) || (CTListIDs == null))
  193.    return;   
  194.   
  195.   ChangeParent = ItemToChange.offsetParent;
  196.   sc_BeforeChange = ChangeParent.innerHTML;    
  197.   var sc_OldValue = ChangeParent.all.item("Value").innerText;
  198.   ChangeParent.innerHTML = "<SELECT NAME=INT_CT_LIST ALIGN=ABSMIDDLE CLASS=width40p id=INTCTLIST onkeydown=top.OnListKeyDown(this) onblur=top.MyClick() onchange=top.ChangeBannerCategory(this) ondblclick=top.ChangeBannerCategory(this)><\SELECT>";  
  199.   
  200.   Banner = Source.selectSingleNode("root\/BANNERBASE\/BANNER[@UIN="+ChangeParent.offsetParent.id+"]");
  201.   if (Banner != null)
  202.    b_cat = Banner.getAttribute("ID_CATEGORY");
  203.    
  204.   for (i=0; i < CTListIDs.length; i++)
  205.   {  
  206.    var objOption= top.frames[1].document.createElement ("OPTION");
  207.    objOption.text = CTListNames[i].nodeValue;
  208.    objOption.value =CTListIDs[i].nodeValue;
  209.    if (Banner && (b_cat == objOption.value))
  210.     k=i;
  211.    top.frames[1].document.all["INT_CT_LIST"].options.add (objOption);   
  212.  }  
  213.  top.frames[1].document.all["INT_CT_LIST"].selectedIndex = k;
  214.  ChangeParent.firstChild.focus(); 
  215. }
  216.  
  217.  
  218. function ChangeOnInsertOrRename(Edit, bInsert, bMode)
  219.  var Key;
  220.  if (bMode)
  221.   Key=13;
  222.  else
  223.   Key=top.frames[0].event.keyCode;        //27 - Esc, 13 - Enter  
  224.  
  225.  if (Key == 27)    
  226.  {
  227.     ChangeParent.style.display = "none";    
  228.     ChangeParent.innerHTML = "";
  229.     ChangeParent.insertAdjacentHTML("beforeEnd", sc_BeforeChange);
  230.     ChangeParent.style.display = "";                
  231.     ChangeParent = null; 
  232.     return;
  233.  }
  234.  if (Key != 13)
  235.    return;  
  236.  
  237.  var   CatName = Edit.value;   
  238.  
  239.  if ((CatName == null) || (CatName == "") || (CatName == " ") || (CatName == "  "))
  240.  {   
  241.    alert ("The category name cannot be blank.");
  242.    //ChangeParent.firstChild.focus();
  243.    return;  
  244.  }
  245.    
  246.  
  247.   var    CTListNames = Source.selectNodes("root\/CTLIST\/CATEGORY\/@Name");
  248.   var    CIDs =   Source.selectNodes("root\/CTLIST\/CATEGORY\/@CID");  
  249.   var    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");  
  250.   
  251.   if (((CurrentCT.nodeValue == "0000000000000000") || (CurrentCT.nodeValue == "0000000000000001")) && (!bInsert))
  252.   {
  253.    return;
  254.   }  
  255.   
  256.   var    Category =   Source.selectSingleNode("root\/CTLIST\/CATEGORY[@CID="+CurrentCT.nodeValue+"]");  
  257.   var   newCID = 0;
  258.    
  259.   for (i=0; i < CTListNames.length; i++)
  260.   {
  261.     if (CTListNames[i].nodeValue == CatName)
  262.     {
  263.         alert("This category already exists!");        
  264.             //ChangeParent.firstChild.focus();
  265.         return;
  266.     }
  267.   }  
  268.       
  269.  if (bInsert)   
  270.  {
  271.       for (Index = 0; Index < CIDs.length; Index++)    
  272.       {
  273.         if (parseInt(CIDs[Index].text, 10) > newCID)
  274.           newCID = parseInt(CIDs[Index].text, 10);
  275.       }
  276.       newCID++;
  277.       var    sc_CID = "0000000000000000" + newCID;
  278.       sc_CID = sc_CID.substr(sc_CID.length - 16); 
  279.   
  280.         // check empty page
  281.         var    Root = Source.selectSingleNode("root");
  282.         if (Root == null)
  283.         {
  284.             // insert processing instruction
  285.             ElXML = Source.createProcessingInstruction('xml', ' version="1.0" encoding="utf-8" ');                
  286.             Source.insertBefore(ElXML, null);                
  287.  
  288.             //  insert root element 
  289.             Root = Source.createElement("root");
  290.             Root.text = "\n\t";
  291.             Source.appendChild(Root);
  292.         }            
  293.         var    CtList = Source.selectSingleNode("root/CTLIST");            
  294.         if (CtList == null)    
  295.         {                
  296.             CtList = Source.createElement("CTLIST");
  297.             CtList.setAttribute("CurrentCategory", "0000000000000000");
  298.             CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");  
  299.         }
  300.                     
  301.         CtNew = Source.createElement("CATEGORY");
  302.         CtNew.setAttribute("CID", sc_CID);                
  303.         CtNew.setAttribute("Name",  CatName);                
  304.         CtNew.text = "\n";
  305.                     
  306.         Root.appendChild(CtList);
  307.         CtList.appendChild(CtNew);    
  308.         
  309.         AddCTToList (CatName, sc_CID, CurrentCT.nodeValue);          
  310.     }
  311.     else
  312.     {     
  313.       Select=top.frames[0].document.all["CT_LIST"];    
  314.       Select.options[Select.selectedIndex].text=CatName; 
  315.       Category.setAttribute("Name",  CatName);      
  316.     }
  317.     
  318.     ChangeParent.style.display = "none";    
  319.     ChangeParent.innerHTML = sc_BeforeChange;        
  320.     ChangeParent.style.display = "";
  321.     if (bInsert)
  322.      SaveSource ();
  323.     else
  324.      Sort(1);     
  325.     ChangeParent = null; 
  326. }
  327.  
  328.  
  329. function UpdateDisabledButtons ()
  330. {
  331.  var    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");  
  332.    if ((CurrentCT.nodeValue == "0000000000000000") || (CurrentCT.nodeValue == "0000000000000001"))
  333.     {
  334.      top.frames[0].document.all["btnDelCT"].src = "delct_d.gif";
  335.      top.frames[0].document.all["btnRenameCT"].src = "renct_d.gif";
  336.      top.frames[0].document.all["btnRenameCT"].runtimeStyle.cursor = "default";
  337.      top.frames[0].document.all["btnDelCT"].runtimeStyle.cursor = "default";
  338.      top.frames[0].document.all["btnDelCT"].UpdateButton(1, 0);
  339.      top.frames[0].document.all["btnRenameCT"].UpdateButton(1, 0);
  340.     }
  341.     else
  342.     {
  343.      top.frames[0].document.all["btnDelCT"].src = "delct_g.gif";
  344.      top.frames[0].document.all["btnRenameCT"].src = "renct_g.gif";
  345.      top.frames[0].document.all["btnRenameCT"].runtimeStyle.cursor = "hand";
  346.      top.frames[0].document.all["btnDelCT"].runtimeStyle.cursor = "hand";
  347.      top.frames[0].document.all["btnDelCT"].UpdateButton(0, 0);
  348.      top.frames[0].document.all["btnRenameCT"].UpdateButton(0, 0);
  349.     }
  350. }
  351.  
  352. function CheckToolbar ()
  353. {
  354.   if (top.frames[0].document.all["btnDelCT"]!=null)  
  355.   {
  356.     clearInterval (idDis);
  357.     UpdateDisabledButtons();
  358.   } 
  359. }
  360.  
  361.  
  362. function InsertOrRenameCategory (ItemToChange, bInsert)
  363. {
  364.    bOk = false;
  365.    var    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");  
  366.    if (((CurrentCT.nodeValue == "0000000000000000") || (CurrentCT.nodeValue == "0000000000000001")) && (!bInsert))
  367.    { 
  368.      //alert ("This category cannot be renamed.");
  369.      return;
  370.     }        
  371.  
  372.     SetButtonImage(ItemToChange, 1);
  373.  
  374.     ChangeParent = ItemToChange.parentElement; //offsetParent;    
  375.     sc_BeforeChange = ChangeParent.innerHTML;    
  376.     if (bInsert)
  377.     {
  378.       ChangeParent.innerHTML = "<INPUT TYPE=TEXT id=idEdit onkeydown=top.ChangeOnInsertOrRename(this,1) onblur='setTimeout(\"top.MyClick()\", 500)' id=TEXTINSERT name=TEXTINSERT style='width:160px; height:20px;margin-bottom:9px; font-size:11px;'></INPUT><BUTTON TYPE=BUTTON ONCLICK='bOk=true;top.ChangeOnInsertOrRename(idEdit,1, true);return false;' style='margin-bottom:9px; font-family: Verdana,Arial; font-size: 8pt;'>ok</BUTTON>";      
  379.       ChangeParent.firstChild.value = "";
  380.     }
  381.     else
  382.     {
  383.       var    Category =   Source.selectSingleNode("root\/CTLIST\/CATEGORY[@CID="+CurrentCT.nodeValue+"]");        
  384.       CatName = Category.getAttribute("Name");
  385.       ChangeParent.innerHTML = "<INPUT TYPE=TEXT id=idEdit onkeydown=top.ChangeOnInsertOrRename(this,0) onblur='setTimeout(\"top.MyClick()\", 500)' id=TEXTRENAME name=TEXTRENAME style='width:160px; height:20px; margin-bottom:9px; font-size:11px;'></INPUT><BUTTON TYPE=BUTTON ONCLICK='bOk=true;top.ChangeOnInsertOrRename(idEdit,0, true);return false;' style='margin-bottom:9px; font-family: Verdana,Arial; font-size: 8pt;'>ok</BUTTON>";
  386.       ChangeParent.firstChild.value = CatName;
  387.       ChangeParent.firstChild.select();
  388.     }    
  389.  
  390.     ChangeParent.firstChild.focus();    
  391.     ChangeParent.firstChild.focus();
  392.     ChangeParent.firstChild.focus();    
  393.  
  394.     bInsertOrRename = true;
  395. }
  396.  
  397.  
  398. function DeleteCategory ()
  399. {  
  400.  
  401.    szCID = top.frames[0].document.all["CT_LIST"].options[top.frames[0].document.all["CT_LIST"].selectedIndex ].value;
  402.    
  403.    if ((szCID == "0000000000000000") || (szCID == "0000000000000001")) // all categories
  404.    {    
  405.     //alert ("This category cannot be deleted.");
  406.     return;    
  407.    }
  408.    
  409.    
  410.    if (szCID == "0000000000000001") // common category
  411.    {
  412.     //alert ("This category cannot be deleted.");
  413.     return;    
  414.    }
  415.  
  416.    if (top.confirm ("Do you want to delete a category and all the images it contains?") == 0)
  417.     return;
  418.  
  419.     
  420.     if (Source.readyState == 4)    
  421.     {        
  422.         var    Banners =   Source.selectNodes("root\/BANNERBASE\/BANNER[@ID_CATEGORY="+szCID+"]");  
  423.         var    Category =  Source.selectSingleNode("root\/CTLIST\/CATEGORY[@CID="+szCID+"]");  
  424.         
  425.         if (Category != null)
  426.           Category.parentNode.removeChild(Category);                 
  427.         
  428.         for (i = 0; i < Banners.length; i++)    
  429.         {         
  430.          var Banner = Banners[i];
  431.          Engine.DeleteImageFile (Banner);
  432.          Banner.parentNode.removeChild(Banner);
  433.          }        
  434.          top.frames[0].document.all["CT_LIST"].options.remove(top.frames[0].document.all["CT_LIST"].selectedIndex);
  435.          top.frames[0].document.all["CT_LIST"].selectedIndex = 0;                
  436.          
  437.          
  438.          //set "all categories"; save document, too
  439.          SetCategory();
  440.     }
  441. }
  442.  
  443.  
  444. function MyClick ()
  445. {   
  446.    //if ((!bInsertOrRename) && (!bOpenList)) 
  447.    if (!ChangeParent)
  448.     return;
  449.  
  450.    if (bInsertOrRename) 
  451.    {
  452.     bInsertOrRename = false;
  453.     idDis = setInterval (CheckToolbar, 400);
  454.     
  455.     if (bOk)
  456.     {
  457.         bOk=false;
  458.     return;
  459.     }
  460.    }
  461.     
  462.    if (bOpenList)
  463.     bOpenList = 0;   
  464.    ChangeParent.innerHTML = sc_BeforeChange;
  465.    
  466.    ChangeParent = null; 
  467. }
  468.  
  469.  
  470. function ChangeOnKeyPress(EditBox, bMode)
  471. {
  472.     var Key;
  473.     if (bMode)
  474.         key = 13;
  475.     else
  476.         Key=top.frames[1].event.keyCode;        //27 - Esc, 13 - Enter
  477.  
  478.     if (Key == 27)    
  479.     {
  480.         EditBox.style.display = "none";     
  481.         ChangeParent.innerHTML = sc_BeforeChange;
  482.         ChangeParent.focus();        
  483.         ChangeParent = null; 
  484.     }
  485.     else
  486.      if (Key == 13)    
  487.      {
  488.         var bDestroyMap = true;
  489.         bNoRestore = 1;  
  490.         var    Banner = Source.selectSingleNode("root\/BANNERBASE\/BANNER[@UIN="+ChangeParent.offsetParent.id+"]");
  491.         var sc_NewValue = EditBox.value;
  492.         ChangeParent.innerHTML = sc_BeforeChange;
  493.         if ((top.frames[1].document.all.item("" + ChangeParent.offsetParent.id + "-IMG").useMap != "") && (ChangeParent.all.item("Value").name == "Url"))
  494.         {
  495.             if (confirm("Changing the URL here will destroy the multiple URL references accosiated with the image.\nAre you sure?"))
  496.             {                
  497.                 ChangeParent.all.MURL.outerHTML = "";
  498.                 top.frames[1].document.all.item("" + ChangeParent.offsetParent.id + "-IMG").useMap = "";
  499.                 if (Banner != null)
  500.                 {
  501.                     Banner.setAttribute("Map", "");
  502.                     //SaveSource();
  503.                 }
  504.             }
  505.             else
  506.             {
  507.                 bDestroyMap = false;
  508.             }
  509.         }
  510.         if (bDestroyMap)
  511.         {
  512.             if (ChangeParent.all.item("Value").name == "Url")
  513.             {
  514.                 strl = sc_NewValue;
  515.                 str = new String (strl);
  516.                 if ((str.search ('://') == -1) && (str.search ('@') == -1) && (str.length>0))
  517.                 {             
  518.                  strl="http://"+strl;
  519.                  sc_NewValue = strl;
  520.                 }
  521.                 if ((str.search('@')!=-1) && (str.search('mailto:') == -1))
  522.                 {
  523.                     strl = "mailto:" + strl;
  524.                     sc_NewValue = strl;
  525.                 }            
  526.                 top.frames[1].document.all.item("" + ChangeParent.offsetParent.id + "-URL").href = sc_NewValue;                
  527.                 ChangeParent.all.item("Value").href=sc_NewValue;
  528.             }        
  529.             else if (ChangeParent.all.item("Value").name == "Name")
  530.             {
  531.                 top.frames[1].document.all.item("" + ChangeParent.offsetParent.id + "-IMG").alt = sc_NewValue;
  532.             }
  533.         
  534.             EditBox.style.display = "none";     
  535.             ChangeParent.all.item("Value").innerHTML = sc_NewValue;
  536.             ChangeParent.focus();        
  537.  
  538.             if (Banner != null)    
  539.             {
  540.              Banner.setAttribute(ChangeParent.all.item("Value").name, sc_NewValue);                          
  541.             }
  542.         }
  543.         bNoRestore = 0;        
  544.         if (IsNeedSort(ChangeParent.all.item("Value").name))        
  545.          Sort(1);
  546.         else
  547.          SaveSource();        
  548.  
  549.         ChangeParent = null; 
  550.      }
  551. }
  552.  
  553. function RealySort()
  554. {
  555.  Sort(1);  
  556.  top.focus();
  557. }
  558.  
  559.  
  560. function Sort( bSave )
  561. {    
  562.  
  563.     var SortOrder = top.frames[0].document.all.item("SortOrder");
  564.     if (SortOrder != null)    
  565.     {
  566.         var sz_Order = SortOrder.value;
  567.  
  568.         if (Source.readyState == 4)    
  569.         {
  570.             var Orders = Source.getElementsByTagName("root/BANNERBASE/@SortOrder");
  571.             for (var Index = 0; Index < Orders.length; Index++)
  572.                 Orders[Index].nodeValue = sz_Order;
  573.  
  574.             if (bSave) 
  575.              SaveSource();
  576.         }
  577.  
  578.         if (Style.readyState == 4)    
  579.         {
  580.             var Orders = Style.getElementsByTagName("*/xsl:for-each/@order-by");
  581.             var OrdersF = StyleFirst.getElementsByTagName("*/xsl:for-each/@order-by");
  582.  
  583.  
  584.             // set order for second xsl template
  585.             for (var Index = 0; Index < Orders.length; Index++)
  586.                 Orders[Index].nodeValue = sz_Order;
  587.  
  588.             // set order for first xsl template
  589.             for (var Index = 0; Index < OrdersF.length; Index++)
  590.                 OrdersF[Index].nodeValue = sz_Order;
  591.  
  592.             
  593.             DisplayDocument(1);
  594.         }
  595.     }
  596. }
  597.  
  598. function DeleteAll()
  599. {
  600.    
  601.     if (showModalDialog ("wrn.htm", "", "dialogWidth:292px; dialogHeight:140px; center:yes; border:thin; status:no; scroll:no; help:no;") == 0)
  602.      return;   
  603.  
  604.     if (Source.readyState == 4)    
  605.     {        
  606.         var    Banners = Source.getElementsByTagName("root/BANNERBASE/BANNER");
  607.  
  608.         for (i=0; i < Banners.length; i++)    
  609.         {
  610.             var    Banner = Banners[i];
  611.             Engine.DeleteAllImages (Banner.parentNode);
  612.             Banner.parentNode.removeChild(Banner);
  613.         }        
  614.  
  615.         Sort(1);        
  616.     }
  617. }
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624. function DeleteBanner(sz_Index)
  625. {
  626.     
  627.     if (Source.readyState == 4)    
  628.     {
  629.     
  630.         var ConfirmDelete = Source.selectSingleNode("root\/BANNERBASE\/@ConfirmDelete");  
  631.         if (ConfirmDelete &&  (ConfirmDelete.nodeValue == 1))
  632.          if (!confirm("Do you want to delete this image?"))
  633.           return;
  634.     
  635.         var    Banners = Source.selectNodes("root\/BANNERBASE\/BANNER[@UIN="+sz_Index+"]");
  636.  
  637.         if (Banners.length > 0)    
  638.         {
  639.             var    Banner = Banners[0];
  640.             Engine.DeleteImageFile (Banner);
  641.             Banner.parentNode.removeChild(Banner);
  642.         }        
  643.  
  644.         
  645.         SaveSource();            
  646.         CurElement = top.frames[1].event.srcElement;
  647.         Div=CurElement.parentElement.parentElement.parentElement.parentElement.parentElement;
  648.         Div.style.display = "none";
  649.         //Div.outerText="";        
  650.         if (!LoadPictures ())
  651.          setTimeout (LoadPictures, 100); 
  652.     }    
  653. }
  654.  
  655. function AccessBanner(sz_Index)
  656. {    
  657.  
  658.     if (Source.readyState == 4)    
  659.     {
  660.         var    Banner = Source.selectSingleNode("root\/BANNERBASE\/BANNER[@UIN="+sz_Index+"]");
  661.   
  662.         if (Banner != null)    
  663.         {
  664.             var    sc_Time = "0000000000000000" + Date.parse(new Date());
  665.             sc_Time = sc_Time.substr(sc_Time.length - 16);
  666.  
  667.             Banner.setAttribute("LastAccess", sc_Time);
  668.             SaveSource();                        
  669.             if (GetSortMode() == 3)
  670.              Engine.UpdateData (null);             
  671.         }
  672.     }
  673. }
  674.  
  675. function ReplaceCTToTop (newCIN)
  676. {
  677.  var    CTList = Source.selectSingleNode("root/CTLIST");
  678.  var    child = Source.selectSingleNode("root\/CTLIST\/CATEGORY[@CID="+newCIN+"]");  
  679.  var    childOldFirst = CTList.firstChild; 
  680.  
  681.     if (child && (child !== childOldFirst))
  682.     {
  683.      CTList.removeChild(child);
  684.      CTList.insertBefore(child, childOldFirst);
  685.      return 1;
  686.     }        
  687.     else
  688.      return 0;
  689. }
  690.  
  691.  
  692. function SetCategory ()
  693.  var    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory"); 
  694.  var CIN = top.frames[0].document.all["CT_LIST"].options[top.frames[0].document.all["CT_LIST"].selectedIndex].value;
  695.  if (CurrentCT == null)
  696.   return;
  697.   
  698.  CurrentCT.nodeValue=CIN;
  699.  if ((CIN== "0000000000000000") || (CIN== "0000000000000001"))
  700.  {    
  701.    top.frames[0].document.all["btnRenameCT"].src = "renct_d.gif";
  702.    top.frames[0].document.all["btnDelCT"].src = "delct_d.gif";
  703.    top.frames[0].document.all["btnRenameCT"].runtimeStyle.cursor = "default";
  704.    top.frames[0].document.all["btnDelCT"].runtimeStyle.cursor = "default";
  705.    top.frames[0].document.all["btnDelCT"].UpdateButton(1, 0);
  706.    top.frames[0].document.all["btnRenameCT"].UpdateButton(1, 0);
  707.  }
  708.  else
  709.  {
  710.    top.frames[0].document.all["btnRenameCT"].src = "renct_g.gif";
  711.    top.frames[0].document.all["btnDelCT"].src = "delct_g.gif";
  712.    top.frames[0].document.all["btnRenameCT"].runtimeStyle.cursor = "hand";
  713.    top.frames[0].document.all["btnDelCT"].runtimeStyle.cursor = "hand";
  714.    top.frames[0].document.all["btnDelCT"].UpdateButton(0, 0);
  715.    top.frames[0].document.all["btnRenameCT"].UpdateButton(0, 0);
  716.  
  717.  }
  718.  
  719.  // replace current category to the top of the list
  720.  bb = ReplaceCTToTop (CIN); 
  721.  // sort/save
  722.  Sort (1);   
  723.  // fill category list anew
  724.  if (bb)
  725.   FillCTList ();
  726.  top.focus();  
  727.  
  728.  
  729. function AddCTToList (sz_Name, CID, CurrentCID)
  730. {  
  731.   var objOption= top.frames[0].document.createElement ("OPTION");
  732.   objOption.text =  sz_Name;
  733.   objOption.value = CID;
  734.   top.frames[0].document.all["CT_LIST"].options.add (objOption);    
  735.   if (CID == CurrentCID)
  736.     objOption.selected=true; 
  737.   else
  738.     objOption.selected=false;   
  739. }
  740.  
  741. function FillCTList ()
  742. {
  743.  var    CTList = Source.getElementsByTagName("root/CTLIST/CATEGORY");
  744.  var    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");
  745.  var    Sel = top.frames[0].document.all.CT_LIST;  
  746.    
  747.  while (Sel.options[1])   
  748.   Sel.options.remove(1);  
  749.   
  750.  
  751.  if (CTList == null)
  752.   return;
  753.   
  754.  for (i=0; i<CTList.length; i++)
  755.  {
  756.   var    Category = CTList[i];  
  757.   AddCTToList (Category.attributes[1].value, Category.attributes[0].value, CurrentCT == null ? null : CurrentCT.nodeValue);
  758.  }
  759.  
  760.  if ((CurrentCT.nodeValue == "0000000000000000") || (CurrentCT.nodeValue == "0000000000000001"))
  761.  {                              
  762.    top.frames[0].document.all["btnDelCT"].src = "delct_d.gif";
  763.    top.frames[0].document.all["btnRenameCT"].src = "renct_d.gif";
  764.    top.frames[0].document.all["btnRenameCT"].runtimeStyle.cursor = "default";
  765.    top.frames[0].document.all["btnDelCT"].runtimeStyle.cursor = "default";
  766.    top.frames[0].document.all["btnDelCT"].UpdateButton(1, 0);
  767.    top.frames[0].document.all["btnRenameCT"].UpdateButton(1, 0);
  768.  }
  769. }
  770.  
  771.  
  772.  
  773. function LoadPictures()
  774.  var Height = 0;
  775.  var Image;
  776.  
  777.  if (idTimeout)
  778.   idTimeout = 0;
  779.  
  780.  
  781.  DIVs = top.frames[1].document.all.tags("DIV");
  782.  topMargin = top.frames[1].document.body.scrollTop;
  783.  bottomMargin = topMargin + top.frames[1].document.body.clientHeight;   
  784.  if (topMargin == bottomMargin)
  785.   return 0;  
  786.  
  787.  for (i=1; i < DIVs.length;i++)
  788.  { 
  789.    Image = DIVs[i].all.tags("IMG")[0];    
  790.    if ((Image) && (!Image.useMap))  
  791.    {
  792.     if ((Height+DIVs[i].scrollHeight >= topMargin) && (Height <= bottomMargin))
  793.     {
  794.      Image.src = Image.TEMPSRC;   
  795.     }
  796.     else
  797.     {
  798.      Image.src = ""; 
  799.     }
  800.    }     
  801.    Height += DIVs[i].scrollHeight;
  802.  } 
  803.  
  804.  return 1; 
  805. }
  806.  
  807.  
  808.  
  809.  
  810. function DisplayDocument(bFirst)
  811. {    
  812.  
  813.     if ((Source.readyState == 4) && (Style.readyState == 4) && (StyleFirst.readyState == 4))    
  814.     {    
  815.     
  816.         
  817.         var str;                
  818.  
  819.  
  820.    
  821.         if (bFirst) 
  822.         {
  823.          top.frames[1].document.all.item("XSLResult").style.display="none";
  824.  
  825.          sz_HTML = Source.transformNode(StyleFirst);                        
  826.          top.frames[1].document.all.XSLResult.innerHTML = sz_HTML;                
  827.         }
  828.         else
  829.         {
  830.          sz_HTML = Source.transformNode(Style);                        
  831.          top.frames[1].document.all.XSLResult.insertAdjacentHTML("beforeEnd", sz_HTML);
  832.         }
  833.         
  834.         var szText = "";           
  835.         
  836.         var MapsToEscape = top.frames[1].document.all.tags("MAP");
  837.         if (MapsToEscape != null)    
  838.         {
  839.             for (var Index = MapsToEscape.length - 1; Index >= 0; Index--)    
  840.             {
  841.                 MapsToEscape[Index].innerHTML = unescape(MapsToEscape[Index].innerHTML);                        
  842.             }
  843.         }                
  844.  
  845.         var MapsToChange = top.frames[1].document.all.tags("MAPTOCHANGE");
  846.         if (MapsToChange != null)    
  847.         {
  848.             for (var MapIndex = 0; MapIndex < MapsToChange.length; MapIndex++)    
  849.             {
  850.                 var AreasToChange = MapsToChange[MapIndex].parentElement.all.tags("AREA");
  851.                 if (AreasToChange != null)    
  852.                 {
  853.                     for (var AreaIndex = 0; AreaIndex < AreasToChange.length; AreaIndex++)    
  854.                     {
  855.                         AreasToChange[AreaIndex].target = "_blank";                        
  856.                     }
  857.                 }
  858.                 MapsToChange[MapIndex].parentElement.outerHTML = MapsToChange[MapIndex].nextSibling.outerHTML;                                        
  859.                 MapIndex--; // becouse there is decrement collection length                
  860.             }
  861.             
  862.         }                 
  863.  
  864.  
  865.         if (bFirst) 
  866.          top.frames[1].document.all.XSLResult.style.display="block";        
  867.           
  868.                   
  869.         if (bFirst  &&  (top.frames[1].document.all.tags("DIV").length == 31))                
  870.         {         
  871.          setTimeout("DisplayDocument(0)", 300);          
  872.         }
  873.  
  874.         
  875.         if (bFirst) 
  876.          setTimeout(LoadPictures, 50);         
  877.  
  878.     }
  879. }
  880.  
  881.  
  882. function ChangeXSL(sz_FileName)
  883. {    
  884.     var    b_Ok = Style.load(sz_FileName);
  885.  
  886.     StyleFirst.load("first.xsl");
  887.  
  888.     if (!b_Ok)
  889.         alert ("Error loading Image Co-Tracker StyleSheet (" + sz_FileName + ")");
  890.  
  891.     
  892.  
  893.     return    b_Ok;
  894. }
  895.  
  896. function SetNewBase (NewSourceXML, bMode)
  897. {    
  898.         ElXML = NewSourceXML.createProcessingInstruction('xml', ' version="1.0" encoding="utf-8" ');                
  899.         NewSourceXML.insertBefore(ElXML, null);                
  900.  
  901.         //  insert root element 
  902.         var Root = NewSourceXML.createElement("root");
  903.         Root.setAttribute("dbversion","1.0");
  904.         Root.text = "\n\t";
  905.         NewSourceXML.appendChild(Root);        
  906.                 
  907.         var CtList = NewSourceXML.createElement("CTLIST");
  908.         CtList.setAttribute("CurrentCategory", "0000000000000000");
  909.                 
  910.         var CtCommon = NewSourceXML.createElement("CATEGORY");
  911.         CtCommon.setAttribute("CID", "0000000000000001");                
  912.         CtCommon.setAttribute("Name", "Common");                
  913.         CtCommon.text = "\n";
  914.                 
  915.         Root.appendChild(CtList);
  916.         CtList.appendChild(CtCommon);
  917.  
  918.         var BannerBase = NewSourceXML.createElement("BANNERBASE");
  919.  
  920.         BannerBase.setAttribute("OpenMode", "_blank");
  921.         BannerBase.setAttribute("SortOrder", "-@CreationDate");
  922.         if (Engine.Options == -1)
  923.         {
  924.          BannerBase.setAttribute("ShowSlots", "191");
  925.          BannerBase.setAttribute("ConfirmDelete", "0");
  926.          BannerBase.setAttribute("SmallPictures", "0");
  927.          Engine.Options = 191;
  928.         }
  929.         else
  930.         {         
  931.          BannerBase.setAttribute("ShowSlots", Engine.Options & 255);
  932.  
  933.          if (Engine.Options & 1024)
  934.           BannerBase.setAttribute("ConfirmDelete", "1");
  935.          else
  936.           BannerBase.setAttribute("ConfirmDelete", "0");
  937.  
  938.          if (Engine.Options & 2048)
  939.           BannerBase.setAttribute("SmallPictures", "1");
  940.          else
  941.           BannerBase.setAttribute("SmallPictures", "0");
  942.         }
  943.  
  944.         BannerBase.text = "\n\t\t";
  945.  
  946.         Root.appendChild(BannerBase);
  947.         
  948.         if (bMode)
  949.         {
  950.             var str = Engine.GetXMLPath();
  951.             if (str)
  952.             {
  953.                 var szSrcPath = szProductPath + "\\1.png";
  954.                 Engine.CopyImageFile(szSrcPath, str);
  955.             }
  956.  
  957.             // insert banner with link to program's tutorial
  958.             var Banner = NewSourceXML.createElement("BANNER");
  959.         
  960.             Banner.setAttribute("UIN", "0000000000000001");
  961.             Banner.setAttribute("Name", "INTRODUCTION: HOW TO USE IMAGE CO-TRACKER");
  962.             Banner.setAttribute("Image", str + "1.png");
  963.             Banner.setAttribute("Width", "738");
  964.             Banner.setAttribute("Height", "359");
  965.             Banner.setAttribute("Url", "http://cogitum.com/co-tracker/howtouse.html");
  966.             Banner.setAttribute("Map", "");
  967.             Banner.setAttribute("IsMap", "false");        
  968.             Banner.setAttribute("Comment", "Launch Microsoft Internet Explorer 5.0 or higher. Click the right " + 
  969.             "mouse button on any Internet image, and select the Grab Image option from the pop-up menu. " + 
  970.             "Write in comments and select a category if you want, then click OK. To begin work with catalog of " + 
  971.             "'grabbed' images, click the Start button and select Image Co-Tracker from the Programs menu. " +
  972.             "For more information, click on the '?' icon on the toolbar.");
  973.             Banner.setAttribute("SourceUrl", "http://cogitum.com/co-tracker/howtouse.html");
  974.             Banner.setAttribute("LastAccess", "0000971160889000");
  975.             Banner.setAttribute("CreationDate", "0000971160889000");
  976.             Banner.setAttribute("IMGNode", "<IMG alt=Cogitum height=52 src="img/h_lhead.gif" width=284>");
  977.             Banner.setAttribute("ID_CATEGORY", "0000000000000001");
  978.             
  979.             BannerBase.appendChild(Banner);
  980.         }
  981.  
  982. }
  983.  
  984.  
  985. function ChangeXML()
  986. {    
  987.     var strCaption;    
  988.  
  989.     strCaption = Engine.OpenXMLBase (Source, 1, 0);     
  990.     if (!strCaption)
  991.     {    
  992.         SetNewBase (Source, true);
  993.         strCaption = SaveSource();
  994.         DisplayDocument(1);
  995.     }
  996.     else
  997.      CheckOptions();
  998.  
  999.  
  1000.     var SortOrders = Source.getElementsByTagName("root/BANNERBASE/@SortOrder");
  1001.     if (SortOrders.length > 0)    
  1002.     {
  1003.         var SortOrder = top.frames[0].document.all.item("SortOrder");
  1004.         if (SortOrder != null)    
  1005.         {
  1006.             for (Index = 0; Index < SortOrder.options.length; Index++)    
  1007.             {
  1008.                 if (SortOrder.options(Index).value == SortOrders[0].nodeValue)
  1009.                     SortOrder.options(Index).selected = true;
  1010.             }
  1011.         }
  1012.     }
  1013.     else
  1014.      top.frames[0].document.all.item("SortOrder").value = "-@CreationDate"; 
  1015.  
  1016.     SetCaptionBar (strCaption);
  1017.     return    strCaption;
  1018. }
  1019.  
  1020. function AboutDlg ()
  1021. {
  1022.   showModalDialog ("about.htm", Engine, "dialogWidth=500px;dialogHeight=340px;center=yes;border=thin;status=no;scroll=no; help:no;");
  1023. }
  1024.  
  1025. function UsePrgDlg ()
  1026. {  
  1027.   showHelp ('ctrack.chm');
  1028. }
  1029.  
  1030. function ChooseCtListDlg ()
  1031. {
  1032.   bSave = showModalDialog ("choose.htm", Source, "dialogWidth=530px;dialogHeight=420px;center=yes;border=thin;status=no;scroll=no; help:no;");  
  1033.   if (bSave)  
  1034.   {
  1035.    SaveSource(); 
  1036.    FillCTList ();  
  1037.   }
  1038. }
  1039.  
  1040.  
  1041. function ShowOptions()
  1042.  
  1043.   var BBase = Source.selectSingleNode("root\/BANNERBASE");
  1044.   var ShowSlots = Source.selectSingleNode("root\/BANNERBASE\/@ShowSlots");    
  1045.   // for previous XML format compatible
  1046.   if (ShowSlots == null)    
  1047.   {                
  1048.    BBase.setAttribute("ShowSlots", 191);
  1049.    ShowSlots = Source.selectSingleNode("root\/BANNERBASE\/@ShowSlots");   
  1050.   }
  1051.   ShowSlotsVal = ShowSlots.nodeValue;
  1052.   var ConfirmDelete = Source.selectSingleNode("root\/BANNERBASE\/@ConfirmDelete");  
  1053.   if (ConfirmDelete == null)    
  1054.   {
  1055.    BBase.setAttribute("ConfirmDelete", 0);
  1056.    ConfirmDelete = Source.selectSingleNode("root\/BANNERBASE\/@ConfirmDelete");     
  1057.   }
  1058.   ConfirmDeleteVal = ConfirmDelete.nodeValue;
  1059.   var SmallPictures = Source.selectSingleNode("root\/BANNERBASE\/@SmallPictures");  
  1060.   if (SmallPictures == null)    
  1061.   {
  1062.    BBase.setAttribute("SmallPictures", "0");
  1063.    SmallPictures = Source.selectSingleNode("root\/BANNERBASE\/@SmallPictures");     
  1064.   }
  1065.   SmallPicturesVal = SmallPictures.nodeValue;
  1066.   
  1067.   if (isNaN(ShowSlotsVal))
  1068.     ShowSlotsVal = parseInt(ShowSlotsVal, 10);  
  1069.    
  1070.   var RowBitsOld = ShowSlotsVal;
  1071.   if (parseInt(ConfirmDeleteVal))
  1072.    RowBitsOld=RowBitsOld | 1024;
  1073.   if (parseInt(SmallPicturesVal))
  1074.    RowBitsOld=RowBitsOld | 2048;
  1075.    
  1076.   
  1077.    RowBits = showModalDialog ("options.htm", RowBitsOld, "dialogWidth:230px; dialogHeight:100px; dialogTop:150px; center:yes; border:thin; status:no; scroll:no; help:no;");
  1078.    if (RowBits != RowBitsOld)
  1079.    {
  1080.     Engine.Options = RowBits;
  1081.  
  1082.     if (top.frames[1].document.selection) 
  1083.      top.frames[1].document.selection.empty();
  1084.  
  1085.     if (RowBits & 1024)    
  1086.      BBase.setAttribute("ConfirmDelete", 1);     
  1087.     else
  1088.      BBase.setAttribute("ConfirmDelete", 0);     
  1089.      
  1090.      
  1091.      if  (RowBits & 2048)         
  1092.       BBase.setAttribute("SmallPictures", 1);     
  1093.      else 
  1094.       BBase.setAttribute("SmallPictures", 0);          
  1095.      BBase.setAttribute("ShowSlots", RowBits & 255);
  1096.      Sort(1);     
  1097.    }  
  1098.  
  1099. }
  1100.  
  1101.  
  1102.  
  1103. function ChangeXML_XSL(sz_XSLFileName)
  1104. {    
  1105.     if (ChangeXML())
  1106.         if (ChangeXSL(sz_XSLFileName))    
  1107.         {
  1108.             Sort(0);            
  1109.             return    true;
  1110.         }
  1111.  
  1112.     return    false;
  1113. }
  1114.  
  1115.  
  1116. function SetCaptionBar (str)
  1117. {
  1118.     if (str != null)
  1119.     {
  1120.      // set new captionbar
  1121.      str = "Image Co-Tracker - " + str;
  1122.      top.document.title = str;
  1123.     }      
  1124. }
  1125.  
  1126.  
  1127. function Init()
  1128. {   
  1129.      var str;
  1130.  
  1131.     IEVersion = window.navigator.appVersion.substring(22, 25);
  1132.     //if (IEVersion.charAt(0) != '5')   
  1133.     //{
  1134.     //alert ("This program runs under Microsoft Internet Explorer 5.0 or higher only.");   
  1135.     //top.close();
  1136.     //return;
  1137.     //}
  1138.  
  1139.        var userAgent = navigator.userAgent;
  1140.     var MSIEIndex = userAgent.indexOf("MSIE");
  1141.     if ((userAgent.indexOf("Win") == -1 )
  1142.      || (userAgent.indexOf("MSIE") == -1)
  1143.      || userAgent.substring((MSIEIndex + 5),(MSIEIndex + 6)) < 5)
  1144.     {
  1145.         alert ("This program runs under Microsoft Internet Explorer 5.0 or higher only.");   
  1146.         top.close();
  1147.         return;
  1148.     }
  1149.  
  1150.     if (top.frames[0].document.body.clientHeight == 0)
  1151.     return;    
  1152.   
  1153.     Engine.HdWnd = 1;            
  1154.     
  1155.     //fs = new ActiveXObject("Scripting.FilesystemObject");      
  1156.     //WshShell = new ActiveXObject("WScript.Shell");
  1157.     
  1158.     Source = new ActiveXObject("Microsoft.XMLDOM");
  1159.     Source.async = false;            
  1160.  
  1161.     Style = new ActiveXObject("Microsoft.XMLDOM");
  1162.     Style.async = false;                    
  1163.  
  1164.     StyleFirst = new ActiveXObject("Microsoft.XMLDOM");
  1165.     StyleFirst.async = false;                    
  1166.     
  1167.     ChangeXML_XSL(sz_XSLPath);            
  1168.  
  1169.  
  1170.     FillCTList ();                        
  1171.  
  1172.     FnHead2ScreenSize();
  1173.  
  1174. //===================================================================================================================================================
  1175. //========================================== Find functions =========================================================================================
  1176.  
  1177. function TFind ()
  1178. {
  1179.   top.frames[1].focus();
  1180.   Engine.CallIECommand (0);
  1181. }
  1182.  
  1183. function OnFind ()
  1184. {
  1185.   top.frames[1].focus();
  1186.   setTimeout  (TFind, 500); 
  1187. }
  1188.  
  1189. //====================================================================================================================================================
  1190. //========================================== Print functions =========================================================================================
  1191.  
  1192. function TPrint ()
  1193. {  
  1194.   LoadAllPics();   
  1195.   if (gnImageNum > 0)
  1196.    idImgTimer = top.frames[1].setInterval (TWaitLoadImages, 20);  
  1197.   else
  1198.    fnPrint();
  1199. }
  1200.  
  1201. function OnPrint ()
  1202.   if (ConfirmPrint ()) 
  1203.   {
  1204.    top.frames[1].focus();
  1205.    top.frames[1].setTimeout (TPrint, 50);     
  1206.   }
  1207. }
  1208.  
  1209. function TWaitLoadImages ()
  1210. {
  1211.   if (CheckLoadingPics ())
  1212.    fnPrint();  
  1213. }
  1214.  
  1215.  
  1216. function fnPrint ()
  1217. {
  1218.   if (idImgTimer)
  1219.   {
  1220.    top.frames[1].clearInterval(idImgTimer);
  1221.    idImgTimer = 0;
  1222.   }
  1223.   top.frames[1].focus();
  1224.   Engine.CallIECommand (1);   
  1225. }
  1226.  
  1227. function ConfirmPrint ()
  1228. {
  1229.  var DIVs = top.frames[1].document.all.tags("DIV");   
  1230.   
  1231.  if ((DIVs.length > 150) && (!confirm ("You want to print more than 150 images. It may cause some troubles. Do you want to continue?")))
  1232.   return 0;
  1233.  else
  1234.   return 1;
  1235. }
  1236.  
  1237.  
  1238. function CheckLoadingPics ()
  1239. {
  1240.  var DIVs = top.frames[1].document.all.tags("DIV");  
  1241.  
  1242.  for (i=1; i < DIVs.length;i++)
  1243.  { 
  1244.    CurImage = DIVs[i].all.tags("IMG")[0];
  1245.    if (CurImage && (!CurImage.useMap) && (CurImage.fileSize) && (CurImage.readyState != "complete"))   
  1246.    {     
  1247.      return 0;
  1248.    }        
  1249.  } 
  1250.  return 1; 
  1251. }
  1252.  
  1253.  
  1254. function LoadAllPics ()
  1255.  var CurImage;
  1256.  var DIVs = top.frames[1].document.all.tags("DIV");  
  1257.  var NumImg;  
  1258.    
  1259.  NumImg = 0;
  1260.  for (i=1; i < DIVs.length;i++)
  1261.  { 
  1262.    CurImage = DIVs[i].all.tags("IMG")[0];
  1263.    if (CurImage && (!CurImage.useMap) && (CurImage.fileSize == -1))   
  1264.    {     
  1265.      NumImg++;
  1266.      CurImage.src = CurImage.TEMPSRC;   
  1267.    }        
  1268.  }   
  1269.  gnImageNum = NumImg;
  1270. }
  1271.  
  1272. function fnBeforePrint ()
  1273. {
  1274.  var Button;
  1275.  var DIVs = top.frames[1].document.all.tags("DIV");    
  1276.  
  1277.  for (i=1; i < DIVs.length;i++)
  1278.  { 
  1279.     Button = DIVs[i].all.tags("INPUT")[0];  
  1280.     if (Button)
  1281.      Button.style.display = "none";
  1282.  }   
  1283. }
  1284.  
  1285.  
  1286.  
  1287.  
  1288. function fnAfterPrint ()
  1289.  var Button;
  1290.  var DIVs = top.frames[1].document.all.tags("DIV");
  1291.  
  1292.  for (i=1; i < DIVs.length;i++)
  1293.  { 
  1294.     Button = DIVs[i].all.tags("INPUT")[0];
  1295.     if (Button)
  1296.      Button.style.display = "";
  1297.  }  
  1298. }
  1299.  
  1300. //============================================Head resize functions======================================================================================
  1301. function FnHead2ScreenSize ()
  1302. {    
  1303.   if (top.frames[0].document.body) 
  1304.    top.document.all.tags('FRAMESET')[0].rows = top.frames[0].document.body.scrollHeight + "px, *";
  1305. }
  1306.  
  1307.  
  1308. function FnHeadResize (HeadFrame)
  1309.   if (top.frames[0].document.body)   
  1310.    top.document.all.tags('FRAMESET')[0].rows = top.frames[0].document.body.scrollHeight + "px, *";  
  1311. }
  1312.  
  1313.  
  1314. //=======================================================================================================================================================
  1315.  
  1316. function SetButtonImage(oImg, bGray)
  1317. {
  1318.    var    CurrentCT;
  1319.  
  1320.    if (Source == null)
  1321.     return;
  1322.    
  1323.    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");  
  1324.    if (((CurrentCT.nodeValue == "0000000000000000") || (CurrentCT.nodeValue == "0000000000000001")) && ((oImg.id == "btnDelCT") || (oImg.id == "btnRenameCT"))) 
  1325.     return;
  1326.  
  1327.  
  1328.  
  1329.  
  1330.   if (bGray == 1)
  1331.    oImg.src = oImg.graysrc;
  1332.   else
  1333.    oImg.src = oImg.colorsrc;
  1334. }
  1335.  
  1336. function File2Tracker (nCommand)
  1337. {
  1338.  var strCaption;
  1339.  
  1340.  switch (nCommand)
  1341.  {
  1342.    case @NEW_XMLDB:
  1343.     SourceNew = new ActiveXObject("Microsoft.XMLDOM");
  1344.     SourceNew.async = false;            
  1345.     SetNewBase (SourceNew);
  1346.     strCaption = Engine.NewXMLBase (SourceNew);
  1347.     if (strCaption)    
  1348.     {
  1349.      Source = SourceNew;         
  1350.      Engine.UpdateData(null);     
  1351.     }
  1352.     break;       
  1353.  
  1354.    case @OPEN_XMLDB:
  1355.     SourceNew = new ActiveXObject("Microsoft.XMLDOM");
  1356.     SourceNew.async = false;
  1357.     strCaption = Engine.OpenXMLBase (SourceNew, 0, 0);     
  1358.     if (strCaption)
  1359.     {
  1360.      Source = SourceNew;    
  1361.      Engine.UpdateData(null);     
  1362.     }
  1363.     break;       
  1364.  
  1365.    case @SAVE_XMLDB:    
  1366.     strCaption = Engine.SaveAsXMLBase (Source);     
  1367.     if (strCaption)    
  1368.       SetCaptionBar(strCaption);    
  1369.     break;        
  1370.  }
  1371.  
  1372. }
  1373.  
  1374.  
  1375. function CheckOptions ()
  1376. {
  1377.   var BBase = Source.selectSingleNode("root\/BANNERBASE");
  1378.   var ShowSlots = Source.selectSingleNode("root\/BANNERBASE\/@ShowSlots");    
  1379.   var ConfirmDelete = Source.selectSingleNode("root\/BANNERBASE\/@ConfirmDelete");    
  1380.   var SmallPictures = Source.selectSingleNode("root\/BANNERBASE\/@SmallPictures");  
  1381.   var CtOptions = Engine.Options;
  1382.   var Val;
  1383.   var bNoChange = true;
  1384.  
  1385.   //debugger;
  1386.  
  1387.   
  1388.   if (CtOptions == -1)    
  1389.   {
  1390.    Val = ShowSlots.nodeValue & 255;
  1391.    if ((ConfirmDelete) &&  (ConfirmDelete.nodeValue == 1)) 
  1392.     Val = Val | 1024;
  1393.    if ((SmallPictures) &&  (SmallPictures.nodeValue == 1)) 
  1394.     Val = Val | 2048;
  1395.    
  1396.    Engine.Options = Val;                   
  1397.   } 
  1398.   else
  1399.   {
  1400.    if ((!ShowSlots) ||  (ShowSlots.nodeValue != (CtOptions & 255)))
  1401.    {
  1402.     Val = CtOptions & 255;
  1403.     BBase.setAttribute("ShowSlots", Val);
  1404.     bNoChange = false;
  1405.    }
  1406.  
  1407.    if ((!ConfirmDelete) ||  (ConfirmDelete.nodeValue != (CtOptions & 1024)))
  1408.    {
  1409.     if ( CtOptions & 1024 )
  1410.      BBase.setAttribute("ConfirmDelete", 1);
  1411.     else    
  1412.      BBase.setAttribute("ConfirmDelete", 0);
  1413.     bNoChange = false;
  1414.    }
  1415.  
  1416.  
  1417.    if ((!SmallPictures) ||  (SmallPictures.nodeValue != (CtOptions & 2048)))
  1418.    {
  1419.     if ( CtOptions & 2048 )
  1420.      BBase.setAttribute("SmallPictures", 1);     
  1421.     else
  1422.      BBase.setAttribute("SmallPictures", 0);         
  1423.     bNoChange = false;
  1424.    }  
  1425.  
  1426.    if (bNoChange == false)
  1427.     SaveSource();
  1428.   }
  1429. }
  1430.  
  1431.  
  1432. function ExportF ()
  1433. {
  1434.   Engine.Export (null);
  1435. }
  1436.  
  1437. function ImportF ()
  1438. {
  1439.   Engine.Import (null);
  1440. }
  1441.  
  1442. function PublishHTML ()
  1443. {
  1444.  var HTMLText;
  1445.  var strDirName;
  1446.  
  1447.  str = Engine.GetHTMLName ();  
  1448.  
  1449.  if (str != null)
  1450.  {
  1451.      strTmp = str;
  1452.      strDir = "";
  1453.      do
  1454.      {
  1455.       nPos = strTmp.search (/\\/i);
  1456.       if (nPos != -1)      
  1457.       {
  1458.        strTmp = strTmp.substring (nPos+1, strTmp.length);
  1459.        strDir = str.substring (0, nPos+strDir.length+1);         
  1460.       }
  1461.      } while (nPos != -1); 
  1462.  
  1463.      nPos = strTmp.search (/\./);
  1464.      if (nPos != -1)
  1465.       strTmp = strTmp.substring (0, nPos);
  1466.      strDir = strDir + strTmp + "_images\\";
  1467.      strDirName = strTmp + "_images\\"; // name subdirectory with images
  1468.  
  1469.  
  1470.    var PSlotsOld = Source.selectSingleNode("root\/BANNERBASE\/@PubSlots");    
  1471.    var BBase = Source.selectSingleNode("root\/BANNERBASE");
  1472.  
  1473.    if (PSlotsOld == null)   
  1474.    {
  1475.     PSlotsOld = Source.selectSingleNode("root\/BANNERBASE\/@ShowSlots");    
  1476.     if (PSlotsOld)
  1477.      BBase.setAttribute("PubSlots", PSlotsOld.nodeValue);
  1478.     else
  1479.     {
  1480.      BBase.setAttribute("PubSlots", "191"); 
  1481.      PSlotsOld = Source.selectSingleNode("root\/BANNERBASE\/@PubSlots");    
  1482.     }
  1483.     SaveSource();
  1484.    }
  1485.  
  1486.    var PNamesOld = Source.selectSingleNode("root\/BANNERBASE\/@FieldNames");    
  1487.    if (PNamesOld == null)   
  1488.    {
  1489.     BBase.setAttribute("FieldNames", "1"); 
  1490.     PNamesOld = Source.selectSingleNode("root\/BANNERBASE\/@FieldNames");    
  1491.     SaveSource();
  1492.    }
  1493.  
  1494.    if (PNamesOld.nodeValue == 1)
  1495.     nSlots = PSlotsOld.nodeValue | 1024;
  1496.    else
  1497.     nSlots = PSlotsOld.nodeValue;
  1498.  
  1499.    var nSlots = showModalDialog ("pub_opts.htm", nSlots, "dialogWidth:230px; dialogHeight:100px; dialogTop:150px; center:yes; border:thin; status:no; scroll:no; help:no;");
  1500.    if (!nSlots)
  1501.     return;
  1502.  
  1503.    if ((nSlots & 191)  != PSlotsOld.nodeValue)
  1504.    {
  1505.     BBase.setAttribute("PubSlots", (nSlots & 191));
  1506.     SaveSource();
  1507.    }
  1508.  
  1509.    if ((nSlots & 1024) != PNamesOld.nodeValue)
  1510.    {
  1511.     if (nSlots & 1024)
  1512.      BBase.setAttribute("FieldNames", "1"); 
  1513.     else
  1514.      BBase.setAttribute("FieldNames", "0"); 
  1515.    }
  1516.  
  1517.  
  1518.    XSL4HTML = new ActiveXObject("Microsoft.XMLDOM");
  1519.    XSL4HTML.load("htm.xsl");
  1520.    HTMLText = Source.transformNode(XSL4HTML);
  1521.    top.frames[2].document.all.XSLResult.innerHTML = HTMLText;
  1522.  
  1523.    var MapsToEscape = top.frames[2].document.all.tags("MAP");
  1524.    if (MapsToEscape != null)    
  1525.     {
  1526.        for (var Index = MapsToEscape.length - 1; Index >= 0; Index--)                
  1527.          MapsToEscape[Index].innerHTML = unescape(MapsToEscape[Index].innerHTML);                                    
  1528.     }                
  1529.  
  1530.     var MapsToChange = top.frames[2].document.all.tags("MAPTOCHANGE");
  1531.     if (MapsToChange != null)    
  1532.     {
  1533.             for (var MapIndex = 0; MapIndex < MapsToChange.length; MapIndex++)    
  1534.             {
  1535.                 var AreasToChange = MapsToChange[MapIndex].parentElement.all.tags("AREA");
  1536.                 if (AreasToChange != null)    
  1537.                 {
  1538.                     for (var AreaIndex = 0; AreaIndex < AreasToChange.length; AreaIndex++)    
  1539.                      AreasToChange[AreaIndex].target = "_blank";                                            
  1540.                 }
  1541.                 MapsToChange[MapIndex].parentElement.outerHTML = MapsToChange[MapIndex].nextSibling.outerHTML;                                        
  1542.                 MapIndex--; // becouse there is decrement collection length                
  1543.             }
  1544.             
  1545.     }                 
  1546.  
  1547.    var Imgs = top.frames[2].document.all.tags("IMG");
  1548.    for (i=0; i<Imgs.length; i++)
  1549.    {
  1550.     StrSrc =  unescape (Imgs[i].src);    
  1551.     Engine.CopyImageFile (Imgs[i].src, strDir);    
  1552.     do
  1553.     {
  1554.       nPos = StrSrc.search ('/');
  1555.       if (nPos != -1)      
  1556.        StrSrc = StrSrc.substring (nPos+1, StrSrc.length);         
  1557.      } while (nPos != -1);
  1558.  
  1559.      StrSrc = strDirName + StrSrc;          
  1560.      Imgs[i].src = StrSrc;
  1561.    }
  1562.  
  1563.    HTMLText = top.frames[2].document.all.XSLResult.innerHTML;
  1564.    HTMLText = "<HTML><BODY STYLE='background-color:white'>" + HTMLText + "</BODY></HTML>"
  1565.    top.frames[2].document.all.XSLResult.innerHTML = "";
  1566.  
  1567.    var fso = new ActiveXObject("Scripting.FilesystemObject");
  1568.    var fstream = fso.CreateTextFile (str, true, true);
  1569.    fstream.Write (HTMLText);   
  1570.    fstream.Close ();
  1571.  
  1572.  }
  1573.    
  1574. }    
  1575.  
  1576.  
  1577. function fnContextMenuBubble ()
  1578. {
  1579.  if (event) 
  1580.  {
  1581.   event.cancelBubble = true;
  1582.   event.returnValue = false;
  1583.  }
  1584.  else
  1585.  {
  1586.   top.frames[0].event.cancelBubble = true;
  1587.   top.frames[0].event.returnValue = false;
  1588.  }
  1589.  
  1590.  return false;
  1591. }
  1592.  
  1593.  
  1594. function fnContextMenuCheck ()
  1595. {
  1596.  if ((top.frames[1].event.srcElement.tagName != "IMG") && (top.frames[1].event.srcElement.tagName != "INPUT"))
  1597.  {  
  1598.   top.frames[1].event.cancelBubble = true;
  1599.   top.frames[1].event.returnValue = false;
  1600.   return false;
  1601.  }
  1602. }
  1603.  
  1604.  
  1605. function Attach2Email (bPopup)
  1606. {
  1607.   //top.frames[0].document.all["btnMail"].UpdateButton(0, 1);
  1608.   if (top.frames[0].event)
  1609.   {
  1610.    x = top.frames[0].event.x;
  1611.    y = top.frames[0].event.y;
  1612.   }
  1613.   else
  1614.   {
  1615.    x=0;
  1616.    y=50; 
  1617.   }
  1618.  
  1619.   if (bPopup)
  1620.    Engine.MailClientsPopupMenu  (1, x, y);
  1621.   else
  1622.    Engine.MailClientsPopupMenu  (0, x, y);
  1623.  
  1624.   //top.frames[0].document.all["btnMail"].UpdateButton(0, 0);
  1625.   top.window.focus();
  1626. }
  1627.  
  1628. </SCRIPT>
  1629. </HEAD>
  1630. <FRAMESET BORDER=0 ROWS="40px, *, 0px" ID=Main onload="Init()" oncontextmenu="fnContextMenuBubble()">
  1631. <FRAME FRAMEBORDER=1 SCROLLING=NO SRC=hd.htm APPLICATION="yes" onresize="FnHeadResize (this)" NORESIZE> 
  1632. <FRAME FRAMEBORDER=0 SCROLLING=AUTO SRC=data.htm  APPLICATION="yes" onresize="LoadPictures()" NORESIZE>
  1633. <FRAME SRC=data.htm style="display:none" APPLICATION="yes" NORESIZE>
  1634. <NOFRAMES> There is no frame support!  </NOFRAMES>
  1635. </FRAMESET>
  1636. </HTML>
  1637.