function rsplit(_s,_d){var a=new Array();var i=0;while(_s != null && _s.length){if((p=_s.indexOf(_d))!=-1){p=_s.indexOf(_d)+_d.length;a[i++]=_s.substring(0,(p-_d.length));_s=_s.substring(p,_s.length);}else{a[i++]=_s;_s='';}}return a;} function loadjscssfile( _filename, _filetype ) { if(_filetype=="js") { var _fileref = document.createElement('script'); _fileref.setAttribute("type","text/javascript"); _fileref.setAttribute("src", _filename); } else if ( _filetype == "css" ) { var _fileref = document.createElement("link"); _fileref.setAttribute("rel", "stylesheet"); _fileref.setAttribute("type", "text/css"); _fileref.setAttribute("href", _filename); } if( typeof _fileref != "undefined" ) document.getElementsByTagName("head")[0].appendChild( _fileref ); } var jQueryScriptOutputted = false; function initJQuery() { if (typeof(jQuery) == 'undefined' ) { if (!jQueryScriptOutputted) { jQueryScriptOutputted = true; loadjscssfile( "http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js", "js"); loadjscssfile( "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css", "css"); loadjscssfile( "http://astrocirta.com/wp-content/plugins/wp-viral-checkout/style/fb-style-jquery-ui.css", "css"); loadjscssfile( "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js", "js"); } } else { loadjscssfile( "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css", "css"); loadjscssfile( "http://astrocirta.com/wp-content/plugins/wp-viral-checkout/style/fb-style-jquery-ui.css", "css"); loadjscssfile( "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js", "js"); } } initJQuery(); jQuery(function() { jQuery("body").prepend("
"); var pIds = ''; jQuery("input[id=item_number]").each(function() { pIds += (jQuery(this).val() + ','); aform = jQuery(this).parent(); aform.find('input[type=image]').css("cursor", "default"); aform.attr("onsubmit", "return false;") .append(' Preparing...'); }); jQuery.ajaxSetup({cache: false}); jQuery.ajax({ url: "http://astrocirta.com/wp-admin/admin-ajax.php", cache: false, dataType: "json", contentType: "application/json", data: { action : "wpsc_get_products_fbdiscount", pIds: pIds }, success: function(data) { info = rsplit( data.data, ";" ); jQuery("form[target=paypal]").each(function() { var _wpvc_onsubmit = false; aform = jQuery(this); aform.find('.spin-img, .spin-text').remove(); aform.attr("onsubmit", ""); aform.find('input[type=image]').css("cursor", "pointer").click(function() { _aform = jQuery(this).parent(); _aform.attr("target", ""); if( !_wpvc_onsubmit ) { product_id = _aform.find("input[id=item_number]").val(); fbdiscount = 0; product_name = ''; var element = null; for( var i=0; (element = info[i]) != null; i++ ) { //alert('element = '+element); if( element != "" && fbdiscount == 0 ) { discount = rsplit( element, ":" ); if( product_id == discount[0] ) { fbdiscount = discount[1]; product_name = discount[2]; } } } if( fbdiscount == 0 ) return true; FB.init({appId: '158602437576113', status: true, cookie: true}); var publish = { method: 'feed', message: '', name: "Astro Cirta Search Engine Marketing", caption: "I just bought stuff from Astro Cirta to help my websites rank better! Check it out!", description: (product_name + ' (1)'), link: 'http://astrocirta.com', picture: 'http://astrocirta.com/wp-content/uploads/2012/01/smalllogo.png', actions: [ { name: 'wpviralcheckout', link: 'http://astrocirta.com' } ], user_message_prompt: '', display:'popup' }; jQuery( "#wpvc-dialog-confirm" ) .html("Receive $" + fbdiscount + " Off When You Share This Purchase On Facebook!
Do you want money off this purchase?") .dialog({ resizable: false, width:380, height:220, modal: false, buttons: { "Yes": function() { jQuery( this ).dialog( "close" ); FB.ui(publish, callback); }, "No": function() { jQuery( this ).html('
Now Redirecting To Payment...
'); jQuery( ".ui-dialog-title" ).html("Wait a moment, please"); jQuery( ".ui-dialog-buttonpane" ).hide(); //jQuery( this ).dialog( "close" ); //_wpvc_onsubmit = true; // _aform.find('input[type=image]').trigger("click"); } } }); function callback(response) { jQuery( "#wpvc-dialog-confirm" ) .html('
Now Redirecting To Payment...
') .dialog({ title: 'Wait a moment, please', autoOpen: true, resizable: false, width:380, height:220, modal: false, }); jQuery( ".ui-dialog-buttonpane" ).hide(); if( response && response.post_id ) { _aform.append(""); _wpvc_onsubmit = true; _aform.submit(); } else { _wpvc_onsubmit = true; _aform.submit(); } } return false; } else { _wpvc_onsubmit = false; return true; } }); }); } }); });