Array.prototype.Filter=function(){var a=this.length-1;while(a>-1){if(!str_notEmpty(this[a])){this.splice(a,1);}a--;}};Array.prototype.inArray=function(a){for(var i=0;i<this.length;i++){if(a==this[i]){return true;}}return false;};Array.prototype.ReturnIndex=function(a){for(var i=0;i<this.length;i++){if(a==this[i]){return i;}}return-1;};String.prototype.ucwords=function(){return this.replace(/\bw+\b/g,function(a){return a.substring(0,1).toUpperCase()+a.substring(1);});};function _int(a){return a-0;}function $(id,d){if(typeof(id)=='string'){return(isDefined(d)?d:document).getElementById(id);}return id;}function $et(t,d){return(isDefined(d)?d:document).getElementsByTagName(t);}function $f(a){return document[a];}function $ga(a,b){var c=a.getAttribute(b);return c?c:false;}function $rs(id,a){return $(id).style[(isDefined(a)?a:'display')];}function add_s_text(id,ind,val){$(id).options[ind].text=val;}function add_s_value(id,ind,val){$(id).options[ind].value=val;}function Ajax(a,b,c,d,e,f,g){var h=GetXmlHttpObject();if(h==null){alert("Your browser does not support AJAX!");return;}h.onreadystatechange=function(){if(h.readyState==4){if(h.status==200){if(!str_notEmpty(b)||h.responseText==b){if(str_notEmpty(c)){eval(c);}else{alert(h.responseText);}}else{if(str_notEmpty(d)){eval(d);}else{alert(h.responseText);}}}else{if(str_notEmpty(e)){eval(e);}else{alert('Error: Could Not Run Asynchronous Request');}}}else{}};if(a=='POST'){h.open("POST",f,true);h.setRequestHeader('Content-Type','application/x-www-form-urlencoded');h.send(g);}else{h.open("GET",f+(str_notEmpty(g)?'?'+g:''),true);h.send(null);}}function Append_Url(a){a=Form_Data(a);var b='';var c=a[0].length;for(var x=0;x<c;x++){b+='&'+a[0][x]+'='+clean_url(a[1][x]);}return b;}function bold(t,s){if(s=='1'){return'<b>'+t+'</b>';}else{return t;}}function C_Count(a,b,c){var rem=a-return_value(b).length;if(rem<0){text_value(b,return_value(b).substring(0,a));}else{insert_html(c,rem);}}function changeOpac(a,b){style_display(b,a/100,'opacity');style_display(b,a/100,'MozOpacity');style_display(b,a/100,'KhtmlOpacity');style_display(b,'alpha(opacity='+a+')','filter');}function checkbox_bold(a,b){insert_html(b,bold(trim_tag(return_html(b),'b'),return_check(a)));}function clean_url(s){return encodeURIComponent(s);}function Confirm_Action(a,b){a=s2a(a);if(a[0]==1){fd(b,return_check(a[1]));}else{for(var x=1;x<=a[0];x++){switch($(a[x]).type){case'text':if(isDefined(c)&&c!=return_value($(a[x]))){return fd(b,true);}else{var c=return_value($(a[x]));}break;case'select-one':if(isDefined(c)&&c!=return_s_text($(a[x]))){return fd(b,true);}else{var c=return_s_text($(a[x]));}break;case'checkbox':case'radio':if(!return_check($(a[x]))){return fd(b,true);}break;}}fd(b,false);}}function decode_url(s){return decodeURIComponent(s);}function dimvalue(id,attr){return _int(strip($rs(id,attr),'px'));}function dtype(i){return(document.all)?'block':i;}function Fade(a,b,c,d,e){if(!isDefined(e)){var a=return_MemOfIdByTag(a,b);style_display(a[c],'block');if(a.length>1){setTimeout(function(){Fade(a,0,c,isDefined(d)?d:5,1);},4000);}}else{if(b==0){style_display(a[c],'none');c=(c==a.length-1)?0:c+1;style_display(a[c],'block');}changeOpac(b>=100?100:b,a[c]);setTimeout(function(){Fade(a,b>=100?0:b+d,c,d,1);},b>=100?5000:20);}}function fd(id,value){var s=s2a(id);for(var i=1;i<=s[0];i++){$(s[i]).disabled=value;}}function form_check(id,value){var s=s2a(id);for(var i=1;i<=s[0];i++){$(s[i]).checked=value;}}function Form_Data(a){function return_id_name(a){return a.id?a.id:a.name;}function push_data(a){switch(a.type){case'select-one':if(return_s_value(a)){b[0].push(return_id_name(a));b[1].push(return_s_value(a));}break;case'select-multiple':if(return_s_index(a)>-1){var c=return_id_name(a);var d=return_ms_info(a)[1];var e=d.length;for(var x=0;x<e;x++){b[0].push(c);b[1].push(d[x]);}}break;case'checkbox':case'radio':if(return_check(a)){b[0].push(return_id_name(a));b[1].push(return_value(a));}break;default:if(str_notEmpty(strip(return_value(a),' '))){b[0].push(return_id_name(a));b[1].push(return_value(a));}break;}}var b=[[],[]];if(typeof(a)=='string'){a=s2a(a);for(var x=1;x<=a[0];x++){a[x]=$(a[x])?$(a[x]):$f(a[x]);}}else{a=[1,a];}for(var x=1;x<=a[0];x++){if(a[x].elements){for(var y=0;y<a[x].elements.length;y++){push_data(a[x].elements[y]);}}else{push_data(a[x]);}}return b;}function format_num(a,b,c){a=a.toFixed(isDefined(b)?b:2);if(isDefined(c)&&c==0){return a;}var d=a.indexOf('.');if(d==-1){d=a.length;}var e=1;while(d>0){if(e==4&&a.substr(d-1,1)!='-'){a=a.substring(0,d)+','+a.substring(d);e=0;}e++;d--;}return a;}function GetXmlHttpObject(){var b=false;try{b=new ActiveXObject("Msxml2.XMLHTTP");}catch(exception1){try{b=new ActiveXObject("Microsoft.XMLHTTP");}catch(exception2){b=false;}}if(!b&&window.XMLHttpRequest){b=new XMLHttpRequest();}return b;}function hover(a,b,c){var a=typeof(a)=='string'?$et(a):a;var d=a.length;for(var i=0;i<d;i++){if(a[i].className.split(' ').inArray(b)){a[i].onmouseover=function(){this.className+=' '+c;return false;};a[i].onmouseout=function(){this.className=this.className.split(' ').slice(0,-1).join(' ');return false;};}}}function insert_html(id,value){id=s2a(id);for(var i=1;i<=id[0];i++){$(id[i]).innerHTML=value;}}function isDefined(a){return typeof(a)=='undefined'?false:true;}function LBox(a){var d,e,f,g;if(window.innerHeight&&window.scrollMaxY){d=document.body.scrollWidth;e=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){d=document.body.scrollWidth;e=document.body.scrollHeight;}else{d=document.body.offsetWidth;e=document.body.offsetHeight;}if(self.innerHeight){f=self.innerWidth;g=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){f=document.documentElement.clientWidth;g=document.documentElement.clientHeight;}else if(document.body){f=document.body.clientWidth;g=document.body.clientHeight;}if(e<g){e=g;}if(d<f){d=f;}var a=isDefined(a)?a:'OL';style_display(a,e+'px','height');style_display(a,'block');}function PageScroll(a){if(window.pageYOffset||window.pageXOffset){var ret=[window.pageXOffset,window.pageYOffset];}else if(document.documentElement.scrollTop||document.documentElement.scrollLeft){var ret=[document.documentElement.scrollLeft,document.documentElement.scrollTop];}else{var ret=[document.body.scrollLeft,document.body.scrollTop];}if(!isDefined(a)){return ret;}else if(a=='x'){return ret[0];}else{return ret[1];}}function PageSize(a){if(self.innerHeight){var r=[self.innerWidth,self.innerHeight];}else if(document.documentElement&&document.documentElement.clientHeight){var r=[document.documentElement.clientWidth,document.documentElement.clientHeight];}else if(document.body){var r=[document.body.clientWidth,document.body.clientHeight];}else{var r=[0,0];}if(!isDefined(a)){return r;}else if(a=='w'){return r[0];}else{return r[1];}}function Payment(a,b,c,d,e,f){if(typeof(a)!='number'){a=_int(strip(a,['$',',']));}if(typeof(b)!='number'){b=_int(strip(b,['$',',']));}if(typeof(c)!='number'){c=_int(strip(c,'%'));}if(typeof(d)!='number'){d=_int(d);}if(typeof(e)!='number'){e=_int(e);}c=c/1200;var p=((a-b)*c)/(1-Math.pow((1+c),-(d*e)));if(typeof(f)=='object'){if(str_notEmpty(f[0])){insert_html(f[0],format_num(p));}if(str_notEmpty(f[1])){insert_html(f[1],format_num(p*d*e));}if(str_notEmpty(f[2])){insert_html(f[2],format_num((p*d*e)-a+b));}}else{return[p,p*d*e,(p*d*e)-a+b];}}function remove_element(a){a=s2a(a);for(var i=1;i<=a[0];i++){$(a[i]).parentNode.removeChild($(a[i]));}}function remove_options(a,b){var b=isDefined(b)?s2a(b).slice(1):[];var n=$(a).options.length-1;for(var i=n;i>=0;i--){if(!b.inArray(i)){$(a).options[i]=null;}}}function resize(a,b,c,d,e,f,g){switch(isDefined(f)?f:'C'){case'C':var cw=$rs(d,'width')==''?a[0]:dimvalue(d,'width');var ch=$rs(d,'height')==''?b[0]:dimvalue(d,'height');var tc=c[0]*Math.sqrt((Math.pow(a[1]-cw,2)+Math.pow(b[1]-ch,2))/(Math.pow(a[1]-a[0],2)+Math.pow(b[1]-b[0],2)));c[0]=tc<Infinity?tc:c[0];a[0]=cw;b[0]=ch;delete cw;delete ch;delete tc;case'SFI':style_display(d,a[0]+'px','width');style_display(d,b[0]+'px','height');break;}if($rs(d)!='block'){style_display(e,'none');style_display(d,'block');}if(dimvalue(d,'width')==a[1]&&dimvalue(d,'height')==b[1]){style_display(e,'block');}else{var g=isDefined(g)?g:'F';if(dimvalue(d,'width')!=a[1]){var inc=(a[1]-a[0])*(c[1]/1000)/c[0];if(((dimvalue(d,'width')+inc>a[1])&&a[1]>a[0])||((dimvalue(d,'width')+inc<a[1])&&a[1]<a[0])){style_display(d,a[1]+'px','width');}else{style_display(d,(dimvalue(d,'width')+inc)+'px','width');}}if(dimvalue(d,'height')!=b[1]){var inc=(b[1]-b[0])*(c[1]/1000)/c[0];if(((dimvalue(d,'height')+inc>b[1])&&b[1]>b[0])||((dimvalue(d,'height')+inc<b[1])&&b[1]<b[0])){style_display(d,b[1]+'px','height');}else{style_display(d,(dimvalue(d,'height')+inc)+'px','height');}if(g=='T'){style_display(d,(-(dimvalue(d,'height')/2))+'px','marginTop');}}setTimeout('resize(['+a+'],['+b+'],['+c+'],\''+d+'\',\''+e+'\',\'\',\''+g+'\')',c[1]);}}function return_check(id){return $(id).checked;}function return_date(d){if(d.substr(2,1)!='/'){d='0'+d;}if(d.substr(5,1)!='/'){d=d.substr(0,3)+'0'+d.substr(3);}var month=new Array('','January','February','March','April','May','June','July','August','September','October','November','December');return month[d.substr(0,2)-0]+' '+(d.substr(3,2)-0)+', '+d.substr(6,4);}function return_fvalue(a,b){return $f(a)[b].value;}function return_html(id){return $(id).innerHTML;}function return_MemOfIdByTag(a,b){return $(a).getElementsByTagName(b);}function return_ms_info(a){var b=$(a).options.length;var c=[[],[],[]];for(var i=0;i<b;i++){if($(a).options[i].selected==true){c[0].push(i);c[1].push(return_s_value(a,i));c[2].push(return_s_text(a,i));}}return c[0].length>0?c:-1;}function return_s_index(id){return $(id).selectedIndex;}function return_s_text(id,opt){return $(id).options[isDefined(opt)?opt:return_s_index(id)].text;}function return_s_value(id,opt){if(return_s_index(id)>-1||isDefined(opt)){return $(id).options[isDefined(opt)?opt:return_s_index(id)].value;}else{return false;}}function return_tax(a){var tax_percent=6;return Math.round(a*tax_percent*100)/10000;}function return_value(id){return $(id).value;}function s2a(s,d){s=s.split((isDefined(d)?d:','));s.unshift(s.length);return s;}function select_option(id,ind){id=typeof(id)=='object'?[1,id]:s2a(id);for(var i=1;i<=id[0];i++){$(id[i]).selectedIndex=ind;}}function select_radio(f,n,ind,value){$f(f)[n][ind].checked=value;}function setTop(a,b,c,d){var d=isDefined(d)?d:'F';var e=[PageSize('h'),PageScroll('y')];if(e[1]<=b){e[0]=e[0]+e[1]-b;e[1]=b;}if(e[0]>a){e[1]=e[1]+((e[0]-(d=='F'?a:0))/2);}else{e[1]=e[1]+(d=='F'?0:a/2);}style_display(c,e[1]+'px','top');}function str_notEmpty(a){return isDefined(a)&&a!==''?true:false;}function strip(s,c){if(typeof(c)=='object'){c.unshift(c.length);}else{c=s2a(c);}var sl=s.length;for(var x=0;x<sl;x++){for(var i=1;i<=c[0];i++){s=s.replace(c[i],'');}}return s;}function style_display(id,value,a){if(typeof(id)=='string'){id=s2a(id);}else{if(typeof(id.length)=='undefined'){id=[1,id];}else{var id2=[id.length];for(var i=0;i<id2[0];i++){id2.push(id[i]);}id=id2;}}var a=isDefined(a)?a:'display';for(var i=1;i<=id[0];i++){if($(id[i])){$(id[i]).style[a]=value;}}}function text_value(id,value){id=s2a(id);for(var i=1;i<=id[0];i++){$(id[i]).value=value;}}function trim_tag(s,t){if(s.indexOf('<'+t.toLowerCase()+'>')=='0'||s.indexOf('<'+t.toUpperCase()+'>')=='0'){return s.slice(t.length+2,s.length-t.length-3);}else{return s;}}function validate(id,type,min,bgcolor,fcolor){text_value(id,return_value(id).replace(new RegExp(/^\s+/gm),''));text_value(id,return_value(id).replace(new RegExp(/\s+$/gm),''));if(type=='text'){var ret=(return_value(id).length<min)?false:true;}else if(type=='email'){var c=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;var ret=(c.test(return_value(id))==false||return_value(id).length<min)?false:true;}else if(type=='select'){var ret=(return_s_index(id)>min)?true:false;}else{return true;}if(ret==false){style_display(id,bgcolor,'backgroundColor');style_display(id,fcolor,'color');$(id).focus();}else{style_display(id,'','backgroundColor');style_display(id,'','color');}return ret;}function VIN_Check(a,b){var Letter=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R',' ','S','T','U','V','W','X','Y','Z'];var XLetter=['I','O','Q'];var XYear=['U','Z','0'];var Weight=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2];if(a.length==17){VIN_CheckSum=[0,''];a=a.toUpperCase();for(var i=0;i<17;i++){VIN_CheckSum[1]=a.charAt(i);if(XLetter.inArray(VIN_CheckSum[1])){return alert('VIN ERROR: Invalid VIN Character');}if(isNaN(parseInt(VIN_CheckSum[1]))){VIN_CheckSum[1]=(Letter.ReturnIndex(VIN_CheckSum[1])+1)%9;if(VIN_CheckSum[1]==0){VIN_CheckSum[1]=9;}}VIN_CheckSum[0]+=_int(VIN_CheckSum[1])*Weight[i];}if(!(VIN_CheckSum[0]%11==parseInt(a.charAt(8))||(VIN_CheckSum[0]%11==10&&a.CharAt(8)=='X'))){return alert('VIN ERROR: Invalid VIN Check Digit');}delete VIN_CheckSum;if(XYear.inArray(a.charAt(9))){return alert('VIN ERROR: Invalid VIN Date');}Ajax('GET','','VIN_Parse(h.responseXML,'+b+');','','','/Services/VIN/vin_web_service.php','VIN='+clean_url(a));}else{alert('VIN ERROR: Invalid VIN Length');}}function VIN_Parse(a,b){var items=$et('ITEM',a).length;if(items>0){var v=[],cv=[],cv2=[],citem,cvalue;for(var i=0;i<items;i++){citem=$et('ITEM',a)[i];cvalue=$ga(citem,'VALUE');if($ga(citem,'KEY')=='VIN'){cv.push(cv2);if(cvalue!=cv2[0]){v.push(cv);cv=[];}cv2=[];}cv2.push(cvalue);}cv.push(cv2);v.push(cv);v.shift();b(v);}else{alert('VIN ERROR: '+$ga($et('VIN',a)[0],'STATUS'));}}
