﻿function updatefileds()
        {
         
        if (eval(document.aspnetForm)) {
        		
	        var where_is_mytool=readCookie("cmasterids=");
	        if (where_is_mytool) {
	        document.aspnetForm.allprods.value=where_is_mytool;
	        var mytool_array=where_is_mytool.split(",");
	        var arralength = mytool_array.length;
         
	        for (x=1; x<arralength; x++) 
		        { 
        		
		        for (y=0;y<10; y++)
		        {
		        if (document.aspnetForm.cb[y].value == mytool_array[x])
				        {
        					
						        document.aspnetForm.cb[y].checked=true;
				        }
        			
				        }
		        } 
        		
		        }
        }
        }
         
         
        function storeCookie(theElement)
        {
            var count = 0;
            for (var x = 0; x < document.getElementsByName("cb").length; x++) {
                if (document.getElementsByName("cb")[x].checked)
                    count++;
            }
            if (count == 1)
                document.cookie = "cmasterids=";
                
          var thecookie = readCookie("cmasterids=");
          box = theElement.checked;
          count = (box ? 1 : 0);
          if (count > 0)
          {
            document.cookie = "cmasterids"+"="+thecookie+","+theElement.value+";";
          }
          else 
          {
	        var newCookie = removeID(thecookie, ","+theElement.value);
	        document.cookie = "cmasterids"+"="+newCookie+";";
          }
         
        updatefileds();
        }

         
         
        function removeID(myString, pattern) 
        {
           var newString = myString.replace(pattern,"");
           return(newString);
        }
         
        function readCookie(theCookie)
        {
          var allcookies = document.cookie;
          var pos = allcookies.indexOf(theCookie);
          if (pos != -1)
          {
            var start = pos + theCookie.length;
	        var end = allcookies.indexOf(";", start);
	        if (end == -1) end = allcookies.length;
	        var value = allcookies.substring(start, end);
	        value = unescape(value);
         
        }
         
          return (value);
          
        }
         
        function clearCookie(theElement)
        {
          var allcookies = document.cookie;
          for(var i = 0; i < 250; i++)
          {
            var pos = allcookies.indexOf("cmasterids["+i+"]=");
            if (pos != -1)
            {
              var s = "1"+i;
              var digit = s.length - 1;
              var start = pos + 13 + digit;
              var end = allcookies.indexOf(";", start);
              if (end == -1) end = allcookies.length;
              var value = allcookies.substring(start, end);
              value = unescape(value);
            }
            if (value == theElement.value)
            {
              document.cookie = "cmasterids["+i+"]=; expires=Fri, 02-Jan-1970 00:00:00 GMT";
            }
          }
        }
         
         
         
        function openitremove(theURL) { //v2.0
          window.open(theURL,'winName','width=700,height=450,scrollbars=yes');
        }
         
         
         
        