var ajaxFileProcessingPath="/shop/_ajaxProductProcessor.php";function loadSubCategoriesForCategoryalert(cID){if(document.getElementById('subCategories'+cID).innerHTML.toLowerCase()=="<li><a>please wait</a></li>"){var param="?action=load_ajax_sub_categories";var data="categories_id="+cID;$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){document.getElementById('subCategories'+cID).innerHTML=msg;}});}}
function verifyAdminCompetitionEntryPassword(passVal,cID){var param="?action=verify_ajax_admin_competition_password";var data="competitions_id="+cID+"&competitions_password="+passVal;$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){if(msg!="")document.getElementById("submitCompetitionEntryByAdmin").innerHTML=msg;executeJavascriptInIt(msg);}});}
function ajaxLoadFullShoppingCart(parameterList){var param="?action=update_ajax_product";var data=parameterList;$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){document.getElementById("mainShoppingCartPageShoppingCartContents").innerHTML=msg;executeJavascriptInIt(msg);}});}
function ajaxRemoveProduct(productId,dealId,deal_id){var param="?action=remove_ajax_product";var data="products_id[]="+productId+"&cart_delete[]="+productId+"&deal_id="+deal_id;$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){document.getElementById("shopping_cart").innerHTML=msg;executeJavascriptInIt(msg);showShoppingCartProcessing();if(dealId!='')showDealCurrentAppliedStatusMessage(dealId);}});}
function ajaxRemoveAllProducts(productId,dealId,deal_id){var param="?action=remove_ajax_product_all";var data=""
var all_products=productId.split("&");for(i=1;i<all_products.length;i++)
data+="&products_id[]="+all_products[i]+"&cart_delete[]="+all_products[i]+"&deal_id="+deal_id;$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){document.getElementById("shopping_cart").innerHTML=msg;executeJavascriptInIt(msg);showShoppingCartProcessing();if(dealId!='')showDealCurrentAppliedStatusMessage(dealId);}});}
function ajaxAddProductWithDeal(listing_type,dealId,productId,productQty,fromDeal,flyingProductID){var param="?action=add_ajax_product_with_deal";var data="products_id="+productId+"&qty"+productId+"="+productQty;if(dealId!="0")data+="&id[2]="+dealId;if(fromDeal!='')data+="&deal_id="+fromDeal;if(listing_type!='')data+="&listing_type="+listing_type;data+="&flyingProductID="+flyingProductID;if(fromDeal==getQuerystring("deal_id",""))data+="&navigate_to_deal=NO";$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){if(document.getElementById("mainShoppingCartPageShoppingCartContents"))loadRealFinalShoppingCart();if(document.getElementById("shopping_cart"))document.getElementById("shopping_cart").innerHTML=msg;executeJavascriptInIt(msg);setTimeout('hideDealThankYouAndShowCartButton("false", "'+productId+'", "'+listing_type+'")',2000);if(dealId!="0")showDealCurrentAppliedStatusMessage(dealId);}});}
function ajaxLoadLeftColumnShoppingcart(showDelete){var param="?action=load_left_ajax_shopping_cart";var data="checkout_step="+showDelete;$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){if(document.getElementById("shopping_cart"))document.getElementById("shopping_cart").innerHTML=msg;executeJavascriptInIt(msg);}});}
function showDealCurrentAppliedStatusMessage(dealId){if(document.getElementById("dealsProductStatuscountText")){var param="?action=show_ajax_deal_progress_so_far";var data="deal_id="+dealId
$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){if(msg!="")document.getElementById("dealsProductStatuscountText").innerHTML=msg;if((msg!="")&&(msg!="&nbsp;")){funElementDisplayStyle('dealsProductStatuscountText','');}else{funElementDisplayStyle('dealsProductStatuscountText','none');}}});}}
function hideDealThankYouAndShowCartButton(doProcessIT,productId,listing_type){if(doProcessIT){if(document.getElementById("tdNoAddToCartButton1For"+listing_type+productId))document.getElementById("tdNoAddToCartButton1For"+listing_type+productId).style.display="none";if(document.getElementById("tdAddToCartButton1For"+listing_type+productId))document.getElementById("tdAddToCartButton1For"+listing_type+productId).style.display="";if(document.getElementById("trThankDealsListingRowFor"+listing_type+productId))document.getElementById("trThankDealsListingRowFor"+listing_type+productId).style.display="none";}else{setTimeout('hideDealThankYouAndShowCartButton("'+(!doProcessIT)+'", "'+productId+'", "'+listing_type+'")',2000);}}
function hideSourceCodeThankYouAndShowAddCartButton(doProcessIT){if(doProcessIT){funShowHideElement('trShowSourceCodeThanks',false);funShowHideElement('tdShowSourceCodeAddButton',true);}else{setTimeout('hideSourceCodeThankYouAndShowAddCartButton("'+(!doProcessIT)+'")',2000);}}
function ajaxAddProduct(listing_type,productId,productQty,fromDeal,flyingProductID){if(document.getElementById("qty"+productId))productQty=document.getElementById("qty"+productId).value;var param="?action=add_ajax_product";var data="products_id="+productId+"&qty"+productId+"="+productQty
if(fromDeal!='')data=data+"&deal_id="+fromDeal;if(listing_type!='')data+="&listing_type="+listing_type;data+="&flyingProductID="+flyingProductID;$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){document.getElementById("shopping_cart").innerHTML=msg;executeJavascriptInIt(msg);}});}
function ajaxAddSourceCode(sourceCode){var param="?action=add_ajax_source_code";var data="source_code="+sourceCode;$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){document.getElementById("shopping_cart").innerHTML=msg;executeJavascriptInIt(msg);setTimeout('hideSourceCodeThankYouAndShowAddCartButton("false")',2000);}});}
function showProductThankYouAndHideCartButton(listing_type,productId){if(document.getElementById("tdNoAddToCartButton1For"+listing_type+productId))document.getElementById("tdNoAddToCartButton1For"+listing_type+productId).style.display="";if(document.getElementById("tdAddToCartButton1For"+listing_type+productId))document.getElementById("tdAddToCartButton1For"+listing_type+productId).style.display="none";if(document.getElementById("trThankDealsListingRowFor"+listing_type+productId))document.getElementById("trThankDealsListingRowFor"+listing_type+productId).style.display="";setTimeout('hideDealThankYouAndShowCartButton("false", "'+productId+'", "'+listing_type+'")',2000);}
function ajaxAddProductWithoutCart(productId){if(document.getElementById("tdAddToCartButton1For"+productId))document.getElementById("tdAddToCartButton1For"+productId).style.display="none";if(document.getElementById("tdNoAddToCartButton1For"+productId))document.getElementById("tdNoAddToCartButton1For"+productId).style.display="";document.getElementById("trWaiting"+productId).style.display="";var productQty=1;if(document.getElementById("qty"+productId))productQty=document.getElementById("qty"+productId).value;var param="?action=add_ajax_product";var data="products_id="+productId+"&qty"+productId+"="+productQty
$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){document.getElementById("trWaiting"+productId).style.display="none";document.getElementById("trThankDealsListingRowFor"+productId).style.display="";hideDealThankYouAndShowCartButton(false,productId,"")
document.getElementById("shopping_cart").innerHTML=msg;executeJavascriptInIt(msg);}});}
function ajaxLoadProductsDealsForSelectedProduct(listing_type,productId,fromDeal,flyingProductID){var param="?action=add_ajax_product_load_deals";var data="products_id="+productId;if(fromDeal!='')data=data+"&deal_id="+fromDeal;if(listing_type!='')data+="&listing_type="+listing_type;data+="&flyingProductID="+flyingProductID;if(document.getElementById("trWaitDealsListingRowFor"+listing_type+productId))document.getElementById("trWaitDealsListingRowFor"+listing_type+productId).style.display="";$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){document.getElementById("tdDealsListingFor"+listing_type+productId).innerHTML=msg;executeJavascriptInIt(msg);}});}
function setProductListingView(nView){var param="?action=save_ajax_product_listing_view";var data="listing_view="+nView;setCookie('listing_view',nView,'12');$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){location.href=location.href;}});}
function setTutionListingView(nView){var param="?action=save_ajax_tution_listing_view";var data="tution_listing_view_expired="+(nView?1:0);setCookie('tution_listing_view_expired',(nView?1:0),'12');$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){location.href=location.href;}});}
function setExhibitionListingView(nView){var param="?action=save_ajax_exhibition_listing_view";var data="exhibition_listing_view_expired="+(nView?1:0);setCookie('exhibition_listing_view_expired',(nView?1:0),'12');$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){location.href=location.href;}});}
function redeemVoucherCode(iteration,voucherCode,display){var param="";var data="voucher_code="+voucherCode+"&action=add_voucher&display="+display;$.ajax({type:"POST",url:"_ajaxVoucherProcessor.php"+param,data:data,success:function(msg){if(msg.indexOf('N/A')!=-1){if(display)alert('Invalid/Used Voucher');}else{removeCode('voucher'+iteration);}
executeJavascriptInIt(msg);}});}
function removeVoucherCode(iteration,voucherCode){var param="";var data="voucher_code="+voucherCode+"&action=remove_voucher";$.ajax({type:"POST",url:"_ajaxVoucherProcessor.php"+param,data:data,success:function(msg){showCode('voucher'+iteration);executeJavascriptInIt(msg);}});}
function fun_saa_affiliate_track(){var param="?action=affiliate_" + var_saa_log;var data="referralURL="+var_saa_referral_url+"&currentURL="+var_saa_current_url+"&currentIP="+var_saa_current_ip+"&currentSessionID="+var_saa_session_id+"&action=affiliate_"+var_saa_log;$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){}});}
function ajaxLoadAddressListFromPostCode(postcode,waitingMessage,loadingTR,loadingTD){var param="?action=load_ajax_address_list";var data="postcode="+postcode+"&loadingTR="+loadingTR;if(document.getElementById(loadingTD))document.getElementById(loadingTD).innerHTML=waitingMessage;if(document.getElementById(loadingTR))document.getElementById(loadingTR).style.display="";$.ajax({type:"POST",url:"/webservice/GetAddressSelectList.php"+param,data:data,success:function(msg){if(document.getElementById(loadingTD))document.getElementById(loadingTD).innerHTML=msg;executeJavascriptInIt(msg);}});}
function fillAddressToFields(form,address,loadingTR){var addressFields=address.split(",");var totalAddressParts=addressFields.length;if(totalAddressParts>=3){form.city.value=addressFields[totalAddressParts-3].trim();form.state.value=addressFields[totalAddressParts-2].trim();form.postcode.value=addressFields[totalAddressParts-1].trim();var streetAddress=addressFields[0];for(var i=1;i<totalAddressParts-3;i++){streetAddress=streetAddress+", "+addressFields[i];}
form.street_address.value=streetAddress;if((form.city.value==form.street_address.value)&&(form.state.value.toUpperCase()==form.state.value)){form.city.value=form.state.value;form.state.value="";}
addressFields=streetAddress.split(",");totalAddressParts=addressFields.length;streetAddress="";var addressPartsMidIndex=totalAddressParts/2;if(Math.floor(totalAddressParts/2)==addressPartsMidIndex)addressPartsMidIndex=addressPartsMidIndex-1;addressPartsMidIndex=Math.floor(addressPartsMidIndex);for(var i=0;i<=addressPartsMidIndex;i++){if(streetAddress!="")streetAddress=streetAddress+", ";streetAddress=streetAddress+addressFields[i].trim();}
form.street_address.value=streetAddress;streetAddress="";for(var i=addressPartsMidIndex+1;i<totalAddressParts;i++){if(streetAddress!="")streetAddress=streetAddress+", ";streetAddress=streetAddress+addressFields[i].trim();}
form.suburb.value=streetAddress;if(document.getElementById(loadingTR))document.getElementById(loadingTR).style.display="none";}}
function loadCurrentPhoneShopAdverts(loadingTR,PHONESHOP){var param="?action=ajax_load_current_phone_shop_adverts&load=true&PHONESHOP="+PHONESHOP;var data="";$.ajax({type:"POST",url:ajaxFileProcessingPath+param,data:data,success:function(msg){if(document.getElementById(loadingTR))document.getElementById(loadingTR).innerHTML=msg;executeJavascriptInIt(msg);}});}
function loadCurrentPhoneShopCustomerSearchOnCriteria(loadingTR,page,search_membership_number,search_post_code,search_first_name,search_email_address,search_last_name){document.getElementById(loadingTR).innerHTML="Please wait while we are searching customer database";document.getElementById(loadingTR).style.display="";var param="?action=ajax_load_current_phone_shop_customer_search&page="+page;var data="search_membership_number="+escape(search_membership_number);data+="&search_post_code="+escape(search_post_code)
data+="&search_first_name="+escape(search_first_name)
data+="&search_email_address="+escape(search_email_address)
data+="&search_last_name="+escape(search_last_name)
$.ajax({type:"GET",url:ajaxFileProcessingPath+param,data:data,success:function(msg){if(document.getElementById(loadingTR))document.getElementById(loadingTR).innerHTML=msg;}});}
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"");}
String.prototype.ltrim=function(){return this.replace(/^\s+/,"");}
String.prototype.rtrim=function(){return this.replace(/\s+$/,"");}
function executeJavascriptInIt(productItems){var productItemsArray=productItems.split('<script language="javascript">');for(var i=1;i<productItemsArray.length;i++){eval((productItemsArray[i].split('</script>'))[0]);}}
function funShowHideElement(elementID,show){if(!show){funElementDisplayStyle(elementID,'none');}else{funElementDisplayStyle(elementID,'');}}
function funElementDisplayStyle(elementID,displayStyle){if(document.getElementById(elementID)){document.getElementById(elementID).style.display=displayStyle;}}
function getQuerystring(key,default_)
{if(default_==null)default_="";key=key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regex=new RegExp("[\\?&]"+key+"=([^&#]*)");var qs=regex.exec(window.location.href);if(qs==null)
return default_;else
return qs[1];}
