;(function($){var _remove=$.fn.remove;$.fn.remove=function(){$("*",this).add(this).triggerHandler("remove");return _remove.apply(this,arguments);};function isVisible(element){function checkStyles(element){var style=element.style;return(style.display!='none'&&style.visibility!='hidden');}
var visible=checkStyles(element);(visible&&$.each($.dir(element,'parentNode'),function(){return(visible=checkStyles(this));}));return visible;}
$.extend($.expr[':'],{data:function(a,i,m){return $.data(a,m[3]);},tabbable:function(a,i,m){var nodeName=a.nodeName.toLowerCase();return(a.tabIndex>=0&&(('a'==nodeName&&a.href)||(/input|select|textarea|button/.test(nodeName)&&'hidden'!=a.type&&!a.disabled))&&isVisible(a));}});$.keyCode={BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38};function getter(namespace,plugin,method,args){function getMethods(type){var methods=$[namespace][plugin][type]||[];return(typeof methods=='string'?methods.split(/,?\s+/):methods);}
var methods=getMethods('getter');if(args.length==1&&typeof args[0]=='string'){methods=methods.concat(getMethods('getterSetter'));}
return($.inArray(method,methods)!=-1);}
$.widget=function(name,prototype){var namespace=name.split(".")[0];name=name.split(".")[1];$.fn[name]=function(options){var isMethodCall=(typeof options=='string'),args=Array.prototype.slice.call(arguments,1);if(isMethodCall&&options.substring(0,1)=='_'){return this;}
if(isMethodCall&&getter(namespace,name,options,args)){var instance=$.data(this[0],name);return(instance?instance[options].apply(instance,args):undefined);}
return this.each(function(){var instance=$.data(this,name);(!instance&&!isMethodCall&&$.data(this,name,new $[namespace][name](this,options)));(instance&&isMethodCall&&$.isFunction(instance[options])&&instance[options].apply(instance,args));});};$[namespace][name]=function(element,options){var self=this;this.widgetName=name;this.widgetEventPrefix=$[namespace][name].eventPrefix||name;this.widgetBaseClass=namespace+'-'+name;this.options=$.extend({},$.widget.defaults,$[namespace][name].defaults,$.metadata&&$.metadata.get(element)[name],options);this.element=$(element).bind('setData.'+name,function(e,key,value){return self._setData(key,value);}).bind('getData.'+name,function(e,key){return self._getData(key);}).bind('remove',function(){return self.destroy();});this._initialized();};$[namespace][name].prototype=$.extend({},$.widget.prototype,prototype);$[namespace][name].getterSetter='option';};$.widget.prototype={_initialized:function(){},destroy:function(){this.element.removeData(this.widgetName);},option:function(key,value){var options=key,self=this;if(typeof key=="string"){if(value===undefined){return this._getData(key);}
options={};options[key]=value;}
$.each(options,function(key,value){self._setData(key,value);});},_getData:function(key){return this.options[key];},_setData:function(key,value){this.options[key]=value;if(key=='disabled'){this.element[value?'addClass':'removeClass'](this.widgetBaseClass+'-disabled');}},enable:function(){this._setData('disabled',false);},disable:function(){this._setData('disabled',true);},_trigger:function(type,e,data){var eventName=(type==this.widgetEventPrefix?type:this.widgetEventPrefix+type);e=e||$.event.fix({type:eventName,target:this.element[0]});return this.element.triggerHandler(eventName,[e,data],this.options[type]);}};$.widget.defaults={disabled:false};$.ui={plugin:{add:function(module,option,set){var cbgPrototype=$.ui[module].prototype;for(var i in set){cbgPrototype.plugins[i]=cbgPrototype.plugins[i]||[];cbgPrototype.plugins[i].push([option,set[i]]);}},call:function(instance,name,args){var set=instance.plugins[name];if(!set){return;}
for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args);}}}},cssCache:{},hasScroll:function(e,a){if($(e).css('overflow')=='hidden'){return false;}
var scrollDirection=(a&&a=='left')?'scrollLeft':'scrollTop',has=false;if(e[scrollDirection]>0){return true;}
e[scrollDirection]=1;has=(e[scrollDirection]>0);e[scrollDirection]=0;return has;}};$.ui.mouse={_initialiseMouseEvents:function(){var self=this;this.element.bind('mousedown.'+this.widgetName,function(e){return self._mouseClickcbg(e);});if($.browser.msie){this._noSelectText=this.element.attr('unselectable');this.element.attr('unselectable','on');}
this.started=false;},_mouseClickcbg:function(e){(this._mouseInMotioncbg&&this._mouseUpEvent(e));this._mouseDownEvent=e;var self=this,btnIsLeft=(e.which==1),elIsCancel=(typeof this.options.cancel=="string"?$(e.target).parents().add(e.target).filter(this.options.cancel).length:false);if(!btnIsLeft||elIsCancel||!this._CapturemouseEvent(e)){return true;}
this.cbgMouseDelay=!this.options.delay;if(!this.cbgMouseDelay){this._mouseDelayTimer=setTimeout(function(){self.cbgMouseDelay=true;},this.options.delay);}
if(this._findMouseDistance(e)&&this._cbgMouseDelay(e)){this._mouseInMotioncbg=(this._mouseStart(e)!==false);if(!this._mouseInMotioncbg){e.preventDefault();return true;}}
this._mouseMoveDelegate=function(e){return self._mouseInMotion(e);};this._mouseUpDelegate=function(e){return self._mouseUpEvent(e);};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);return false;},_mouseUpEvent:function(e){$(document).unbind('mousemove.'+this.widgetName,this._mouseMoveDelegate).unbind('mouseup.'+this.widgetName,this._mouseUpDelegate);if(this._mouseInMotioncbg){this._mouseInMotioncbg=false;this._mouseMotionStopped(e);}
return false;},_destroyMouseEvent:function(){this.element.unbind('.'+this.widgetName);($.browser.msie&&this.element.attr('unselectable',this._noSelectText));},_findMouseDistance:function(e){return(Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance);},_cbgMouseDelay:function(e){return this.cbgMouseDelay;},_mouseInMotion:function(e){if($.browser.msie&&!e.button){return this._mouseUpEvent(e);}
if(this._mouseInMotioncbg){this._mouseDrag(e);return false;}
if(this._findMouseDistance(e)&&this._cbgMouseDelay(e)){this._mouseInMotioncbg=(this._mouseStart(this._mouseDownEvent,e)!==false);(this._mouseInMotioncbg?this._mouseDrag(e):this._mouseUpEvent(e));}
return!this._mouseInMotioncbg;},_mouseStart:function(e){},_mouseDrag:function(e){},_mouseMotionStopped:function(e){},_CapturemouseEvent:function(e){return true;}};$.ui.mouse.defaults={cancel:null,distance:1,delay:0};})(jQuery);$(document).ready(function(){(function($){$.fn.unwrap=$.fn.unwrap||function(expr){return this.each(function(){$(this).parents(expr).eq(0).after(this).remove();});};$.widget("ui.cbgBudgetBar",{plugins:{},ui:function(e){return{options:this.options,handle:this.currentHandle,value:this.options.axis!="both"||!this.options.axis?Math.round(this.value(null,this.options.axis=="vertical"?"y":"x")):{x:Math.round(this.value(null,"x")),y:Math.round(this.value(null,"y"))},range:this._calculateRange()};},_passOnThenEvent:function(n,e){$.ui.plugin.call(this,n,[e,this.ui()]);this.element.triggerHandler(n=="slide"?n:"slide"+n,[e,this.ui()],this.options[n]);},destroy:function(){this.element.removeClass("ui-slider ui-slider-disabled").removeData("slider").unbind(".slider");if(this.handle&&this.handle.length){this.handle.unwrap("a");this.handle.each(function(){$(this).data("mouse")._destroyMouseEvent();});}
this.generated&&this.generated.remove();},_setData:function(key,value){$.widget.prototype._setData.apply(this,arguments);if(/min|max|steps/.test(key)){this._definelimitValues();}
if(key=="range"){value?this.handle.length==2&&this._createRange():this._removeRange();}},_initialized:function(){var self=this;this.element.addClass("ui-slider");this._definelimitValues();this.handle=$(this.options.handle,this.element);if(!this.handle.length){self.handle=self.generated=$(self.options.handles||[0]).map(function(){var handle=$("<div/>").addClass("ui-slider-handle").appendTo(self.element);if(this.id)
handle.attr("id",this.id);return handle[0];});}
var handleclass=function(el){this.element=$(el);this.element.data("mouse",this);this.options=self.options;this.element.bind("mousedown",function(){if(self.currentHandle)this.blur(self.currentHandle);self._setFocusofelem(this,true);});this._initialiseMouseEvents();};$.extend(handleclass.prototype,$.ui.mouse,{_mouseStart:function(e){return self._sliderBegin.call(self,e,this.element[0]);},_mouseMotionStopped:function(e){return self._stopSlider.call(self,e,this.element[0]);},_mouseDrag:function(e){return self._sliderIsDrag.call(self,e,this.element[0]);},_CapturemouseEvent:function(){return true;},trigger:function(e){this._mouseClickcbg(e);}});$(this.handle).each(function(){new handleclass(this);}).wrap('<a href="#" style="outline:none;border:none;"></a>').parent().bind('click',function(){return false;}).bind('focus',function(e){self._setFocusofelem(this.firstChild);}).bind('blur',function(e){self._setBlurofelem(this.firstChild);});this.element.bind('mousedown.slider',function(e){self._clickIsDone.apply(self,[e]);self.currentHandle.data("mouse").trigger(e);self.firstValue=self.firstValue+1;});$.each(this.options.handles||[],function(index,handle){self.moveTo(handle.start,index,true);});if(!isNaN(this.options.startValue))
this.moveTo(this.options.startValue,0,true);this.previousHandle=$(this.handle[0]);if(this.handle.length==2&&this.options.range)this._createRange();},_definelimitValues:function(){var element=this.element[0],currentOption=this.options;this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};$.extend(currentOption,{axis:currentOption.axis||(element.offsetWidth<element.offsetHeight?'vertical':'horizontal'),max:!isNaN(parseInt(currentOption.max,10))?{x:parseInt(currentOption.max,10),y:parseInt(currentOption.max,10)}:({x:currentOption.max&&currentOption.max.x||100,y:currentOption.max&&currentOption.max.y||100}),min:!isNaN(parseInt(currentOption.min,10))?{x:parseInt(currentOption.min,10),y:parseInt(currentOption.min,10)}:({x:currentOption.min&&currentOption.min.x||0,y:currentOption.min&&currentOption.min.y||0})});currentOption.realMax={x:currentOption.max.x-currentOption.min.x,y:currentOption.max.y-currentOption.min.y};currentOption.stepping={x:currentOption.stepping&&currentOption.stepping.x||parseInt(currentOption.stepping,10)||(currentOption.steps?currentOption.realMax.x/(currentOption.steps.x||parseInt(currentOption.steps,10)||currentOption.realMax.x):0),y:currentOption.stepping&&currentOption.stepping.y||parseInt(currentOption.stepping,10)||(currentOption.steps?currentOption.realMax.y/(currentOption.steps.y||parseInt(currentOption.steps,10)||currentOption.realMax.y):0)};},_clickIsDone:function(e){var pointer=[e.pageX,e.pageY];var isHandleFlag=false;this.handle.each(function(){if(this==e.target)
isHandleFlag=true;});if(isHandleFlag||this.options.disabled||!(this.currentHandle||this.previousHandle))
return;if(!this.currentHandle&&this.previousHandle)
this._setFocusofelem(this.previousHandle,true);this.offset=this.element.offset();this.moveTo({y:this._calculateValue(e.pageY-this.offset.top-this.currentHandle[0].offsetHeight/2,"y"),x:this._calculateValue(e.pageX-this.offset.left-this.currentHandle[0].offsetWidth/2,"x")},null,!this.options.distance);},_createRange:function(){if(this.rangeElement)return;this.rangeElement=$('<div></div>').addClass('ui-slider-range').css({position:'absolute'}).appendTo(this.element);this._modifiedRange();},_modifiedRange:function(){var propAxisAxis=this.options.axis=="vertical"?"top":"left";var Newsize=this.options.axis=="vertical"?"height":"width";this.rangeElement.css(propAxis,(parseInt($(this.handle[0]).css(propAxis),10)||0)+this._offsetHandle(0,this.options.axis=="vertical"?"y":"x")/2);this.rangeElement.css(Newsize,(parseInt($(this.handle[1]).css(propAxis),10)||0)-(parseInt($(this.handle[0]).css(propAxis),10)||0));},_calculateRange:function(){return this.rangeElement?this._calculateValue(parseInt(this.rangeElement.css(this.options.axis=="vertical"?"height":"width"),10),this.options.axis=="vertical"?"y":"x"):null;},_setFocusofelem:function(handle,hard){this.currentHandle=$(handle).addClass('ui-slider-handle-active');if(hard)
this.currentHandle.parent()[0].focus();},_removeRange:function(){this.rangeElement.remove();this.rangeElement=null;},_changeIndex:function(){return this.handle.index(this.currentHandle[0]);},value:function(handle,axis){if(this.handle.length==1)this.currentHandle=this.handle;if(!axis)axis=this.options.axis=="vertical"?"y":"x";var curHandle=$(handle!=undefined&&handle!==null?this.handle[handle]||handle:this.currentHandle);if(curHandle.data("mouse").sliderValue){return parseInt(curHandle.data("mouse").sliderValue[axis],10);}else{return parseInt(((parseInt(curHandle.css(axis=="x"?"left":"top"),10)/(this.actualSize[axis=="x"?"width":"height"]-this._offsetHandle(handle,axis)))*this.options.realMax[axis])+this.options.min[axis],10);}},_calculateValue:function(value,axis){return this.options.min[axis]+(value/(this.actualSize[axis=="x"?"width":"height"]-this._offsetHandle(null,axis)))*this.options.realMax[axis];},_setBlurofelem:function(handle){$(handle).removeClass('ui-slider-handle-active');if(this.currentHandle&&this.currentHandle[0]==handle){this.previousHandle=this.currentHandle;this.currentHandle=null;};},_translateValue:function(value,axis){return((value-this.options.min[axis])/this.options.realMax[axis])*(this.actualSize[axis=="x"?"width":"height"]-this._offsetHandle(null,axis));},_convertbounds:function(value,axis){if(value>=this.actualSize[axis=="x"?"width":"height"]-this._offsetHandle(null,axis))
value=this.actualSize[axis=="x"?"width":"height"]-this._offsetHandle(null,axis);if(value<=0)
value=0;return value;},_offsetHandle:function(handle,axis){return $(handle!=undefined&&handle!==null?this.handle[handle]:this.currentHandle)[0]["offset"+(axis=="x"?"Width":"Height")];},_convertRange:function(value,axis){if(this.rangeElement){if(this.currentHandle[0]==this.handle[0]&&value>=this._translateValue(this.value(1),axis))
value=this._translateValue(this.value(1,axis)-this._oneStep(axis),axis);if(this.currentHandle[0]==this.handle[1]&&value<=this._translateValue(this.value(0),axis))
value=this._translateValue(this.value(0,axis)+this._oneStep(axis),axis);}
if(this.options.handles){var handle=this.options.handles[this._changeIndex()];if(value<this._translateValue(handle.min,axis)){value=this._translateValue(handle.min,axis);}else if(value>this._translateValue(handle.max,axis)){value=this._translateValue(handle.max,axis);}}
return value;},_sliderBegin:function(e,handle){var currentOption=this.options;if(currentOption.disabled)return false;this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};if(!this.currentHandle)
this._setFocusofelem(this.previousHandle,true);this.offset=this.element.offset();this.handleOffset=this.currentHandle.offset();this.clickOffset={top:e.pageY-this.handleOffset.top,left:e.pageX-this.handleOffset.left};this.firstValue=this.value();this._passOnThenEvent('start',e);this._sliderIsDrag(e,handle);return true;},_stopSlider:function(e){this._passOnThenEvent('stop',e);if(this.firstValue!=this.value())
this._passOnThenEvent('change',e);this._setFocusofelem(this.currentHandle,true);UpdateOtherFields($("#bdgt input"));return false;},_sliderIsDrag:function(e,handle){var currentOption=this.options;var position={top:e.pageY-this.offset.top-this.clickOffset.top,left:e.pageX-this.offset.left-this.clickOffset.left};if(!this.currentHandle)this._setFocusofelem(this.previousHandle,true);position.left=this._convertbounds(position.left,"x");position.top=this._convertbounds(position.top,"y");if(currentOption.stepping.x){var value=this._calculateValue(position.left,"x");value=Math.round(value/currentOption.stepping.x)*currentOption.stepping.x;position.left=this._translateValue(value,"x");}
if(currentOption.stepping.y){var value=this._calculateValue(position.top,"y");value=Math.round(value/currentOption.stepping.y)*currentOption.stepping.y;position.top=this._translateValue(value,"y");}
position.left=this._convertRange(position.left,"x");SingleSliderUnit=((UpperBudget-Lowerbudget)/sliderWidth);totalBudget=(SingleSliderUnit*position.left)+Lowerbudget;totalBudget=Math.round(totalBudget);totalBudget=Math.round(totalBudget/500,0)*500;$("#originalvalue").attr('value',totalBudget);$budgetTxt='<div id="budgetTxt">'+$("#originalvalue").attr('value')+'</div>';var newvalParcent=position.left;$("#backgroundshade").width(newvalParcent);$("#sliderbudget").css('left',newvalParcent);$("#sliderbudget").html($budgetTxt);$("#budgetTxt").cbgcurrency({format:"£,£££",locale:"us"});formattedVal=$("#budgetTxt").html();$("#budgetTxt").html($("#bdgt span").html()+formattedVal);position.top=this._convertRange(position.top,"y");if(currentOption.axis!="vertical")this.currentHandle.css({left:position.left});if(currentOption.axis!="horizontal")this.currentHandle.css({top:position.top});this.currentHandle.data("mouse").sliderValue={x:Math.round(this._calculateValue(position.left,"x"))||0,y:Math.round(this._calculateValue(position.top,"y"))||0};if(this.rangeElement)
this._modifiedRange();this._passOnThenEvent('slide',e);return false;},moveTo:function(value,handle,noPropagation){}});$.ui.cbgBudgetBar.getter="value";$.ui.cbgBudgetBar.defaults={handle:".ui-slider-handle",distance:1,animate:false};})(jQuery);(function(cbgInputparam){cbgInputparam.formatNumber=function(inputNumber,options){var options=jQuery.extend({},cbgInputparam.fn.parse.defaults,options);return String(inputNumber);};cbgInputparam.fn.parse=function(options){var options=jQuery.extend({},cbgInputparam.fn.parse.defaults,options);var cbgValidInputString="1234567890.-";var formattedArray=[];this.each(function(){var inputText=new String(jQuery(this).text());inputText=inputText.replace(",",'');var validatedFinaltxt="";for(var i=0;i<inputText.length;i++){if(cbgValidInputString.indexOf(inputText.charAt(i))>-1)
validatedFinaltxt=validatedFinaltxt+inputText.charAt(i);}
var inputNumber=new Number(validatedFinaltxt);formattedArray.push(inputNumber);});return formattedArray;};cbgInputparam.fn.cbgcurrency=function(options){var options=jQuery.extend({},cbgInputparam.fn.cbgcurrency.defaults,options);var validFormat="0#-,.";return this.each(function(){var inputText=new String(cbgInputparam(this).text());var inputNumber=new Number(inputText.replace(",",''));var returnValidatedString="";var decVal=inputNumber%1;var countFlag=0;var outPutFormat="";var lengthLimit=9999;var decPor=".";var appendString="";if(options.format.indexOf(".")>-1){var decFormt=options.format.substring(options.format.lastIndexOf(".")+1);var decStr=new String(decVal.toFixed(decFormt.length));decStr=decStr.substring(decStr.lastIndexOf(".")+1);for(var i=0;i<decFormt.length;i++){if(decFormt.charAt(i)=='£'&&decStr.charAt(i)!='0'){decPor+=decStr.charAt(i);break;}
else if(decFormt.charAt(i)=="0"){decPor+=decStr.charAt(i);}}
returnValidatedString+=decPor}
else
inputNumber=Math.round(inputNumber);var noOfOnes=Math.floor(inputNumber);if(inputNumber<0)
noOfOnes=Math.ceil(inputNumber);if(noOfOnes==0){appendString="0";}
else{if(options.format.indexOf(".")==-1)
outPutFormat=options.format;else
outPutFormat=options.format.substring(0,options.format.indexOf("."));var onceOPTxt=new String(noOfOnes);if(outPutFormat.lastIndexOf(",")!=-1)
lengthLimit=outPutFormat.length-outPutFormat.lastIndexOf(",")-1;for(var i=onceOPTxt.length-1;i>-1;i--){appendString=onceOPTxt.charAt(i)+appendString;countFlag++;if(countFlag==lengthLimit&&i!=0){appendString=","+appendString;countFlag=0;}}}
returnValidatedString=appendString+returnValidatedString;cbgInputparam(this).text(returnValidatedString);});};cbgInputparam.fn.parse.defaults={locale:"us"};cbgInputparam.fn.cbgcurrency.defaults={format:"£,£££.00",locale:"us"};})(jQuery);$("#content-slider").cbgBudgetBar({animate:true,handle:".content-slider-handle"});chkZeroFlag=0;sliderWidth=$("#content-slider").width()-16;$("#backgroundshade").width(0);$("#originalvalue").attr('value',DefaultBudget);SingleSliderUnit=((UpperBudget-Lowerbudget)/sliderWidth);$("#backgroundshade").width((DefaultBudget/SingleSliderUnit));$('#getmouseposition').css('left',(DefaultBudget/SingleSliderUnit));$budgetTxt='<div id="budgetTxt">'+$("#originalvalue").attr('value')+'</div>';$("#sliderbudget").css('left',(DefaultBudget/SingleSliderUnit));$("#sliderbudget").html($budgetTxt);$("#budgetTxt").cbgcurrency({format:"£,£££",locale:"us"});formattedVal=$("#budgetTxt").html();$("#budgetTxt").html($("#bdgt span").html()+formattedVal);$(".high span:last").cbgcurrency({format:"£,£££",locale:"us"});$("#originalvalue").keyup(function(event){chkZeroFlag++;var zeroValue=$("#originalvalue").attr('value');if(chkZeroFlag>=1&&zeroValue!=''){if(zeroValue==0){$("#originalvalue").attr('value',0);chkZeroFlag=0;}
else{newProperValue='';zeroValueArr=zeroValue.split('00');for(var j=0;j<zeroValueArr.length;j++){if((zeroValueArr[j]>0&&zeroValueArr[j]<=zeroValueArr[j+1])||zeroValueArr[j]>zeroValueArr[j+1]){newProperValue=zeroValue;break;}
if(zeroValueArr[j]!=''){newProperValue+=zeroValueArr[j];}}
$("#originalvalue").attr('value',newProperValue);}}
originalvalueBud="";originalvaluetmp=$("#originalvalue").attr('value');var originalvalue=originalvaluetmp.split(',');if(originalvalue.length>1){for(var i=0;i<originalvalue.length;i++){originalvalueBud+=originalvalue[i];}}
else{originalvalueBud=$("#originalvalue").attr('value');}
var newdiv=document.getElementById('getmouseposition');var backgroundDiv=document.getElementById('backgroundshade');SingleSliderUnit=((UpperBudget-Lowerbudget)/sliderWidth);if(originalvalueBud<=UpperBudget){$("#backgroundshade").width((originalvalueBud/SingleSliderUnit));$('#getmouseposition').css('left',(originalvalueBud/SingleSliderUnit));$("#sliderbudget").css('left',(originalvalueBud/SingleSliderUnit));}
else if(originalvalueBud==''){$("#backgroundshade").width(0);}
else{$("#backgroundshade").width((UpperBudget/SingleSliderUnit));$('#getmouseposition').css('left',(UpperBudget/SingleSliderUnit));$("#sliderbudget").css('left',(UpperBudget/SingleSliderUnit));}
if(originalvalueBud>UpperBudget){$("#originalvalue").attr('value',UpperBudget);$budgetTxt='<div id="budgetTxt">'+$("#originalvalue").attr('value')+'</div>';}else if($("#originalvalue").attr('value')==''){$budgetTxt='<div id="budgetTxt"> </div>';}
else{$budgetTxt='<div id="budgetTxt">'+$("#originalvalue").attr('value')+'</div>';}
$("#sliderbudget").html($budgetTxt);$("#budgetTxt").cbgcurrency({format:"£,£££",locale:"us"});formattedVal=$("#budgetTxt").html();$("#budgetTxt").html($("#bdgt span").html()+formattedVal);});$.fn.regex=function(value,regexp){if(regexp.constructor!=RegExp)
regexp=new RegExp(regexp);else if(regexp.global)
regexp.lastIndex=0;return regexp.test(value);}
$("#maincontentarea").width(($("#bg_theme").width()-15));if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var ieversion=new Number(RegExp.$1)
if(ieversion>=7&&ieversion<8){$("#maincontentarea").width(($("#bg_theme").width()-17));}}
$("#centertop,#centerbottom").width(($("#bg_theme").width()-14));$("#bdgt input").bind("contextmenu",function(e){return false;});bodyTypeImageFlag=0;dontMindValue='All';rePopulatemodelFlag=0;ChangeModel('disable');var waitImagDiv='<div id="waitImage"></div>';$("#maincontentarea").append(waitImagDiv);function ChangeModel(flag){var model=$("#mdll select");switch(flag){case'enable':if(model.attr("disabled")){model.removeAttr("disabled");}break;case'disable':if(!model.attr("disabled")){model.attr("disabled","disabled");}break;default:;}}
firstTimebudget=1;$("#bdgt input").focus(function(){if(firstTimebudget==1){$(this).val('');firstTimebudget=0;}});$("#bdgt input").keypress(function(e){if(e.which!=8&&e.which!=0&&e.which!=3&&e.which!=13&&(e.which<48||e.which>57)){alert(budgetValidationString);return false;}
if(e.which==13){goToResult();}});$("#make select").change(function(){makeValue=$(this).val();if(makeValue!=dontMindValue){ChangeModel('enable');}else{ChangeModel('disable');}});function CollectMasterFields(){masterField=[];masterFieldValue=[];$(".masterfield").each(function(){var controlValue='';var controlValueSeperator='';var controlId=$(this).attr("id");switch(controlId){case'bdtpimage':bodyTypeImageFlag=1;controlId='bdtp';$(this).find(":checked").each(function(){controlValue+=controlValueSeperator+$(this).val();controlValueSeperator=",";});if(controlValue==''){controlValue=dontMindValue;}
break;case'bdgt':controlValue=$(this).find("input").val();if(controlValue==''){controlValue=dontMindValue;}else if(parseInt(controlValue,10)>UpperBudget){controlValue=UpperBudget;}else if(parseInt(controlValue,10)<Lowerbudget){controlValue=Lowerbudget;}
var textBoxEntry=(controlValue==dontMindValue)?'':controlValue;$(this).find("select,input").val(textBoxEntry);break;case'mdll':var model=$("#mdll select");if(model.attr("disabled")){controlValue=dontMindValue;}
default:controlValue=$(this).find("select,input").val();break;}
masterField.push(controlId);masterFieldValue.push(controlValue);});}
CreateQuery(-1);function CreateQuery(position){CollectMasterFields();query=stubpageurl+"?action=entrypoint&fieldValueList=";var querySeperator='';for(i=0;i<=position;i++){if(masterFieldValue[i]!=dontMindValue){query+=querySeperator+masterField[i]+":"+masterFieldValue[i];querySeperator=";";}}
for(i>position;i<masterField.length;i++){if(masterField[i]=='bdgt'){query+=querySeperator+masterField[i]+":"+masterFieldValue[i];}else{query+=querySeperator+masterField[i]+":"+dontMindValue;}
querySeperator=";";}
callajxandupdate();}
$(".bg_ser_dropdown").keypress(function(e){if(e.which==13){goToResult();}});function UpdateOtherFields($tgt){if($tgt.regex($("#bdgt input").attr('value'),'^[0-9]+$')||$("#bdgt input").attr('value')==''){var selectedField=$tgt.parents(".masterfield").get(0).getAttribute("id");var selecteFieldIndex;for(i=0;i<masterField.length;i++){if(masterField[i]==selectedField){selecteFieldIndex=i;}}
if(selecteFieldIndex!=masterField.length-1){$("#tableWrapper").css('position','relative');$("#waitImage").height($("#maincontentarea").height());$("#waitImage").width($("#maincontentarea").width());CreateQuery(selecteFieldIndex);}}
else{alert(incorrectBdgtValidation);$("#bdgt input").attr('value','');}}
$(".bg_ser_dropdown,#bdgt input").change(function(e){var $tgt=$(e.target);UpdateOtherFields($tgt);});$("#bdtpimage").bind('click',function(e){var $tgt=$(e.target);if($tgt.is('input')){var selecteFieldIndex;for(i=0;i<masterField.length;i++){if(masterField[i]=='bdtp'){selecteFieldIndex=i;}}
if(selecteFieldIndex!=masterField.length-1){CreateQuery(selecteFieldIndex);}}});$("#ser_search").bind('click',function(e){if($(this).regex($("#bdgt input").attr('value'),'^[0-9]+$')||$("#bdgt input").attr('value')==''){goToResult();}
else{alert(incorrectBdgtValidation);$("#bdgt input").attr('value','');}});function goToResult(){CollectMasterFields();query=resultPageUrl+"?action=result&fieldValueList=";var querySeperator='';for(i=0;i<masterField.length;i++){var value;if(masterField[i]=='bdgt'){if(masterFieldValue[i]==dontMindValue){value=Lowerbudget+","+UpperBudget;}else{var fieldvalue=parseInt(masterFieldValue[i],10);var tempBdgtLow=Math.ceil(fieldvalue-(fieldvalue*0.1));var bdgtlow=tempBdgtLow>Lowerbudget?tempBdgtLow:Lowerbudget;var tempBdgthigh=Math.ceil(fieldvalue+(fieldvalue*0.2));var bdgthigh=tempBdgthigh>UpperBudget?UpperBudget:tempBdgthigh;value=bdgtlow+","+bdgthigh;}}else{value=masterFieldValue[i];}
query+=querySeperator+masterField[i]+":"+value;querySeperator=";";}
query=query.replace(/\+/g,"%2B");window.open(query,'_self');}
function callajxandupdate(){query=query.replace(/\+/g,"%2B");$.ajax({type:"GET",url:query,dataType:"text",success:function(data){var xml;if(typeof data=="string"){if($.browser.msie){xml=new ActiveXObject("Microsoft.XMLDOM");xml.async=false;xml.loadXML(data);}else{var parser=new DOMParser();xml=parser.parseFromString(data,"text/xml");}}else{xml=data;}
$(xml).find('enpt').each(function(){$(this).find('fld').each(function(){var id=$(this).attr("id");if(bodyTypeImageFlag==1&&id=='bdtp'){var control="#bdtpimage div.options";var structure='';for(i=0;i<masterField.length;i++){if(id==masterField[i])
selectedValue=masterFieldValue[i];}
seperatedValues=selectedValue.split(',');$(this).find('optn').each(function(){var value=$(this).text();var source=bodyTypeImagePath+'/'+value.replace(/ /g,'')+".png";structure+='<div class="bt_options">';structure+='<img src="'+source+'" alt="'+value+'" class="bt_image" />';structure+='<div class="bt_opt_footer">';structure+='<input type="checkbox" value="'+value+'" id="'+value+'"';for(i=0;i<seperatedValues.length;i++){if(value==seperatedValues[i])
structure+='checked = "checked"';}
structure+='" />';structure+='<label class="bt_model" for="'+value+'">'+value+'</label></div></div>';});$(control).html(structure);}else{var control="#"+id+" select";var options='';var selectedValue='';var selectedValueFlag=0;for(i=0;i<masterField.length;i++){if(id==masterField[i])
selectedValue=masterFieldValue[i];}
options+='<option value="'+dontMindValue+'"';options+='>'+dontMindText+'</option>';$(this).find('optn').each(function(){var value=$(this).attr("val");var text=$(this).text();if(id!='ager'){value=text;}
options+='<option value="'+value+'"'
if(selectedValue==value){options+=' selected="selected"';selectedValueFlag=1;if(id=='make'){rePopulatemodelFlag=1;}}
options+='>'+text+'</option>';});if(selectedValueFlag==0){var key='<option value="'+dontMindValue+'"'+'>'+dontMindText+'</option>';var newkey='<option value="'+dontMindValue+'"'+' selected="selected"'+'>'+dontMindText+'</option>';options.replace(new RegExp(key,'g'),newkey);if(id=='make'){ChangeModel('disable');}}
$(control).html(options);}});});if(rePopulatemodelFlag==1){for(i=0;i<masterField.length;i++){if(masterField[i]=='make'){selecteFieldIndex=i;}}
CreateQuery(selecteFieldIndex);rePopulatemodelFlag=0;}
$("#tableWrapper").css('position','static');$("#waitImage").height(0);$("#waitImage").width(0);},error:function(xhr,err,e){alert("Error: "+err+e+xhr);}});}});