home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 June / Chip_2004-06_cd2.bin / officexp / download / info_soubory / searchui.js < prev    next >
Text File  |  2004-04-27  |  11KB  |  471 lines

  1.  
  2. var d = document;
  3. PageLoaded = false;
  4. var uplevel = false;
  5.  
  6. if(document.createAttribute) uplevel = true;;
  7.  
  8. function gsfx_drawselectlist(po, co, pn){
  9.     
  10.     if(failure==0){
  11.         var lcid ;
  12.         var potl;
  13.         var catalog = false;
  14.  
  15.         if(po){
  16.             catalog = true;
  17.             if(po.type){
  18.                 potl = po.type.toLowerCase();
  19.                 if(potl.indexOf("select") > -1) ctl = po.selectedIndex;
  20.                 else ctl = 0;
  21.             }else if(po.length){
  22.                 potl = "radio";
  23.                 ctl = -1;
  24.                 for(i=0; i<po.length; i++){
  25.                     if(po[i].checked){
  26.                         ctl = i;
  27.                         
  28.                         } 
  29.                 }
  30.                 if(ctl < 0) ctl = 0;
  31.                 
  32.                 
  33.                 
  34.             }
  35.         }else ctl = 0;
  36.         
  37.         var si = 0;
  38.         var ms = true;
  39.  
  40.         if(po){
  41.             if(potl.indexOf("select") > -1){
  42.                 if(po.options[ctl].value.indexOf("PRODLISTSRC=OFF") > -1) ms = false;
  43.                     catalogEntry = po[ctl].value;
  44.             }else if(potl.indexOf("hidden") > -1){
  45.                 catalogEntry = po.value;
  46.                 if(po.value.indexOf("PRODLISTSRC=OFF") > -1) ms = false;
  47.             }else if(potl == "radio"){
  48.                 catalogEntry = po[ctl].value;
  49.                 
  50.                 DisplayScopeElement(po[ctl].getAttribute("MT"),po[ctl].getAttribute("CC"),po);    
  51.                 if(po[ctl].value.indexOf("PRODLISTSRC=OFF") > -1) ms = false;
  52.             }
  53.             j = catalogEntry.indexOf('=');
  54.             lcid = catalogEntry.substring(j+1,catalogEntry.indexOf('&'));        
  55.         }
  56.         
  57.         
  58.         var arraylen;
  59.         if(co && co.options){
  60.             if(catalog) arraylen = eval(pn+"_"+co.name+"_"+lcid+'.length;');
  61.             else arraylen = eval(pn+"_"+co.name+"_"+ctl+'.length;');
  62.             
  63.             if(co.children && navigator.appVersion.indexOf("Macintosh") < 0){
  64.                 while(co.children.length > 0){
  65.                     for(i=0;i<co.children.length;i++){
  66.                         co.remove(co.children[i]);
  67.                     }
  68.                 }
  69.             }else for(i=0;i<co.options.length;i++){co.options[i] = null;}
  70.         }
  71.     
  72.         
  73.         var initial = 0;
  74.         if(co && co.options){
  75.             if(ms){
  76.             if(po){
  77.             tval = fetchcookieval(lcid+"_Prod")
  78.             if(tval != 'blank' && tval != '')
  79.             {     
  80.                 tval = tval.substring(0,tval.length-1);
  81.                 var productlist = new Array();
  82.                 productlist = tval.split("$");
  83.                 
  84.                 if(productlist.length > 0)
  85.                 {
  86.                     productlist = productlist.reverse();
  87.     
  88.                     for(i=0 ;i<productlist.length ;i++)
  89.                     {
  90.                         var productentry = new Array();
  91.                         productentry = productlist[i].toString().split("|");
  92.                         productName = unescape(productentry[0]);
  93.                         productID    = unescape(productentry[1]);
  94.                         ts1 = productName + "\",\"" + productID;
  95.                         eval("co.options[i] = new Option(\""+ts1+"\")");    
  96.                     }    
  97.                     ts1 = "----------------------------------------------------------\",\"line";    
  98.                     eval("co.options[i] = new Option(\""+ts1+"\")");        
  99.                     initial = i+1;
  100.             }
  101.             }
  102.             
  103.             
  104.             }
  105.                 
  106.                 
  107.                 for(i=0;i<arraylen;i++){
  108.                     if(catalog)    ts = eval(pn+"_"+co.name+"_"+lcid+'['+i+']');
  109.                     else ts = eval(pn+"_"+co.name+"_"+ctl+'['+i+']');
  110.                     
  111.                     eval("co.options[i+initial] = new Option(\""+ts+"\")");
  112.                     co.disabled = false;
  113.                 }
  114.             
  115.             if(catalog) si = eval(pn + "_" + co.name + "_" + lcid + "default");        
  116.             else si = eval(pn + "_" + co.name + "_" + ctl + "default");        
  117.             
  118.             }else{
  119.                 co.options[0] = new Option("", "");
  120.                 si = 0;
  121.                 co.disabled = true;
  122.             }
  123.             
  124.             co.selectedIndex = si;
  125.         }
  126.     }
  127. }
  128.  
  129. function DisplayScopeElement(mt,cc,catalogElem)
  130. {
  131.  
  132.     var hideMT ,hideCC ;
  133.     
  134.     if(mt != null && mt.length > 0)
  135.     {
  136.         mtrow = d.getElementById("InMT_row");
  137.         mtrow1 = d.getElementById("InMT_row1");
  138.         if(mtrow && mtrow1)
  139.         {        
  140.             if(mt.toLowerCase() == "false")
  141.             {    
  142.                 mtrow.style.display = "none";
  143.                 mtrow1.style.display = "none";
  144.                 hideMT = true;        
  145.             }
  146.             else
  147.             {
  148.                 mtrow.style.display = "block";
  149.                 mtrow1.style.display = "block";
  150.             }
  151.         }
  152.     }
  153.     else hideMT = true;
  154.     if(cc != null && cc.length > 0)
  155.     {
  156.         ccrow = d.getElementById("InCC_row");
  157.         ccrow1 = d.getElementById("InCC_row1");
  158.         if(ccrow && ccrow1)
  159.         {
  160.             if(cc.toLowerCase() == "false")
  161.             {    
  162.                 ccrow.style.display = "none";
  163.                 ccrow1.style.display = "none";
  164.                 hideCC = true;        
  165.             }
  166.             else
  167.             {
  168.                 ccrow.style.display = "block";
  169.                 ccrow1.style.display = "block";
  170.  
  171.             }
  172.         }
  173.     }
  174.     else hideCC = true;
  175.     
  176.         var scope = document.getElementById("Scope_row");
  177.         if(scope) 
  178.         {
  179.             if(hideMT & hideCC) scope.style.display = "none"; 
  180.             else scope.style.display = "block"; 
  181.         }
  182.     
  183.     
  184. }
  185.  
  186.  
  187.  
  188. function getUrlParam(param){
  189.     var rv = "";
  190.     var q = new Array();
  191.     if(param.indexOf("_") > 0) {
  192.         argParam = param.split("_")[1];
  193.     } else {
  194.         argParam = param;
  195.     }
  196.     var here = document.location.href;    
  197.     q = here.split("?");
  198.     if(q.length > 1){
  199.         var argarray = new Array();
  200.         argarray = q[1].toString().split("&");
  201.         var keyval;
  202.         for(i=0; i<argarray.length; i++){
  203.             keyval = argarray[i].toString().split("=");
  204.             if(keyval[0].toLowerCase() == argParam.toLowerCase()){
  205.                 if(uplevel)    rv = decodeURI(keyval[1]);                else rv = unescape(keyval[1]);
  206.                 break;
  207.             }
  208.         }
  209.     }
  210.     
  211.     if(rv == "") {
  212.         rv = unescape(fetchcookieval(param));
  213.         if(rv == "blank") { rv = ""; }
  214.     }
  215.     return rv;
  216. }
  217.  
  218.  
  219. function GetContentIDEntry(ct)
  220. {
  221. var cdid = "";
  222. if(ct != 'blank' && ct != '') { 
  223.     cdid = ct.split("&")[1].split("=")[1];
  224. }        
  225. return cdid ;
  226.  
  227. }
  228.  
  229.  
  230. function AppendSelect(catalogElement,selectElement,webpartName,selectName){
  231. gsfx_drawselectlist(catalogElement,selectElement,webpartName)
  232. tval = fetchcookieval(webpartName + '_' + selectName )
  233. if(tval != "blank"){
  234.     for(i=0; i<selectElement.options.length; i++){
  235.         if(selectElement.options[i].value == unescape(tval)){
  236.             selectElement.selectedIndex = i;
  237.             break;
  238.         }
  239.     }
  240. }
  241.  
  242. }
  243.  
  244. function AppendRadio(radioElement,webpartName,radioName){
  245.  
  246. tval = fetchcookieval(webpartName + '_' + radioName )
  247. if(tval != "blank"){
  248.     for(i=0; i<radioElement.length; i++){
  249.         if(radioElement[i].value == unescape(tval)){
  250.             radioElement[i].checked = true;
  251.             radioElement[i].click();
  252.             break;
  253.         }
  254.     }
  255. }
  256.  
  257. }
  258.  
  259. function AppendText(textElement,webpartName,textName,defaultstring)
  260. {
  261.     if(textElement)
  262.     {
  263.         tval = fetchcookieval(webpartName + '_' + textName)
  264.             if(tval != 'blank' && tval != '')
  265.             { 
  266.                 textElement.value =UnicodeFixup(unescape(tval)); 
  267.             } 
  268.             else 
  269.             { 
  270.                 textElement.value = defaultstring;
  271.             }
  272.     }        
  273. }
  274.  
  275. function AdvSrchText(textElement,webpartName,textName){
  276.     var arg = getUrlParam(webpartName + '_' + textName);
  277.     if(arg != ""){
  278.         textElement.value = arg;
  279.     }
  280.  
  281. }
  282.  
  283. function AdvSrchSelect(catalogElement,selectElement,webpartName,selectName){
  284.  
  285. gsfx_drawselectlist(catalogElement,selectElement,webpartName)
  286. var arg = getUrlParam(webpartName + "_" + selectName);
  287. if(arg != ""){
  288.     for(i=0; i<selectElement.options.length; i++){
  289.         if(selectElement.options[i].value.toLowerCase() == arg.toLowerCase())
  290.         {    selectElement.selectedIndex = i;
  291.             break;
  292.         }
  293.     }
  294. }
  295.  
  296. }
  297.  
  298. function AdvSrchCheckBox(catalogElement,scopeName)
  299. {
  300.     cbElement   = document.getElementById(scopeName);
  301.     
  302.     if(cbElement)
  303.     {
  304.         if(catalogElement)
  305.         {
  306.             var contentID;
  307.             
  308.             if(catalogElement.length > 0)
  309.             {
  310.                 for(i=0;i<catalogElement.length;i++)
  311.                 {
  312.                     if(catalogElement[i].checked) contentID = GetContentIDEntry(catalogElement[i].value);
  313.                 }
  314.             }
  315.             else
  316.             {
  317.                 contentID = GetContentIDEntry(catalogElement.value);    
  318.             }    
  319.             tval = fetchcookieval(scopeName + "_" +  contentID);
  320.                         
  321.             if(tval != 'blank' && tval != '')
  322.             {
  323.                 if(tval == "0") cbElement.checked = false;
  324.                 else cbElement.checked = true;
  325.             }
  326.         
  327.         }
  328.     
  329.     }
  330.  
  331. }
  332.  
  333.  
  334. function AdvSrchRadio(radioElement,webpartName,radioName){
  335. var arg = getUrlParam(webpartName + "_" + radioName);
  336. if(arg != ""){
  337.     for(i=0; i<radioElement.length; i++){
  338.         if(radioElement[i].value.toLowerCase() == arg.toLowerCase())
  339.         {
  340.             radioElement[i].checked = true;
  341.             radioElement[i].click();
  342.             break;
  343.         }
  344.     }
  345. }
  346. }
  347.  
  348. function SubmitSelect(selectElement,webpartName,selectName)
  349. {
  350.     srch_setcookieval(webpartName + "_" + selectName,escape(selectElement.options[selectElement.selectedIndex].value));
  351. }
  352.  
  353.  
  354. function SubmitCheckBox(cbElement,catalogElement,hdncbElement,scopeName,defvalue)
  355. {
  356.     var scopeRow = d.getElementById(scopeName +"_row");
  357.     if(scopeRow)
  358.     {
  359.         if(scopeRow.style.display == "block" | scopeRow.style.display == "")
  360.         {
  361.             if(cbElement.checked) hdncbElement.value = "true";
  362.             else hdncbElement.value = "false";
  363.         }    
  364.         else hdncbElement.value = defvalue ;
  365.     }    
  366.     
  367.     if(catalogElement)
  368.     {
  369.         var contentID;
  370.         if(catalogElement.length > 0)
  371.         {
  372.             for(i=0;i<catalogElement.length;i++)
  373.             {
  374.                 if(catalogElement[i].checked) contentID = GetContentIDEntry(catalogElement[i].value);
  375.             }
  376.         }
  377.         else contentID = GetContentIDEntry(catalogElement.value);
  378.         
  379.         if(cbElement.checked) setcookieval(scopeName + "_" +  contentID,"1");
  380.         else setcookieval(scopeName + "_" +  contentID,"0");
  381.  
  382.     }    
  383.  
  384.  
  385. }
  386.  
  387.  
  388. function SubmitText(textElement,leftTextElement,webpartName,textName,defaultstring,productElement,catalogElement)
  389. {
  390. if(productElement && productElement.options)
  391. {
  392.     
  393.     var prodName = productElement.options[productElement.selectedIndex].text;
  394.     var prodID = productElement.options[productElement.selectedIndex].value;
  395.     var lcid = "1033";
  396.     var catSelected = -1;
  397.     var catalogEntry ;
  398.     if(prodID != '' && (prodID.toLowerCase().indexOf("msall") < 0))
  399.     { 
  400.         if(catalogElement)
  401.         {
  402.             
  403.             if(catalogElement.length)
  404.             {
  405.                 for(i=0; i<catalogElement.length; i++){
  406.                     if(catalogElement[i].checked) catSelected = i;
  407.                 }
  408.                     
  409.                     if(catSelected < 0) catSelected = 0;
  410.                     catalogEntry = catalogElement[catSelected].value;    
  411.                         
  412.             }
  413.             else
  414.             {
  415.                 catalogEntry = catalogElement.value;
  416.             
  417.             }
  418.         }
  419.         
  420.         j = catalogEntry.indexOf('=');
  421.         lcid = catalogEntry.substring(j+1,catalogEntry.indexOf('&'));
  422.         tval = fetchcookieval(lcid + "_Prod")
  423.     
  424.         if(tval != 'blank' && tval != '')
  425.         
  426.         { 
  427.             if(tval.indexOf(prodID + '$') < 0)
  428.             { 
  429.                 //Check if no. of products in cookie > 10
  430.                 if(tval.split("$").length > 10)
  431.                 {
  432.                     
  433.                     tval = tval.substring(tval.indexOf('$') + 1 ,tval.length);
  434.                 }
  435.                 setcookieval(lcid + "_Prod",tval + escape(prodName) + '|' + escape(prodID) + '$');    
  436.                                     
  437.             }
  438.         }
  439.         else
  440.         {
  441.             setcookieval(lcid +"_Prod",escape(prodName) + '|' + escape(prodID) + '$');
  442.         }
  443.     }
  444. }
  445.     if(leftTextElement.value == defaultstring) leftTextElement.value = '';
  446.     textElement.value = leftTextElement.value;
  447.     srch_setcookieval(webpartName+ "_" + textName, UnicodeFixup(escape(leftTextElement.value)));
  448. }
  449.  
  450.  
  451.  
  452. function SubmitRadio(radioElement,webpartName,radioName)
  453. {
  454. for(i=0;i<radioElement.length;i++){
  455.         if(radioElement[i].checked){
  456.             srch_setcookieval(webpartName + '_' + radioName,escape(radioElement[i].value));
  457.             
  458.         }
  459.     }
  460. }
  461.  
  462. function ChangeLink(prd)
  463. {
  464.     if(document.getElementById)
  465.     {
  466.         var advLink = document.getElementById("advLinkRt");
  467.         if(advLink) advLink.href = advLink.href + "&Product=" + prd;
  468.     }
  469. }
  470.  
  471.