function MM_preloadImages(){var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();var i,j=d.MM_p.length,a=arguments;for(i=0;i<a.length;i++)
if(a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}}}
function MM_swapImgRestore(){var i,x,a=document.MM_sr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)x.src=x.oSrc;}
function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function MM_swapImage(){var i,j=0,x,a=arguments;document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)
if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;if(!x.oSrc)x.oSrc=x.src;x.src=a[i+2];}}
function trim(str,chars){return ltrim(rtrim(str,chars),chars);}
function ltrim(str,chars){chars=chars||"\\s";return str.replace(new RegExp("^["+chars+"]+","g"),"");}
function rtrim(str,chars){chars=chars||"\\s";return str.replace(new RegExp("["+chars+"]+$","g"),"");}
function getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
var pageWidth,pageHeight;if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
return[pageWidth,pageHeight];}
var gallery=function(c){var g=this;this.c=c;this.t=document.getElementById(this.c.t);this.p=[];this.init=function(){if(this.t==undefined||this.c.i.length==0)return false;var a,b,c,d,e,z;this.i=document.createElement('img');this.i.setAttribute('id',this.t.id+'_i');z=document.createElement('div');if(this.c.c.images)z.className=this.c.c.images;z.appendChild(this.i);b=['next','prev'];d=document.createElement('div');for(a=0;a<b.length;a++){c=document.createElement('div');if(this.c.c[b[a]])c.className=this.c.c[b[a]];c.innerHTML=this.c.a[b[a]]!=undefined?this.c.a[b[a]]:b[a];c.g=this;c.onclick=this[b[a]];d.appendChild(c);}
this.t.appendChild(z);this.t.appendChild(d);this.load('first');};this.prev=function(){this.g.load('prev');};this.next=function(){this.g.load('next');};this.load=function(e){this.k=this.getK(e);document.getElementById(this.t.id+'_i').setAttribute('src',this.c.i[this.k]);if(e=='first'||e=='last'){this.preload(this.c.i[this.getK('next')]);this.preload(this.c.i[this.getK('prev')]);}
else this.preload(this.c.i[this.getK(e)]);};this.getK=function(e){var a=this.k;a=a!=undefined?a:0;switch(e){case'first':a=0;break;case'last':a=(this.c.i.length-1);break;case'prev':a=(a-1)<0?(this.c.i.length-1):(a-1);break;case'next':a=(a+1)==this.c.i.length?0:(a+1);break;}
return a;}
this.preload=function(e){if(!this.preloaded(e)){MM_preloadImages(e);this.p.push(e);}}
this.preloaded=function(e){for(var a=0;a<this.p.length;a++){if(e==this.p[a])return true;}
return false;}
this.init();return this;};function cc(e,c,s,t){if(!e)return false;var a;if(typeof(e)=='object'){for(a=0;a<e.length;a++){cc(e[a],typeof(c)=='object'?c[a]:c,s,t);}}
if(typeof(e)=='string')e=document.getElementById(e);if(e==undefined||(!c&&e.cc_prev==undefined))return false;e.className=e.className!=undefined?e.className:'';a=e.className;if(t)e.className=e.cc_prev!=undefined?e.cc_prev:c;else e.className=(s?e.className:'')+(c?c:e.cc_prev);e.cc_prev=a;return true;}
function updateDate_date_of_birth(o,d,f){return updateDate('date_of_birth',o,d,f);}
function updateDate_dob(o,d,f){return updateDate('dob',o,d,f);}
function updateDate_archive_on(o,d,f){return updateDate('archive_on',o,d,f);}
function updateDate_date_from(o,d,f){return updateDate('date_from',o,d,f);}
function updateDate_date_to(o,d,f){return updateDate('date_to',o,d,f);}
function updateDate_date(o,d,f){return updateDate('date',o,d,f);}
function updateDate_do_initial_registration(o,d,f){return updateDate('do_initial_registration',o,d,f);}
function updateDate_do_availability(o,d,f){return updateDate('do_availability',o,d,f);}
function updateDate_pd_date_of_birth(o,d,f){return updateDate('pd_date_of_birth',o,d,f);}
function updateDate_date_of_service(o,d,f){return updateDate('date_of_service',o,d,f);}
function updateDate_pd_date_of_service(o,d,f){return updateDate('pd_date_of_service',o,d,f);}
function updateDate_alt_date_of_service(o,d,f){return updateDate('alt_date_of_service',o,d,f);}
function updateDate_pd_alt_date_of_service(o,d,f){return updateDate('pd_alt_date_of_service',o,d,f);}
function updateHiddenBirth(){if(!document.getElementById('pd_date_of_birth'))return false;xY=document.getElementById('b_year').options[document.getElementById('b_year').options.selectedIndex].value;xM=document.getElementById('b_month').options[document.getElementById('b_month').options.selectedIndex].value;xD=document.getElementById('b_day').options[document.getElementById('b_day').options.selectedIndex].value;str=xY+'-'+xM+'-'+xD;document.getElementById('pd_date_of_birth').value=str;xDateC.setStartDate(new Date(xY,(xM-1),xD));return true;}
function updateDate(i,o,d,f){if(!document.getElementById(i+'_out'))return false;if(i=='pd_date_of_birth'){if(!o){o=new Date();}else{o=new Date(o);}
bd=o.getDate();bm=o.getMonth()+1;by=o.getFullYear();str='<select name="b_day" id="b_day" onchange="updateHiddenBirth();"><option value=""></option>';for(x=1;x<=31;x++){str+='<option value="'+x+'" '+(bd==x?'selected="selected"':'')+'>'+(x<10?'0'+x:x)+'</option>';}
str+='</select> . ';str+='<select name="b_month" id="b_month" onchange="updateHiddenBirth();"><option value=""></option>';for(x=1;x<=12;x++){str+='<option value="'+x+'" '+(bm==x?'selected="selected"':'')+'>'+(x<10?'0'+x:x)+'</option>';}
str+='</select> . ';str+='<select name="b_year" id="b_year" onchange="updateHiddenBirth();"><option value=""></option>';for(x=2010;x>=1910;x--){str+='<option value="'+x+'" '+(by==x?'selected="selected"':'')+'>'+x+'</option>';}
str+='</select>';document.getElementById(i+'_out').innerHTML=str;return true;}
switch(window.globals.template){case'vehicles':case'site_news':f=f?f:'form';break;default:f=f?f:(window.globals.layout=='site'?'form':'content');}
var a=o||d?' <a href="javascript:void(0);" onclick="javascript:updateDate_'+i+'(null,null,\''+f+'\');return false;">'+window.globals.dict.remove+'</a>':'';document.getElementById(i+'_out').innerHTML=o?o.getPHPDate(window.globals.date_format)+a:(d?d+a:window.globals.dict.please_choose);if(!o&&!d)document.forms[f][i].value='';return true;}
var xDateC;function initDateChooser(f,d){var sDate,date,uf;for(var i=0;i<f.length;i++){if(!document.getElementById(f[i]+'_out'))continue;date=d[i];date=date.split('-');sDate=date.length==3?new Date(date[0],(date[1]-1),date[2]):false;date=document.getElementById(f[i]+'_out');date.DateChooser=new DateChooser();date.DateChooser.setWeekStartDay(1);uf={};uf[f[i]]='Y-m-d';var ufunc=eval("updateDate_"+f[i]);date.DateChooser.setUpdateField(uf);date.DateChooser.setUpdateFunction(ufunc);date.DateChooser.setIcon('/_inc/datechooser/datechooser.gif',f[i]+'_out');if(sDate){date.DateChooser.setStartDate(sDate);xDateC=date.DateChooser;}
ufunc(sDate);}
return true;}
var cofunready=false;var sp_stack=[];var sp_to=[];var sp_timeout=2000;function HttpRequest(c){if(window.XMLHttpRequest)var req=new XMLHttpRequest();else if(window.ActiveXObject)var req=new ActiveXObject("Microsoft.XMLHTTP");var res=null;var parameter='';if(c.parameter!=undefined){for(var i in c.parameter){var e=c.parameter[i];if(e!=null){parameter+=i+'='+encodeURIComponent(e)+'&';}}}
var sp_loading=c.parameter.sp_loading?c.parameter.sp_loading:c.parameter.sp;sp_to[sp_loading]=sp_to[sp_loading]!=undefined?sp_to[sp_loading]:null;var ov=document.getElementById('sp_overlay_'+sp_loading);if(ov==undefined){ov=document.getElementById('sp_overlay');sp_loading='page';}
sp_stack[sp_loading]=sp_stack[sp_loading]!=undefined?sp_stack[sp_loading]:0;sp_stack[sp_loading]++;req.open((c.method?c.method:'GET'),c.url,true);req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');req.onreadystatechange=function(){if(req.readyState==4){if(req.status==200){res=eval("("+(req.responseText?req.responseText:"{status:'"+(c.parameter.sp?c.parameter.sp+': ':'')+"no data'}")+")");}
sp_hide_overlay(sp_loading);}
else{if(req.readyState!=0)res=eval("({status:'"+(c.parameter.sp?c.parameter.sp+': ':'')+"loading...'})");}
if(typeof(window[c.callback])=='function'){window[c.callback](res,(c.args?c.args:false));}
if(cofunready){cufonReplacer();initBGMorph();}};sp_show_overlay(sp_loading);req.send(parameter);}
function showHttpRequestStatus(a,b,c,d,e){hideHttpRequestStatus();var s;s=document.getElementById('http_request_'+(e?e+'_':'')+(c?c:'status'));if(s!=undefined){if(a){cc(s,(s.className?s.className+' ':'')+'visible');s.innerHTML=a+(d?'<div class="line"></div>':'');if(!isNaN(b)){setTimeout('hideHttpRequestStatus(\''+c+'\''+(e?',\''+e+'\'':'')+')',b*1000);}}}}
function hideHttpRequestStatus(a,e){var s;s=document.getElementById('http_request_'+(e?e+'_':'')+(a?a:'status'));if(s!=undefined){cc(s,'hidden');}}
function executeSp(r,args){var a,b,c,p;if(!r){HttpRequest({url:(args.url?args.url:globals.url)+(!args.no_param?'?'+(window.globals._g.style?'style='+window.globals._g.style+'&':'')+'mode=js_sp':''),method:'POST',parameter:args,callback:'executeSp',args:args});}
else{var m,t;if(r.error){m=r.error;t=undefined;cc('http_request_'+(r.id_message?r.id_message+'_':'')+'message','error');}
else if(r.success){m=r.success;t=3;cc('http_request_'+(r.id_message?r.id_message+'_':'')+'message','success');}
if(m)showHttpRequestStatus(m,t,'message',r.id_message?false:true,r.id_message?r.id_message:false);else hideHttpRequestStatus('message');if(r.status)showHttpRequestStatus(r.status,1,'status');if(r.html!=undefined)r.html=trim(r.html);if(r.t){c=document.getElementById(r.t);if(c){if(r.html!=undefined)c.innerHTML=r.html;else if(r.value)c.value=r.value;}}
if(r.cb&&typeof(window[r.cb])=='function'){window[r.cb](r);}
if(r.cufon){brandsBarHover();cufonReplacer();initBGMorph();}
if(r.inside){activateInside();}}
return true;}
function sp_resize_overlay(){var ps,o,l,w,h;o=document.getElementById('sp_overlay');l=document.getElementById('sp_overlay_loading');if(!o)return false;ps=getPageSize();o.style.width=ps[0]+'px';o.style.height=ps[1]+'px';if(l){w=window.innerWidth!=null?window.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:document.body!=null?document.body.clientWidth:null;h=window.innerHeight!=null?window.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:document.body!=null?document.body.clientHeight:null;l.style.left=Math.round(w/2)+'px';l.style.top=Math.round(h/2)+'px';}
return true;}
function sp_show_overlay(sp){if(window.globals.template=='newsletter'&&window.globals._g.mode=='emit')return false;var ov=document.getElementById('sp_overlay_'+sp);if(ov==undefined){sp='page';ov=document.getElementById('sp_overlay');}
if(ov==undefined)return false;if(sp_to[sp]==null){sp_to[sp]=window.setTimeout("cc('"+ov.id+"','sp_overlay visible');",sp_timeout);}}
function sp_hide_overlay(sp){var ov=document.getElementById('sp_overlay_'+sp);if(ov==undefined){sp='page';ov=document.getElementById('sp_overlay');}
sp_stack[sp]--;if(sp_stack[sp]==0){if(sp_to[sp])clearTimeout(sp_to[sp]);sp_to[sp]=null;if(ov!=undefined)cc(ov,'sp_overlay hidden');}}
function getValue(e){var a,b;if(e.length){for(a=0;a<e.length;a++){if(e[a].checked){b=e[a].value;break;}}}
return b?b:false;}
function printDebug(i){if(i&&(window.globals.debug||globals.debug)){alert(i);}}
function number_format(number,decimals,dec_point,thousands_sep){var n=number,prec=decimals,dec=dec_point,sep=thousands_sep;n=!isFinite(+n)?0:+n;prec=!isFinite(+prec)?0:Math.abs(prec);sep=sep==undefined?',':sep;var s=n.toFixed(prec),abs=Math.abs(n).toFixed(prec),_,i;if(abs>1000){_=abs.split(/\D/);i=_[0].length%3||3;_[0]=s.slice(0,i+(n<0))+
_[0].slice(i).replace(/(\d{3})/g,sep+'$1');s=_.join(dec||'.');}else{s=abs.replace('.',dec_point);}
return s;}
