(function(a){a.fn.addOption=function(){var e=function(k,n,q,m){var p=document.createElement("option");p.value=n,p.text=q;var j=k.options;var o=j.length;if(!k.cache){k.cache={};for(var l=0;l<o;l++){k.cache[j[l].value]=l}}if(typeof k.cache[n]=="undefined"){k.cache[n]=o}k.options[k.cache[n]]=p;if(m){p.selected=true}};var d=arguments;if(d.length==0){return this}var c=true;var b=false;var h,g,f;if(typeof(d[0])=="object"){b=true;h=d[0]}if(d.length>=2){if(typeof(d[1])=="boolean"){c=d[1]}else{if(typeof(d[2])=="boolean"){c=d[2]}}if(!b){g=d[0];f=d[1]}}this.each(function(){if(this.nodeName.toLowerCase()!="select"){return}if(b){for(var i in h){e(this,i,h[i],c)}}else{e(this,g,f,c)}});return this};a.fn.ajaxAddOption=function(k,h,j,f,i){if(typeof(k)!="string"){return this}if(typeof(h)!="object"){h={}}if(typeof(j)!="boolean"){j=true}this.each(function(){var b=this;a.getJSON(k,h,function(c){a(b).addOption(c,j);if(typeof f=="function"){if(typeof i=="object"){f.apply(b,i)}else{f.call(b)}}})});return this};a.fn.removeOption=function(){var m=arguments;if(m.length==0){return this}var c=typeof(m[0]);var l,h;if(c=="string"||c=="object"||c=="function"){l=m[0];if(l.constructor==Array){var g=l.length;for(var f=0;f<g;f++){this.removeOption(l[f],m[1])}return this}}else{if(c=="number"){h=m[0]}else{return this}}this.each(function(){if(this.nodeName.toLowerCase()!="select"){return}if(this.cache){this.cache=null}var b=false;var e=this.options;if(!!l){var i=e.length;for(var d=i-1;d>=0;d--){if(l.constructor==RegExp){if(e[d].value.match(l)){b=true}}else{if(e[d].value==l){b=true}}if(b&&m[1]===true){b=e[d].selected}if(b){e[d]=null}b=false}}else{if(m[1]===true){b=e[h].selected}else{b=true}if(b){this.remove(h)}}});return this};a.fn.sortOptions=function(d){var c=a(this).selectedValues();var b=typeof(d)=="undefined"?true:!!d;this.each(function(){if(this.nodeName.toLowerCase()!="select"){return}var i=this.options;var f=i.length;var h=[];for(var e=0;e<f;e++){h[e]={v:i[e].value,t:i[e].text}}h.sort(function(g,j){o1t=g.t.toLowerCase(),o2t=j.t.toLowerCase();if(o1t==o2t){return 0}if(b){return o1t<o2t?-1:1}else{return o1t>o2t?-1:1}});for(var e=0;e<f;e++){i[e].text=h[e].t;i[e].value=h[e].v}}).selectOptions(c,true);return this};a.fn.selectOptions=function(k,m){var c=k;var l=typeof(k);if(l=="object"&&c.constructor==Array){var h=this;a.each(c,function(){h.selectOptions(this,m)})}var f=m||false;if(l!="string"&&l!="function"&&l!="object"){return this}this.each(function(){if(this.nodeName.toLowerCase()!="select"){return this}var b=this.options;var d=b.length;for(var e=0;e<d;e++){if(c.constructor==RegExp){if(b[e].value.match(c)){b[e].selected=true}else{if(f){b[e].selected=false}}}else{if(b[e].value==c){b[e].selected=true}else{if(f){b[e].selected=false}}}}});return this};a.fn.copyOptions=function(e,f){var c=f||"selected";if(a(e).size()==0){return this}this.each(function(){if(this.nodeName.toLowerCase()!="select"){return this}var b=this.options;var d=b.length;for(var g=0;g<d;g++){if(c=="all"||(c=="selected"&&b[g].selected)){a(e).addOption(b[g].value,b[g].text)}}});return this};a.fn.containsOption=function(k,m){var c=false;var l=k;var h=typeof(l);var f=typeof(m);if(h!="string"&&h!="function"&&h!="object"){return f=="function"?this:c}this.each(function(){if(this.nodeName.toLowerCase()!="select"){return this}if(c&&f!="function"){return false}var b=this.options;var d=b.length;for(var e=0;e<d;e++){if(l.constructor==RegExp){if(b[e].value.match(l)){c=true;if(f=="function"){m.call(b[e],e)}}}else{if(b[e].value==l){c=true;if(f=="function"){m.call(b[e],e)}}}}});return f=="function"?this:c};a.fn.selectedValues=function(){var b=[];this.selectedOptions().each(function(){b[b.length]=this.value});return b};a.fn.selectedTexts=function(){var b=[];this.selectedOptions().each(function(){b[b.length]=this.text});return b};a.fn.selectedOptions=function(){return this.find("option:selected")}})(jQuery);function recalcCGtotal(){var e=0;var f=parseFloat($("#guseprice").val());var d=parseFloat($("#ogcount").val());var a="";while(e<d){if($("#ctype_"+e).val()=="rd"){f=f+parseFloat($("#val_cfg_"+e).val());if($("#useimg_cfg_"+e).val()=="1"){a=a+"&"+$("#gid_cfg_"+e).val()+"="+$("#oid_cfg_"+e).val()}}else{if($("#ctype_"+e).val()=="cb"){var c=0;var b=parseFloat($("#occount_"+c).val());while(c<b){if($("#cb_"+e+"_"+c).is(":checked")){f=f+parseFloat($("#val_cfg_"+e+"_"+c).val());if($("#useimg_cfg_"+e).val()=="1"){a=a+"&"+$("#gid_cfg_"+e+"_"+c).val()+"="+$("#oid_cfg_"+e+"_"+c).val()}}c++}}}e++}$("#prodPrice").html(addCommas(f));$("#prodVatPrice").html(addCommas(f/parseFloat($("#vatRate").val())));$("#prodPrice").effect("highlight",{},3000);checkImgChange(a)}function checkImgChange(a){$.ajax({type:"POST",url:"/ajax/cf_multimg.html",data:({thestring:a,sid:$("#stock_id").val()}),cache:false,success:function(d){if(d=="nowt"){var b="/images/1/products/"+$("#defimgname").val()+"_std."+$("#defimgtype").val();var c="/images/1/products/"+$("#defimgname").val()+"."+$("#defimgtype").val()}else{var b="/images/arcadeconfig/mainprod/"+d;var c=b.replace("_std","")}if($("#std_pic").attr("src")!=b){$("#picgal0").attr("href",c);$("#std_pic").fadeOut("medium",function(){$(this).attr({src:b}).fadeIn("slow")})}}})}$(document).ready(function(){$(".cfgcb").change(function(){recalcCGtotal()});$(".multicfg").change(function(){var d=$(this).val();var b=String($(this).attr("id")).substring(8);var c=$("#var_cfg_"+b+" :selected").text();$("#oid_cfg_"+b).val(d);var a="/ajax/cfoption_image.html?coid="+d;$.ajax({type:"GET",url:a,dataType:"xml",async:false,cache:false,success:function(e){$(e).find("thisdata").each(function(){var h=$(this).find("imgurl").text();var g=$(this).find("sellprice").text();if(h=="nowt"){$("#optPicSpan_"+b).hide()}else{$("#optPicSpan_"+b).show();$("#optPicLink_"+b).attr("href",h);$("#optPicLink_"+b).attr("name",c)}$("#val_cfg_"+b).val(g);$(this).find("ddoption").each(function(){$("#var_cfg_"+b).addOption($(this).attr("id"),$(this).text())});$("#var_cfg_"+b).selectOptions(d);var i=$(this).find("width").text();var f=$(this).find("height").text();var k=$(this).find("depth").text();var j=$(this).find("weight").text();if(i>0){$("#s_width_cm").html(i)}if(f>0){$("#s_height_cm").html(f)}if(k>0){$("#s_depth_cm").html(k)}if(j>0){$("#s_weight_cm").html(j)}})}});recalcCGtotal()});$(".addConfigCart").click(function(){var c="/addproduct.html?pid="+$("#prod_id").val()+"&varrr=none&isconfig=true&dellcode="+$("#del_select").val()+"&quantity="+$("#quantity").val()+"&dellextra=";if($("#del_extra:checked").val()=="on"){c=c+"1"}else{c=c+"0"}var e=1;var g=parseFloat($("#conf_basecost").val());var i=0;while(e<(parseFloat($("#ogcount").val())+1)){if($("#ctype_"+(e-1)).val()=="rd"){c=c+"&og_rd_"+e+"="+$("#oid_cfg_"+(e-1)).val();i++}else{var d=0;var l=0;var f=parseFloat($("#occount_"+(e-1)).val());while(d<f){if($("#cb_"+(e-1)+"_"+d).is(":checked")){c=c+"&og_cb_"+e+"_"+d+"="+$("#oid_cfg_"+(e-1)+"_"+d).val();l++;i++}d++}c=c+"&og_cb_count_"+e+"="+l}e++}c=c+"&ogcount="+$("#ogcount").val()+"&totParams="+i;if($("#ai_count").length>0){var b=$("#ai_count").val();var h=0;var a=0;while(h<b){if($("#ai_"+h).is(":checked")){a=a+1;c=c+"&aip_"+a+"="+$("#ai_pid_"+h).val();if($("#ai_var_"+h).length>0){c=c+"&aip_v_"+a+"="+$("#ai_var_"+h).val()}}h=h+1}if(a>0){c=c+"&ai_count="+a}}$("#innercart").slideToggle("slow");$.get(c,function(j){$("#innercart").html(j);$("#innercart").slideToggle("slow")});return false})});
