function opendir(index) 
{
	document.form1.command.value='open';
	document.getElementById('opendir').value=document.getElementById('folder_path'+index).value;
	document.form1.submit();	
}

function opendir__(index) 
{
	document.form1.command.value='open';
	document.getElementById('opendir').value=document.getElementById('folder_path'+index).value;
	document.form1.submit();	
}

function openpath(path) {
	document.form1.command.value='open';
	document.getElementById('opendir').value=path;
	document.form1.submit();	
}


var can_add=1;

function add_product() {
	if (can_add==1) {
		if (document.getElementById('products_list').value>0) {
			add_new_product(parseInt(document.getElementById('products_list').value));
		}
		document.getElementById('products_list').selectedIndex=null;
	}
}

function add_maat(id,maat) {
	var maat=escape(maat);
	xmlhttpPost(host+'index.php?command=addmaat&id='+id+'&maat='+maat,'');
}

function add_qt(id,qt) {
	var qt=escape(qt);
	xmlhttpPost(host+'index.php?command=addqt&id='+id+'&qt='+(qt>0 ? qt : 1),'');			
}

function add_new_product(id) {
	if (document.getElementById('row'+id)) {
		var qt=parseInt(document.getElementById('qt_'+id).value)+1;
		document.getElementById('qt_'+id).value=qt>0 ? qt : 1;
		xmlhttpPost(host+'index.php?command=addqt&id='+id+'&qt='+(qt>0 ? qt : 1),'');			
	} else {
		var row=document.createElement("div");
		row.className='product_list_line';
		row.id='row'+id;	
		document.getElementById('product_list').appendChild(row);	
		document.getElementById('row'+id).innerHTML='<img src=\"'+host+'images/load.gif\" width=100% height=13>';
		can_add=0;
		xmlhttpPost(host+'index.php?command=getproductrow&id='+id,'row'+id);	
	}		
}

function remove_product(id) {
	if (document.getElementById('row'+id)) {
		xmlhttpPost(host+'index.php?command=deleteprod&id='+id,'');	
		document.getElementById('row'+id).innerHTML='';
		document.getElementById('row'+id).style.display='none';
		document.getElementById('row'+id).id=null;		
	}
}

//initiate XMLHttpReguest

function changestatus(strURL)
  {
    var xmlHttpReq = false;
    var self = this;
    
	// Mozilla/Safari
    if (window.XMLHttpRequest)
	  {
        self.xmlHttpReq = new XMLHttpRequest();
      }
    // IE
    else if (window.ActiveXObject)
	      {
            self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
          }
		  
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function()
	  {
        if (self.xmlHttpReq.readyState == 4)
		  {
           // updatepage(self.xmlHttpReq.responseText);
          }
      }
    self.xmlHttpReq.send(getquerystring());
  }
  
function xmlhttpLoadForm(strURL,div)
{
	var xmlHttpReq = false;

	// Mozilla/Safari
	if (window.XMLHttpRequest)
	  {
	    xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
	    xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlHttpReq.open('POST', strURL, true);
	xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttpReq.onreadystatechange = function()
	{
	    if (xmlHttpReq.readyState == 4) {
			updatepage(xmlHttpReq.responseText,div);		    		
			
			if(typeof sIFR == "function") {	
				sIFR.replaceElement("TABLE.std_wnd TD.content H1", host+"/trebuchetms.swf", "#0484C1", named({sBgColor:"#FFFFFF",sWmode:"transparent"}));
				sIFR.replaceElement("TABLE.std_wnd TD.content H2", host+"/trebuchetms.swf", "#828073", named({sBgColor:"#FFFFFF",sWmode:"transparent"}));
				sIFR.replaceElement("TABLE.std_wnd TD.content H5", host+"/trebuchetms.swf", "#322D0F", named({sBgColor:"#FFFFFF",sWmode:"transparent"}));				
			}
		
	    }
	}	
	xmlHttpReq.send(getquerystring());
}  

function xmlhttpPostForm(url,parameters,div) {
	  
	  var xmlHttpReq = false;

	
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         xmlHttpReq = new XMLHttpRequest();
         if (xmlHttpReq.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            xmlHttpReq.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!xmlHttpReq) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
	
      xmlHttpReq.onreadystatechange = function()
		{
		    if (xmlHttpReq.readyState == 4) {
				updatepage(xmlHttpReq.responseText,div);		    		
				
				if(typeof sIFR == "function") {	
					sIFR.replaceElement("TABLE.std_wnd TD.content H1", host+"/trebuchetms.swf", "#0484C1", named({sBgColor:"#FFFFFF",sWmode:"transparent"}));			
					sIFR.replaceElement("TABLE.std_wnd TD.content H2", host+"/trebuchetms.swf", "#828073", named({sBgColor:"#FFFFFF",sWmode:"transparent"}));			
					sIFR.replaceElement("TABLE.std_wnd TD.content H5", host+"/trebuchetms.swf", "#322D0F", named({sBgColor:"#FFFFFF",sWmode:"transparent"}));					
				}
			
		    }
		};
      xmlHttpReq.open('POST', url, true);
      xmlHttpReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlHttpReq.setRequestHeader("Content-length", parameters.length);
      xmlHttpReq.setRequestHeader("Connection", "close");
      xmlHttpReq.send(parameters);

}


function xmlhttpPost(strURL,div)
  {
    var xmlHttpReq = false;
    
    // Mozilla/Safari
    if (window.XMLHttpRequest)
	  {
        xmlHttpReq = new XMLHttpRequest();
      }
    // IE
    else if (window.ActiveXObject)
	  {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
      }
    
	xmlHttpReq.open('POST', strURL, true);
    xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xmlHttpReq.onreadystatechange = function()
	  {
        if (xmlHttpReq.readyState == 4)
	      {
            	updatepage(xmlHttpReq.responseText,div);			    
            	can_add=1;
		  }
      }
    xmlHttpReq.send(getquerystring());
  }
  

function xmlhttpPost2(strURL)
  {
    var xmlHttpReq = false;
    var self = this;
        
    // Mozilla/Safari
    if (window.XMLHttpRequest)
	  {
        self.xmlHttpReq = new XMLHttpRequest();
      }
    // IE
    else if (window.ActiveXObject)
	  {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
      }
    
	self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function()
	  {
        if (self.xmlHttpReq.readyState == 4)
	      {
		  	  ;
		  }
      }
    self.xmlHttpReq.send(getquerystring());
  }


function getquerystring()
  {
  }

function updatepage(str,div)
  {								
  	if (document.getElementById(div))
   		document.getElementById(div).innerHTML = str;
  }

/*ajax*/

