//The following is all for Share this.
function wpsc_akst_share(id, url, title) {
if ((jQuery('#wpsc_akst_form').css("display") == 'block') && (jQuery('#wpsc_akst_post_id').attr("value") == id)) {
jQuery('#wpsc_akst_form').css("display", "none");
return;
}
var offset = {};
new_container_offset = jQuery('#wpsc_akst_link_' + id).offset();
if(offset['left'] == null) {
offset['left'] = new_container_offset.left;
offset['top'] = new_container_offset.top;
}
jQuery("#wpsc_akst_delicious").attr("href", wpsc_akst_share_url("http://del.icio.us/post?url={url}&title={title}", url, title));
jQuery("#wpsc_akst_digg").attr("href", wpsc_akst_share_url("http://digg.com/submit?phase=2&url={url}&title={title}", url, title));
jQuery("#wpsc_akst_furl").attr("href", wpsc_akst_share_url("http://furl.net/storeIt.jsp?u={url}&t={title}", url, title));
jQuery("#wpsc_akst_netscape").attr("href", wpsc_akst_share_url(" http://www.netscape.com/submit/?U={url}&T={title}", url, title));
jQuery("#wpsc_akst_yahoo_myweb").attr("href", wpsc_akst_share_url("http://myweb2.search.yahoo.com/myresults/bookmarklet?u={url}&t={title}", url, title));
jQuery("#wpsc_akst_stumbleupon").attr("href", wpsc_akst_share_url("http://www.stumbleupon.com/submit?url={url}&title={title}", url, title));
jQuery("#wpsc_akst_google_bmarks").attr("href", wpsc_akst_share_url(" http://www.google.com/bookmarks/mark?op=edit&bkmk={url}&title={title}", url, title));
jQuery("#wpsc_akst_technorati").attr("href", wpsc_akst_share_url("http://www.technorati.com/faves?add={url}", url, title));
jQuery("#wpsc_akst_blinklist").attr("href", wpsc_akst_share_url("http://blinklist.com/index.php?Action=Blink/addblink.php&Url={url}&Title={title}", url, title));
jQuery("#wpsc_akst_newsvine").attr("href", wpsc_akst_share_url("http://www.newsvine.com/_wine/save?u={url}&h={title}", url, title));
jQuery("#wpsc_akst_magnolia").attr("href", wpsc_akst_share_url("http://ma.gnolia.com/bookmarklet/add?url={url}&title={title}", url, title));
jQuery("#wpsc_akst_reddit").attr("href", wpsc_akst_share_url("http://reddit.com/submit?url={url}&title={title}", url, title));
jQuery("#wpsc_akst_windows_live").attr("href", wpsc_akst_share_url("https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url={url}&title={title}&top=1", url, title));
jQuery("#wpsc_akst_tailrank").attr("href", wpsc_akst_share_url("http://tailrank.com/share/?link_href={url}&title={title}", url, title));
jQuery('#wpsc_akst_post_id').value = id;
jQuery('#wpsc_akst_form').css("left", offset['left'] + 'px');
jQuery('#wpsc_akst_form').css("top", (offset['top']+ 14 + 3) + 'px');
jQuery('#wpsc_akst_form').css("display", 'block');
}
function wpsc_akst_share_url(base, url, title) {
base = base.replace('{url}', url);
return base.replace('{title}', title);
}
function wpsc_akst_share_tab(tab) {
var tab1 = document.getElementById('wpsc_akst_tab1');
var tab2 = document.getElementById('wpsc_akst_tab2');
var body1 = document.getElementById('wpsc_akst_social');
var body2 = document.getElementById('wpsc_akst_email');
switch (tab) {
case '1':
tab2.className = '';
tab1.className = 'selected';
body2.style.display = 'none';
body1.style.display = 'block';
break;
case '2':
tab1.className = '';
tab2.className = 'selected';
body1.style.display = 'none';
body2.style.display = 'block';
break;
}
}
//End Share this JS
function wpsc_shipping_same_as_billing(){
jQuery('#shippingsameasbillingmessage').slideDown('slow');
jQuery("input[title='billingfirstname'], input[title='billinglastname'], textarea[title='billingaddress'], input[title='billingcity'], input[title='billingpostcode'], input[title='billingphone'], input[title='billingfirstname'], input[title='billingstate']").unbind('change', wpsc_shipping_same_as_billing).unbind('keyup', wpsc_shipping_same_as_billing).keyup(wpsc_shipping_same_as_billing).change(wpsc_shipping_same_as_billing);
jQuery("select[title='billingregion'], select[title='billingstate'], select[title='billingcountry'], input[title='billingstate']").die( 'change', wpsc_shipping_same_as_billing ).live( 'change', wpsc_shipping_same_as_billing );
var fields = new Array(
Array(
"input[title='billingfirstname']",
"input[title='shippingfirstname']"
),
Array(
"input[title='billinglastname']",
"input[title='shippinglastname']"
),
Array(
"textarea[title='billingaddress']",
"textarea[title='shippingaddress']"
),
Array(
"input[title='billingcity']",
"input[title='shippingcity']"
),
Array(
"input[title='billingpostcode']",
"input[title='shippingpostcode']"
),
Array(
"input[title='billingphone']",
"input[title='shippingphone']"
),
Array(
"input[title='billingemail']",
"input[title='shippingemail']"
)
);
for(var i in fields) {
jQuery(fields[i][1]).val(jQuery(fields[i][0]).val());
jQuery(fields[i][1]).parents('tr:first').hide();
if(!jQuery(fields[i][0]).hasClass('intra-field-label'))
jQuery(fields[i][1]).removeClass('intra-field-label');
else
jQuery(fields[i][1]).addClass('intra-field-label');
}
if( jQuery("input[title='billingstate']").length ){
jQuery("input[title='shippingstate']").val(jQuery("input[title='billingstate']").val());
jQuery("input[title='shippingstate']").parents('tr:first').hide();
if(!jQuery("input[title='billingstate']").hasClass('intra-field-label'))
jQuery("input[title='shippingstate']").removeClass('intra-field-label');
else
jQuery("input[title='shippingstate']").addClass('intra-field-label');
} else {
jQuery("input[title='shippingstate']").val(jQuery("select[title='billingstate']").val());
jQuery(".shipping_region_name").text(jQuery("select[title='billingstate'] option[selected='selected']").text());
jQuery("input[title='shippingstate']").parents('tr:first').hide();
}
jQuery("input.shipping_country").val(
jQuery("select[title='billingcountry']").val()
).removeClass('intra-field-label').parents('tr:first').hide();
jQuery("span.shipping_country_name").html(
jQuery("select[title='billingcountry'] :selected").text()
).hide();
jQuery('select[title="shippingcountry"] option').removeAttr('selected').parents('tr:first').hide();
jQuery('select[title="shippingcountry"] option[value="' + jQuery('select[title="billingcountry"] option:selected').val() + '"]').attr('selected', 'selected');
jQuery('select[title="shippingstate"] option').removeAttr('selected').parents('tr:first').hide();
jQuery('select[title="shippingstate"] option[value="' + jQuery('select[title="billingstate"] option:selected').val() + '"]').attr('selected', 'selected');
jQuery('select[title="shippingcountry"]').change();
jQuery('select[title="shippingstate"]').change();
//evil. If shipping is enabled checks if shipping country is the same and billing and if shipping state is the same as billing. If not - changes shipping country and (or) state to billing.
if(
//if shipping is enabled this element will be present, so if it's not, then it will skip everything
jQuery('#change_country #current_country').val()
&&
//also we only need to do this when shipping country is different than billing country. following code does the check
(
//check if countries are different
(
//if billing country dropdown is present
jQuery('select[title="billingcountry"]')
&&
//and if the value is different from shipping
jQuery('#change_country #current_country').val() != jQuery('select[title="billingcountry"]').val()
)
||
//ceck if billing region is different
(
//if billing region is present
jQuery('select[title="billingstate"]')
&&
//if its different from shipping
jQuery('select[title="billingstate"]').val() != jQuery('#change_country #region').val()
)
)
){
jQuery('#current_country option').removeAttr('selected');
jQuery('#current_country option[value="'+jQuery('select[title="billingcountry"]').val()+'"]').attr('selected', 'selected');
jQuery('#region').remove();
if(jQuery('select[title="billingstate"]').html()){
jQuery('#change_country #current_country').after('')
jQuery('#region option').removeAttr('selected');
jQuery('#region option[value='+jQuery('select[title="billingstate"]').val()+']').attr('selected', 'selected');
}
var request_vars = {'country' : jQuery('#current_country').val(), 'wpsc_ajax_actions' : 'update_location', 'wpsc_update_location' : true, 'wpsc_submit_zipcode' : 'Calculate' };
if(jQuery('#region'))
request_vars.region = jQuery('#region').val();
if(typeof(updated_shipping_quote_after)=='undefined')
updated_shipping_quote_after = false;
jQuery.post(
location.href,
request_vars,
function(){
if(!updated_shipping_quote_after){
jQuery('select[title="billingcountry"]').change();
updated_shipping_quote_after = false;
} else
updated_shipping_quote_after = false;
}
);
}
}
// this function is for binding actions to events and rebinding them after they are replaced by AJAX
// these functions are bound to events on elements when the page is fully loaded.
jQuery(document).ready(function () {
if(jQuery('#checkout_page_container .wpsc_email_address input').val())
jQuery('#wpsc_checkout_gravatar').attr('src', 'https://secure.gravatar.com/avatar/'+MD5(jQuery('#checkout_page_container .wpsc_email_address input').val().split(' ').join(''))+'?s=60&d=mm');
jQuery('#checkout_page_container .wpsc_email_address input').keyup(function(){
jQuery('#wpsc_checkout_gravatar').attr('src', 'https://secure.gravatar.com/avatar/'+MD5(jQuery(this).val().split(' ').join(''))+'?s=60&d=mm');
});
jQuery('#fancy_notification').appendTo('body');
//this bit of code runs on the checkout page. If the checkbox is selected it copies the valus in the billing country and puts it in the shipping country form fields. 23.07.09
if(jQuery("#shippingSameBilling").is(":checked"))
wpsc_shipping_same_as_billing();
jQuery("#shippingSameBilling").change(function(){
if(jQuery(this).is(":checked")){
var data = {
action: 'wpsc_shipping_same_as_billing',
wpsc_shipping_same_as_billing: true
};
jQuery.post(wpsc_ajax.ajaxurl, data, function(response) {
});
wpsc_shipping_same_as_billing();
} else {
var data = {
action: 'wpsc_shipping_same_as_billing',
wpsc_shipping_same_as_billing: false
};
jQuery.post(wpsc_ajax.ajaxurl, data, function(response) {
});
jQuery(this).parents('table:first').find('tr').show();
jQuery('.shipping_country_name').show();
jQuery('#shippingsameasbillingmessage').hide();
jQuery("select[title='billingregion'], select[title='billingstate'], select[title='billingcountry'], input[title='billingstate']").die( 'change', wpsc_shipping_same_as_billing );
jQuery("input[title='billingfirstname'], input[title='billinglastname'], textarea[title='billingaddress'], input[title='billingcity'], input[title='billingpostcode'], input[title='billingphone'], input[title='billingfirstname'], input[title='billingstate']").unbind('change', wpsc_shipping_same_as_billing).unbind('keyup', wpsc_shipping_same_as_billing);
}
});
// Submit the product form using AJAX
jQuery("form.product_form").live('submit', function() {
// we cannot submit a file through AJAX, so this needs to return true to submit the form normally if a file formfield is present
file_upload_elements = jQuery.makeArray(jQuery('input[type="file"]', jQuery(this)));
if(file_upload_elements.length > 0) {
return true;
} else {
form_values = jQuery(this).serialize();
// Sometimes jQuery returns an object instead of null, using length tells us how many elements are in the object, which is more reliable than comparing the object to null
if(jQuery('#fancy_notification').length == 0) {
jQuery('div.wpsc_loading_animation',this).css('visibility', 'visible');
}
jQuery.post( 'index.php?ajax=true', form_values, function(returned_data) {
eval(returned_data);
jQuery('div.wpsc_loading_animation').css('visibility', 'hidden');
if(jQuery('#fancy_notification') != null) {
jQuery('#loading_animation').css("display", 'none');
//jQuery('#fancy_notificationimage').css("display", 'none');
}
});
wpsc_fancy_notification(this);
return false;
}
});
jQuery('a.wpsc_category_link, a.wpsc_category_image_link').click(function(){
product_list_count = jQuery.makeArray(jQuery('ul.category-product-list'));
if(product_list_count.length > 0) {
jQuery('ul.category-product-list', jQuery(this).parent()).toggle();
return false;
}
});
// this is for storing data with the product image, like the product ID, for things like dropshop and the the ike.
jQuery("form.product_form").livequery(function(){
product_id = jQuery('input[name="product_id"]',this).val();
image_element_id = 'product_image_'+product_id;
jQuery("#"+image_element_id).data("product_id", product_id);
parent_container = jQuery(this).parents('div.product_view_'+product_id);
jQuery("div.item_no_image", parent_container).data("product_id", product_id);
});
//jQuery("form.product_form").trigger('load');
// Toggle the additional description content
jQuery("a.additional_description_link").click(function() {
parent_element = jQuery(this).parent(".additional_description_container, .additional_description_span");
jQuery('.additional_description',parent_element).slideToggle('fast');
return false;
});
// update the price when the variations are altered.
jQuery(".wpsc_select_variation").live('change', function() {
jQuery('option[value="0"]', this).attr('disabled', 'disabled');
parent_form = jQuery(this).parents("form.product_form");
form_values =jQuery("input[name='product_id'], .wpsc_select_variation",parent_form).serialize( );
jQuery.post( 'index.php?update_product_price=true', form_values, function(returned_data) {
variation_msg = '';
eval(returned_data);
if( product_id != null ) {
if( variation_msg != '' ){
if(variation_status){
jQuery("div#stock_display_"+product_id).removeClass('out_of_stock');
jQuery("div#stock_display_"+product_id).addClass('in_stock');
}else{
jQuery("div#stock_display_"+product_id).removeClass('in_stock');
jQuery("div#stock_display_"+product_id).addClass('out_of_stock');
}
jQuery("div#stock_display_"+product_id).html(variation_msg);
}
if( typeof(price) !== 'undefined' && typeof(old_price) !== 'undefined' && typeof(you_save) !== 'undefined' && typeof(numeric_price) !== 'undefined' ) {
target_id = "product_price_"+product_id;
price_target_selector = "#" + target_id + ".pricedisplay, ." + product_id + " .currentprice";
second_target_id = "donation_price_"+product_id;
third_target_id = "old_product_price_"+product_id;
yousave_target_id = "yousave_"+product_id;
buynow_id = "BB_BuyButtonForm"+product_id;
if(jQuery("input#"+target_id).attr('type') == 'text') {
jQuery("input#"+target_id).val(numeric_price);
} else {
jQuery(price_target_selector).html(price);
jQuery("#"+third_target_id).html(old_price);
jQuery("#"+yousave_target_id).html(you_save);
}
jQuery("input#"+second_target_id).val(numeric_price);
}
}
});
return false;
});
// Object frame destroying code.
jQuery("div.shopping_cart_container").livequery(function(){
object_html = jQuery(this).html();
window.parent.jQuery("div.shopping-cart-wrapper").html(object_html);
});
// Ajax cart loading code.
jQuery("div.wpsc_cart_loading").livequery(function(){
form_values = "ajax=true"
jQuery.post( 'index.php?wpsc_ajax_action=get_cart', form_values, function(returned_data) {
eval(returned_data);
});
});
// Object frame destroying code.
jQuery("form.wpsc_product_rating").livequery(function(){
jQuery(this).rating();
});
jQuery("form.wpsc_empty_the_cart").livequery(function(){
jQuery(this).submit(function() {
form_values = "ajax=true&";
form_values += jQuery(this).serialize();
jQuery.post( 'index.php', form_values, function(returned_data) {
eval(returned_data);
});
return false;
});
});
jQuery("form.wpsc_empty_the_cart a.emptycart").live('click',function(){
parent_form = jQuery(this).parents("form.wpsc_empty_the_cart");
form_values = "ajax=true&";
form_values += jQuery(parent_form).serialize();
jQuery.post( 'index.php', form_values, function(returned_data) {
eval(returned_data);
});
return false;
});
//Shipping bug fix by James Collins
var radios = jQuery(".productcart input:radio[name='shipping_method']");
if (radios.length == 1) {
// If there is only 1 shipping quote available during checkout, automatically select it
jQuery(radios).click();
} else if (radios.length > 1) {
// There are multiple shipping quotes, simulate a click on the checked one
jQuery(".productcart input:radio[name='shipping_method']:checked").click();
}
});
// update the totals when shipping methods are changed.
function switchmethod(key,key1){
// total=document.getElementById("shopping_cart_total_price").value;
form_values = "ajax=true&";
form_values += "wpsc_ajax_action=update_shipping_price&";
form_values += "key1="+key1+"&";
form_values += "key="+key;
jQuery.post( 'index.php', form_values, function(returned_data) {
eval(returned_data);
});
}
// submit the country forms.
function submit_change_country(){
document.forms.change_country.submit();
}
// submit the fancy notifications forms.
function wpsc_fancy_notification(parent_form){
if(typeof(WPSC_SHOW_FANCY_NOTIFICATION) == 'undefined'){
WPSC_SHOW_FANCY_NOTIFICATION = true;
}
if((WPSC_SHOW_FANCY_NOTIFICATION == true) && (jQuery('#fancy_notification') != null)){
var options = {
margin: 1 ,
border: 1 ,
padding: 1 ,
scroll: 1
};
form_button_id = jQuery(parent_form).attr('id') + "_submit_button";
var button_offset = jQuery('#'+form_button_id).offset();
jQuery('#fancy_notification').css("left", (button_offset.left - 130) + 'px');
jQuery('#fancy_notification').css("top", (button_offset.top + 40) + 'px');
jQuery('#fancy_notification').css("display", 'block');
jQuery('#loading_animation').css("display", 'block');
jQuery('#fancy_notification_content').css("display", 'none');
}
}
function shopping_cart_collapser() {
switch(jQuery("#sliding_cart").css("display")) {
case 'none':
jQuery("#sliding_cart").slideToggle("fast",function(){
jQuery.post( 'index.php', "ajax=true&set_slider=true&state=1", function(returned_data) { });
jQuery("#fancy_collapser").attr("src", (WPSC_CORE_IMAGES_URL + "/minus.png"));
});
break;
default:
jQuery("#sliding_cart").slideToggle("fast",function(){
jQuery.post( 'index.php', "ajax=true&set_slider=true&state=0", function(returned_data) { });
jQuery("#fancy_collapser").attr("src", (WPSC_CORE_IMAGES_URL + "/plus.png"));
});
break;
}
return false;
}
function set_billing_country(html_form_id, form_id){
var billing_region = '';
country = jQuery(("div#"+html_form_id+" select[class='current_country']")).val();
region = jQuery(("div#"+html_form_id+" select[class='current_region']")).val();
if(/[\d]{1,}/.test(region)) {
billing_region = "&billing_region="+region;
}
form_values = "wpsc_ajax_action=change_tax&form_id="+form_id+"&billing_country="+country+billing_region;
jQuery.post( 'index.php', form_values, function(returned_data) {
eval(returned_data);
if(jQuery("#shippingSameBilling").is(':checked')){
jQuery('.shipping_region').parent().parent().hide();
jQuery('.shipping_country_name').parent().parent().hide();
}
});
}
function set_shipping_country(html_form_id, form_id){
var shipping_region = '';
country = jQuery(("div#"+html_form_id+" select[class='current_country']")).val();
if(country == 'undefined'){
country = jQuery("select[title='billingcountry']").val();
}
region = jQuery(("div#"+html_form_id+" select[class='current_region']")).val();
if(/[\d]{1,}/.test(region)) {
shipping_region = "&shipping_region="+region;
}
form_values = {
wpsc_ajax_action: "change_tax",
form_id: form_id,
shipping_country: country,
shipping_region: region
}
jQuery.post( 'index.php', form_values, function(returned_data) {
eval(returned_data);
if(jQuery("#shippingSameBilling").is(':checked')){
jQuery('.shipping_region').parent().parent().hide();
jQuery('.shipping_country_name').parent().parent().hide();
}
});
}
jQuery(document).ready(function(){
jQuery('.wpsc_checkout_table input, .wpsc_checkout_table textarea').each(function(){
var real_value = jQuery(this).val();
value = jQuery('label[for="'+jQuery(this).attr('id')+'"]').html();
if(null != value){
value = value.replace(/\*<\/span>/i,'');
}
jQuery(this).inlineFieldLabel({label:jQuery.trim(value)});
if(real_value != '')
jQuery(this).val(real_value).removeClass('intra-field-label');
});
});
//Javascript for variations: bounce the variation box when nothing is selected and return false for add to cart button.
jQuery(document).ready(function(){
jQuery('.productcol, .textcol, .product_grid_item').each(function(){
jQuery('.wpsc_buy_button', this).click(function(){
jQuery(this).parents('form:first').find('select.wpsc_select_variation').each(function(){
if(jQuery(this).val() <= 0){
jQuery(this).css('position','relative');
jQuery(this).animate({'left': '-=5px'}, 50, function(){
jQuery(this).animate({'left': '+=10px'}, 100, function(){
jQuery(this).animate({'left': '-=10px'}, 100, function(){
jQuery(this).animate({'left': '+=10px'}, 100, function(){
jQuery(this).animate({'left': '-=5px'}, 50);
});
});
});
});
}
});
if(jQuery(this).parents('form:first').find('select.wpsc_select_variation[value="0"]:first').length)
return false;
});
});
});
jQuery(document).ready(function(){
jQuery('.attachment-gold-thumbnails').click(function(){
jQuery(this).parents('.imagecol:first').find('.product_image').attr('src', jQuery(this).parent().attr('rev'));
jQuery(this).parents('.imagecol:first').find('.product_image').parent('a:first').attr('href', jQuery(this).parent().attr('href'));
return false;
});
});
//MD5 function for gravatars
eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('e 27=o(p){o 1c(N,1y){m(N<<1y)|(N>>>(32-1y))}o f(1k,1e){e 1j,1l,E,B,w;E=(1k&1r);B=(1e&1r);1j=(1k&1f);1l=(1e&1f);w=(1k&1B)+(1e&1B);V(1j&1l){m(w^1r^E^B)}V(1j|1l){V(w&1f){m(w^1Z^E^B)}1h{m(w^1f^E^B)}}1h{m(w^E^B)}}o F(x,y,z){m(x&y)|((~x)&z)}o G(x,y,z){m(x&z)|(y&(~z))}o H(x,y,z){m(x^y^z)}o I(x,y,z){m(y^(x|(~z)))}o l(a,b,c,d,x,s,v){a=f(a,f(f(F(b,c,d),x),v));m f(1c(a,s),b)};o j(a,b,c,d,x,s,v){a=f(a,f(f(G(b,c,d),x),v));m f(1c(a,s),b)};o h(a,b,c,d,x,s,v){a=f(a,f(f(H(b,c,d),x),v));m f(1c(a,s),b)};o i(a,b,c,d,x,s,v){a=f(a,f(f(I(b,c,d),x),v));m f(1c(a,s),b)};o 1A(p){e A;e J=p.1g;e 1q=J+8;e 1D=(1q-(1q%1G))/1G;e 1m=(1D+1)*16;e t=1z(1m-1);e K=0;e q=0;24(q>>29;m t};o W(N){e 1n="",1o="",1p,M;1v(M=0;M<=3;M++){1p=(N>>>(M*8))&1X;1o="0"+1p.1U(16);1n=1n+1o.1V(1o.1g-2,2)}m 1n};o 1C(p){p=p.1W(/\\r\\n/g,"\\n");e u="";1v(e n=0;n1T)&&(c<25)){u+=D.C((c>>6)|26);u+=D.C((c&1s)|1i)}1h{u+=D.C((c>>12)|2c);u+=D.C(((c>>6)&1s)|1i);u+=D.C((c&1s)|1i)}}m u};e x=1z();e k,1t,1u,1x,1w,a,b,c,d;e Z=7,Y=12,19=17,L=22;e S=5,R=9,Q=14,P=20;e T=4,U=11,X=16,O=23;e 18=6,1b=10,1a=15,1d=21;p=1C(p);x=1A(p);a=2d;b=2b;c=2a;d=28;1v(k=0;k