
function SendCartRequest(url)
{
	// Ajax + JSON
	req = FactoryXMLHttpRequest();
	req.open("GET", url, true);
	 
	if (true) {
		req.onreadystatechange = function() {
		  if(req.readyState == 4 && req.status == 200) {
			var response = null;
			alert(req.responseText);			
		  }
		}
	}
	
	req.send("");
}

function AddProduct(product_name, product_desc, product_price)
{
	SendCartRequest(document.getElementById('web_server_tak').value + "/seller/add/" + product_id);

}


function DeleteProduct(product_id, member_id)
{
	alert("test" + product_id);
	SendCartRequest(document.getElementById('web_server_tak').value + "/seller/Delete/" + product_id);
}

function EditProduct(product_id, member_id)
{

}

function ListAllProduct(member_id)
{

}

function DivControlOff()
{
	document.getElementById("sellDiv").style.display = "none";
}

function DivControlOn()
{
	document.getElementById("sellDiv").style.display = "inline";
	
}

function LoadValueToDivControl(id)
{
	DivControlOn();
	document.getElementById("div_name_txt").value = document.getElementById("div_static_product_name_"+id).innerHTML;
	document.getElementById("div_desc_txt").value = document.getElementById("div_static_product_desc_"+id).innerHTML;
	document.getElementById("div_price_txt").value = document.getElementById("div_static_product_const_"+id).innerHTML;
	
}


function ajax_upload() {
	// request more permissions
	try {
		netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
	} catch (e) {
		alert("Permission to read file was denied.");
	}

	http_request = false;
	http_request = new XMLHttpRequest();
	if (!http_request) {
		alert('Cannot create XMLHTTP instance');
		return false;
	}

	// prepare the MIME POST data
	var boundaryString = 'capitano';
	var boundary = '--' + boundaryString;
	var requestbody = boundary + '\n' 
	+ 'Content-Disposition: form-data; name="mytext"' + '\n' 
	+ '\n' 
	+ mytext + '\n' 
	+ '\n' 
	+ boundary + '\n' 
	+ 'Content-Disposition: form-data; name="myfile"; filename="' 
		+ filename + '"' + '\n' 
	+ 'Content-Type: application/octet-stream' + '\n' 
	+ '\n'
	+ escape(binary.readBytes(binary.available()))
	+ '\n'
	+ boundary;

	document.getElementById('sizespan').innerHTML = 
		"requestbody.length=" + requestbody.length;
	
	// do the AJAX request
	http_request.onreadystatechange = requestdone;
	http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-type", "multipart/form-data; \
		boundary=\"" + boundaryString + "\"");
	http_request.setRequestHeader("Connection", "close");
	http_request.setRequestHeader("Content-length", requestbody.length);
	http_request.send(requestbody);

}

function startUpload()
{    
	document.getElementById('f1_upload_process').style.visibility = 'visible';   
	return true;
	
}

function stopUpload(success)
{      
	var result = '';      
	if (success == 1)
	{        
		document.getElementById('result').innerHTML =     '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';     
	}      
	else 
	{         
		document.getElementById('result').innerHTML =            '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';     
	}     
	document.getElementById('f1_upload_process').style.visibility = 'hidden';     
	return true;   
}