// {{{ // *** // Our jQuery Ready event // *** $(document).ready(function(){ // Table sorter functions $("#partsResults").tablesorter({ // Default sort settings (column 2, desc) sortList: [[2,0]], // pass the headers argument and assing a object headers: { // assign the secound column (we start counting zero) 0: { // disable it by setting the property sorter to false sorter: false } } }); // Assign the sortStart event $('#partsResults').bind('sortStart', function() { // Do something? }).bind('sortEnd', function() { // Do something? }); $("#dealersResults").tablesorter({ // Default sort settings (column 1, desc) sortList: [[0,0]] }); $("#partsFolder").tablesorter({ // Default sort settings (column 2, desc) sortList: [[2,0]], // pass the headers argument and assing a object headers: { 0: { // disable column 0 by setting the property sorter to false sorter: false } , 1: { // disable column 1 by setting the property sorter to false sorter: false } } }); $("#enquiriesList").tablesorter({ // Default sort settings (column 2, desc) // sortList: [[0,0]] }); }); // }}} // {{{ // user.next uses a set of codes to remember what action needs to be carried out after a login // This is replicated in a session variable. // sf = Save Folder // se = Single Enqiry // me = Multi Enquiry var user = { loggedin : false, firstname : false, lastname : false, email : false, next : false } // }}} // {{{ var images = { location : false } // }}} // {{{ var join = { form : function(which) { // Show the modal layer this.modal(); // Show the Login/ Join Popup $('#joinPopup').show(); // Make sure that we are showing the correct div if (which == 'join') { this.change('join'); } else { this.change('login'); } }, modal : function() { // Get the screen height and width var maskHeight = $(document).height(); var maskWidth = $(window).width(); // Set height and width to mask to fill up the whole screen $('#mask').css({'width':maskWidth, 'height':maskHeight}); // Transition effect $('#mask').fadeIn(); }, close : function() { // Hide the popup $('#joinPopup').hide(); // Hide the modal mask $('#mask, .window').hide(); }, change : function(toWhere) { if (toWhere == 'join') { $('#joinPopup').css({height:'300px'}); $('#loginSection').hide(); $('#joinSection').show(); } else { $('#joinPopup').css({height:'240px'}); $('#joinSection').hide(); $('#loginSection').show(); } } } // }}} // {{{ var search = { url : false, restrict : function(location) { if (location == 'dealers') { var brandID = $('#restrictDealers').val(); } else if (location == 'parts') { var brandID = $('#restrictParts').val(); } window.location.href = this.url + '&brandID=' + brandID; } } // *** // Object to do stuff with the main search form // *** var formStuff = { submit : function() { if ($('#q').val() == '') { alert('Please enter something to search for.'); } else { $('#searchForm').submit(); } } }; // }}} // {{{ // *** // Manage the help information layers. // *** var help = { alert : function(info) { // Utlise the join modal screen join.modal(); // Show the help data $('#helpInfo').html(info); $('#helpPopup').show(); }, close : function() { // Hide the help window $('#helpPopup').hide(); // Hide the modal mask $('#mask, .window').hide(); }, search : function() { $('#helpSave').toggle(); setTimeout("$('#helpView').toggle()", 600); }, folder : function() { $('#helpSaveFolder').toggle(); setTimeout("$('#helpSmall').toggle()", 600); setTimeout("$('#helpContact').toggle()", 1200); }, page: function(page) { if (typeof(page) == 'undefined') { alert('Sorry, no help available for this page.'); } else { switch(page) { case 'code': var helpHTML = '
to save a part to your parts folder.
';
var successHTML = '
';
if (data.result == 'login') {
var message = "Enquiry Failed!\n\nPlease make sure that you are logged in.";
$('#enquiry' + partID).html(failHTML);
} else if (data.result == 'folder') {
var message = "Enquiry Failed!\n\nPlease make sure that have parts in your folder!";
$('#enquiry' + partID).html(failHTML);
} else if (data.result == 'email') {
var message = "Enquiry Failed!\n\nThis dealer has not provided a valid contact email address, please contact by phone, or in person.";
$('#enquiry' + partID).html(failHTML);
} else if (data.result == 'send') {
var message = "Enquiry Failed!\n\nThis dealer has not provided a valid contact email address, please contact by phone.";
$('#enquiry' + partID).html(failHTML);
} else if (data.result == 'previousSuccess') {
var message = "You have already made an enquiry about this part.\n\nThe dealer will contact you soon.";
$('#enquiry' + partID).html(successHTML);
} else if (data.result == 'previousFail') {
var message = "You have already tried to make enquiry about this part.\n\nThe enquiry failed so please contact the dealer by phone.";
$('#enquiry' + partID).html(failHTML);
} else {
var message = 'You enquiry has ben successfully sent';
$('#enquiry' + partID).html(successHTML);
}
alert(message);
},
error: function() {
$('#enquiry' + partID).html('
');
alert('Sorry, there was an error making this enquiry.');
}
});
},
multiEnquiry : function() {
if (!user.loggedin) {
user.next = 'me';
join.form();
} else {
$('#multyEnquiryDiv').html('
');
}
}
if (typeof(data['failed']) != 'undefined') {
var failed = data['failed'];
someFailure = true;
if(someSuccess) {
message += "\n\n";
}
message += data['failed'].length + " part fail.";
for (var id in data['failed']) {
var partID = data['failed'][id];
$('#enquiry' + partID).html('
');
}
}
if (typeof(data['previousSuccess']) != 'undefined') {
var previousSuccess = data['previousSuccess'];
somePreviousSuccess = true;
if(someSuccess || someFailure) {
message += "\n\n";
}
message += data['previousSuccess'].length + " part[s] previously contacted.";
for (var id in data['previousSuccess']) {
var partID = data['previousSuccess'][id];
$('#enquiry' + partID).html('
');
}
}
if (typeof(data['previousFailure']) != 'undefined') {
var previousFailure = data['previousFailure'];
somePreviousFailure = true;
if(someSuccess || someFailure || somePreviousSuccess) {
message += "\n\n";
}
message += data['previousFailure'].length + " part[s] previously failed to contact.";
for (var id in data['previousFailure']) {
var partID = data['previousFailure'][id];
$('#enquiry' + partID).html('
');
}
}
$('#multyEnquiryDiv').html('