$(document).ready(function() {
logEvent('M2', "[M2]"); // 20150903
$("#m2products").focusin(function() {
// console.log("MLFocus: firstsw:"+$('#firstsw').val());
if ($('#firstsw').val() == '')
$("#m2partslookup").submit();
// location.reload(true);
// location.reload();
});
}) // END ready function
function calcSize(curvalue, multiplier) {
var newsize = parseFloat( curvalue ) * multiplier;
return parseInt( newsize );
}
function dispProduct(vehid, prodtype, prodname) {
// if (prodname == "shackles") winhgt = 1200;
var dispprod = window.open("es-products.php?&selstockid="+vehid+
"&selprtypeid="+prodtype+"&View=V",'products'); // 20240419
// "&selprtypeid=" + prodtype + "&View=V", +
// "_blank", "status=0,location=0,height=1200"+
// ",width=1180,scrollbars=1,top=100"); // 20160210
if (window.focus) {dispprod.focus()}; // 20150202
return false;
} // END dispProduct detailed setup info
function dispImage(stockno, prodtype,fileextn,eatonno) {
var winhgt = 300;
var winwid = 470;
if (prodtype == "coil") {
winhgt = 300;
winwid = 450;
}
else
if (prodtype == "leaf") {
winhgt = 300;
winwid = 500;
}
else
if (prodtype == "shock") {
winhgt = 300;
winwid = 300;
}
else
if (prodtype == "ikit") {
winhgt = 400;
winwid = 400;
}
else
if (prodtype == "timbren") {
winhgt = 300;
winwid = 300;
}
var imgname = "pdf/" + prodtype + "/" + stockno + fileextn;
getImageAjax(imgname, stockno, eatonno);
return false;
} // END dispImage Product Image
function dispPDF(stockno, prodtype,fileextn) { // 20141016
winhgt = 1200;
if (prodtype == "shock") winhgt = 1000;
if (prodtype == "ikit") winhgt = 1000;
var disppdf = window.open("pdf/" + prodtype + "/" + stockno + fileextn, +
"pdfpopup","status=0,location=no,height="+winhgt+
",width=1100, top=10");
if (window.focus) {disppdf.focus()}; // 20150202
return false;
} // END dispPDF // 20141016
function getImageAjax(imgname,stockno,eatonno) {
$.ajax( { url : 'es-getimagesize.php',
type : 'POST',
data : {imgsrc: imgname
},
success : function(xhrdata, xhrstatus, xhr) {
// console.log ('R=' + xhrdata + ', S=' + xhrstatus);
if (xhrstatus == 'success') {
resps = xhrdata.split("|");
rinfo = resps[1];
rdata = rinfo.split("~");
if (resps[0] == 'NO') {
alert("The Image source was not passed. \n");
} // NF
else { // NOT NF - Found body
if (resps[0] == 'OK' || resps[0] == 'DF') {
imghgt = parseInt(rdata[0]);
imgwid = parseInt(rdata[1]);
if (imgwid > 0) {
winhgt=imghgt + 99;
winwid=imgwid + 40;
}
var winopts = 'status=0,location=0,menubar=0,'+
'titlebar=0,toolbar=0,top=400,left=10,'+
'width='+winwid+',height='+winhgt+"'";
// alert("Src:" + imgname + ", Opt:" + winopts);
var dspprod = window.open('', "imgwin", winopts);
setTimeout(function() {
dspprod.document.write('
'+
'
Stock No. '+stockno+'
'+
'
Eaton No. '+eatonno+'
'+
'
');
dspprod.document.title = 'Eaton Detroit Springs Product Image'},100);
if (window.focus) {dspprod.focus()}; // 20150202
} // OK or DF
else { // NOT OK
alert ("AJAX ERROR in es-getimagesize:" +
xhrdata);
} // NOT OK
} // NOT NF
return true;
} // xhrstatus = success
}, // success function
error : function(xhr, xhrstatus, xhrerror) {
alert('Get Image size for '+imgname+ ' FAILED!\n' +
'Status: ' + xhrstatus +
', ERROR: ' + xhrerror + '\n' +
'Please notify S.E.S @ 248-310-7400');
return false;
} // error on callback
}); // ajax function
} // END getImageAjax
function logEvent(evtype, searchfor) { // 20150903
var yearindex = 0;
var makeindex = 0;
var modelindex = 0;
var bodyindex = 0;
var engineindex = 0;
var vehid = 0;
var prods = searchfor; // 20150903
var sep = '=';
var email = '';
// alert("Ev=" + evtype + ", Br=" + brand);
$.ajax( { url : 'eventlogger.php',
type : 'POST',
data : {
year: yearindex,
mak: makeindex,
mod: modelindex,
bod: bodyindex,
eng: engineindex,
veh: vehid,
prd: prods,
eml: email,
typ: evtype
},
success : function(resp, stat, xhr) {
if (stat == "success") {
// alert("Ran eventtracker.php OK");
return true;
} // success
}, // success function
error : function(resp, stat, xhrerror) {
// alert("Running eventtracker.php FAILED\n" +
// 'Status: ' + stat +
// ', ERROR: ' + xhrerror+ '\n'
// );
return true;
} // ERROR function
}); // ajax function
} // END function logEvent // 20150903
function OpenOrderForm(fromonline,ordermode) {
var sproducts = fillProds();
var miscprods = $('#mprods').val();
var prods = "[M2]"+sproducts+"^"+miscprods; // 20150903
// alert("P="+prods);
logEvent('OF', prods); // 20150903
$('#prods').val(sproducts);
$('#firstsw').val('');
var selvehid = 'M2';
// alert("OpenOrd sprod:" + sproducts);
// alert("Veh=" + fvehid + ", #pr=" + numprod + ",Prods=" + prods);
ordform=window.open('es-orderform.php?mode='+ordermode+
'&selid='+escape(selvehid)+
'&mprods='+miscprods+'&prods='+sproducts+
'&fromonline='+fromonline,+
'orderwin'); // 20240419
// 'orderwin',+
// 'location=0,resizable=1,scrollbars=1,'+
// 'menubar=1,width=1500px,height=1200'); // 20220620
if (window.focus) {ordform.focus()};
/*
ordform=window.open('es-orderform.php?mode=Orderinq'+
'&selid='+escape(selvehid)+
'&mprods='+miscprods+'&prods='+sproducts+
'&fromonline=Y',+
'orderwin',+
'location=0,resizable=1,scrollbars=1,'+
'menubar=1,width=1080,height=1200');
*/
} // END OpenOrderForm
function OpenProductLookup() {
$('#firstsw').val('');
var selvehid = $('#selvehid').val();
var miscprods = $('#mprods').val();
var sproducts = fillProds();
$('#sprods').val(sproducts);
// alert("Veh=" + fvehid + ", #pr=" + numprod + ",Prods=" + prods);
prodlu=window.open('es-partslookup.php?mode=Order&vehid='+selvehid+
'&mprods='+miscprods+'&prods='+sproducts+
'&action=refresh&runby=p&contshop=Y',+
'springsluwin'); // 20240419
// 'springsluwin',+
// 'location=0,resizable=1,scrollbars=1,'+
// 'menubar=1,width=1040,height=1010');
if (window.focus) {prodlu.focus()};
} // END OpenProductLookup
function fillProds() {
var prods = "";
var prodtyp = "";
var prodseq = "";
var numprod = $("input:checked").length;
if (numprod > 0) {
$("input:checkbox:checked").each(function () {
var prodno = $(this).val();
// alert("Checked:" + prodno);
prods += prodno + "~";
});
} // numprod > 0
return prods;
} // END function fillProds
function saveItemQty(pgroup,ptype,eatonno) {
var miscprods = $('#mprods').val();
var prodqtyfld = '#qty' + eatonno;
var prodqty = $(prodqtyfld).val();
var newprod = miscprods + pgroup + ptype + eatonno + ':' + prodqty + '|';
// var prodsincart = newprod.split("|").length - 1;
var partsA = newprod.split("|");
var prodsA = new Array();
var partno = '';
var prodsincart = 0;
for (p=0; p 0) {
var prA = partsA[p].split(':');
partno = prA[0];
pqty = prA[1];
prodqty = ($.isNumeric(pqty)) ? parseInt(pqty) : 0;
// console.log('P#=' + partno + ', Q=' + prodqty + ', pic=' + prodsincart);
if ( (partno in prodsA) && prodqty < 1) {
if (prodsA[partno] > 0) {
if (prodsincart > 0) prodsincart--;
prodsA[partno] = 0;
}
}
else
if ( !(partno in prodsA) ||
(partno in prodsA && prodsA[partno] == 0)) {
if (prodqty > 0) {
prodsA[partno] = prodqty;
prodsincart++;
}
} // Not in prods array
} // At least 1 part qty entered
} // END for p
// console.log('Endingpic=' + prodsincart);
if (prodsincart == 0)
$('#selectlink').html(' ');
else
$('#selectlink').html(prodsincart + ' Selected');
$('#mprods').val(newprod);
} // END saveItemQty
function checkIKits(fr,chkbox) { // 20130729
var chkboxid = '#'+chkbox;
var chkpre = chkbox.substr(0, 6);
var numchkid = '#numchk'+fr+'s';
var numiktid = '#numik'+fr;
var ordiktid = '#ordif'+fr+'0';
var numkits = $(numiktid).val();
var numchkcs = $(numchkid).val();
// alert('#kits=' + numkits + ', #chks=' + numchks +
// ', cbox=' + chkboxid + ', oik=' + ordiktid);
if (numkits == 1 && chkpre == 'ordcsf') {
if ($(chkboxid).is(":checked")) {
numchkcs++;
}
else {
numchkcs--;
}
if (numchkcs > 0) {
$(ordiktid).prop('checked', true);
}
else {
$(ordiktid).prop('checked', false);
}
}
$(numchkid).val(numchkcs);
var numchks = $("input:checked").length;
if (numchks == 0) {
$('#btnOrder').prop('disabled', true);
$('#btnOrder').removeClass('EatonBlueBG').addClass('WhiteRows');
}
else {
$('#btnOrder').prop('disabled', false);
$('#btnOrder').removeClass('WhiteRows').addClass('EatonBlueBG');
}
} // END checkIKits