var hjq=false;var iev=-1;function DialogBox(title, htmlContent, close){var full=false;if(close!=null&&close==true){full=true;}if(document.getElementById('dlgBx')!=null){closeDialogBox();}var dlgBx=document.createElement('div');dlgBx.className="dlgBx ui-widget-content";dlgBx.setAttribute("id","dlgBx");dlgBx.innerHTML='<div class="dlgtitlebar"><div class="dlgfulltitle">'+title+(full?'':'<a href="#" class="dlgclose" id="dlgclose" onclick="closeDialogBox();return false;"><img alt="Close" title="Close" src="/close.png" width="42" height="42" onmouseover="this.src=\'/close-hi.png\';" onmouseout="this.src=\'/close.png\';" /></a>')+'</div></div><div id="dlgbody" class="dlgbody">'+htmlContent+'</div>';document.body.appendChild(dlgBx);rsdlg();if(hjq){$('#dlgBx').draggable({handle:'div.dlgtitlebar',cancel:'div.dlgbody'});}}function addBg(){var dlgBg=document.createElement('div');dlgBg.className="dlgBg";dlgBg.setAttribute("id","dlgBg");document.body.appendChild(dlgBg);}var norsz=true;function rsdlg(){var d=document.getElementById('dlgBx');if(d!=null&&!norsz){var h=getWindowHeight();d.style.position="fixed";if(h<640){d.style.position="absolute";d.style.top='140px';d.style.marginTop='0px';}else{d.style.top='50%';d.style.marginTop='-180px';}var w=getWindowWidth();if(w<1000){d.style.position="absolute";d.style.marginLeft='0px';d.style.left='260px';d.style.top='140px';d.style.marginTop='0px';}else{d.style.marginLeft='-250px';d.style.left='50%';}}}function closeDialogBox(){endBusy();rmChild('dlgBg');rmChild('dlgBx');return false;}function getWindowWidth(){var w = 0;if(typeof(window.innerWidth)=='number'){w = window.innerWidth;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){w = document.documentElement.clientWidth;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight ) ){w = document.body.clientWidth;}return w;}function getWindowHeight(){var w = 0;if(typeof(window.innerHeight)=='number'){w = window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientHeight||document.documentElement.clientHeight)){w = document.documentElement.clientHeight;}else if(document.body&&(document.body.clientHeight||document.body.clientHeight ) ){w = document.body.clientHeight;}return w;}function ctrack(c,a,ol){if(typeof track=='function')track(c,a,ol);}var openPagesInNewWindow=false;var openPagesInline=true;var cUrl=null;function OpenPage(title,url,lUrl){if(document.getElementById('dlgBx')!=null){ctrack('op','clwin');closeDialogBox();}cUrl=lUrl?lUrl:url;if(cUrl.indexOf('http')!=0){var t=cUrl;if(t.indexOf('/')!=0){cUrl='http://www.myscenicdrives.com/';}else{cUrl='http://www.myscenicdrives.com';}
cUrl+=t;}if(openPagesInNewWindow){var nw=window.open(cUrl,'_blank');if(nw){ctrack('op','newwin');return true;}}if(openPagesInline){document.location=cUrl;return false;}if(getWindowWidth()<850||getWindowHeight()<550){document.location=cUrl;ctrack('op','smwin');return false;}ctrack('op','inline');var dlgBx=document.createElement('div');dlgBx.className="openPg";dlgBx.setAttribute("id","dlgBx");dlgBx.innerHTML='<div class="dlgtitlebar" id="dlgtitlebar"><div class="dlgtitle">'+title+'</div><div class="dlgbuttons"><a href="'+cUrl+'" class="dlgexpand" id="dlgexpand" title="Full browser view">[]</a><a href="#" class="dlgclose" onclick="closeDialogBox();return false;" id="dlgclose" title="Close">X</a></div></div><div class="clear"></div><div class="dlgbody" id="dlgbdc"></div>';document.body.appendChild(dlgBx);document.getElementById('dlgbdc').innerHTML='<iframe src=\"'+url+'\">Loading '+url+'</iframe>';startBusy(false);return true;}function startBusy(shouldBg){if(document.getElementById('busy')!=null){endBusy();}var hasBg=true;if(shouldBg!=null&&shouldBg==false){hasBg=false;}if(hasBg){var busyBg=document.createElement('div');busyBg.className="busyBg";busyBg.setAttribute("id","busyBg");document.body.appendChild(busyBg);}var busy=document.createElement('div');busy.className="busy";busy.setAttribute("id","busy");busy.innerHTML='<img src="/busy.gif" id="busypict" />';document.body.appendChild(busy);}function endBusy(){rmChild('busy');rmChild('busyBg');}function rmChild(id){var e=document.getElementById(id);if(e!=null)document.body.removeChild(e);}function rmAllChildren(id){var e=document.getElementById(id);if(!e)return;while(e.hasChildNodes()){e.removeChild(e.firstChild);}return true;}function drawLink(link,soc){if(document.getElementById('dlgBx')==null){DialogBox('Share the link', '<div class="dlgfrm"><div class="share"><p>Paste link in e-mail or IM</p><p><input type=\"text\" value=\"'+link+'\" size=\"50\" id=\"sharelink\" onFocus=\"select(); return false;\"/></p><p><div id=\"socshare\"></div></p></div></div><div class="dlgbtns"><input type=\"submit\" value=\"Close\" onClick=\"closeDialogBox();return false;\" /></div>',false);document.getElementById('sharelink').focus();if(soc){document.getElementById('socshare').innerHTML='<p>'+soc+'</p>';}}}function isInPoly(points,ptLat,ptLong){var lat=[];var lng=[];for (var i=0;i<points.length/2;++i){var p=i*2;lat.push(points[p]-ptLat);lng.push(points[p+1]-ptLong);}var lC=0;var rC=0;for (var i=0;i<lat.length;++i){var ptLa=lat[i];var ptLo=lng[i];var np=(i+(lat.length-1))%lat.length;var npLa=lat[np];var npLo=lng[np];if(ptLo==0&&ptLa==0){return true;}var rStad=(ptLa>0)!=(npLa>0);var lStad=(ptLa<0)!=(npLa<0);if(rStad||lStad){var x=(ptLo*npLa-npLo*ptLa)/(npLa-ptLa);if(x>0&&rStad){++rC;}if(x<0&&lStad){++lC;}}}if((rC%2)!=(lC%2)){return true;}return (rC%2)==1;}/* imported from http:/www.JSON.org/json2.js */if(!this.JSON){ this.JSON ={}; }(function (){function f(n){return n < 10 ? '0' + n : n;}if(typeof Date.prototype.toJSON !== 'function'){Date.prototype.toJSON = function (key){return isFinite(this.valueOf()) ?this.getUTCFullYear()  + '-' +f(this.getUTCMonth() + 1) + '-' +f(this.getUTCDate())   + 'T' +f(this.getUTCHours())   + ':' +f(this.getUTCMinutes())  + ':' +f(this.getUTCSeconds())  + 'Z' : null;};String.prototype.toJSON =Number.prototype.toJSON =Boolean.prototype.toJSON = function (key){return this.valueOf();};}var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta ={'\b': '\\b','\t': '\\t','\n': '\\n','\f': '\\f','\r': '\\r','"' : '\\"','\\': '\\\\'},rep;function quote(string){escapable.lastIndex = 0;return escapable.test(string) ?'"' + string.replace(escapable, function (a){var c = meta[a];return typeof c === 'string' ? c :'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);}) + '"' :'"' + string + '"';}function str(key, holder){var i,k,v,length,mind = gap,partial,value = holder[key];if(value && typeof value === 'object' &&typeof value.toJSON === 'function'){value = value.toJSON(key);}if(typeof rep === 'function'){value = rep.call(holder, key, value);}switch (typeof value){case 'string':return quote(value);case 'number':return isFinite(value) ? String(value) : 'null';case 'boolean':case 'null':return String(value);case 'object':if(!value){return 'null';}gap += indent;partial = [];if(Object.prototype.toString.apply(value) === '[object Array]'){length = value.length;for (i = 0; i < length; i += 1){partial[i] = str(i, value) || 'null';}v = partial.length === 0 ? '[]' :gap ? '[\n' + gap +partial.join(',\n' + gap) + '\n' +mind + ']' :'[' + partial.join(',') + ']';gap = mind;return v;}if(rep && typeof rep === 'object'){length = rep.length;for (i = 0; i < length; i += 1){k = rep[i];if(typeof k === 'string'){v = str(k, value);if(v){partial.push(quote(k) + (gap ? ': ' : ':') + v);}}}} else{for (k in value){if(Object.hasOwnProperty.call(value, k)){v = str(k, value);if(v){partial.push(quote(k) + (gap ? ': ' : ':') + v);}}}}v = partial.length === 0 ? '{}' :gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +mind + '}' : '{' + partial.join(',') + '}';gap = mind;return v;}}if(typeof JSON.stringify !== 'function'){JSON.stringify = function (value, replacer, space){var i;gap = '';indent = '';if(typeof space === 'number'){for (i = 0; i < space; i += 1){indent += ' ';}} else if(typeof space === 'string'){indent = space;}rep = replacer;if(replacer && typeof replacer !== 'function' &&(typeof replacer !== 'object' ||typeof replacer.length !== 'number')){throw new Error('JSON.stringify');}return str('',{'': value});};}if(typeof JSON.parse !== 'function'){JSON.parse = function (text, reviver){var j;function walk(holder, key){var k, v, value = holder[key];if(value && typeof value === 'object'){for (k in value){if(Object.hasOwnProperty.call(value, k)){v = walk(value, k);if(v !== undefined){value[k] = v;} else{delete value[k];}}}}return reviver.call(holder, key, value);}cx.lastIndex = 0;if(cx.test(text)){text = text.replace(cx, function (a){return '\\u' +('0000' + a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))){j = eval('(' + text + ')');return typeof reviver === 'function' ?walk({'': j}, '') : j;}throw new SyntaxError('JSON.parse');};}}());function getComputedRealXY(obj){var curleft=curtop=0;if(hjq&&obj.id){var p=$('#'+obj.id).offset();curleft=p.left;curtop=p.top;}else{if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}while(obj=obj.offsetParent);}}return [curleft,curtop];}function getStyle(el, style){if(!document.getElementById) return;var value = el.style[toCamelCase(style)];if(!value)if(document.defaultView)value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style);else if(el.currentStyle)value = el.currentStyle[toCamelCase(style)];return value;}function toCamelCase(s){return s;}function getHttpRequest(){var httpRequest=null;if(window.XMLHttpRequest){httpRequest=new XMLHttpRequest();}else if(window.ActiveXObject){httpRequest=newActiveXObject("Microsoft.XMLHTTP");}else{alert("An error has occurred; please contact us (httpReq).");}return httpRequest;}function sendMail(f,s,r,cb,oe,to){var params='js=&f='+encodeURIComponent(f)+'&s='+encodeURIComponent(s)+'&r='+encodeURIComponent(r);if(to){if(to instanceof Array){for(var i=0;i<to.length;++i){sendMail(f,s,r,cb,oe,to[i]);}return;}params+='&z='+encodeURIComponent(to);}var hr=getHttpRequest();hr.open('POST','/ContactUs.html',true);hr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');startBusy();hr.onreadystatechange=function(){if(hr.readyState!=4){return;}endBusy();var m;try{m=JSON.parse(hr.responseText);}catch(e){oe('An unknown error ocurred. Please try again in a few minutes.');return;}if('error' in m){oe(m.error);return;}else{cb();}};hr.send(params);}function mkUniqField(){return 'msd'+Math.floor(Math.random()*79797);}FileUpload={mkframe : function(c){var n=mkUniqField();var d=document.createElement('div');d.innerHTML='<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="FileUpload.loaded(\''+n+'\')"></iframe>';document.body.appendChild(d);var i=document.getElementById(n);i.onComplete=c.onComplete;return n;},form:function(f,name){f.setAttribute('target',name);},submit:function(f,c){FileUpload.form(f,FileUpload.mkframe(c));return c.onStart();},loaded:function(id){var i=document.getElementById(id);var d=null;if(i.contentDocument){d=i.contentDocument;}else if(i.contentWindow){d=i.contentWindow.document;}else{d=window.frames[id].document;}if(d.location.href=="about:blank"){return;}var r=d.body.innerHTML;if(r.match('^<pre.*<\/pre>$')){var pre='<pre>';r=r.substring(r.indexOf('>')+1,r.length-(pre.length+1));}i.onComplete(r);}};var mobile=false;function createPOITip(p,poi){if(!poi)poi=p.poi;rmChild('poiTip');var dt=document.createElement('div');dt.className="poiTip";dt.setAttribute("id","poiTip");var m=document.getElementById('maparea');if(m==null)m=document.getElementById('rtmap');if(m==null)m=document.getElementById('dirmap');if(m==null)m=document.getElementById('rtpmobmap');if(m==null)m=document.getElementById('welmap');if(m.style.position=='fixed'){dt.style.position='fixed';}else{dt.style.position='absolute';}dt.style.display='block';var off=getComputedRealXY(m);if(overlay!=='undefined'&&overlay&&poi!=='undefined'&&poi){var t=overlay.getProjection().fromLatLngToContainerPixel(poi.getCenter());off[0]+=t.x;off[1]+=t.y;}var left=off[0]-250;var top=off[1];if(left<=0){left=off[0];top+=100;}if(top<0){top=0;}if(mobile){left=20;top+=100;}if(document.getElementById('rtpmobmap')!=null){top=0;left=35;}dt.style.left=left+'px';dt.style.top=top+'px';dt.style.maxWidth='200px';dt.style.minWidth='150px';var del='';if(poi!=='undefined'&&poi.getOptions){del+=poi.getOptions();}if(poi!=='undefined'&&poi.canDelete()){var onRC="var p=document.getElementById('"+p.id+"').poi;removeMarker(p);p.onRemoveMarker();return false;";del+='<a href="#" onclick="'+onRC+'">Remove</a> &#8226; ';}var onC="rmChild('poiTip');return false;";dt.innerHTML='<p>'+del+'<a href="#" onclick="'+onC+'">Close</a></p>';document.body.appendChild(dt);return dt;}function defaultElement(id,defaultTxt){var e=document.getElementById(id);if(e.placeholder&&elementSupportsAttribute('input','placeholder'))return true;var val=e.value;if(val==null||val==''){e.value=defaultTxt;addClass(e,'default_value');}else if(val==defaultTxt){addClass(e,'default_value');}e.onfocus=function(i){removeClass(e,'default_value');if(e.value==defaultTxt)e.value='';};e.onblur=function(){var val=e.value;if(val==null||val==''){e.value=defaultTxt;addClass(e,'default_value');}};}function addClass(e,v){if(!e.className){e.className=v;}else{var c=e.className;c+=' ';c+=v;e.className=v;}}function addClassL(e,v){return addClass(document.getElementById(e),v);}function hasClass(e,c){if(!e.className){return false;}return e.className.match('(\\s|^)'+c+'(\\s|$)');}function hasClassL(e,c){return hasClass(document.getElementById(e),c);}function removeClass(e,c){if(!e||!e.className){return true;}var r='(\\s|^)'+c+'(\\s|$)';if(e.className.match(r)){e.className=e.className.replace(new RegExp(r),' ');}}function removeClassL(e,c){return removeClass(document.getElementById(e),c);}function maybeAdvance(c,l,n){if(document.getElementById(c).value.length==l){document.getElementById(n).focus();}}function setErrorField(b,e,err){if(e){document.getElementById(e).innerHTML=err;document.getElementById(b).style.display='block';}else{document.getElementById(b).style.display='none';}}var curForm;var lstD;var lstP;function uploadPicture(id,fl,va){curForm=id;lstD=fl;lstP=va;var func="'onStart':upload,'onComplete':uploaded";var f=document.getElementById(id);f.innerHTML='<div class="imgUpld"><h2>Share your pictures!</h2><p>Share your experience of this drive with our community by uploading your photographs.</p><p class="small">Approved pictures will be posted on this and other pages per our <a href="/About/terms.html">terms of use</a>.</p><p id="imgErr" class="error" style="display:none"><b>Error</b><span id="imgErrMsg"></span></p><form action="/image-uploader" method="post" onsubmit="if(document.getElementById(\'imgFile\').value==\'\'){document.getElementById(\'imgErrMsg\').innerHTML=\'Please select a file to upload.\';showElement(\'imgErr\');return false;}return FileUpload.submit(this,{'+func+'});" target="upldtgt" enctype="multipart/form-data"><input type="hidden" name="'+fl+'" value="'+va+'" /><p><label for="imgDesc">Description:</label> <input id="imgDesc" type="text" name="e" /></p><p><label for="imgFile">File:</label> <input id="imgFile" type="file" name="imgFile" /></p><input id="imgSubm" type="submit" value="Share" /> <div id="imgBusy" style="display:none">Please wait<img src="/small-busy.gif" alt="Please wait" /></div></form></div>';}function upload(){hideElement('imgErr');showElement('imgBusy');hideElement('imgSubm');hideElement('imgFile');return true;}function hideElement(id){var f=document.getElementById(id);if(f==null)alert(id);f.style.display='none';}function showElement(id){var f=document.getElementById(id);if(f==null)alert(id);f.style.display='block';}function showElementI(id){var f=document.getElementById(id);if(f==null)alert(id);f.style.display='inline';}function isShown(id){var f=document.getElementById(id);if(f==null)alert(id);return f.style.display!=''&&f.style.display!='none';}function uploaded(d){var done=false;try{var da=JSON.parse(d);done='success' in da;}catch(e){}if(!done){document.getElementById('imgErrMsg').innerHTML='An error occurred. Please try again.';showElement('imgErr');hideElement('imgBusy');showElement('imgSubm');showElement('imgFile');}var f=document.getElementById(curForm);var msg="'"+curForm+"'";f.innerHTML='<div class="imgUpldGood">Thanks for sharing! <a href="#" onclick="uploadPicture('+msg+',lstD,lstP);return false;">Share another picture?</a></div>';}function elementSupportsAttribute(e,a){var t=document.createElement(e);if(a in t)return true;return false;}function supportsDataList(){return !!document.createElement('datalist').options;}function focusElement(e){if(!elementSupportsAttribute('input','autofocus')){document.getElementById(e).focus();}}var datePicker={calDiv : null,calForm : null,destId : null,dateToDisplay : null,onSet:null,shortDate:false,getFirstDay:function(year,month){return new Date(year,month,1).getDay();},getMonthLen:function(year,month){var mo=new Date(year,month+1,1);mo.setHours(mo.getHours()-3);return mo.getDate();},useShortDate:function(){this.shortDate=true;},populateTable:function(form){var today=new Date();var mo=form.chooseMonth.selectedIndex;var yr=parseInt(form.calyear.options[form.calyear.selectedIndex].text);var firstDay=this.getFirstDay(yr,mo);var howMany=this.getMonthLen(yr,mo);var dc=1;var tb=document.getElementById("caltb");while(tb.rows.length>0){tb.deleteRow(0);}var nr,nc,dateNum;var done=false;while(!done){nr=tb.insertRow(tb.rows.length);if(nr){for(var i=0;i<7;++i){nc=nr.insertCell(nr.cells.length);if(tb.rows.length==1&&i<firstDay){nc.innerHTML='&nbsp;';continue;}if(dc==howMany)done=true;if(dc<=howMany){if(this.dateToDisplay.getFullYear()==yr&&this.dateToDisplay.getMonth()==form.chooseMonth.selectedIndex&&this.dateToDisplay.getDate()==dc){nc.id='caltoday';}if(today.getFullYear()>yr||(today.getFullYear()==yr&&today.getMonth()>form.chooseMonth.selectedIndex)||(today.getFullYear()==yr&&today.getMonth()==form.chooseMonth.selectedIndex&&dc<today.getDate()))nc.innerHTML=dc;else{nc.innerHTML="<a href='#' onclick='datePicker.chooseDate("+dc+","+mo+","+yr+");return false;'>"+dc+"</a>";}dc++;}else{nc.innertHTML='&nbsp;';}}}else{done=true;}}},init:function(calDiv,calForm,destId,onSet){this.onSet=onSet;this.calDiv=calDiv;this.calForm=calForm;this.destId=destId;instContMen();var off=getComputedRealXY(document.getElementById(destId));if(off[0]+300>getWindowWidth())off[0]=getWindowWidth()-300;showElement(calDiv.id);this.calDiv.style.top=off[1]+'px';this.calDiv.style.left=off[0]+'px';this.fillYears();document.getElementById(destId).blur();document.getElementById('calprevmo').onclick=function(){if(calForm.chooseMonth.selectedIndex==0){if(calForm.calyear.selectedIndex==0)return false;else calForm.calyear.selectedIndex=calForm.calyear.selectedIndex-1;calForm.chooseMonth.selectedIndex=calForm.chooseMonth.options.length;}else{calForm.chooseMonth.selectedIndex=calForm.chooseMonth.selectedIndex-1;}calForm.chooseMonth.onchange(null);return false;};document.getElementById('calnextmo').onclick=function(){if(calForm.chooseMonth.selectedIndex==calForm.chooseMonth.options.length-1){if(calForm.calyear.selectedIndex==calForm.calyear.options.length-1)return false;calForm.chooseMonth.selectedIndex=0;calForm.calyear.selectedIndex=calForm.calyear.selectedIndex+1;}else{calForm.chooseMonth.selectedIndex=calForm.chooseMonth.selectedIndex+1;}calForm.chooseMonth.onchange(null);return false;};var today=new Date();var v=Date.parse(document.getElementById(this.destId).value);this.dateToDisplay=isNaN(v)||v<today.getMilliseconds()?today:new Date(v);calForm.chooseMonth.selectedIndex=this.dateToDisplay.getMonth();document.getElementById('calyear').selectedIndex=this.dateToDisplay.getYear()-today.getYear();this.populateTable(calForm);},fillYears:function(){var today=new Date();var yr=today.getFullYear();var yearChooser=document.getElementById('calyear');yearChooser.options.length=0;for(i=yr;i<yr+2;++i){yearChooser.options[yearChooser.options.length]=new Option(i,i);}this.setCurrMonth(today);},setCurrMonth:function(today){document.getElementById("chooseMonth").selectedIndex=today.getMonth();},chooseDate:function(date,month,year){document.getElementById(this.destId).value=document.getElementById("chooseMonth").options[month].text+' '+date+', '+year;if(this.shortDate){var dow=["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"];var mos=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var d=new Date(document.getElementById(this.destId).value);document.getElementById(this.destId).value=dow[d.getDay()]+" "+mos[month]+" "+date+", "+year;}hideElement(this.calDiv.id);if(this.onSet)this.onSet();}};function copyList(dst,src){dst.options.length=0;for(var i=0;i<src.options.length;++i){dst.options[i]=new Option(src.options[i].text,src.options[i].value);}dst.selectedIndex=0;}var timeToFade=1000.0;function fade(eid){var e=document.getElementById(eid);if(e==null)return;if(e.fadeState==null){if(e.style.opacity==null||e.style.opacity==''||e.style.opactiy=='1')e.fadeState=2;else e.fadeState=-2;}if(e.fadeState==1||e.fadeState==-1){e.fadeState=e.fadeState==1?-1:1;e.fadeTimeLeft=timeToFade-e.fadeTimeLeft;}else{e.fadeState=e.fadeState==2?-1:1;e.fadeTimeLeft=timeToFade;setTimeout("animateFade("+new Date().getTime()+",'"+eid+"')", 33);}}function animateFade(lastTick,eid){var curTick=new Date().getTime();var elapsed=curTick-lastTick;var e=document.getElementById(eid);if(e.fadeState==2||e.fadeState==-2)return;if(e.fadeTimeLeft<=elapsed){e.style.opacity=e.fadeState==1?'1':'0';e.style.filter='alpha(opacity='+(e.fadeState==1?'100':'0')+')';e.fadeState=e.fadeState==1?2:-2;return;}e.fadeTimeLeft-=elapsed;var newOpVal=e.fadeTimeLeft/timeToFade;if(e.fadeState==1)newOpVal=1-newOpVal;e.style.opacity=newOpVal;e.style.opacity=newOpVal;e.style.filter='alpha(opacity='+(newOpVal*100)+')';setTimeout('animateFade('+curTick+",'"+eid+"')",33);}var searchState=null;var searchDest=null;var searchQ=null;var searchHtml5Ok=true;var searchCallback=null;function doSearch(url,srchTxt,div,noHtml5,searchCb){if(searchState==null){searchState=getHttpRequest();}searchCallback=searchCb;if(noHtml5)searchHtml5Ok=false;if(searchDest!=null&&document.getElementById(searchDest)!=null){hideElement(searchDest);}searchDest=div;searchQ=srchTxt;if(searchState==null)return;if(searchState.readyState==4||searchState.readyState==0){var srch=escape(document.getElementById(srchTxt).value);searchState.open("GET",url+(url.indexOf('?')!=-1?'&':'?')+"s="+srch, true);searchState.onreadystatechange=handleSearchRequest;searchState.send(null);}}function handleSearchRequest(){if(searchState.readyState==4){var html5=searchHtml5Ok&&supportsDataList();if(navigator.userAgent.toLowerCase().indexOf('safari')>0&&navigator.userAgent.toLowerCase().indexOf('iphone')==-1){html5=false;}var div=document.getElementById(searchDest);div.innerHTML='';var ul=document.createElement('ul');div.appendChild(ul);try{m=JSON.parse(searchState.responseText);}catch(e){hideElement(searchDest);return;}if('error' in m){hideElement(searchDest);return;}if('list' in m){var list=document.getElementById(searchDest+'l');if(html5){while(list.hasChildNodes()){list.removeChild(list.firstChild);}}var q=document.getElementById(searchQ);var off=getComputedRealXY(q);var st=off[1]+20;var sl=off[0];div.style.left=sl+'px';div.style.top=st+'px';for(var i=0;i<m.list.length;++i){var li=document.createElement('li');li.innerHTML='<a href="#" onclick="document.getElementById(&quot;'+searchQ+'&quot;).value=&quot;'+m.list[i]+'&quot;;hideElement(&quot;'+searchDest+'&quot;);'+(searchCallback!=null?'searchCallback('+m.list[i]+');':'')+'return false;">'+m.list[i]+'</a>';if(i==0){li.innerHTML+="<div style='float:right;'><a href='#' onclick=\"hideElement('"+searchDest+"');return false;\">X</a></div>";}ul.appendChild(li);if(html5){var no=document.createElement("option");no.value=m.list[i];list.appendChild(no);}}}if(!html5){div.style.opacity='1';div.style.filter='alpha(opacity=100)';div.fadeState=2;showElement(searchDest);}else{document.getElementById(searchQ).setAttribute('autocomplete','on');}}}function createContextMenu(r){var div=document.getElementById('context_menu');if(div!=null){rmChild('context_menu');if(div.style.display!='none'){return null;}}div=document.createElement('div');div.setAttribute('id','context_menu');div.style.display='block';if(r){var prt=document.getElementById(r);var off=getComputedRealXY(prt);var st=off[1]+prt.offsetHeight;var sl=off[0];div.style.left=sl+'px';div.style.top=st+'px';}instContMen();return div;}function addContextMenuDivider(ul){var l=document.createElement('li');l.setAttribute('class','divider');l.innerHTML=' ';ul.appendChild(l);}function addContextMenuItem(ul,hr,oc,d,t){var l=document.createElement('li');l.innerHTML='<a href="'+hr+'" onclick="'+oc+(t?('" title="'+t):'')+'">'+d+'</a>';ul.appendChild(l);}function instContMen(){document.onmouseup=function(){var vs=['context_menu',searchDest];for(var i=0;i<vs.length;++i){if(vs[i]==null)continue;var e=document.getElementById(vs[i]);if(e!=null){if(isShown(vs[i])){hideElement(vs[i]);}}}};}function moveListUp(id){var li=document.getElementById(id);var p=li.parentNode;var l=getIndex(id);if(l==0||l==-1){return false;}p.removeChild(li);p.insertBefore(li,p.childNodes[l-1]);return true;}function moveListDown(id){var li=document.getElementById(id);var p=li.parentNode;var l=getIndex(id);if(l==p.childNodes.length||l==-1){return false;}p.removeChild(li);p.insertBefore(li,p.childNodes[l+1]);return true;}function getIndex(id){var li=document.getElementById(id);var p=li.parentNode;for(var i=0;i<p.childNodes.length;++i){if(p.childNodes[i]==li){return i;}}return -1;}function clearOptionList(opt){for(var i=0;i<opt.options.length;++i){opt.remove(0);}}function copyToOptionList(opt,l){clearOptionList(opt);for(var i=0;i<l.length;++i){var v=new Option(l[i],l[i]);if(iev!=-1){opt.add(v,i);}else{opt[i]=v;}}}function copyFromOptionList(l){var retval=[];for(var i=0;i<l.length;++i){retval[retval.length]=l[i].value;}return retval;}function removeSelectedFromOptions(opts){if(opts.selectedIndex!=-1){opts.remove(opts.selectedIndex);}}/*Find the selector s and apply function f to it*/function tweakStyle(s,f){var r=[];for(y in document.styleSheets){try{if('cssRules' in document.styleSheets[y]){r=document.styleSheets[y].cssRules;}else if('rules' in document.styleSheets[y]){r=document.styleSheets[y].rules;}}catch(e){continue;}for(n in r){if(r[n].selectorText==s){f(r[n]);}}}}function toggleShowHide(t,p,op,cl){if(isShown(t)){hideToggle(t,p,op,cl);}else{showToggle(t,p,op,cl);}return false;}function hideToggle(t,p,op,cl){if(op==null)op='&#9660;';if(cl==null)cl='&#9668;';hideElement(t);if(hjq){$('#'+p).html(cl);}else{var pd=document.getElementById(p);if(pd)pd.innerHTML=(iev!=-1&&iev<9)?'<span>'+cl+'</span>':cl;}return false;}function showToggle(t,p,op,cl){if(op==null)op='&#9660;';if(cl==null)cl='&#9668;';showElement(t);var pd=document.getElementById(p);if(hjq){$('#'+p).html(op);}else{if(pd)pd.innerHTML=(iev!=-1&&iev<9)?'<span>'+op+'</span>':op;}return false;}if(!Array.indexOf){Array.prototype.indexOf = function(obj){for(var i=0; i<this.length; i++){if(this[i]==obj){return i;}}return -1;}}var progSteps=0;var progCurSteps=0;function initProg(ttl,steps){if(document.getElementById('progbar')){endProg();}var p=document.createElement('div');p.setAttribute('id','progbar');var t=document.createElement('div');t.setAttribute('id','progttl');t.innerHTML=ttl;p.appendChild(t);t=document.createElement('div');t.setAttribute('id','progbarbar');p.appendChild(t);var ta=document.createElement('div');ta.setAttribute('id','progbardn');t.appendChild(ta);ta.style.width='0px';t=document.createElement('div');t.setAttribute('id','progbarlbl');t.innerHTML='0% complete';p.appendChild(t);document.body.appendChild(p);progSteps=steps;progCurSteps=0;}function incStep(){++progCurSteps;if(progCurSteps>progSteps)progCurSteps=progSteps;var prog=((progCurSteps/progSteps)*100);var t=document.getElementById('progbardn');t.style.width=prog+'px';t=document.getElementById('progbarlbl');t.innerHTML=prog.toFixed(1)+'% complete';}function endProg(){rmChild('progbar');}
