var url = './ajax/ajax.php?';
function getXMLHttp()
{
  var xmlHttp
 
  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  return xmlHttp;
}
/*
$(document).ready(function() {
$('#submit').click(function () {
var name = $('.uname').val();
var data = 'uname=' + name;
$.ajax({
type:"POST",0921251372
url:"welcome.php",
data: data,
success: function (html) {
$('#message').html(html);
}
});
return false;opcs_entry_item_Aprons.php gradebox() SubmitPrice SubmitGrade
});SubmitPrice  ProfileForm showbeltcategory
});
insert into `beltPrice` set pricemcm = 'hgff'  showPrice();

function showPrice(){
$('#PriceForm').css({visibility: "visible", display: "block"});
$('#showPriceList').css({visibility: "visible", display: "block"});
$('#PriceForm').css({visibility: "hidden", display: "none"});
$('#GradeForm').css({visibility: "hidden", display: "none"});
$('#showbeltcategory').css({visibility: "hidden", display: "none"});DelProfile showProfile ApronFormType ApronFormTyp AppronRangeForm ApronGradebox DelApronGrade
SubmitApronPriceFix DelApronPrice SubmitApronPriceRange Rangepriceps CotsGradebox SubmitCotsGrade DelCotsGrade DelCotPrice timbeltGradebox showtimbeltGradeName SubmittimbeltPrice
}
*/

function submitform(btn_value)
{
var Select = document.getElementById('select').value;
//alert(Select);
var date = document.getElementById('date').value;
var client = document.getElementById('client').value;
var Principal = document.getElementById('Principal').value;
var o_order = document.getElementById('o_order').value;
var dt = document.getElementById('dt').value;
var pkgalw = document.getElementById('pkgalw').value;
var pkgperc = document.getElementById('pkgperc').value;
var url="opcs_submit_order.php";
url=url+"?Select="+Select+"&date="+date+"&client="+client+"&Principal="+Principal+"&o_order="+o_order+"&dt="+dt+"&pkgalw="+pkgalw+"&pkgperc="+pkgperc;
if(Select == '1')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('shape').value == '')
	{
		alert("Shape Can Not Be Empty");
	    return false;
	}
	if(document.getElementById('flange').value == '')
	{
		alert("Flange Can Not Be Empty");
		return false;
	}
	if(document.getElementById('wire').value == '')
	{
		alert("Wire Can Not Be Empty");
		return false;
	}
	if(document.getElementById('finish').value == '')
	{
		alert("Finish Can Not Be Empty");
		return false;
	}
	if(document.getElementById('number').value == '')
	{
		alert("Number Can Not Be Empty");
		return false;
	}
	if(document.getElementById('numbermili').value == '')
	{
		alert("Number Can Not Be Empty");
		return false;
	}

var shape = document.getElementById('shape').value;
var flange = document.getElementById('flange').value;
var wire = document.getElementById('wire').value;
var finish = document.getElementById('finish').value;
var number = document.getElementById('number').value;
var numbermili = document.getElementById('numbermili').value;
url=url+"&shape="+shape+"&flange="+flange+"&wire="+wire+"&finish="+finish+"&number="+number+"&numbermili="+numbermili;
}
if(Select == '2')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('quality').value == '')
	{
		alert("Quality Can Not Be Empty");
	    return false;
	}
	if(document.getElementById('brd').value == '')
	{
		alert("BRD Can Not Be Empty");
		return false;
	}
	if(document.getElementById('fod').value == '')
	{
		alert("FOD Can Not Be Empty");
		return false;
	}
	if(document.getElementById('wid').value == '')
	{
		alert("Width Can Not Be Empty");
		return false;
	}
	if(document.getElementById('core').value == '')
	{
		alert("Core Can Not Be Empty");
		return false;
	}
	if(document.getElementById('eg').value == '')
	{
		alert("Eg Can Not Be Empty");
		return false;
	}
	if(document.getElementById('spec').value == '')
	{
		alert("Spec Can Not Be Empty");
		return false;
	}
var quality = document.getElementById('quality').value;
var brd = document.getElementById('brd').value;
var fod = document.getElementById('fod').value;
var wid = document.getElementById('wid').value;
var core = document.getElementById('core').value;
var eg = document.getElementById('eg').value;
var spec = document.getElementById('spec').value;

url=url+"&quality="+quality+"&brd="+brd+"&fod="+fod+"&wid="+wid+"&core="+core+"&eg="+eg+"&spec="+spec;
}
if(Select == '3')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('quality').value == '')
	{
		alert("Quality Can Not Be Empty");
	    return false;
	}
	if(document.getElementById('id').value == '')
	{
		alert("ID Can Not Be Empty");
		return false;
	}
	if(document.getElementById('width').value == '')
	{
		alert("Width Can Not Be Empty");
		return false;
	}
	if(document.getElementById('thick').value == '')
	{
		alert("Thick Can Not Be Empty");
		return false;
	}
	if(document.getElementById('spec').value == '')
	{
		alert("Spec Can Not Be Empty");
		return false;
	}
	
var quality = document.getElementById('quality').value;
var id = document.getElementById('id').value;
var width = document.getElementById('width').value;
var thick = document.getElementById('thick').value;
var spec = document.getElementById('spec').value;
url=url+"&quality="+quality+"&id="+id+"&width="+width+"&thick="+thick+"&spec="+spec;
}
if(Select == '4')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('quality').value == '')
	{
		alert("Quality Can Not Be Empty");
	    return false;
	}
	if(document.getElementById('length').value == '')
	{
		alert("Length Can Not Be Empty");
		return false;
	}
	if(document.getElementById('width').value == '')
	{
		alert("Width Can Not Be Empty");
		return false;
	}
	if(document.getElementById('spec').value == '')
	{
		alert("Spec Can Not Be Empty");
		return false;
	}
var quality = document.getElementById('quality').value;
var length = document.getElementById('length').value;
var width = document.getElementById('width').value;
var spec = document.getElementById('spec').value;
url=url+"&quality="+quality+"&length="+length+"&width="+width+"&spec="+spec;
}
if(Select == '5')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('quality').value == '')
	{
		alert("Quality Can Not Be Empty");
	    return false;
	}
	if(document.getElementById('length').value == '')
	{
		alert("Length Can Not Be Empty");
		return false;
	}
	if(document.getElementById('width').value == '')
	{
		alert("Width Can Not Be Empty");
		return false;
	}
	if(document.getElementById('mm').value == '')
	{
		alert("Width Can Not Be Empty");
		return false;
	}
	if(document.getElementById('spec').value == '')
	{
		alert("Spec Can Not Be Empty");
		return false;
	}
	
var quality = document.getElementById('quality').value;
var length = document.getElementById('length').value;
var width = document.getElementById('width').value;
var mm = document.getElementById('mm').value;
var spec = document.getElementById('spec').value;
url=url+"&quality="+quality+"&length="+length+"&width="+width+"&mm="+mm+"&spec="+spec;
}
if(Select == '6')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('miscellenous').value == '')
	{
		alert("Miscellenous Can Not Be Empty");
	    return false;
	}
	
var miscellenous = document.getElementById('miscellenous').value;
url=url+"&miscellenous="+miscellenous;
}
if(Select == '7')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('flange').value == '')
	{
		alert("Flange Can Not Be Empty");
	    return false;
	}
	if(document.getElementById('series').value == '')
	{
		alert("Series Can Not Be Empty");
		return false;
	}
	if(document.getElementById('type').value == '')
	{
		alert("Type Can Not Be Empty");
		return false;
	}
	if(document.getElementById('hf').value == '')
	{
		alert("hf Can Not Be Empty");
		return false;
	}
	if(document.getElementById('number').value == '')
	{
		alert("Number Can Not Be Empty");
		return false;
	}
	if(document.getElementById('textfield').value == '')
	{
		alert("Number Can Not Be Empty");
		return false;
	}
var flange = document.getElementById('flange').value;
var series = document.getElementById('series').value;
var type = document.getElementById('type').value;
var hf = document.getElementById('hf').value;
var number = document.getElementById('number').value;
var textfield = document.getElementById('textfield').value;
url=url+"&flange="+flange+"&series="+series+"&type="+type+"&hf="+hf+"&number="+number+"&textfield="+textfield;
}
if(Select == '8')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('shape').value == '')
	{
		alert("Shape Can Not Be Empty");
	    return false;
	}
	if(document.getElementById('flange').value == '')
	{
		alert("Flange Can Not Be Empty");
		return false;
	}
	if(document.getElementById('wire').value == '')
	{
		alert("Wire Can Not Be Empty");
		return false;
	}
	if(document.getElementById('finish').value == '')
	{
		alert("Finish Can Not Be Empty");
		return false;
	}
	if(document.getElementById('number').value == '')
	{
		alert("Number Can Not Be Empty");
		return false;
	}
	if(document.getElementById('textfield').value == '')
	{
		alert("Number Can Not Be Empty");
		return false;
	}
var shape = document.getElementById('shape').value;
var flange = document.getElementById('flange').value;
var wire = document.getElementById('wire').value;
var finish = document.getElementById('finish').value;
var number = document.getElementById('number').value;
var textfield = document.getElementById('textfield').value;
url=url+"&shape="+shape+"&flange="+flange+"&wire="+wire+"&finish="+finish+"&number="+number+"&textfield="+textfield;
}
if(Select == '9')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('toproller').value == '')
	{
		alert("Top Roller Can Not Be Empty");
	    return false;
	}
	if(document.getElementById('flange').value == '')
	{
		alert("Unit Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dicount').value == '')
	{
		alert("Discount(%) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('qty').value == '')
	{
		alert("Qty. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('rate').value == '')
	{
		alert("Rate Can Not Be Empty");
		return false;
	}
	if(document.getElementById('textfield').value == '')
	{
		alert("Rate Can Not Be Empty");
		return false;
	}
var toproller = document.getElementById('toproller').value;
var flange = document.getElementById('flange').value;
var dicount = document.getElementById('dicount').value;
var qty = document.getElementById('qty').value;
var rate = document.getElementById('rate').value;
var textfield = document.getElementById('textfield').value;
url=url+"&toproller="+toproller+"&flange="+flange+"&dicount="+dicount+"&qty="+qty+"&rate="+rate+"&textfield="+textfield;
}
if(Select == '10')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('shape').value == '')
	{
		alert("Type Can Not Be Empty");
	    return false;
	}
	if(document.getElementById('flange').value == '')
	{
		alert("Len Can Not Be Empty");
		return false;
	}
	if(document.getElementById('wire').value == '')
	{
		alert("Width Can Not Be Empty");
		return false;
	}
	if(document.getElementById('finish').value == '')
	{
		alert("ToT Can Not Be Empty");
		return false;
	}
	if(document.getElementById('number').value == '')
	{
		alert("Make Can Not Be Empty");
		return false;
	}
var shape = document.getElementById('shape').value;
var flange = document.getElementById('flange').value;
var wire = document.getElementById('wire').value;
var finish = document.getElementById('finish').value;
var number = document.getElementById('number').value;

url=url+"&shape="+shape+"&flange="+flange+"&wire="+wire+"&finish="+finish+"&number="+number;
}
if(Select == '11')
{
	if(document.getElementById('date').value == '')
	{
	alert("Entry Date Can Not Be Empty");	
	return false;
	}
	if(document.getElementById('client').value == '')
	{
		alert("Client Can Not Be Empty");
		return false;
	}
	if(document.getElementById('Principal').value == '')
	{
		alert("Principal Can Not Be Empty");
		return false;
	}
	if(document.getElementById('o_order').value == '')
	{
		alert("Order No. Can Not Be Empty");
		return false;
	}
	if(document.getElementById('dt').value == '')
	{
		alert("Order Date Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgalw').value == '')
	{
		alert("Pkg - alwd Can Not Be Empty");
		return false;
	}
	if(document.getElementById('pkgperc').value == '')
	{
		alert("Pkg - (%age) Can Not Be Empty");
		return false;
	}
	if(document.getElementById('variatorbelt').value == '')
	{
		alert("Variator Belt Can Not Be Empty");
	    return false;
	}
	
var variatorbelt = document.getElementById('variatorbelt').value;
url=url+"&variatorbelt="+variatorbelt;
}
var xmlHttp = getXMLHttp();
xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText);
    }
  }
  xmlHttp.open("GET", url, true);
  xmlHttp.send(null);

}
function HandleResponse(response)
{
  document.getElementById('ResponseDiv').innerHTML = response;
  //document.getElementById('qimage').innerHTML = response;
}
function delete_order()
{
alert("Searching Record...");

var entry_date = document.getElementById('date2').value;
var client = document.getElementById('client').value;
var odr = document.getElementById('odr').value;
var date = document.getElementById('date').value;
var xmlHttp = getXMLHttp();

xmlHttp.onreadystatechange = function()
  {
//alert(xmlHttp.readyState);
if(xmlHttp.readyState == 4)
    {
      HandleResponse_delete(xmlHttp.responseText);
    }
  }
var url="opcs_entry_order_delete_action.php";
url=url+"?i="+entry_date+"&j="+client+"&k="+odr+"&l="+date;
  xmlHttp.open("GET", url, true);
  xmlHttp.send(null);	
  //alert(url);
}
function HandleResponse_delete(response)
{
//alert("del_odr");
document.getElementById('del_odr').innerHTML = response;
}
function showtimbeltPrice(){
	var showtimbeltGrade = $('#showtimbeltGrade').val();
	$.ajax({
		type: "POST",
		data: {
			action: "ShowtimbeltPrice",
			showtimbeltGrade: showtimbeltGrade,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showtimbeltPriceList').html(data);				
}
});
}
function DeltimbeltPrice(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Price List??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DeltimbeltPrice",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Price List Deleted");	
		showtimbeltPrice();				
}
	});
	}else
 {
  return false;
  }
}
function SubmittimbeltPrice(){
	//var tapecate = $('#tapecate').val(); spec
	var showtimbeltGrade = $('#showtimbeltGrade').val();
	var size = $('#size').val();
	var per = $('#per').val();
	var price = $('#price').val();
	var spec = $('#spec').val();
	var showtimbeltGrade_length = $("#showtimbeltGrade").val().length;
	var size_length = $("#size").val().length;
	var per_length = $("#per").val().length;
	var price_length = $("#price").val().length;
	var spec_length = $("#spec").val().length;
	if (showtimbeltGrade_length >= 1 && size_length >= 1 && per_length >= 1 && price_length >= 1 && spec_length >= 1){
	$.ajax({
		type: "POST",
		data: {
			action: "inserttimbeltPrice",
			showtimbeltGrade: showtimbeltGrade,
			size: size,
			per: per,
			price: price,
			spec: spec,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#size').val("");
		$('#per').val("");
		$('#price').val("");
		$('#spec').val("");
		//$('#showtimbeltGrade').val("");
		showTapePrice();		
}
});
}else{
alert("fields can't be left blank");	
}
}
function timbeltPricebox(){
	//var tapecate = $('#tapecate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showtimbeltGrade",
			//tapecate: tapecate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#timbeltGradePriceForm').css({visibility: "visible", display: "block"});
		$('#timbeltGradeForm').css({visibility: "hidden", display: "none"});
		//$('#showtimbeltPriceList').css({visibility: "hidden", display: "none"});
		$('#showtimbeltGradeName').html(data);	
}
	});
}

function DeltimbeltGrade(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Grade??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DeltimbeltGrade",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Grade Deleted");	
		showtimbeltGrade();				
}
	});
	}else
 {
  return false;
  }
}


function showtimbeltGrade(){
	//var tapecate = $('#tapecate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showtimbeltGradeList",
			//tapecate: tapecate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showtimbeltGradeList').html(data);				
}
	});
}


function SubmittimbeltGrade(){
	//var tapecate = $('#tapecate').val();
	var timbeltgradename = $('#timbeltgradename').val();
	var timbeltgradename_length = $("#timbeltgradename").val().length; 
    if (timbeltgradename_length >= 1){ 
	$.ajax({
		type: "POST",
		data: {
			action: "inserttimbeltGrade",
			//tapecate: tapecate,
			timbeltgradename: timbeltgradename,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#timbeltgradename').val("");
		showtimbeltGrade();
		
}
	});
	
}else{
alert("fields can't be left blank");	
}

}


function timbeltGradebox(){
$('#timbeltGradeForm').css({visibility: "visible", display: "block"});
$('#timbeltGradePriceForm').css({visibility: "hidden", display: "none"});
//$('#showbeltcategory').css({visibility: "visible", display: "block"});
}


function showGrade(){
	var beltcate = $('#beltcate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "ShowGradeList",
			beltcate: beltcate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showGradeList').html(data);				
}
	});
}


function DelGrade(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Grade??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelGrade",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Grade Deleted");	
		showGrade();				
}
	});
	}else
 {
  return false;
  }
}


function DelCotPrice(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Price List??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelCotPrice",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Price List Deleted");
		showCotPrice();
				
}
	});
	}else
 {
  return false;
  }
}

function showCotPrice(){
	$.ajax({
		type: "POST",
		data: {
			action: "ShowCotPrice",
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showCotPriceList').html(data);				
}
	});
}



function SubmitCotPrice(){
	var cotBRD = $('#cotBRD').val();
	var cotFOD = $('#cotFOD').val();
	var cotWidth = $('#cotWidth').val();
	var cotPlain = $('#cotPlain').val();
	var cotPVC = $('#cotPVC').val();
	var cotALUCORE = $('#cotALUCORE').val();
	var cotBRD_length = $("#cotBRD").val().length;
	var cotFOD_length = $("#cotFOD").val().length;
	var cotWidth_length = $("#cotWidth").val().length;
	var cotPVC_length = $("#cotPVC").val().length;
	var cotALUCORE_length = $("#cotALUCORE").val().length;
	var cotPlain_length = $("#cotPlain").val().length;
	if (cotBRD_length >= 1 && cotFOD_length >= 1 && cotWidth_length >= 1 && cotPVC_length >= 1 && cotALUCORE_length >= 1 && cotPlain_length >= 1){
	$.ajax({
		type: "POST",
		data: {
			action: "insertCotPrice",
			cotBRD: cotBRD,
			cotFOD: cotFOD,
			cotWidth: cotWidth,
			cotPlain: cotPlain,
			cotPVC: cotPVC,
			cotALUCORE: cotALUCORE,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#cotBRD').val("");
		$('#cotFOD').val("");
		$('#cotWidth').val("");
		$('#cotPlain').val("");
		$('#cotPVC').val("");
		$('#cotALUCORE').val("");
		showCotPrice();
		
}
	});
}else{
alert("fields can't be left blank");	
}
	
}




function CotsPricebox(){
	var tapecate = $('#tapecate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showTapeGrade",
			tapecate: tapecate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#cotsGradePriceForm').css({visibility: "visible", display: "block"});
		$('#CotsGradeForm').css({visibility: "hidden", display: "none"});
		//$('#showtapecategory').css({visibility: "visible", display: "block"});
		//$('#showTapeGradeName').html(data);
		
		
}
	});
}


function DelCotsGrade(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Grade??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelCotsGrade",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Grade Deleted");	
		showCotsGrade();				
}
	});
	}else
 {
  return false;
  }
}



function showCotsGrade(){
	//var tapecate = $('#tapecate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showcotsGradeList",
			//tapecate: tapecate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showcotsGradeList').html(data);
		
}
	});
}



function SubmitCotsGrade(){
	//var tapecate = $('#tapecate').val();
	var cotsgradename = $('#cotsgradename').val();
	var cotsgradename_length = $("#cotsgradename").val().length; 
    if (cotsgradename_length >= 1){ 
	$.ajax({
		type: "POST",
		data: {
			action: "insertCotsGrade",
			//tapecate: tapecate,
			cotsgradename: cotsgradename,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#cotsgradename').val("");
		showCotsGrade();
		
}
	});
	
}else{
alert("fields can't be left blank");	
}

}

function CotsGradebox(){
$('#CotsGradeForm').css({visibility: "visible", display: "block"});
$('#cotsGradePriceForm').css({visibility: "hidden", display: "none"});
//$('#AppronFixForm').css({visibility: "hidden", display: "none"});
//$('#AppronRangeForm').css({visibility: "hidden", display: "none"});
//$('#ApronFormTyp').css({visibility: "hidden", display: "none"});
//$('#showApronPriceListRange').css({visibility: "hidden", display: "none"});
//$('#showApronPriceListFix').css({visibility: "hidden", display: "none"});
}


function showApronPriceRange(){
	var ApronFormTy = $('#ApronFormTy').val();
	$.ajax({
		type: "POST",
		data: {
			action: "ShowApronPriceRange",
			ApronFormTy: ApronFormTy,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showApronPriceListRange').html(data);				
}
	});
}




function SubmitApronPriceRange(){
	var ApronFormTy = $('#ApronFormTy').val();
	var interDiaFrom = $('#interDiaFrom').val();
	var interDiaTO = $('#interDiaTO').val();
	var WidthFrom = $('#WidthFrom').val();
	var WidthTo = $('#WidthTo').val();
	var Rangepriceps = $('#Rangepriceps').val();
	var ApronFormTy_length = $("#ApronFormTy").val().length;
	var interDiaFrom_length = $("#interDiaFrom").val().length;
	var interDiaTO_length = $("#interDiaTO").val().length;
	var WidthFrom_length = $("#WidthFrom").val().length;
	var WidthTo_length = $("#WidthTo").val().length;
	var Rangepriceps_length = $("#Rangepriceps").val().length;
	if (ApronFormTy_length >= 1 && interDiaFrom_length >= 1 && interDiaTO_length >= 1 && WidthFrom_length >= 1 && WidthTo_length >= 1 && Rangepriceps_length >= 1){
	$.ajax({
		type: "POST",
		data: {
			action: "insertApronPriceRange",
			ApronFormTy: ApronFormTy,
			interDiaFrom: interDiaFrom,
			interDiaTO: interDiaTO,
			WidthFrom: WidthFrom,
			WidthTo: WidthTo,
			Rangepriceps: Rangepriceps,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#ApronFormTy').val("Range");
		$('#interDiaFrom').val("");
		$('#interDiaTO').val("");
		$('#WidthFrom').val("");
		$('#WidthTo').val("");
		$('#Rangepriceps').val("");
		showApronPriceRange();
		
}
	});
}else{
alert("fields can't be left blank");	
}
	
}

function DelApronPrice(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Price List??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelApronPrice",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Price List Deleted");
		if($('#ApronFormTy').val() == "Fixed"){
		showApronPriceFix();
		}
		if($('#ApronFormTy').val() == "Range"){
		showApronPriceRange();
		}
		
}
	});
	}else
 {
  return false;
  }
}




function showApronPriceFix(){
	var ApronFormTy = $('#ApronFormTy').val();
	$.ajax({
		type: "POST",
		data: {
			action: "ShowApronPriceFix",
			ApronFormTy: ApronFormTy,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showApronPriceListFix').html(data);				
}
	});
}

function SubmitApronPriceFix(){
	var ApronFormTy = $('#ApronFormTy').val();
	var apronID = $('#apronID').val();
	var apronWidth = $('#apronWidth').val();
	var apronThick = $('#apronThick').val();
	var Fixpriceps = $('#Fixpriceps').val();
	var ApronFormTy_length = $("#ApronFormTy").val().length;
	var apronID_length = $("#apronID").val().length;
	var apronWidth_length = $("#apronWidth").val().length;
	var apronThick_length = $("#apronThick").val().length;
	var Fixpriceps_length = $("#Fixpriceps").val().length;
	if (ApronFormTy_length >= 1 && apronID_length >= 1 && apronWidth_length >= 1 && apronThick_length >= 1 && Fixpriceps_length >= 1){
	$.ajax({
		type: "POST",
		data: {
			action: "insertApronPriceFix",
			ApronFormTy: ApronFormTy,
			apronID: apronID,
			apronWidth: apronWidth,
			apronThick: apronThick,
			Fixpriceps: Fixpriceps,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#ApronFormTy').val("Fixed");
		$('#apronID').val("");
		$('#apronWidth').val("");
		$('#apronThick').val("");
		$('#Fixpriceps').val("");
		showApronPriceFix();
}
	});
}else{
alert("fields can't be left blank");	
}
	
}

function DelApronGrade(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Grade??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelApronGrade",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Grade Deleted");	
		showApronGrade();				
}
	});
	}else
 {
  return false;
  }
}

function showApronGrade(){
	//var tapecate = $('#tapecate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showapronGradeList",
			//tapecate: tapecate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showapronGradeList').html(data);				
}
	});
}

function SubmitApronGrade(){
	//var tapecate = $('#tapecate').val();
	var aprongradename = $('#aprongradename').val();
	var aprongradename_length = $("#aprongradename").val().length; 
    if (aprongradename_length >= 1){ 
	$.ajax({
		type: "POST",
		data: {
			action: "insertApronGrade",
			//tapecate: tapecate,
			aprongradename: aprongradename,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#aprongradename').val("");
		showApronGrade();
}
	});
	
}else{
alert("fields can't be left blank");	
}

}

function ApronFormType(){
	
	if($('#ApronFormTy').val() == "Fixed"){
	$('#AppronFixForm').css({visibility: "visible", display: "block"})
	$('#ApronGradeForm').css({visibility: "hidden", display: "none"});
	$('#AppronRangeForm').css({visibility: "hidden", display: "none"});
	$('#showApronPriceListRange').css({visibility: "hidden", display: "none"});
	$('#showApronPriceListFix').css({visibility: "visible", display: "block"});
	}
	
	if($('#ApronFormTy').val() == "Range"){
	$('#AppronRangeForm').css({visibility: "visible", display: "block"})
	$('#ApronGradeForm').css({visibility: "hidden", display: "none"});
	$('#AppronFixForm').css({visibility: "hidden", display: "none"});
	$('#showApronPriceListRange').css({visibility: "visible", display: "block"});
	$('#showApronPriceListFix').css({visibility: "hidden", display: "none"});
	}
}


function ApronGradebox(){
$('#ApronGradeForm').css({visibility: "visible", display: "block"});
$('#AppronFixForm').css({visibility: "hidden", display: "none"});
$('#AppronRangeForm').css({visibility: "hidden", display: "none"});
$('#ApronFormTyp').css({visibility: "hidden", display: "none"});
$('#showApronPriceListRange').css({visibility: "hidden", display: "none"});
$('#showApronPriceListFix').css({visibility: "hidden", display: "none"});
}

function ApronPricebox(){
		$('#ApronFormTyp').css({visibility: "visible", display: "block"});
		$('#ApronFormTy').val("Fixed");
		$('#AppronFixForm').css({visibility: "visible", display: "block"});
		$('#ApronGradeForm').css({visibility: "hidden", display: "none"});
		$('#AppronRangeForm').css({visibility: "hidden", display: "none"});
		$('#showApronPriceListFix').css({visibility: "visible", display: "block"});
}

function showChemicalPriceRange(){
	var ChemicalFormTy = $('#ChemicalFormTy').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showChemicalPriceRange",
			ChemicalFormTy: ChemicalFormTy,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showChemicalPriceListRange').html(data);				
}
	});
}


function SubmitChemicalPriceRange1(){
alert("fields can't be left blank");		
}

function SubmitChemicalPriceRange(){
	var ChemicalFormTy = $('#ChemicalFormTy').val();
	var interDiaFrom = $('#interDiaFrom').val();
	var interDiaTO = $('#interDiaTO').val();
	var WidthFrom = $('#WidthFrom').val();
	var WidthTo = $('#WidthTo').val();
	var Rangepriceps = $('#Rangepriceps').val();
	var ChemicalFormTy_length = $("#ChemicalFormTy").val().length;
	var interDiaFrom_length = $("#interDiaFrom").val().length;
	var interDiaTO_length = $("#interDiaTO").val().length;
	var WidthFrom_length = $("#WidthFrom").val().length;
	var WidthTo_length = $("#WidthTo").val().length;
	var Rangepriceps_length = $("#Rangepriceps").val().length;
	//alert("fields can't be left blank");
	if (ChemicalFormTy_length >= 1 && interDiaFrom_length >= 1 && interDiaTO_length >= 1 && WidthFrom_length >= 1 && WidthTo_length >= 1 && Rangepriceps_length >= 1){
	$.ajax({
		type: "POST",
		data: {
			action: "insertChemicalPriceRange",
			ChemicalFormTy: ChemicalFormTy,
			interDiaFrom: interDiaFrom,
			interDiaTO: interDiaTO,
			WidthFrom: WidthFrom,
			WidthTo: WidthTo,
			Rangepriceps: Rangepriceps,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#ChemicalFormTy').val("Range");
		$('#interDiaFrom').val("");
		$('#interDiaTO').val("");
		$('#WidthFrom').val("");
		$('#WidthTo').val("");
		$('#Rangepriceps').val("");
		showChemicalsPriceRange();
		
}
	});
}else{
alert("fields can't be left blank");	
}
	
}

function DelChemicalPrice(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Price List??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelChemicalPrice",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Price List Deleted");
		if($('#ChemicalFormTy').val() == "Fixed"){
		showChemicalPriceFix();
		}
		if($('#ChemicalFormTy').val() == "Range"){
		showChemicalPriceRange();
		}
		
}
	});
	}else
 {
  return false;
  }
}

function showChemicalPriceFix(){
	var ChemicalFormTy = $('#ChemicalFormTy').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showChemicalPriceFix",
			ChemicalFormTy: ChemicalFormTy,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showChemicalPriceListFix').html(data);				
}
	});
}


function SubmitChemicalPriceFix(){
	var ChemicalFormTy = $('#ChemicalFormTy').val();
	var ChemicalID = $('#ChemicalID').val();
	var ChemicalWidth = $('#ChemicalWidth').val();
	var ChemicalThick = $('#ChemicalThick').val();
	var Fixpriceps = $('#Fixpriceps').val();
	var ChemicalFormTy_length = $("#ChemicalFormTy").val().length;
	var ChemicalID_length = $("#ChemicalID").val().length;
	var ChemicalWidth_length = $("#ChemicalWidth").val().length;
	var ChemicalThick_length = $("#ChemicalThick").val().length;
	var Fixpriceps_length = $("#Fixpriceps").val().length;
	if (ChemicalFormTy_length >= 1 && ChemicalID_length >= 1 && ChemicalWidth_length >= 1 && ChemicalThick_length >= 1 && Fixpriceps_length >= 1){
	$.ajax({
		type: "POST",
		data: {
			action: "insertChemicalPriceFix",
			ChemicalFormTy: ChemicalFormTy,
			ChemicalID: ChemicalID,
			ChemicalWidth: ChemicalWidth,
			ChemicalThick: ChemicalThick,
			Fixpriceps: Fixpriceps,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#ChemicalFormTy').val("Fixed");
		$('#ChemicalID').val("");
		$('#ChemicalWidth').val("");
		$('#ChemicalThick').val("");
		$('#Fixpriceps').val("");
		showApronPriceFix();
		
}
	});
}else{
alert("fields can't be left blank");	
}
	
}

function DelChemicalGrade(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Grade??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelChemicalGrade",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Grade Deleted");	
		showChemicalGrade();				
}
	});
	}else
 {
  return false;
  }
}

function showChemicalGrade(){
	//var tapecate = $('#tapecate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showchemicalGradeList",
			//tapecate: tapecate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showchemicalGradeList').html(data);				
}
	});
}

function SubmitChemicalGrade(){
	alert(asdf);
	//var tapecate = $('#tapecate').val();
	var chemicalgradename = $('#chemicalgradename').val();
	var chemicalgradename = $("#chemicalgradename").val().length; 
    if (chemicalgradename_length >= 1){ 
	$.ajax({
		type: "POST",
		data: {
			action: "insertChemicalGrade",
			//tapecate: tapecate,
			chemicalgradename: chemicalgradename,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#chemicalgradename').val("");
		showChemicalGrade();
		
}
	});
	
}else{
alert("fields can't be left blank");	
}

}

function ChemicalFormType(){
	
	if($('#ChemicalFormTy').val() == "Fixed"){
	$('#ChemicalFixForm').css({visibility: "visible", display: "block"})
	$('#ChemicalGradeForm').css({visibility: "hidden", display: "none"});
	$('#ChemicalRangeForm').css({visibility: "hidden", display: "none"});
	$('#showChemicalPriceListRange').css({visibility: "hidden", display: "none"});
	$('#showChemicalPriceListFix').css({visibility: "visible", display: "block"});
	}
	
	if($('#ChemicalFormTy').val() == "Range"){
	$('#ChemicalRangeForm').css({visibility: "visible", display: "block"})
	$('#ChemicalGradeForm').css({visibility: "hidden", display: "none"});
	$('#ChemicalFixForm').css({visibility: "hidden", display: "none"});
	$('#showChemicalPriceListRange').css({visibility: "visible", display: "block"});
	$('#showChemicalPriceListFix').css({visibility: "hidden", display: "none"});
	}
}


function ChemicalGradebox(){
$('#ChemicalGradeForm').css({visibility: "visible", display: "block"});
$('#ChemicalFixForm').css({visibility: "hidden", display: "none"});
$('#ChemicalRangeForm').css({visibility: "hidden", display: "block"});
$('#ChemicalFormTyp').css({visibility: "hidden", display: "none"});
$('#showChemicalPriceListRange').css({visibility: "hidden", display: "none"});
$('#showChemicalPriceListFix').css({visibility: "hidden", display: "none"});
}

function ChemicalPricebox(){
		$('#ChemicalFormTyp').css({visibility: "visible", display: "block"});
		$('#ChemicalFormTy').val("Fixed");
		$('#ChemicalFixForm').css({visibility: "visible", display: "block"});
		$('#ChemicalGradeForm').css({visibility: "hidden", display: "none"});
		$('#ChemicalRangeForm').css({visibility: "hidden", display: "block"});
		$('#showChemicalPriceListFix').css({visibility: "visible", display: "block"});
}


function showTapePrice(){
	var tapecate = $('#tapecate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "ShowTapePrice",
			tapecate: tapecate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showTapePriceList').html(data);				
}
	});
}

function DelTapePrice(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Price List??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelTapePrice",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Price List Deleted");	
		showTapePrice();				
}
	});
	}else
 {
  return false;
  }
}

function SubmitTapePrice(){
	var tapecate = $('#tapecate').val();
	var showTapeGrade = $('#showTapeGrade').val();
	var pricemcm = $('#pricemcm').val();
	var joChLess = $('#joChLess').val();
	var joChgreater = $('#joChgreater').val();
	var showTapeGrade_length = $("#showTapeGrade").val().length;
	var pricemcm_length = $("#pricemcm").val().length;
	var joChLess_length = $("#joChLess").val().length;
	var joChgreater_length = $("#joChgreater").val().length;
	if (showTapeGrade_length >= 1 && pricemcm_length >= 1 && joChLess_length >= 1 && joChgreater_length >= 1){
	$.ajax({
		type: "POST",
		data: {
			action: "insertTapePrice",
			tapecate: tapecate,
			showTapeGrade: showTapeGrade,
			pricemcm: pricemcm,
			joChLess: joChLess,
			joChgreater: joChgreater,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#pricemcm').val("");
		$('#showTapeGrade').val("");
		showTapePrice();
		
}
	});
}else{
alert("fields can't be left blank");	
}
}


function tapePricebox(){
	var tapecate = $('#tapecate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showTapeGrade",
			tapecate: tapecate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#TapeGradePriceForm').css({visibility: "visible", display: "block"});
		$('#TapeGradeForm').css({visibility: "hidden", display: "none"});
		$('#showtapecategory').css({visibility: "visible", display: "block"});
		$('#showTapeGradeName').html(data);
		
		
}
	});
}

function DelTapeGrade(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Grade??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelTapeGrade",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Grade Deleted");	
		showTapeGrade();				
}
	});
	}else
 {
  return false;
  }
}



function showTapeGrade(){
	var tapecate = $('#tapecate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showtapeGradeList",
			tapecate: tapecate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showtapeGradeList').html(data);				
}
	});
}


function SubmitTapeGrade(){
	var tapecate = $('#tapecate').val();
	var tapegradename = $('#tapegradename').val();
	var tapegradename_length = $("#tapegradename").val().length; 
    if (tapegradename_length >= 1){ 
	$.ajax({
		type: "POST",
		data: {
			action: "insertTapeGrade",
			tapecate: tapecate,
			tapegradename: tapegradename,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#tapegradename').val("");
		showTapeGrade();
		
}
	});
	
}else{
alert("fields can't be left blank");	
}

}


function tapeGradebox(){
$('#TapeGradeForm').css({visibility: "visible", display: "block"});
$('#TapeGradePriceForm').css({visibility: "hidden", display: "none"});
$('#showbeltcategory').css({visibility: "visible", display: "block"});
}


function showGrade(){
	var beltcate = $('#beltcate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "ShowGradeList",
			beltcate: beltcate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showGradeList').html(data);				
}
	});
}


function DelGrade(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Grade??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelGrade",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Grade Deleted");	
		showGrade();				
}
	});
	}else
 {
  return false;
  }
}

function showProfile(){
	var profileCate = $('#profileCate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "ShowProfile",
			profileCate: profileCate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showProfileList').html(data);				
}
	});
}


function DelProfile(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Profile??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelProfile",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Profile Deleted");	
		showProfile();				
}
	});
	}else
 {
  return false;
  }
}


function showPrice(){
	var beltcate = $('#beltcate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "ShowPrice",
			beltcate: beltcate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#showPriceList').html(data);				
}
	});
}

function DelPrice(obj){
	var id = obj;
	var where_to= confirm("Do you really want to delete Price List??");
	if (where_to== true){
	$.ajax({
		type: "POST",
		data: {
			action: "DelPrice",
			id: id,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert("Price List Deleted");	
		showPrice();				
}
	});
	}else
 {
  return false;
  }
}

function SubmitProfile(){
	var profileCate = $('#profileCate').val();
	var subProType = $('#subProType').val();
	var profilePrice = $('#profilePrice').val();
	var profileCate_length = $("#profileCate").val().length;
	var subProType_length = $("#subProType").val().length;
	var profilePrice_length = $("#profilePrice").val().length;
	if (profileCate_length >= 1 && subProType_length >= 1 && profilePrice_length >= 1){
	
	$.ajax({
		type: "POST",
		data: {
			action: "insertProfile",
			profileCate: profileCate,
			subProType: subProType,
			profilePrice: profilePrice,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		//$('#profileCate').val("");
		$('#subProType').val("");	
		$('#profilePrice').val("");
		showProfile();
				
}
	});
}else{
alert("fields can't be left blank");	
}	
}

function profilebox(){
$('#ProfileForm').css({visibility: "visible", display: "block"});
$('#PriceForm').css({visibility: "hidden", display: "none"});
$('#GradeForm').css({visibility: "hidden", display: "none"});
$('#showbeltcategory').css({visibility: "hidden", display: "none"});
}


function SubmitPrice(){
	var beltcate = $('#beltcate').val();
	var showBeltGrade = $('#showBeltGrade').val();
	var pricemcm = $('#pricemcm').val();
	var joChLess = $('#joChLess').val();
	var joChgreater = $('#joChgreater').val();
	var showBeltGrade_length = $("#showBeltGrade").val().length;
	var pricemcm_length = $("#pricemcm").val().length;
	var joChLess_length = $("#joChLess").val().length;
	var joChgreater_length = $("#joChgreater").val().length;
	if (showBeltGrade_length >= 1 && pricemcm_length >= 1 && joChLess_length >= 1 && joChgreater_length >= 1){
	
	$.ajax({
		type: "POST",
		data: {
			action: "insertPrice",
			beltcate: beltcate,
			showBeltGrade: showBeltGrade,
			pricemcm: pricemcm,
			joChLess: joChLess,
			joChgreater: joChgreater,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#pricemcm').val("");
		$('#joChLess').val("");	
		$('#joChgreater').val("");
		$('#showBeltGrade').val("");
		showPrice();
		
}
	});
}else{
alert("fields can't be left blank");	
}
	
}





function SubmitGrade(){
	var beltcate = $('#beltcate').val();
	var gradename = $('#gradename').val();
	var gradename_length = $("#gradename").val().length; 
    if (gradename_length >= 1){ 
	$.ajax({
		type: "POST",
		data: {
			action: "insertGrade",
			beltcate: beltcate,
			gradename: gradename,
			time: Math.random()
		},
		url: url,
		success: function(data){
		alert(data);
		$('#gradename').val("");
		showGrade();
		
}
	});
	
}else{
alert("fields can't be left blank");	
}

}

function pricebox(){
	var beltcate = $('#beltcate').val();
	$.ajax({
		type: "POST",
		data: {
			action: "showGrade",
			beltcate: beltcate,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#PriceForm').css({visibility: "visible", display: "block"});
		$('#GradeForm').css({visibility: "hidden", display: "none"});
		$('#showbeltcategory').css({visibility: "visible", display: "block"});
		$('#ProfileForm').css({visibility: "hidden", display: "none"});
		$('#showGradeName').html(data);
		
		
}
	});
}


function gradebox(){
$('#GradeForm').css({visibility: "visible", display: "block"});
$('#PriceForm').css({visibility: "hidden", display: "none"});
$('#ProfileForm').css({visibility: "hidden", display: "none"});
$('#showbeltcategory').css({visibility: "visible", display: "block"});
}


function loadPagePrice(obj){
	
var myval = obj.value;
if(myval == "1"){
$('#indexcontent').load('opcs_entry_order_Bra_TRAV.php #content');
}
if(myval == "2"){
$('#indexcontent').load('opcs_entry_order_cots.php #content');
}
if(myval == "3"){
$('#indexcontent').load('opcs_entry_item_aprons.php #content');
}
if(myval == "4"){
$('#indexcontent').load('opcs_entry_item_tapes.php #content');
}
if(myval == "5"){
$('#indexcontent').load('opcs_entry_price_belts.php #content');
}
if(myval == "6"){
$('#indexcontent').load('opcs_entry_item_miscellenous.php #content');
}
if(myval == "7"){
$('#indexcontent').load('opcs_entry_item_kanaitrav.php #content');
}
if(myval == "8"){
$('#indexcontent').load('opcs_entry_item_traveller.php #content');
}
if(myval == "9"){
$('#indexcontent').load('opcs_entry_item_toproller.php #content');
}
if(myval == "10"){
$('#indexcontent').load('opcs_entry_item_timbelt1.php #content');
}
if(myval == "11"){
$('#indexcontent').load('opcs_entry_item_variatorbelt.php #content');
}
if(myval == "21"){
$('#indexcontent').load('opcs_entry_item_chemicals.php #content');
}
}


function loadPage(obj){
	
var myval = obj.value;
if(myval == "1"){
$('#indexcontent').load('opcs_entry_newItem_Bra_TRAV.php #content');
}
if(myval == "2"){
$('#indexcontent').load('opcs_entry_newItem_cots.php #content');
}
if(myval == "3"){
$('#indexcontent').load('opcs_entry_newItem_aprons.php #content');
}
if(myval == "4"){
$('#indexcontent').load('opcs_entry_newItem_tapes.php #content');
}
if(myval == "5"){
$('#indexcontent').load('opcs_entry_newItem_belts.php #content');
}
if(myval == "6"){
$('#indexcontent').load('opcs_entry_item_miscellenous.php #content');
}
if(myval == "7"){
$('#indexcontent').load('opcs_entry_item_kanaitrav.php #content');
}
if(myval == "8"){
$('#indexcontent').load('opcs_entry_item_traveller.php #content');
}
if(myval == "9"){
$('#indexcontent').load('opcs_entry_item_toproller.php #content');
}
if(myval == "10"){
$('#indexcontent').load('opcs_entry_item_timingbelts.php #content');
}
if(myval == "11"){
$('#indexcontent').load('opcs_entry_item_variatorbelt.php #content');
}
if(myval == "21"){
$('#indexcontent').load('opcs_entry_item_chemicals.php #content');
}
}


function packDiscount(){
	$('#pkgalwd').css({visibility: "visible"});
	$('#pkgper').css({visibility: "visible"});
}




function ViewClnt(Obj){
	//alert("Test");
	var clnt_code = Obj.value;
	//alert(+clnt_code);
	$.ajax({
		type: "POST",
		data: {
			action: "ViewClient",
			clnt_code: clnt_code,
			time: Math.random()
		},
		url: url,
		success: function(data){
		var	data1 = data.split("#");
		$('#clntName').html(data1[0]);
		if(undefined != data1[1]){
		var confirmData = "Payment Overdue, Accept Order?";
		}else{
		var confirmData = "";
		}
		if(!confirm(data1[1] +"\n"+ confirmData)){
		$('#clntName').html("");
		$('#client').val("");
		$('#Principal').val("");
		}else{
		if(clnt_code == "0000"){
		$('#Principal').val("");
		$('#co').css({visibility: "visible"});	
		}else{
		$('#Principal').val("0000");
		$('#co').css({visibility: "hidden"});
		}
		}
}
	});
}



function getMachineModle(Obj){
	var machVal = Obj.value;
	var clnt_code = $('#clnt_code').val();
	$.ajax({
		type: "POST",
		data: {
			action: "machine",
			machVal: machVal,
			clnt_code: clnt_code,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#Add').css({visibility: "visible"});
		$('#Delete').css({visibility: "hidden"});
		$('#Edit').css({visibility: "hidden"});
		$('#Select').css({visibility: "hidden"});
		$('#Save').css({visibility: "hidden"});
		$('#macharea').html(data);
}
	});
}


function modleMac(Obj){
	var machVal = $('input:radio[name=mactype]:checked').val();
	var modcode = Obj.value;
	var clnt_code = $('#clnt_code').val();
	$.ajax({
		type: "POST",
		data: {
			action: "model",
			modcode: modcode,
			machVal: machVal,
			clnt_code: clnt_code,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#Add').css({visibility: "visible"});
		$('#Delete').css({visibility: "visible"});
		$('#Edit').css({visibility: "visible"});
		$('#Select').css({visibility: "visible"});
		$('#Save').css({visibility: "visible"});
	var	data1 = data.split("#");
	$('#nom').val(data1[0]);
	$('#spmc').val(data1[1]);
	$('#LIFTGUAG').val(data1[2]);
	$('#DRAFTING').val(data1[3]);
	$('#DRVTYP').val(data1[4]);
	$('#RTS_MCN').val(data1[5]);
	$('#RTS_SEC').val(data1[6]);
	$('#DRM_MCN').val(data1[7]);
	$('#MOTORHP').val(data1[8]);
	$('#LENMON').val(data1[9]);
	$('#makmod').html(data1[10]);
	
	if(parseInt(data1[1]) > 0){
	$('#spmcdes').css({visibility: "visible"});	
	}else{
	$('#spmcdes').css({visibility: "hidden"});	  
	}
		
}
	});
}


function addMakeModel(Obj){
	var machVal = $('input:radio[name=mactype]:checked').val();
	var clnt_code = $('#clnt_code').val();
	$.ajax({
		type: "POST",
		data: {
			action: "addmachine",
			machVal: machVal,
			clnt_code: clnt_code,
			time: Math.random()
		},
		url: url,
		success: function(data){
		$('#makmod').css({visibility: "hidden"});
		$('#dropdownmak').html(data);
}
	});
}


function setImageRate(rateObj){
	var imageId = $('#hid_image_id').val();
	var rateVal = rateObj.value;
	$.ajax({
		type: "POST",
		data: {
			action: "imageRating",
			imageId: imageId,
			rateVal: rateVal,
			time: Math.random()
		},
		url: url,
		success: function(data){

					alert(data);
//					$('#div_login_error').html(data);
		}
	});
}

function login(){

	var sUsername = $('#txt_login_username').val();
	var sPass     = $('#txt_login_password').val();
	if(validateLoginForm()){
		$.ajax({
			type: "POST",
			data: {
				action: "login",
				username: sUsername,
				password: sPass,
				time: Math.random()
			},
			url: url,
			success: function(data){
					if(data == '1'){
						callApp(true);
						$('#div_login_popup_id').css({visibility: "hidden", display: "none"});;
						$('#hid_is_logged').val('1');
//						callApp(true);
					}else{
//						callApp(false);
						$('#div_login_error').html(data);
					}
			}
		});
	}
    return false;
}

function register(){
	var sUsername = $('#txt_register_username').val();
	var sPass     = $('#txt_register_password').val();
	var cPass     = $('#txt_register_cpassword').val();

	if(validateRegistrationForm()){

		$.ajax({
			type: "POST",
			data: {
				action: "register",
				username: sUsername,
				password: sPass,
				time: Math.random()
			},
			url: url,
			success: function(data){
					if(data == '1'){
						callApp(true);
						$('#div_login_popup_id').css({visibility: "hidden", display: "none"});;
						$('#hid_is_logged').val('1');
					}else{
						$('#div_register_error').html(data);
//						callApp(false);
					}
	//			$('#message_div').html('pramod');
			}
		});
	}
    return false;
}

function checkLogin(){
	$.ajax({
		type: "POST",
		data: {
			action: "isLogin",
			time: Math.random()
		},
		url: url,
		success: function(data){
				if(data == 1){
					isLogged = true;
				}else{
					isLogged = false;
				}
		}
	});

	return false;
}

function saveCustomerInfoAndGoReview(){

	if(validateCheckOutFormOnSubmit()){

		var shipFirstName		= $('#txt_ship_first_name').val();
		var shipLastName		= $('#txt_ship_last_name').val();
		var shipCompany			= $('#txt_ship_company').val();
		var shipAddress1		= $('#txt_ship_address1').val();
		var shipAddress2		= $('#txt_ship_address2').val();
		var shipCity			= $('#txt_ship_city').val();
		var shipCountry			= $('#txt_ship_country').val();
		var shipState			= $('#txt_ship_state').val();
		var shipZip				= $('#txt_ship_zip').val();
		var shipPhone			= $('#txt_ship_phone').val();
		var shipEmail			= $('#txt_ship_email').val();
		var billFirstName		= $('#txt_bill_first_name').val();
		var billLastName		= $('#txt_bill_last_name').val();
		var billCompany			= $('#txt_bill_company').val();
		var billAddress1		= $('#txt_bill_address1').val();
		var billAddress2		= $('#txt_bill_address2').val();
		var billCity			= $('#txt_bill_city').val();
		var billCountry			= $('#txt_bill_country').val();
		var billState			= $('#txt_bill_state').val();
		var billZip				= $('#txt_bill_zip').val();
		var billPhone			= $('#txt_bill_phone').val();
		var billEmail			= $('#txt_bill_email').val();
		//var shipBy				= $("input[name='rad_ship_by']:checked").val();
		var paymentMethod		= $("input[name='rad_payment_method']:checked").val();
		var comments			= $('#txt_comments').val();

		$.ajax({
			type: "POST",
			data: {
				action: "customerOrderInfo",
				shipFirstName: shipFirstName,
				shipLastName: shipLastName,
				shipCompany: shipCompany,
				shipAddress1: shipAddress1,
				shipAddress2: shipAddress2,
				shipCity: shipCity,
				shipCountry: shipCountry,
				shipState: shipState,
				shipZip: shipZip,
				shipPhone: shipPhone,
				shipEmail: shipEmail,
				billFirstName: billFirstName,
				billLastName: billLastName,
				billCompany: billCompany,
				billAddress1: billAddress1,
				billAddress2: billAddress2,
				billCity: billCity,
				billCountry: billCountry,
				billState: billState,
				billZip: billZip,
				billPhone: billPhone,
				billEmail: billEmail,
//				shipBy: shipBy,
				paymentMethod: paymentMethod,
				comments: comments,
				time: Math.random()
			},
			url: url,
			success: function(data){
				
				window.location="review.php";
				//alert(data);
			}
		});
	}
    return false;

}


function saveOrder(){
	if($('#hid_is_logged').val() == 'false'){
		showLoginDiv();
		return false;
	}

	$.ajax({
		type: "POST",
		data: {
			action: "saveOrder",
			time: Math.random()
		},
		url: url,
		success: function(data){
			window.location="thanks.php";
			//alert("Order has been saved");
		}
	});
    return false;

}



function checkoutTotalPreviewHtml(val){

	$.ajax({
		type: "POST",
		data: {
			action: "checkoutTotalPreview",
			shipCountry: val,
			time: Math.random()
		},
		url: url,
		success: function(data){
			$('#div_total_preview').html(data);
		}
	});
    return false;

}



function showLoginDiv(){
	$('#div_login_popup_id').css({visibility: "visible", display: "block"});
}

function hideLoginDiv(){
	$('#div_login_popup_id').css({visibility: "hidden", display: "none"});

}


// Internet Explorer and Mozilla-based browsers refer to the Flash application 
// object differently.
// This function returns the appropriate reference, depending on the browser.
function getMyApp(appName) {
   if (navigator.appName.indexOf ("Microsoft") !=-1) {
	   return window[appName];
   } else {
	   return document[appName];
   }
}

function callApp(flag) {
	flashObj = getMyApp("MemoOnline");
	if(flashObj){
		getMyApp("MemoOnline").callFromJS(flag);
	}
}

