/*
FoxyCart Multiship Javascript
v2.4
2013-03-02
INSTRUCTIONS:
http://wiki.foxycart.com/integration/foxycart/multiship_javascript_070
IMPORTANT:
If you're having problems with this script, MAKE SURE YOUR PAGE IS VALID.
Seriously, if your page is invalid (particularly with regard to forms
spanning beyond where they should, like starting in one
and going into
another) this code might have issues.
*/
function shipto_initialize() {
jQuery('div.shipto_select').show();
jQuery('div.shipto_name').hide();
jQuery('div.shipto_name input').val("");
}
// shipto_check checks for the existence of the shipto cookie
// returns an array of values, or false if no cookie found
function shipto_array() {
if (jQuery.cookie('shipto_names')) {
// Define the global shipto array
var shipto_array = jQuery.cookie('shipto_names').split('||');
shipto_array = unique(shipto_array);
shipto_array.sort();
return shipto_array;
} else {
return false;
}
}
function shipto_select() {
// Clear the shipto select boxes first
jQuery('div.shipto_select select').html('');
var shipto_options = '';
var shipto = shipto_array();
// alert('shipto: ' + shipto);
if (shipto) {
// alert('shipto is true');
jQuery.each(shipto, function(i, val){
// alert('starting the .each loop with: ' + i + ' = ' + val);
if (val != 'undefined' && val != 'null' && val != '' && val != 'Me') {
shipto_options += '