// Updatefilterarea


function updatelayouts() {var futdate = new Date();var expdate = futdate.getTime();expdate += 86400*60000;futdate.setTime(expdate);var newCookie="filterlayout=1; path=/; domain=americaslocalads.com;";newCookie += " expires=" + futdate.toGMTString();window.document.cookie=newCookie}
function updatelayoutg() {var futdate = new Date();var expdate = futdate.getTime();expdate += 86400*60000;futdate.setTime(expdate);var newCookie="filterlayout=2; path=/; domain=americaslocalads.com;";newCookie += " expires=" + futdate.toGMTString();window.document.cookie=newCookie}
function updatelayoute() {var futdate = new Date();var expdate = futdate.getTime();expdate += 86400*60000;futdate.setTime(expdate);var newCookie="filterlayout=3; path=/; domain=americaslocalads.com;";newCookie += " expires=" + futdate.toGMTString();window.document.cookie=newCookie}


function updatestatecityc() {
var futdate = new Date();var expdate = futdate.getTime();expdate += 86400*60000;futdate.setTime(expdate);
var newCookie="statefilter="+document.filterbox.state.value+"; path=/; domain=americaslocalads.com;";newCookie += " expires=" + futdate.toGMTString();window.document.cookie=newCookie;
var newCookie="cityfilter="+document.filterbox.city.value+"; path=/; domain=americaslocalads.com;";newCookie += " expires=" + futdate.toGMTString();window.document.cookie=newCookie;

var strs=document.filterbox.state.value;
flts=strs.replace(/-/,"");
flts2=flts.replace(/\s+/g, '');
flts3=flts2.toLowerCase();

var strc=document.filterbox.city.value;
fltc=strc.replace(/-/,"");
fltc2=fltc.replace(/\s+/g, '');
fltc3=fltc2.toLowerCase();

window.location.href = "http:\/\/"+fltc3+'-'+flts3+".americaslocalads.com";
//alert (fltc3+flts3+"http:\/\/"+fltc3+'-'+flts3+".americaslocalads.com");
}

function updatefilterareas() {
var futdate = new Date();var expdate = futdate.getTime();expdate += 86400*60000;futdate.setTime(expdate);
var newCookie="filterarea=state; path=/; domain=americaslocalads.com;";newCookie += " expires=" + futdate.toGMTString();window.document.cookie=newCookie
}

function updatefilterarean() {
var futdate = new Date();var expdate = futdate.getTime();expdate += 86400*60000;futdate.setTime(expdate);
var newCookie="filterarea=national; path=/; domain=americaslocalads.com;";newCookie += " expires=" + futdate.toGMTString();window.document.cookie=newCookie
}


function updatecat() {
var futdate = new Date();var expdate = futdate.getTime();expdate += 86400*60000;futdate.setTime(expdate);
var newCookie="categoryfilter="+document.searching.category.value+"; path=/; domain=americaslocalads.com;";newCookie += " expires=" + futdate.toGMTString();window.document.cookie=newCookie
window.location.href = "classifiedadsearch.cgi?allcat="+document.searching.category.value;
}

function updatefarea() {

if (document.searching.filterarea[1].value == 'national'){var va='van=national';};
if (document.searching.filterarea[1].value == 'state'){var va='van=state';};
if (document.searching.filterarea[1].value == 'city'){var va='van=city';};

var futdate = new Date();var expdate = futdate.getTime();expdate += 86400*60000;futdate.setTime(expdate);
var newCookie="filterarea="+document.searching.filterarea[1].value+"; path=/; domain=americaslocalads.com;";newCookie += " expires=" + futdate.toGMTString();window.document.cookie=newCookie

window.location.href = "classifiedadsearch.cgi?allcat="+document.searching.category.value;
}

// Tabcontent
function ddtabcontent(tabinterfaceid){this.tabinterfaceid=tabinterfaceid;this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a");this.enabletabpersistence=true;this.hottabspositions=[];this.currentTabIndex=0;this.subcontentids=[];this.revcontentids=[];this.selectedClassTarget="link";}
ddtabcontent.getCookie=function(Name){var re=new RegExp(Name+"=[^;]+","i")
if(document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1]
return ""}
ddtabcontent.setCookie=function(name,value){document.cookie=name+"="+value+";path=/; domain=americaslocalads.com;"}
ddtabcontent.prototype={expandit:function(tabid_or_position){this.cancelautorun()
var tabref=""
try{if(typeof tabid_or_position=="string"&&document.getElementById(tabid_or_position).getAttribute("rel"))
tabref=document.getElementById(tabid_or_position)
else if(parseInt(tabid_or_position)!=NaN&&this.tabs[tabid_or_position].getAttribute("rel"))
tabref=this.tabs[tabid_or_position]}
catch(err){alert("Invalid Tab ID or position entered!")}
if(tabref!="")
this.expandtab(tabref)},
cycleit:function(dir,autorun){if(dir=="next"){var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0}
else if(dir=="prev"){var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1}
if(typeof autorun=="undefined")
this.cancelautorun()
this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])},
setpersist:function(bool){this.enabletabpersistence=bool},
setselectedClassTarget:function(objstr){this.selectedClassTarget=objstr || "link"},
getselectedClassTarget:function(tabref){return(this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref},
urlparamselect:function(tabinterfaceid){var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)","i"))
return(result==null)? null : parseInt(RegExp.$1)},
expandtab:function(tabref){var subcontentid=tabref.getAttribute("rel")
var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/,"")+"," : ""
this.expandsubcontent(subcontentid)
this.expandrevcontent(associatedrevids)
for(var i=0;i<this.tabs.length;i++){this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""}
if(this.enabletabpersistence)
ddtabcontent.setCookie(this.tabinterfaceid,tabref.tabposition)
this.setcurrenttabindex(tabref.tabposition)},
expandsubcontent:function(subcontentid){for(var i=0;i<this.subcontentids.length;i++){var subcontent=document.getElementById(this.subcontentids[i])
subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none"}},
expandrevcontent:function(associatedrevids){var allrevids=this.revcontentids
for(var i=0;i<allrevids.length;i++){document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"}},
setcurrenttabindex:function(tabposition){for(var i=0;i<this.hottabspositions.length;i++){if(tabposition==this.hottabspositions[i]){this.currentTabIndex=i
break}}},
autorun:function(){this.cycleit('next',true)},
cancelautorun:function(){if(typeof this.autoruntimer!="undefined")
clearInterval(this.autoruntimer)},
init:function(automodeperiod){var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid)
var selectedtab=-1
var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid)
this.automodeperiod=automodeperiod || 0
for(var i=0;i<this.tabs.length;i++){this.tabs[i].tabposition=i
if(this.tabs[i].getAttribute("rel")){var tabinstance=this
this.hottabspositions[this.hottabspositions.length]=i
this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel")
this.tabs[i].onclick=function(){tabinstance.expandtab(this)
tabinstance.cancelautorun()
return false}
if(this.tabs[i].getAttribute("rev")){this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))}
if(selectedtabfromurl==i || this.enabletabpersistence&&selectedtab==-1&&parseInt(persistedtab)==i || !this.enabletabpersistence&&selectedtab==-1&&this.getselectedClassTarget(this.tabs[i]).className=="selected"){selectedtab=i}}}
if(selectedtab!=-1)
this.expandtab(this.tabs[selectedtab])
else
this.expandtab(this.tabs[this.hottabspositions[0]])
if(parseInt(this.automodeperiod)>500&&this.hottabspositions.length>1){
this.autoruntimer=setInterval(function(){tabinstance.autorun()},this.automodeperiod)}}}
// Tabcontent

// Switchcontent
var switchcontent_ajax_msg='<em>Loading content...</em>'
var switchcontent_ajax_bustcache=true
function switchcontent(className,filtertag){this.className=className
this.collapsePrev=false
this.persistType="none"
this.filter_content_tag=(typeof filtertag!="undefined")? filtertag.toLowerCase(): ""
this.ajaxheaders={}}
switchcontent.prototype.setStatus=function(openHTML,closeHTML){this.statusOpen=openHTML
this.statusClosed=closeHTML}
switchcontent.prototype.setColor=function(openColor,closeColor){this.colorOpen=openColor
this.colorClosed=closeColor}
switchcontent.prototype.setPersist=function(bool,days){if(bool==true){if(typeof days=="undefined")
this.persistType="session"
else{this.persistType="days"
this.persistDays=parseInt(days)}}
else
this.persistType="none"}
switchcontent.prototype.collapsePrevious=function(bool){this.collapsePrev=bool}
switchcontent.prototype.setContent=function(index,filepath){this.ajaxheaders["header"+index]=filepath}
switchcontent.prototype.sweepToggle=function(setting){if(typeof this.headers!="undefined"&&this.headers.length>0){for(var i=0;i<this.headers.length;i++){if(setting=="expand")
this.expandcontent(this.headers[i])
else if(setting=="contract")
this.contractcontent(this.headers[i])}}}
switchcontent.prototype.defaultExpanded=function(){var expandedindices=[]
for(var i=0;(!this.collapsePrev&&i<arguments.length)||(this.collapsePrev&&i==0);i++)
expandedindices[expandedindices.length]=arguments[i]
this.expandedindices=expandedindices.join(",")}
switchcontent.prototype.togglecolor=function(header,status){if(typeof this.colorOpen!="undefined")
header.style.color=status}
switchcontent.prototype.togglestatus=function(header,status){
if(typeof this.statusOpen!="undefined")
header.firstChild.innerHTML=status}
switchcontent.prototype.contractcontent=function(header){var innercontent=document.getElementById(header.id.replace("-title",""))
innercontent.style.display="none"
this.togglestatus(header,this.statusClosed)
this.togglecolor(header,this.colorClosed)}
switchcontent.prototype.expandcontent=function(header){var innercontent=document.getElementById(header.id.replace("-title",""))
if(header.ajaxstatus=="waiting"){switchcontent.connect(header.ajaxfile,header)}
innercontent.style.display="block"
this.togglestatus(header,this.statusOpen)
this.togglecolor(header,this.colorOpen)}
switchcontent.prototype.toggledisplay=function(header){
var innercontent=document.getElementById(header.id.replace("-title",""))
if(innercontent.style.display=="block")
this.contractcontent(header)
else{this.expandcontent(header)
if(this.collapsePrev&&typeof this.prevHeader!="undefined"&&this.prevHeader.id!=header.id)
this.contractcontent(this.prevHeader)}
if(this.collapsePrev)
this.prevHeader=header}
switchcontent.prototype.collectElementbyClass=function(classname){var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)","i")
this.headers=[],this.innercontents=[]
if(this.filter_content_tag!="")
var allelements=document.getElementsByTagName(this.filter_content_tag)
else
var allelements=document.all? document.all : document.getElementsByTagName("*")
for(var i=0;i<allelements.length;i++){if(typeof allelements[i].className=="string"&&allelements[i].className.search(classnameRE)!=-1){if(document.getElementById(allelements[i].id+"-title")!=null){this.headers[this.headers.length]=document.getElementById(allelements[i].id+"-title")
this.innercontents[this.innercontents.length]=allelements[i]}}}}
switchcontent.prototype.init=function(){var instanceOf=this
this.collectElementbyClass(this.className)
if(this.headers.length==0)
return
if(this.persistType=="days"&&(parseInt(switchcontent.getCookie(this.className+"_dtrack"))!=this.persistDays))
switchcontent.setCookie(this.className+"_d","",-1)
var opencontents_ids=(this.persistType=="session"&&switchcontent.getCookie(this.className)!="")? ','+switchcontent.getCookie(this.className)+',' :(this.persistType=="days"&&switchcontent.getCookie(this.className+"_d")!="")? ','+switchcontent.getCookie(this.className+"_d")+',' :(this.expandedindices)? ','+this.expandedindices+',' : ""
for(var i=0;i<this.headers.length;i++){
if(typeof this.ajaxheaders["header"+i]!="undefined"){this.headers[i].ajaxstatus='waiting'
this.headers[i].ajaxfile=this.ajaxheaders["header"+i]}
if(typeof this.statusOpen!="undefined")
this.headers[i].innerHTML='<span class="status"></span>'+this.headers[i].innerHTML
if(opencontents_ids.indexOf(','+i+',')!=-1){this.expandcontent(this.headers[i])
if(this.collapsePrev)
this.prevHeader=this.headers[i]}
else
this.contractcontent(this.headers[i])
this.headers[i].onclick=function(){instanceOf.toggledisplay(this)}}
switchcontent.dotask(window,function(){instanceOf.rememberpluscleanup()},"unload")}
switchcontent.prototype.rememberpluscleanup=function(){var opencontents=new Array("none")
for(var i=0;i<this.innercontents.length;i++){if(this.persistType!="none"&&this.innercontents[i].style.display=="block"&&(!this.collapsePrev ||(this.collapsePrev&&opencontents.length<2)))
opencontents[opencontents.length]=i
this.headers[i].onclick=null}
if(opencontents.length>1)
opencontents.shift()
if(typeof this.statusOpen!="undefined")
this.statusOpen=this.statusClosed=null
if(this.persistType=="session")
switchcontent.setCookie(this.className,opencontents.join(","))
else if(this.persistType=="days"&&typeof this.persistDays=="number"){switchcontent.setCookie(this.className+"_d",opencontents.join(","),this.persistDays)
switchcontent.setCookie(this.className+"_dtrack",this.persistDays,this.persistDays)}}
switchcontent.dotask=function(target,functionref,tasktype){var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if(target.addEventListener)
target.addEventListener(tasktype,functionref,false)
else if(target.attachEvent)
target.attachEvent(tasktype,functionref)}
switchcontent.connect=function(pageurl,header){var page_request=false
var bustcacheparameter=""
if(window.ActiveXObject){try{page_request=new ActiveXObject("Msxml2.XMLHTTP")}
catch(e){try{page_request=new ActiveXObject("Microsoft.XMLHTTP")}
catch(e){}}}
else if(window.XMLHttpRequest)
page_request=new XMLHttpRequest()
else
return false
page_request.onreadystatechange=function(){switchcontent.loadpage(page_request,header)}
if(switchcontent_ajax_bustcache)
bustcacheparameter=(pageurl.indexOf("?")!=-1)? "&"+new Date().getTime(): "?"+new Date().getTime()
page_request.open('GET',pageurl+bustcacheparameter,true)
page_request.send(null)}
switchcontent.loadpage=function(page_request,header){var innercontent=document.getElementById(header.id.replace("-title",""))
innercontent.innerHTML=switchcontent_ajax_msg
if(page_request.readyState==4&&(page_request.status==200 || window.location.href.indexOf("http")==-1)){innercontent.innerHTML=page_request.responseText
header.ajaxstatus="loaded"}}
switchcontent.getCookie=function(Name){var re=new RegExp(Name+"=[^;]+","i");if(document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1]
return ""}
switchcontent.setCookie=function(name,value,days){if(typeof days!="undefined"){var expireDate=new Date();var expstring=expireDate.setDate(expireDate.getDate()+days);document.cookie=name+"="+value+"; path=/; domain=americaslocalads.com; expires="+expireDate.toGMTString()}
else
document.cookie=name+"="+value+"; path=/; domain=americaslocalads.com;"}

// Switchcontent