/**
* jQuery.ScrollTo - User interface fucnctions and client-side ajax for the
* order form on OboeMN.com using jQuery.
* Copyright (c) 2008 Northern Visual Services LLP
* - benzolio(at)gmail(dot)com | http://northernvisual.com
* jQuery is Dual licensed under MIT and GPL.
* Date: 12/15/2008
* @author Ben Marolt
*
*/
$(document).ready(function(){
function show_order_list(){
$("#content").scrollTo($("DIV.cem_order_form").get(0),500);
apply_handlers();
}
function apply_handlers(){
$(".item_data select").change(function(){
var line = new Object();
idkey=$(this).attr("id");
delim_index=idkey.lastIndexOf('_');
line['id']=idkey.substr(delim_index+1);
line[key = idkey.substring(0,delim_index)]=$(this).val();
if (line[key] == 'none') alert('Please make sure you have selected your choice from the options available for this item.');
$(".cem_order_form").load("http://www.oboemn.com/includes/oboemn.com/cem_order_form.php",{order_functions:'customer',update_detail:$.toJSON(line)},apply_handlers);
});
$(".item_data input.qty").change(function(){
var line = new Object();
idkey=$(this).attr("id");
delim_index=idkey.lastIndexOf('_');
line["id"]=idkey.substr(delim_index+1);
line[idkey.substring(0,delim_index)]=$(this).val();
$(".cem_order_form").load("http://www.oboemn.com/includes/oboemn.com/cem_order_form.php",{order_functions:'customer',change_qty:$.toJSON(line)},apply_handlers);
});
$(".cem_ajax_order_form_payment_method input.payment_method").click(function(){
var payment_info = new Object();
payment_info["method"]=$(this).val();
$(".cem_order_form").load("http://www.oboemn.com/includes/oboemn.com/cem_order_form.php",{order_functions:'customer',payment_method:$.toJSON(payment_info)},apply_handlers);
});
$(".cem_ajax_order_form_contact_info select, .cem_ajax_order_form_contact_info input").change(function(){
var contact = new Object();
$(".cem_ajax_order_form_contact_info input, .cem_ajax_order_form_contact_info select").each(function(){
contact[$(this).attr('id')]=$(this).val();
}).add(".cem_order_form").filter(".cem_order_form").load("http://www.oboemn.com/includes/oboemn.com/cem_order_form.php",{order_functions:'customer',contact_info:$.toJSON(contact)},apply_handlers);
});
$("#order_by_email").click(function(){
valid = true;
$(".item_data select").each(function(){
if ($(this).val() == 'none')
{
alert('Please make sure to select your choice from the available options for each item on the order form. You will find these options in the drop-down box in the Item Description column of the order form.');
valid = false;
}
});
if (valid) $(".cem_order_form").load("http://www.oboemn.com/includes/oboemn.com/cem_order_form.php",{order_functions:'customer',send_order:$.toJSON('')},apply_handlers);
});
$("#print_for_mail").click(function(){
valid = true;
$(".item_data select").each(function(){
if ($(this).val() == 'none')
{
alert('Please make sure to select your choice from the available options for each item on the order form. You will find these options in the drop-down box in the Item Description column of the order form.');
valid = false;
}
});
if (valid) location.href='http://www.oboemn.com/?print_order=1';
});
$("#paypal_check_out_button").submit(function(){
valid = true;
$(".item_data select").each(function(){
if ($(this).val() == 'none')
{
valid = false;
alert('ORDER FORM DETAILS ARE NOT COMPLETE!
Please make sure to select your choice from the available options for each item on the order form. You will find these options in the drop-down box in the Item Description column of the order form.');
}
});
return valid;
});
$(".cem_order_form .js-alert").each(function(){
alert($(this).html());
});
}
$(".add_item").click(function(){
var item = new Object();
item["id"]=$(this).attr("item_id");
$(".cem_order_form").load("http://www.oboemn.com/includes/oboemn.com/cem_order_form.php",{order_functions:'customer',add_to_cart:$.toJSON(item)},show_order_list);
});
$(".cem_order_form").load("http://www.oboemn.com/includes/oboemn.com/cem_order_form.php",{},apply_handlers);
$(".js-alert").each(function(){
alert($(this).html());
});
});