function showDashboard()
{
showDiv('dashBoardBack');
showDiv('popup_outer');
}
function stristr (haystack, needle, bool) {
/*
Finds first occurrence of a string within another, case insensitive
version: 909.322
discuss at: http://phpjs.org/functions/stristr
+ original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ bugfxied by: Onno Marsman
* example 1: stristr('Kevin van Zonneveld', 'Van');
* returns 1: 'van Zonneveld'
* example 2: stristr('Kevin van Zonneveld', 'VAN', true);
* returns 2: 'Kevin '
*/
var pos = 0;
haystack += '';
pos = haystack.toLowerCase().indexOf( (needle+'').toLowerCase() );
if (pos == -1){
return false;
} else{
if (bool) {
return haystack.substr( 0, pos );
} else{
return haystack.slice( pos );
}
}
}
function hideDashboard()
{
hideDiv('dashBoardBack');
hideDiv('popup_outer');
}
function hideDiv(div) {
document.getElementById(div).style.display = 'none';
}
function showDiv(div) {
document.getElementById(div).style.display = 'inline';
}
function setVisible(id, visible)
{
document.getElementById(id).style.display = visible;
}
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else {
limitCount.value = limitNum - limitField.value.length;
}
}
function setcookie(name, value, expires, path, domain, secure)
{
expires instanceof Date ? expires = expires.toGMTString() : typeof(expires) == 'number' && (expires = (new Date(+(new Date) + expires * 1e3)).toGMTString());
var r = [name + "=" + escape(value)], s, i;
for(i in s = {expires: expires, path: path, domain: domain}){
s[i] && r.push(i + "=" + s[i]);
}
return secure && r.push("secure"), document.cookie = r.join(";"), true;
}
function getcookie( check_name ) {
var a_all_cookies = document.cookie.split( ';' );
var a_temp_cookie = '';
var cookie_name = '';
var cookie_value = '';
var b_cookie_found = false; // set boolean t/f default f
for ( i = 0; i < a_all_cookies.length; i++ )
{
// now we'll split apart each name=value pair
a_temp_cookie = a_all_cookies[i].split( '=' );
// and trim left/right whitespace while we're at it
cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
// if the extracted name matches passed check_name
if ( cookie_name == check_name )
{
b_cookie_found = true;
// we need to handle case where cookie has no value but exists (no = sign, that is):
if ( a_temp_cookie.length > 1 )
{
cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
}
// note that in cases where cookie is initialized but no value, null is returned
return cookie_value;
break;
}
a_temp_cookie = null;
cookie_name = '';
}
if ( !b_cookie_found )
{
return null;
}
}
function setAddtionalOptsVisible(id, visible, plus)
{
document.getElementById(id).style.display = visible;
if (visible=="none")
document.getElementById(plus).innerHTML = '
'; else
document.getElementById(plus).innerHTML = '
';
}
function setJobVisible(idList, plus)
{
var ids = idList.split(",");
for (var i=0; i'; else
document.getElementById(plus).innerHTML = '
';
}
}
function openJobVisible(idList, plus)
{
var ids = idList.split(",");
for (var i=0; i';
}
}
function closeJobVisible(idList, plus)
{
var ids = idList.split(",");
for (var i=0; i';
}
}
function setFolderItemVisible(id, plus)
{
var item = document.getElementById(id);
var visible = item.style.display;
var visStyle = "";
if (visible!="")
visStyle = ""; else
visStyle = "none";
document.getElementById(id).style.display = visStyle;
if (visible!="")
document.getElementById(plus).innerHTML = '
'; else
document.getElementById(plus).innerHTML = '
';
}
function removeTextInput(form_name, id)
{
document.forms[form_name].removeChild(document.getElementById(id));
document.forms[form_name].removeChild(document.getElementById('remove_'+id));
}
function checkShipping(select, zip, get_prices)
{
document.getElementById(get_prices).disabled = !((document.getElementById(select).value!="") && (document.getElementById(zip).value!=""));
}
function showHideUpload(detailDiv, imageDiv)
{
var detail = document.getElementById(detailDiv);
var image = document.getElementById(imageDiv);
if (detail.style.display == 'none')
{
detail.style.display = '';
image.innerHTML = '
';
} else
{
detail.style.display = 'none';
image.innerHTML = '
';
}
}
function popUp(URL)
{
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 0,top = 0');");
}
function checkoutPayment()
{
var a = document.createElement('a');
a.setAttribute('href', SERVER_NAME+'store/pre-process-payment.html?ajax=true');
a.appendChild(document.createTextNode("Checkout"));
Shadowbox.open(a);
}
function paymentTypeChange(select, showAlerts)
{
for (var i=0; i
To receive the override code please call the office!', 'warning');
} else
if (select.value == 'Purchase Order')
{
$('#purchase_order_num').attr('cancelValidate', '');
$('#purchase_order_override_code').attr('cancelValidate', '');
$('#checkFields').hide();
$('#ccFields').hide();
$('#purchaseorderFields').show();
$('#cashFields').hide();
if (showAlerts)
swal('Notice!', 'Your order will not begin production until the purchase order has been confirmed.
To receive the override code please call the office!', 'warning');
} else
if (select.value == 'Cash')
{
$('#cash_override_code').attr('cancelValidate', '');
$('#ccFields').hide();
$('#checkFields').hide();
$('#cashFields').show();
$('#purchaseorderFields').hide();
if (showAlerts)
swal('Notice!', 'Your order will not begin production until payment is received in full.
To receive the override code please call the office!', 'warning');
} else
if (select.value == 'PayPal')
{
$('#cash_override_code').attr('cancelValidate', 'true');
$('#ccFields').hide();
$('#checkFields').hide();
$('#cashFields').hide();
$('#purchaseorderFields').hide();
} else
if (select.value != '')
{
for (var i=0; i';
}
function openUploadDiv(key)
{
var detail = document.getElementById('details'+key);
var image = document.getElementById('arrow'+key);
detail.style.display = '';
image.innerHTML = '
';
}
function updateCartProduct(key, name, value)
{
makeRequest(SERVER_NAME+'store/update-cart-product.html?ajax=true&update='+name+'^'+key+'&value='+value, 'aResult');
}
function newButtonClicked(key)
{
var a = document.createElement('a');
a.setAttribute('href', SERVER_NAME+'store/edit-shipping-address.html?ajax=true&product_key='+key);
a.appendChild(document.createTextNode("New"));
a.rel = "width=465;height=400;";
Shadowbox.open(a);
return false;
}
function editButtonClicked(id, key)
{
var a = document.createElement('a');
a.setAttribute('href', SERVER_NAME+'store/edit-shipping-address.html?ajax=true&id='+id+'&product_key='+key);
a.appendChild(document.createTextNode("Edit"));
a.rel = "width=465;height=450;";
Shadowbox.open(a);
return false;
}
function dropshipButtonClicked()
{
var a = document.createElement('a');
a.setAttribute('href', SERVER_NAME+'store/edit-dropship-address.html?ajax=true');
a.appendChild(document.createTextNode("Dropship"));
a.rel = "width=690;height=420;";
Shadowbox.open(a);
return false;
}
function shippingAddressOnChange(select, key)
{
$('#tr2'+key).get(0).style.height = '200px';
if (select.selectedIndex==0)
{
$('#btnEdit'+key).hide();
}
if (select.selectedIndex>0)
{
$('#btnEdit'+key).show();
}
if(select.value == 'New')
{
eval('newButtonClicked('+key+');');
$('#btnEdit'+key).hide();
select.selectedIndex=0;
}
else
{
eval('updateShippingOptions'+key+'();');
}
makeRequest(SERVER_NAME+'store/get-shipping-more-info-ajax.html?ajax=true&value='+select.value+'&key='+key, 'shippingInfo'+key);
}
function shippingProviderOnChange(select, key)
{
if (select.selectedIndex==0 || select.value == 'New')
{
$('#shippingAddress'+key).hide();
$('#shippingAddress'+key+'_icon').hide();
$('#shippingAddress'+key+'_icon_text').hide();
$('#shippingInfo'+key).hide();
}
if (select.selectedIndex>0 && select.value != 'New')
{
$('#shippingAddress'+key).show();
$('#shippingAddress'+key+'_icon').show();
$('#shippingAddress'+key+'_icon_text').show();
$('#shippingInfo'+key).show();
}
if (select.options[select.selectedIndex].text == 'UPS')
{
$('#shippingInsurance'+key).show();
} else
{
$('#shippingInsurance'+key).hide();
}
if (select.options[select.selectedIndex].text == 'My Ship Account')
{
$('#shipping_account_span').show();
$('#shipping_account').attr('validate', 'isEmpty');
$('#shipping_account').attr('vmessage', '');
} else
{
$('#shipping_account_span').hide();
$('#shipping_account').removeAttr('validate');
$('#shipping_account').removeAttr('vmessage');
}
if (select.options[select.selectedIndex].text == "Pickup")
{
if ($('#shippingAddress'+key).get(0).options.length>2)
{
$('#shippingAddress'+key).get(0).selectedIndex = 1;
makeRequest(SERVER_NAME+'store/update-cart-product.html?ajax=true&update=shipping_address^'+key+'&value='+$('#shippingAddress'+key).val(), 'aResult');
$('#shippingAddress'+key).change();
}
}
if ($('#shippingAddress'+key).get(0).selectedIndex==0)
{
$('#btnEdit'+key).hide();
}
if ( ($('#shippingAddress'+key).get(0).selectedIndex>0) && ($('#shippingAddress'+key).val()!="New") )
{
$('#btnEdit'+key).show();
}
eval('updateShippingOptions'+key+'();');
if (select.selectedIndex>0)
{
makeRequest(SERVER_NAME+'store/get-shipping-provider-tooltip.html?ajax=true&id='+select.value, 'tooltip'+key);
} else
{
$('#tooltip'+key).html('');
}
}
function isRadioChecked(rbName, formName)
{
var isAnyChecked = false;
for (var ratiosI=0; (ratiosI < document.forms[formName].elements[rbName].length); ratiosI++)
{
if (document.forms[formName].elements[rbName].item(ratiosI).checked)
{
isAnyChecked = true;
}
}
return isAnyChecked;
}
function float_error_correction( number )
{
var num = number;
num *= 100;
num = Math.round(num);
num /= 100;
return num;
}
function number_format( number, decimals, dec_point, thousands_sep )
{
var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
var d = dec_point == undefined ? "." : dec_point;
var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}
function showHideUVCoatingOption(mailing, uv, key)
{
var uv_select = $(uv);
var mailing_select = $(mailing);
var exact_size = $('Must_Be_Exact_Trim_Size');
if (exact_size==null)
{
exact_size = $('Must_Be_Exact_Trim_Size^'+key);
}
if (uv_select!=null)
{
if (mailing_select.options[mailing_select.selectedIndex].text == "Yes Mailing Services")
{
uv_select.options[1].setAttribute('disabled', 'disabled');
if (uv_select.selectedIndex==1) uv_select.selectedIndex = 2;
if (exact_size!=null)
{
for (var i=0; i1) {
scoring.options[0].setAttribute('disabled', 'disabled');
if (scoring.selectedIndex==0) scoring.selectedIndex = 1;
}
} else
{
scoring.options[0].removeAttribute('disabled');
}
scoring.onchange();
}
}
function showHideExactSize(key)
{
if ( (key=='') )
{
var papertype = $('Paper_Type');
var exactsize = $('Must_Be_Exact_Trim_Size');
} else
{
var papertype = $(key);
var parts = key.split('^');
var exactsize = $('Must_Be_Exact_Trim_Size^'+parts[1]);
}
if ( (papertype!=null) && (exactsize!=null) )
{
var selected_papertype = papertype.options[papertype.selectedIndex].text;
if ((selected_papertype=='100# Gloss Text') && (papertype.selectedIndex != 0))
{
exactsize.options[0].setAttribute('disabled', 'disabled');
if (exactsize.selectedIndex==0) exactsize.selectedIndex = 1;
}
else
{
exactsize.options[0].removeAttribute('disabled');
/*if (exactsize.selectedIndex==1) exactsize.selectedIndex = 0; //Commented resetting the value back to No, because it was always resetting when other than 100# is selected*/
}
exactsize.onchange();
}
}
function urlencode( str )
{
var histogram = {}, histogram_r = {}, code = 0, tmp_arr = [];
var ret = str.toString();
var replacer = function(search, replace, str) {
var tmp_arr = [];
tmp_arr = str.split(search);
return tmp_arr.join(replace);
};
// The histogram is identical to the one in urldecode.
histogram['!'] = '%21';
histogram['%20'] = '+';
// Begin with encodeURIComponent, which most resembles PHP's encoding functions
ret = encodeURIComponent(ret);
for (search in histogram) {
replace = histogram[search];
ret = replacer(search, replace, ret) // Custom replace. No regexing
}
// Uppercase for full PHP compatibility
return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
return "%"+m2.toUpperCase();
});
return ret;
}
function ccNumKeyPress(e)
{
if (window.event)
{
if ( (window.event.keyCode == 8) || (window.event.keyCode == 127) ) return true;
} else
{
if ( (e.which == 8) || (e.which == 127) ) return true;
}
return (this.getAttribute('my_maxlength') > this.value.length );
}
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == '')
e.style.display = 'none';
else
e.style.display = '';
}
function nl2br(text)
{
text = escape(text);
if(text.indexOf('%0D%0A') > -1)
{
re_nlchar = /%0D%0A/g ;
}else if(text.indexOf('%0A') > -1)
{
re_nlchar = /%0A/g ;
}else if(text.indexOf('%0D') > -1)
{
re_nlchar = /%0D/g ;
} else
{
return text;
}
return unescape( text.replace(re_nlchar,'|||') );
}
function SaveInstructions(key)
{
var Value = $('special_instructions'+key).value;
Value = nl2br(uni2ent(Value));
makeRequest(SERVER_NAME+'store/update-cart-product.html?ajax=true&update=special_instructions^'+key+'&value='+Value, 'save_instructions_result'+key);
}
function clearText(key)
{
if (key.defaultValue==key.value)
key.value = "";
}
function uni2ent(snippet) {
var uSnip = '';
for (var c=0, val; val = snippet.charCodeAt(c); c++) {
if ( (val < 256) && (val!=35) )
{
uSnip += snippet.charAt(c);
} else
if (val==35)
{
uSnip += "%23";
}
else
{
uSnip += "" + val + ";"
}
}
return uSnip;
}