/* (c) Hagen Software Inc. */var myImage='';var isOpera=(navigator.userAgent.indexOf('Opera')!=-1);var isIE=(!isOpera&&navigator.userAgent.indexOf('MSIE')!=-1);var hidemetimer;var isFading=0;function UpdateChecklist(ev){var el=Event.element(ev);ev.stop();el.blur();if(el.nodeName!=='A'){el=el.down('a')||el.up('a');}
var listType=el.hasClassName('cl_status')?'checklist':'comparelist';var prefix;var idPattern;var Chklist;if(listType==='checklist'){prefix='cl_';idPattern=new RegExp('^check_(.+)_([0-9]+)$');Chklist=new Checklist();}else if(listType==='comparelist'){prefix='cmp_';idPattern=new RegExp('^compare_(.+)_([0-9]+)_([A-F0-9]+)$');Chklist=new Checklist('cmplist');}
var addOrDel=el.hasClassName(prefix+'checked')?'del':'add';if(hidemetimer)
clearTimeout(hidemetimer);var m=el.id.match(idPattern);if(!m){throw'Failed to match '+listType+' + id "'+el.id+'"';return true;}
var sec=m[1];var dbid=m[2];var extra=m[3];if(listType==='comparelist'){var skipLengthCheck;var compareList=Chklist.list();if(typeof(compareMultiSection)==='undefined'||!compareMultiSection){for(var i=0;i<compareList.length;i++){var clSec=compareList[i][0];var clNo=compareList[i][1];if(clSec!==sec){var txt=$('unabletocompare')?$('unabletocompare').innerHTML:'Unable to compare '+Chklist.plural
+' from different sections.';Chklist.showTip('comparelistupdate',txt,el);return true;}
if(clSec===sec&&clNo===dbid&&addOrDel==='add'){skipLengthCheck=1;}}}
if(typeof(compareMax)==='undefined'){compareMax=3;}
if(addOrDel==='add'&&!skipLengthCheck&&compareMax&&compareList.length>=compareMax){ev.stop();var txt=$('toomanycompare')?$('toomanycompare').innerHTML:'You can compare a maximum of '+compareMax
+' '+Chklist.plural+' at once.';Chklist.showTip('comparelistupdate',txt,el);return true;}}
var ret;if(addOrDel==='add'){ret=Chklist.add(sec,dbid,extra);if(ret){el.removeClassName(prefix+'unchecked');el.addClassName(prefix+'checked');el.title='Remove from Checklist';}}else if(addOrDel==='del'){ret=Chklist.del(sec,dbid);if(ret){el.removeClassName(prefix+'checked');el.addClassName(prefix+'unchecked');el.title='Add to Checklist';}}
if(listType==='checklist'){Chklist.showTip('checklistupdate','CheckList contains: '+Chklist.toString(),el);}
return true;}
function rowMouseOver(ev){var el=Event.element(ev);if(el.nodeName!=='TR'){el=el.up('tr');if(!el)return;}
el.addClassName('headlinerowover');var isHLR=el.hasClassName('highlightedrow');if(isHLR)
el.addClassName('highlightedrowover');el.childElements().each(function(td){if(td.hasClassName('selectedcolumn1')||td.hasClassName('selectedcolumn2')){td.addClassName('headlinerowover');if(isHLR)
td.addClassName('highlightedrowover');throw $break;}});}
function rowMouseOut(ev){var el=Event.element(ev);if(el.nodeName!=='TR'){el=el.up('tr');if(!el)return;}
el.removeClassName('highlightedrowover');el.removeClassName('headlinerowover');el.childElements().each(function(td){td.removeClassName('highlightedrowover');td.removeClassName('headlinerowover');});}
function rowClick(ev){var el=Event.element(ev);if(el.nodeName==='IMG'||el.nodeName==='A'){return;}
if(el.nodeName!=='TR'){var colspan=parseInt(el.getAttribute('colspan')||0);if(colspan>1){el=el.up('tr').previousSiblings()[0];}else{el=el.up('tr');}
if(!el)return;}
var alink=el.select('a[rel!="nofollow"]');if(alink.length){ev.stop();if(ev.shiftKey||ev.ctrlKey){window.open(alink[0].href);}else{window.location=alink[0].href;}
return false;}}
Event.observe(window,'load',function(){$$('.tnpop').each(function(el){el.observe('mouseover',function(ev){ev.stop();var parts=el.src.match(/#([0-9]+):([0-9]+):(.+)$/);if(parts){new Tip(el,'<img src="'+parts[3].replace(/,/g,'/')+'" '
+'width="'+parts[1]+'" '
+'height="'+parts[2]+'"/>');}});});$$('.headlinerow').each(function(el){el.observe('mouseover',rowMouseOver)
.observe('mouseout',rowMouseOut)
.observe('click',rowClick);});$$('.cl_status').each(function(el){el.observe('click',UpdateChecklist);$(el.parentNode).observe('click',UpdateChecklist);});$$('.cmp_status').each(function(el){el.observe('click',UpdateChecklist);$(el.parentNode).observe('click',UpdateChecklist);});$$('.nomapavailable').invoke('observe','click',function(ev){ev.stop();});$$('.tnlink').each(function(el){el.observe('click',function(ev){var el=Event.element(ev);if(el){if(el.nodeName=='IMG')el=el.parentNode;ev.stop();window.open(el.href,'userhelp','WIDTH=640,HEIGHT=480,resizable=yes,'
+'scrollbars=yes,left=150,top=100,'
+'screenX=150,screenY=100');return false;}});});$$('a.mapnewwindow').invoke('observe','click',function(ev){ev.stop();window.open(Event.element(ev).href,'mapwindow');});if($('contactadmin')){$$('.alertadmin').invoke('observe','click',initAlertAdminForm);$('closealertadmin').observe('click',closeAlertAdminForm);}
if($('sendfriend')){$$('.sendfriend').invoke('observe','click',initSendToFriend);$('closesendfriend').observe('click',closeSendToFriend);}
if(typeof(adName)=='undefined')
adName='Ad';if(typeof(isAdmin)=='undefined')
isAdmin=0;if($('mark_as_sold')){Event.observe($('mark_as_sold'),'click',confirmMarkAsSold);}
if($('is_sold')){Event.observe($('is_sold'),'click',blockEdit);}
$$('a.hlbroken').invoke('observe','click',highlightBrokenAd);$$('a.cmpbut').invoke('observe','click',compareAds);var Chklist=new Checklist('cmplist');var cmplist=Chklist.list();cmplist.each(function(kvp){var cpKVP=kvp;cpKVP.unshift('compare');var el=$(cpKVP.join('_'));if(el){el.removeClassName('cmp_unchecked');el.addClassName('cmp_checked');}});$$('.vcard').each(function(vcard){var name=[];$w('given-name additional-name family-name').each(function(w){var n=vcard.select('.'+w)[0];if(n&&n.innerHTML){name.push(n.innerHTML.toLowerCase().replace(/[^a-z0-9-]+/g,''));}});if(!name.length)
return;var n=name.join('-');if(!$(n)){vcard.writeAttribute('id','hcard-'+n);}});});function compareAds(ev){var el=Event.element(ev);var Chklist=new Checklist('cmplist');var cmplist=Chklist.list();if(!cmplist||!cmplist.length){ev.stop();el.blur();var txt=$('nocompare')?$('nocompare').innerHTML:'No items to compare.';Chklist.showTip('comparelistupdate',txt,el);return;}
if(cmplist.length<2){ev.stop();el.blur();var txt=$('oneonlycompare')?$('oneonlycompare').innerHTML:'You must select more than one item to compare';Chklist.showTip('comparelistupdate',txt,el);return;}
var ads=[];cmplist.each(function(kvp){if(kvp[2]){ads.push(kvp[2]);}});el.href='/Compare_Ad-'+ads.join(',')+'.html';}
function closeAlertAdminForm(ev){ev.stop();$('contactadmin').hide();}
function closeSendToFriend(ev){ev.stop();$('sendfriend').hide();}
function initSendToFriend(ev){ev.stop();var id=Event.element(ev).id;var adno;var sect;var sectName;var m=id.match(/^sendfriend_([0-9]+)(?:_([a-z0-9_]+))?$/);if(m){adno=m[1];sect=m[2];if(sect&&typeof(sectionNames)!=='undefined'){sectName=sectionNames.get(sect);}}
$('sendfriendadno').update(adno);$('sendfrienddb_id').value=adno;if(sectName){$('sendfriendsectname').update(sectName);}
var replStr=$('sendfriend_defbody')?$('sendfriend_defbody').innerHTML:'Check out <ad> #<adno> in <sectname> of <sitename>\n\n<adurl>';if(typeof(sitename)==='undefined'||!sitename){sitename=location.protocol+'//'+location.host+'/';}
if(!sectName||!sect){replStr=replStr.replace('in <sectname> ','');}
var v=replStr.replace('<ad>',typeof(ad)==='undefined'?'ad':ad)
.replace('<adno>',adno)
.replace('<sectname>',sectName||sect)
.replace('<sitename>',sitename)
.replace('<adurl>',getAdURL(adno));$('sendfriend_body').value=v;$('sendfriend').show();centerEl($('sendfriend'),1);}
function initAlertAdminForm(ev){ev.stop();var id=Event.element(ev).id;var adno;var sect;var sectName;var m=id.match(/^alertadmin_([0-9]+)(?:_([a-z0-9_]+))?$/);if(m){adno=m[1];sect=m[2];if(sect&&typeof(sectionNames)!=='undefined'){sectName=sectionNames.get(sect);}}
$('alertadminadno').update(adno);$('alertadmindb_id').value=adno;if(sectName){$('alertadminsectname').update(sectName);}
var replStr=$('alertadmin_defbody')?$('alertadmin_defbody').innerHTML:'I am writing to alert you to a problem with <ad> #<adno> in <sectname>\n\n<adurl>';if(typeof(sitename)==='undefined'||!sitename){sitename=location.protocol+'//'+location.host+'/';}
if(!sectName||!sect){replStr=replStr.replace('in <sectname> ','');}
var v=replStr.replace('<ad>',typeof(ad)==='undefined'?'ad':ad)
.replace('<adno>',adno)
.replace('<sectname>',sectName||sect)
.replace('<sitename>',sitename)
.replace('<adurl>',getAdURL(adno));$('alertadmin_body').value=v;$('contactadmin').show();centerEl($('contactadmin'),1);}
function CreateWindow(sec,dbid,price,type){if(type=='loan')
type='car_payments';window.open(surlnodb+'db='+sec+';print_'+type+'_popup=on;price='+price,'TheWindow','WIDTH=400,HEIGHT=600,scrollbars=yes,resize=yes,left=150,top=100,screenX=150,screenY=100');}
function printPage(){if(window.print)
window.print();else
printMsg()}
function printMsg(){if(navigator.appVersion.indexOf("Mac")!=-1)
alert("To print this page press Command-P.")
else
alert("To print this page press Control-P.")}
function blockEdit(ev){if(isAdmin){if(!confirm('This '+adName+' has been marked as Sold and should\n'+
'not be edited so as to allow visitors to see the item\n'+
'as it was sold.\n\n'+
'However as you are an admin user you can modify the\n'+
adName+' by clicking on the "OK" button below.')){ev_stop();return;}}else{ev.stop();alert('This '+adName+' has been marked as Sold. To allow visitors to\n'
+'see the item as it was sold this '+adName+' cannot be edited.\n'
+'To edit this '+adName+' you must remove the "Sold" mark.');}}
function confirmMarkAsSold(ev){var isSold=$('is_sold');if(isSold){confirmed=confirm('This will remove the "sold" sign from your '+adName+' and\n'+
'return it back to its regular type so it can be edited.\n\n'+
'Note:\n'+
'The entry should not be marked as unsold if this item really\n'+
'has been sold. This option is provided in case the sale is not\n'+
'completed and you wish to re-list the '+adName+'.\n');}else{confirmed=confirm('This will mark your '+adName+' as sold. You will not be\n'+
'able to make further changes to your '+adName+' once it\n'+
'has been marked as sold. (But you can unmark it).\n\n'+
'Click OK to Mark your '+adName+' as having been sold.');}
if(!confirmed){ev.stop();return;}
if(isSold&&isAdmin){}}
function highlightBrokenAd(ev){ev.stop();var findID=ev.element?Event.element(ev):ev;findID=$(findID.id.replace(/^hb/,'va'));if(findID){new Effect.Highlight(findID.up('tr'));}}
