var ProductIndex=0;var SelectGold=0;var PacSelect=0;$(document).ready(function(){$.post("scripts/php/checksession.php",{cart:"check"},function(a){});$.post("scripts/php/cart.php",{bfunc:"checkcurrency"},function(a){});$(window).bind("load",function(){$("#basketitems").ReturnCartCount();ReturnCurrency(pgeIndex);if(ProductIndex==2){$(".steporder .txtbox").eq(0).show().parent().parent().css({backgroundPosition:"right -65px"});$(".steporder .txtbox").change(function(){thisVal=$(this).val();DefaultCurrency(thisVal);$(this).parent().parent().css({backgroundPosition:"right top"});$("#atb").ReturnPrice2(thisVal)})}else{if(ProductIndex!=2){$(".steporder .txtbox").hide().eq(3).show();ReturnSkiregion();$(".steporder .txtbox").eq(3).change(function(){$(".steporder .txtbox").eq(2).show().parent().parent().css({backgroundPosition:"right -65px"})});$(".steporder .txtbox").eq(2).change(function(){thisVal=$(this).val();PacSelect=0;if(thisVal==4||thisVal==13||thisVal==25||thisVal==28){PacSelect=0;$(".steporder .txtbox").eq(1).show().parent().parent().css({backgroundPosition:"right -65px"});$(".steporder .txtbox").eq(0).show().parent().parent().css({backgroundPosition:"right bottom"});$(".steporder .txtbox").eq(0).hide();SelectGold=1}else{if(thisVal==5||thisVal==6||thisVal==26||thisVal==27){PacSelect=thisVal;$(".steporder .txtbox").eq(1).show().parent().parent().css({backgroundPosition:"right -65px"});$(".steporder .txtbox").eq(0).show().parent().parent().css({backgroundPosition:"right bottom"});$(".steporder .txtbox").eq(0).hide()}else{$(".steporder .txtbox").eq(1).show().parent().parent().css({backgroundPosition:"right -65px"});SelectGold=0;HideAtb()}}});$(".steporder .txtbox").eq(1).change(function(){thisVal=$(this).val();DefaultCurrency(thisVal);if(PacSelect==5||PacSelect==6){elmName=$(".steporder .txtbox");$("#atb").ReturnPrice(elmName.eq(2).val(),elmName.eq(1).val(),elmName.eq(0).val())}else{if(SelectGold==0){$(".steporder .txtbox").eq(0).show().parent().parent().css({backgroundPosition:"right -65px"})}else{elmName=$(".steporder .txtbox");$("#atb").ReturnPrice(elmName.eq(2).val(),elmName.eq(1).val(),elmName.eq(0).val())}}});$(".steporder .txtbox").eq(0).change(function(){if(SelectGold==0){elmName=$(".steporder .txtbox");$("#atb").ReturnPrice(elmName.eq(2).val(),elmName.eq(1).val(),elmName.eq(0).val())}});$("#skiregion").change(function(){selRegion=$(this).val();if(selRegion!="Select Region"){$("#package").ReturnPackage(selRegion,function(){$("#resort").ReturnResorts(selRegion)})}});$("#buyform .txtbox").change(function(){$(this).parent().parent().css({backgroundPosition:"right top"})})}}if(pgeIndex==7){ReturnPostageRegion();LoadCartInfo();$("#postageregion").change(function(){thisVal=$(this).val();ReturnTots2(thisVal)});$("#buycurrency").change(function(){thisVal=$(this).val();DefaultCurrency(thisVal,function(){window.location="basket.html"})});$("#cart").submit(function(){return false});$("#cart #checkout").click(function(){window.location="scripts/php/checkout.php";return false});$("#cart #amendbutton").click(function(){remArr="";$("#cart .itemcheckbox").each(function(){thisVal=$(this).val();if($(this).attr("checked")){remArr=remArr+thisVal+","}});if(remArr!=""){$.post("scripts/php/cart.php",{bfunc:"amendcart",poArr:remArr},function(a){window.location="basket.html"})}})}$("#buyform").submit(function(){elmName=$(".steporder .txtbox");if(ProductIndex==2){$.post("scripts/php/cart.php",{bfunc:"atb",p1:ProductIndex},function(a){if(a==1){window.location="basket.html"}})}else{if(ProductIndex!=2){optionID=elmName.eq(2).val();if(PacSelect==5||PacSelect==6){resortid=62}else{if(SelectGold==1){resortid=62}else{resortid=elmName.eq(0).val()}}$.post("scripts/php/cart.php",{bfunc:"atb",p1:ProductIndex,p2:optionID,p3:resortid},function(a){if(a==1){window.location="basket.html"}})}}return false})})});$(function(){$.fn.ReturnCartCount=function(){elmName=$(this);$.post("scripts/php/cart.php",{bfunc:"returncount"},function(a){elmName.text(a)})};$.fn.ReturnPackage=function(a,b){elmName=$(this);$.post("scripts/php/cart.php",{bfunc:"returnpackage",regid:a,prodId:ProductIndex},function(c){elmName.html(c);if(b!=undefined){b()}})};$.fn.ReturnResorts=function(a){elmName=$(this);$.post("scripts/php/cart.php",{bfunc:"returnresorts",regid:a},function(b){elmName.html(b)})};$.fn.ReturnPrice=function(b,c,a){elmName=$(this);$.post("scripts/php/cart.php",{bfunc:"returnprice",p1:b,p2:c,p3:a,p4:SelectGold},function(d){elmName.html(d);elmName.fadeIn(300)})};$.fn.ReturnPrice2=function(a){elmName=$(this);$.post("scripts/php/cart.php",{bfunc:"returnprice2",p1:a},function(b){elmName.html(b);elmName.fadeIn(300)})}});function ReturnSkiregion(){$.post("scripts/php/cart.php",{bfunc:"skiregion"},function(a){$("#skiregion").html(a)})}function ReturnCurrency(a){$.post("scripts/php/cart.php",{bfunc:"returncurrency",pgeindex:a},function(b){$("#buycurrency").html(b)})}function HideAtb(){$("#buyform #atb").fadeOut(300,function(){$(this).empty()})}function LoadCartInfo(){$.post("scripts/php/cart.php",{bfunc:"returncartinfo"},function(a){spl1=a.split("{subtot}");$("#backetproductinfo").append(spl1[0]);$(".subtotal").html(spl1[1])})}function DefaultCurrency(a,b){$.post("scripts/php/cart.php",{bfunc:"setcurrency",curIndex:a},function(c){if(b!=undefined){b()}})}function ReturnPostageRegion(){$.post("scripts/php/cart.php",{bfunc:"postageregion"},function(a){$("#postageregion").html(a);ReturnTots()})}function ReturnTots(a){poVal=$("#postageregion option").eq(0).val();if(poVal==0){$.post("scripts/php/cart.php",{bfunc:"calccart",calcpost:poVal,postIn:a},function(b){slp1=b.split("{pos}");$(".postage").html(slp1[1]);$(".totalprice").html(slp1[0]);if(slp1[2]==0){$("#cart #checkout").hide();$("#cart #amendbutton").hide()}else{$("#cart #checkout").show();$("#cart #amendbutton").show()}})}}function ReturnTots2(a){$.post("scripts/php/cart.php",{bfunc:"calccart1",postIn:a},function(b){slp1=b.split("{pos}");$(".postage").html(slp1[1]);$(".totalprice").html(slp1[0]);if(slp1[2]==0){$("#cart #checkout").hide();$("#cart #amendbutton").hide()}else{$("#cart #checkout").show();$("#cart #amendbutton").show()}})};