// just your standard ajax request function

function makeHttpRequest(url, callback_function, return_xml)
{
   var http_request = false;

   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
       }
   } else if (window.ActiveXObject) { // IE
       try {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
           try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
       }
   }

   if (!http_request) {
       alert('Unfortunatelly you browser doesn\'t support this feature.');
       return false;
   }
   http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
           if (http_request.status == 200) {
               if (return_xml) {
                   eval(callback_function + '(http_request.responseXML)');
               } else {
                   eval(callback_function + '(http_request.responseText)');
               }
           } else {
               alert('There was a problem with the request.(Code: ' + http_request.status + ')');
           }
       }
   }
   http_request.open('GET', url, true);
   http_request.send(null);
}


/*	sIFR 2.0.1
	Copyright 2004 - 2005 Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben

	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/
function call_functions(tU,cN){setStatus(tU);setFocus(cN);};function setStatus(tU){window.status=typeof(tU)!='undefined'?tU:'';};function setFocus(cN){var eEs=document.getElementsByTagName('embed');eE=eEs[cN];if(eE.focus)eE.focus();};var hasFlash=function(){var a=6;if(navigator.appVersion.indexOf("MSIE")!=-1&&navigator.appVersion.indexOf("Windows")>-1){document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & '+a+'))) \n</script\> \n');if(window.hasFlash!=null)return window.hasFlash}if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]&&navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){var b=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;return parseInt(b.charAt(b.indexOf(".")-1))>=a}return false}();String.prototype.normalize=function(){return this.replace(/\s+/g," ")};if(Array.prototype.push==null){Array.prototype.push=function(){var i=0,a=this.length,b=arguments.length;while(i<b){this[a++]=arguments[i++]}return this.length}}if(!Function.prototype.apply){Function.prototype.apply=function(a,b){var c=[];var d,e;if(!a)a=window;if(!b)b=[];for(var i=0;i<b.length;i++){c[i]="b["+i+"]"}e="a.__applyTemp__("+c.join(",")+");";a.__applyTemp__=this;d=eval(e);a.__applyTemp__=null;return d}}function named(a){return new named.Arguments(a)}named.Arguments=function(a){this.oArgs=a};named.Arguments.prototype.constructor=named.Arguments;named.extract=function(a,b){var c,d;var i=a.length;while(i--){d=a[i];if(d!=null&&d.constructor!=null&&d.constructor==named.Arguments){c=a[i].oArgs;break}}if(c==null)return;for(e in c)if(b[e]!=null)b[e](c[e]);return};var parseSelector=function(){var a=/^([^#.>`]*)(#|\.|\>|\`)(.+)$/;function r(s,t){var u=s.split(/\s*\,\s*/);var v=[];for(var i=0;i<u.length;i++)v=v.concat(b(u[i],t));return v}function b(c,d,e){c=c.normalize().replace(" ","`");var f=c.match(a);var g,h,i,j,k,n;var l=[];if(f==null)f=[c,c];if(f[1]=="")f[1]="*";if(e==null)e="`";if(d==null)d=document;switch(f[2]){case "#":k=f[3].match(a);if(k==null)k=[null,f[3]];g=document.getElementById(k[1]);if(g==null||(f[1]!="*"&&!o(g,f[1])))return l;if(k.length==2){l.push(g);return l}return b(k[3],g,k[2]);case ".":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;k=f[3].match(a);if(k!=null){if(g.className==null||g.className.match("\\b"+k[1]+"\\b")==null)continue;j=b(k[3],g,k[2]);l=l.concat(j)}else if(g.className!=null&&g.className.match("\\b"+f[3]+"\\b")!=null)l.push(g)}return l;case ">":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;j=b(f[3],g,">");l=l.concat(j)}return l;case "`":h=m(d,f[1]);for(i=0,n=h.length;i<n;i++){g=h[i];j=b(f[3],g,"`");l=l.concat(j)}return l;default:if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;l.push(g)}return l}}function m(d,o){if(o=="*"&&d.all!=null)return d.all;return d.getElementsByTagName(o)}function o(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}return r}();var sIFR=function(){var a="http://www.w3.org/1999/xhtml";var b=false;var c=false;var d;var ah=[];var al=document;var ak=al.documentElement;var am=window;var au=al.addEventListener;var av=am.addEventListener;var f=function(){var g=navigator.userAgent.toLowerCase();var f={a:g.indexOf("applewebkit")>-1,b:g.indexOf("safari")>-1,c:navigator.product!=null&&navigator.product.toLowerCase().indexOf("konqueror")>-1,d:g.indexOf("opera")>-1,e:al.contentType!=null&&al.contentType.indexOf("xml")>-1,f:true,g:true,h:null,i:null,j:null,k:null};f.l=f.a||f.c;f.m=!f.a&&navigator.product!=null&&navigator.product.toLowerCase()=="gecko";if(f.m)f.j=new Number(g.match(/.*gecko\/(\d{8}).*/)[1]);f.n=g.indexOf("msie")>-1&&!f.d&&!f.l&&!f.m;f.o=f.n&&g.match(/.*mac.*/)!=null;if(f.d)f.i=new Number(g.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]);if(f.n||(f.d&&f.i<7.6))f.g=false;if(f.a)f.k=new Number(g.match(/.*applewebkit\/(\d+).*/)[1]);if(am.hasFlash&&(!f.n||f.o)){var aj=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;f.h=parseInt(aj.charAt(aj.indexOf(".")-1))}if(g.match(/.*(windows|mac).*/)==null||f.o||f.c||(f.d&&(g.match(/.*mac.*/)!=null||f.i<7.6))||(f.b&&f.h<7)||(!f.b&&f.a&&f.k<124)||(f.m&&f.j<20020523))f.f=false;if(!f.o&&!f.m&&al.createElementNS)try{al.createElementNS(a,"i").innerHTML=""}catch(e){f.e=true}f.p=f.c||(f.a&&f.k<312)||f.n;return f}();function at(){return{bIsWebKit:f.a,bIsSafari:f.b,bIsKonq:f.c,bIsOpera:f.d,bIsXML:f.e,bHasTransparencySupport:f.f,bUseDOM:f.g,nFlashVersion:f.h,nOperaVersion:f.i,nGeckoBuildDate:f.j,nWebKitVersion:f.k,bIsKHTML:f.l,bIsGecko:f.m,bIsIE:f.n,bIsIEMac:f.o,bUseInnerHTMLHack:f.p}}if(am.hasFlash==false||!al.getElementsByTagName||!al.getElementById||(f.e&&f.p))return{UA:at()};function af(e){if((!k.bAutoInit&&(am.event||e)!=null)||!l(e))return;b=true;for(var i=0,h=ah.length;i<h;i++)j.apply(null,ah[i]);ah=[]}var k=af;function l(e){if(c==false||k.bIsDisabled==true||((f.e&&f.m||f.l)&&e==null&&b==false)||(al.body==null||al.getElementsByTagName("body").length==0))return false;return true}function m(n){if(f.n)return n.replace(new RegExp("%\d{0}","g"),"%25");return n.replace(new RegExp("%(?!\d)","g"),"%25")}function as(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}function o(p,q,r,s,t){var u="";var v=p.firstChild;var w,x,y,z;if(s==null)s=0;if(t==null)t="";while(v){if(v.nodeType==3){z=v.nodeValue.replace("<","&lt;");switch(r){case "lower":u+=z.toLowerCase();break;case "upper":u+=z.toUpperCase();break;default:u+=z}}else if(v.nodeType==1){if(as(v,"a")&&!v.getAttribute("href")==false){if(v.getAttribute("target"))t+="&sifr_url_"+s+"_target="+v.getAttribute("target");t+="&sifr_url_"+s+"="+m(v.getAttribute("href")).replace(/&/g,"%26");u+='<a href="asfunction:_root.launchURL,'+s+'">';s++}else if(as(v,"em")){u+="&#194;";}else if(as(v,"strong")){u+="&#206;";}else if(as(v,"span")){u+="&#212;";}else if(as(v,"br"))u+="<br/>";if(v.hasChildNodes()){y=o(v,null,r,s,t);u+=y.u;s=y.s;t=y.t}if(as(v,"a")){u+="</a>"}else if(as(v,"em")){u+="";}else if(as(v,"strong")){u+="";}else if(as(v,"span")){u+="";}}w=v;v=v.nextSibling;if(q!=null){x=w.parentNode.removeChild(w);q.appendChild(x)}}return{"u":u,"s":s,"t":t}}function A(B){if(al.createElementNS&&f.g)return al.createElementNS(a,B);return al.createElement(B)}function C(D,E,z){var p=A("param");p.setAttribute("name",E);p.setAttribute("value",z);D.appendChild(p)}function F(p,G){var H=p.className;if(H==null)H=G;else H=H.normalize()+(H==""?"":" ")+G;p.className=H}function aq(ar){var a=ak;if(k.bHideBrowserText==false)a=al.getElementsByTagName("body")[0];if((k.bHideBrowserText==false||ar)&&a)if(a.className==null||a.className.match(/\bsIFR\-hasFlash\b/)==null)F(a, "sIFR-hasFlash")}function j(I,J,K,sEmColor,sStrongColor,sSpanColor,L,M,N,O,P,Q,R,S,r,T){if(!l())return ah.push(arguments);aq();named.extract(arguments,{sSelector:function(ap){I=ap},sFlashSrc:function(ap){J=ap},sColor:function(ap){K=ap},sEmColor:function(ap){sEmColor=ap},sStrongColor:function(ap){sStrongColor=ap},sSpanColor:function(ap){sSpanColor=ap},sLinkColor:function(ap){L=ap},sHoverColor:function(ap){M=ap},sBgColor:function(ap){N=ap},nPaddingTop:function(ap){O=ap},nPaddingRight:function(ap){P=ap},nPaddingBottom:function(ap){Q=ap},nPaddingLeft:function(ap){R=ap},sFlashVars:function(ap){S=ap},sCase:function(ap){r=ap},sWmode:function(ap){T=ap}});var U=parseSelector(I);if(U.length==0)return false;if(S!=null)S="&"+S.normalize();else S="";if(K!=null)S+="&textcolor="+K;if(sEmColor!=null)S+="&emcolor="+sEmColor;if(sStrongColor!=null)S+="&strongcolor="+sStrongColor;if(sSpanColor!=null)S+="&spancolor="+sSpanColor;if(M!=null)S+="&hovercolor="+M;if(M!=null||L!=null)S+="&linkcolor="+(L||K);if(O==null)O=0;if(P==null)P=0;if(Q==null)Q=0;if(R==null)R=0;if(N==null)N="#FFFFFF";if(T=="transparent")if(!f.f)T="opaque";else N="transparent";if(T==null)T="";var p,V,W,X,Y,Z,aa,ab,ac;var ad=null;for(var i=0,h=U.length;i<h;i++){p=U[i];if(p.className!=null&&p.className.match(/\bsIFR\-replaced\b/)!=null)continue;V=p.offsetWidth-R-P;W=p.offsetHeight-O-Q;aa=A("span");aa.className="sIFR-alternate";ac=o(p,aa,r);Z="txt="+m(ac.u).replace(/\+/g,"%2B").replace(/&/g,"%26").replace(/\"/g, "%22").normalize() + S + "&w=" + V + "&h=" + W + ac.t;F(p,"sIFR-replaced");if(ad==null||!f.g){if(!f.g)p.innerHTML=['<embed class="sIFR-flash" type="application/x-shockwave-flash" src="',J,'" quality="best" wmode="',T,'" bgcolor="',N,'" flashvars="',Z,'" width="',V,'" height="',W,'" sifr="true"></embed>'].join("");else{if(f.d){ab=A("object");ab.setAttribute("data",J);C(ab,"quality","best");C(ab,"wmode",T);C(ab,"bgcolor",N)}else{ab=A("embed");ab.setAttribute("src",J);ab.setAttribute("quality","best");ab.setAttribute("flashvars",Z);ab.setAttribute("wmode",T);ab.setAttribute("bgcolor",N)}ab.setAttribute("sifr","true");ab.setAttribute("type","application/x-shockwave-flash");ab.className="sIFR-flash";if(!f.l||!f.e)ad=ab.cloneNode(true)}}else ab=ad.cloneNode(true);if(f.g){if(f.d)C(ab,"flashvars",Z);else ab.setAttribute("flashvars",Z);ab.setAttribute("width",V);ab.setAttribute("height",W);ab.style.width=V+"px";ab.style.height=W+"px";p.appendChild(ab)}p.appendChild(aa);if(f.p)p.innerHTML+=""}if(f.n&&k.bFixFragIdBug)setTimeout(function(){al.title=d},0)}function ai(){d=al.title}function ae(){if(k.bIsDisabled==true)return;c=true;if(k.bHideBrowserText)aq(true);if(am.attachEvent)am.attachEvent("onload",af);else if(!f.c&&(al.addEventListener||am.addEventListener)){if(f.a&&f.k>=132&&am.addEventListener)am.addEventListener("load",function(){setTimeout("sIFR({})",1)},false);else{if(al.addEventListener)al.addEventListener("load",af,false);if(am.addEventListener)am.addEventListener("load",af,false)}}else if(typeof am.onload=="function"){var ag=am.onload;am.onload=function(){ag();af()}}else am.onload=af;if(!f.n||am.location.hash=="")k.bFixFragIdBug=false;else ai()}k.UA=at();k.bAutoInit=true;k.bFixFragIdBug=true;k.replaceElement=j;k.updateDocumentTitle=ai;k.appendToClassName=F;k.setup=ae;k.debug=function(){aq(true)};k.debug.replaceNow=function(){ae();k()};k.bIsDisabled=false;k.bHideBrowserText=true;return k}();

if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac){
	sIFR.setup();
};

// initialization function
function init(){
	// BEGIN: target="_blank" Replacement
	 if (!document.getElementsByTagName) return;
	 var anchors = document.getElementsByTagName("a");
	 for (var i=0; i<anchors.length; i++) {
	   var anchor = anchors[i];
	   if (anchor.getAttribute("href") &&  anchor.getAttribute("rel") == "external")
		 anchor.target = "_blank";
	 }
	// END: target="_blank" Replacement
	
	if ($('listingPhoto')) {
		if ($('listingPhoto').getElementsByTagName('a')[0]) {
			setTimeout("new Effect.Appear($('listingPhoto').getElementsByTagName('div')[0],{from:0,to:0.75,duration:1});", 1000);
		}
	}
	if ($('removePhoto')) {
		$('removePhoto').onclick = function () {
			if (!confirm('Are you sure you want to remove this photo?'))
				return false;
		}
	}
	if ($('formSearch')) {
		$('formSearch').onsubmit = function () {
			if ($F('mainCategory') == '0') {
				return false;
			}
			if ($F('location') == '' || $F('location') == 'City or zip/postal code') {
				return false;
			}
		}
	}
	if ($('mainCategory')) {
		$('mainCategory').onchange = function () {
			var myAjax = new Ajax.Request(
			'/includes/subs.php', 
			{
				method: 'get', 
				parameters: 'catID='+this.value+'&element=subCategory&dummy=' + new Date().getTime(),
				onComplete: function(response) {
					eval(response.responseText);
					var myAjax = new Ajax.Request(
					'/includes/more-search-options.php', 
					{
						method: 'get', 
						parameters: 'subCategory=' + $F('subCategory') + '&mainCategory=' + $F('mainCategory') + '&dummy=' + new Date().getTime(),
						onComplete: function(response) { eval(response.responseText); }
					});
				}
			});
		}
		
		if ($("subCategory").innerHTML == '<option value="0"></option>') $("subCategory").disabled=true;
		$("subCategory").onchange = function () {
			var myAjax = new Ajax.Request(
				'/includes/more-search-options.php', 
				{
					method: 'get', 
					parameters: 'subCategory=' + $F(this) + '&mainCategory=' + $F('mainCategory') + '&dummy=' + new Date().getTime(),
					onComplete: function(response) { eval(response.responseText); }
			});
		}
		
		$('location').onfocus = function() {
			this.value = '';
			this.onfocus = '';
		}
		$('moreSearch').onclick = function() {
			Effect.toggle('moreSearchOptions','slide');
			if ($('moreSearch').innerHTML=='More Search Options') {
				command = "$('moreSearch').innerHTML='Less Search Options'; $('moreSearch').style.backgroundImage=\"url('/images/iconDelete.gif')\"";
				setTimeout(command,1000);
			} else {
				command = "$('moreSearch').innerHTML='More Search Options'; $('moreSearch').style.backgroundImage=\"url('/images/icon_plus.gif')\"";
				setTimeout(command,1000);
			}
		}

		// autocomplete boxes
		var autoLocationHeader = new Ajax.Autocompleter('location', 'autocompleteHeader', '/includes/autocomplete-location.php', {minChars:3,frequency:.1,indicator:"activity-indicator-header",parameters:"country=US"})
		if ($('txtLocation')) {
			$('selCountry').onchange = function() {
				autoLocation.options.defaultParams = 'country='+$('selCountry').value;
			}
			var autoLocation = new Ajax.Autocompleter('txtLocation', 'autocompleteLocation', '/includes/autocomplete-location.php', {minChars:3,frequency:.1,indicator:"activity-indicator",parameters:"country=US"})
		}

	}
	if ($('mainCategorySelect')) {
		$('mainCategorySelect').onchange = function () {
			var myAjax = new Ajax.Request(
			'/includes/subs.php', 
			{
				method: 'get', 
				parameters: 'catID=' + this.value + '&element=subCategorySelect&dummy=' + new Date().getTime(),
				onComplete: function(response) {
					eval(response.responseText);
					var myAjax = new Ajax.Request(
					'/includes/more-listing-details.php',
					{
						method: 'get',
						parameters: 'subCategory=' + $F('subCategorySelect') + '&mainCategory=' + $F('mainCategorySelect') + '&dummy=' + new Date().getTime(),
						onComplete: function(response) { eval(response.responseText); }
					});
				}
			});
			if ($('detailedDescToggle').style.display == 'none' && $('mainCategorySelect').value != 0) {
				Effect.Appear('detailedDescToggle');
				setTimeout("$('detailedDescToggle').getElementsByTagName('a')[0].innerHTML = '(Show More Options)';",1000);
			} else if ($('mainCategorySelect').value == 0) {
				Effect.Fade('detailedDescToggle');
				setTimeout("$('detailedDescToggle').getElementsByTagName('a')[0].innerHTML = '(Show More Options)';",1000);
			}
		}
		if ($('detailedDescForm').getElementsByTagName('div')[0].innerHTML != '')
			Effect.Appear('detailedDescToggle');
		if ($("subCategorySelect").innerHTML == '<option value=""></option>')
			$("subCategorySelect").disabled=true;
		$('subCategorySelect').onchange = function () {
			var myAjax = new Ajax.Request(
				'/includes/more-listing-details.php', 
				{
					method: 'get', 
					parameters: 'subCategory=' + $F('subCategorySelect') + '&mainCategory=' + $F('mainCategorySelect') + '&dummy=' + new Date().getTime(),
					onComplete: function(response) { eval(response.responseText); }
			});
			if ($('detailedDescToggle').style.display == 'none' && $('mainCategorySelect').value != 0) {
				Effect.Appear('detailedDescToggle');
			} else if ($('mainCategorySelect').value == 0) {
				Effect.Fade('detailedDescToggle');
			}
		}
	}
	
	if ($('detailedDescToggle')) {
		$('detailedDescToggle').getElementsByTagName('a')[0].onclick = function () {
			Effect.toggle('detailedDescForm','slide');
			if ($('detailedDescToggle').getElementsByTagName('a')[0].innerHTML == '(Hide More Options)') {
				setTimeout("$('detailedDescToggle').getElementsByTagName('a')[0].innerHTML = '(Show More Options)';",1000);
			} else {
				setTimeout("$('detailedDescToggle').getElementsByTagName('a')[0].innerHTML = '(Hide More Options)';",1000);
			}
			return false;
		}
	}
	if($('photoUpload')) $('photoUpload').getElementsByTagName('a')[0].onclick = function() {
		Effect.toggle('photoUploadForm','slide',{duration:0.5});
		return false;
	}
	if($('toggleExactDate')) $('toggleExactDateLink').onclick = function() {
		if ($('date').style.display != 'none') {
			$('date').style.display = 'none';
			Effect.toggle('exactDate','appear');
			$('toggleExactDateLink').innerHTML = 'I don\'t know the exact date';
		} else {
			$('exactDate').style.display = 'none';
			Effect.toggle($('date'),'appear');
			$('toggleExactDateLink').innerHTML = 'I know the exact date';
		}
		return false;
	}
	var toggleSearch = document.getElementsByClassName('toggleSearch');
	for (i = 0; i < toggleSearch.length; i++) {
		toggleSearch[i].onclick = function() {
			Effect.toggle('moreSearchOptions','slide');
			if ($('moreSearch').innerHTML=='More Search Options') {
				setTimeout("$('moreSearch').innerHTML='Less Search Options'",1000);
			} else {
				setTimeout("$('moreSearch').innerHTML='More Search Options'",1000);
			}
			return false;
		}
	}
	if ($('tellFriendLink')) {
		$('tellFriendLink').onclick = function() {
			$('tellFriend').getElementsByTagName('input')[0].focus();
			return false;
		}
	}
	if ($('register1')) {
		$('register1').onclick = function() {
			$('lblRegister1').className = 'active';
			$('lblRegister2').className = '';
			$('lblRegister3').className = '';
			$('lblRegister4').className = '';
			$('toggleReturning').style.display = 'none';
			$('toggleReturning1').style.display = 'none';
			$('toggleReturning2').style.display = 'none';
			$('toggleNew').style.display = 'none';
			
			$('curvediv1').style.display = 'block';
			$('curvediv2').style.display = 'none';
			$('curvediv3').style.display = 'none';
			$('curvediv4').style.display = 'none';
			
			$('curvediv1').style.display = 'block';
			$('curvediv2').style.display = 'none';
			$('curvediv3').style.display = 'none';
			$('curvediv4').style.display = 'none';
			Effect.Appear('toggleReturning');
			if ($('toggleBinTagLost')) {
				Effect.Appear('toggleBinTagLost');
			}
		}
		$('register2').onclick = function() {
			$('lblRegister2').className = 'active';
			$('lblRegister1').className = '';
			$('lblRegister3').className = '';
			$('lblRegister4').className = '';
			$('toggleReturning').style.display = 'none';
			$('toggleReturning1').style.display = 'none';
			$('toggleReturning2').style.display = 'none';
			$('toggleNew').style.display = 'none';
			
			$('curvediv1').style.display = 'none';
			$('curvediv2').style.display = 'block';
			$('curvediv3').style.display = 'none';
			$('curvediv4').style.display = 'none';
			
			Effect.Appear('toggleNew');
			if ($('toggleBinTagLost')) {
				$('toggleBinTagLost').style.display = 'none';
			}
		}
		$('register3').onclick = function() {
			$('lblRegister3').className = 'active';
			$('lblRegister1').className = '';
			$('lblRegister2').className = '';
			$('lblRegister4').className = '';
			$('toggleReturning').style.display = 'none';
			$('toggleReturning1').style.display = 'none';
			$('toggleReturning2').style.display = 'none';
			$('toggleNew').style.display = 'none';
			
			$('curvediv1').style.display = 'none';
			$('curvediv2').style.display = 'none';
			$('curvediv3').style.display = 'block';
			$('curvediv4').style.display = 'none';
			
			Effect.Appear('toggleReturning1');
			if ($('toggleBinTagLost')) {
				$('toggleBinTagLost').style.display = 'none';
			}
		}
		$('register4').onclick = function() {
			$('lblRegister4').className = 'active';
			$('lblRegister1').className = '';
			$('lblRegister3').className = '';
			$('lblRegister2').className = '';
			$('toggleReturning').style.display = 'none';
			$('toggleReturning1').style.display = 'none';
			$('toggleReturning2').style.display = 'none';
			$('toggleNew').style.display = 'none';
			
			$('curvediv1').style.display = 'none';
			$('curvediv2').style.display = 'none';
			$('curvediv3').style.display = 'none';
			$('curvediv4').style.display = 'block';
			
			Effect.Appear('toggleReturning2');
			if ($('toggleBinTagLost')) {
				$('toggleBinTagLost').style.display = 'none';
			}
		}
	}
	if ($('lblWhere1')) {
		$('lblWhere1').onclick = function() {
			$('lblWhere1').className = 'active';
			$('lblWhere2').className = '';
			$('addLocation').style.display = 'none';
		}
		$('lblWhere2').onclick = function() {
			$('lblWhere2').className = 'active';
			$('lblWhere1').className = '';
			Effect.Appear('addLocation');
		}
		
		$('addLocation').getElementsByTagName('a')[0].onclick = function() {
			return false;
		}
	}
	if ($('reportAlert')) {
		$('reportAlert').getElementsByTagName('a')[0].onclick = function () {
			Effect.toggle('moreSearchOptions','slide');
			if ($('moreSearch').innerHTML=='More Search Options') {
				setTimeout("$('moreSearch').innerHTML='Less Search Options'",1000);
			} else {
				setTimeout("$('moreSearch').innerHTML='More Search Options'",1000);
			}
			return false;
		}
	}
	if ($('tellFriend')) {
		var textbox = $('tellFriend').getElementsByTagName('input');
		textbox[0].onfocus = function() {
			this.value = '';
			this.onfocus = '';
		}
		textbox[1].onfocus = function() {
			this.value = '';
			this.onfocus = '';
		}
	}
	if ($('tellFriend')) {
		$('tellFriend').getElementsByTagName('form')[0].onsubmit = function () {
			var myAjax = new Ajax.Request(
				'/includes/tell-friend.php', 
				{
					method: 'get', 
					parameters: 'name='+this.getElementsByTagName('input')[0].value+'&email='+this.getElementsByTagName('input')[1].value + '&dummy=' + new Date().getTime(),
					onComplete: function(response) { eval(response.responseText); }
			});
			return false;
		}
		$('tellFriend').getElementsByTagName('input')[2].onclick = function () {
			var myAjax = new Ajax.Request(
				'/includes/tell-friend.php', 
				{
					method: 'get', 
					parameters: 'name='+$('tellFriend').getElementsByTagName('input')[0].value+'&email='+$('tellFriend').getElementsByTagName('input')[1].value + '&dummy=' + new Date().getTime(),
					onComplete: function(response) { eval(response.responseText); }
			});
			return false;
		}
	}
	if ($('formPostItem')) {
		$('formPostItem').onsubmit = function () {
			if (!validateReportItem()) {
				window.scroll(0,0);
				return false;
			}
		}
	}
	
	if ($('searchSummary')) {
		$('searchSummary').getElementsByTagName('div')[0].onclick = function() {
			if ($('mapWrap').style.display == 'none') {
				var mapStatus = 'show';
				setTimeout("$('searchSummary').getElementsByTagName('div')[0].className = 'hide';",1000);
			} else {
				var mapStatus = 'hide';
				setTimeout("$('searchSummary').getElementsByTagName('div')[0].className = '';",1000);
			}
			document.cookie = "mapStatus="+mapStatus;
			Effect.toggle('mapWrap','slide');
		}
	}
	
	if ($('emailListing')) {
		$('emailListingOwner').onclick = function () {
			Effect.SlideDown('pnlEmailListingOwner');
			$('pnlEmailListingToFriend').style.display = 'none';
			return false;
		}
		$('emailListingToFriend').onclick = function () {
			Effect.SlideDown('pnlEmailListingToFriend');
			$('pnlEmailListingOwner').style.display = 'none';
			return false;
		}
		$('emailListing').getElementsByTagName('form')[0].onsubmit = function() {
			var myAjax = new Ajax.Request(
				'/includes/email-owner.php', 
				{
					method: 'get', 
					parameters: 'message='+$('emailListing').getElementsByTagName('textarea')[0].value+'&listing='+$('emailListing').getElementsByTagName('input')[2].value+'&email='+$('emailListing').getElementsByTagName('input')[0].value + '&dummy=' + new Date().getTime(),
					onComplete: function(response) { eval(response.responseText); }
			});
			return false;
		}
		$('emailListing').getElementsByTagName('form')[1].onsubmit = function() {
			var myAjax = new Ajax.Request(
				'/includes/email-listing.php', 
				{
					method: 'get', 
					parameters: 'name='+$('emailListing').getElementsByTagName('input')[3].value+'&email='+$('emailListing').getElementsByTagName('input')[4].value+'&listing='+$('emailListing').getElementsByTagName('input')[2].value + '&dummy=' + new Date().getTime(),
					onComplete: function(response) { eval(response.responseText); }
			});
			return false;
		}
	}
	if ($('addPhoto')) {
		$('addPhoto').onclick = function() {
			Effect.toggle('newImageForm','slide');
			return false;
		}
	}
	
}
function colorRows(){
	var rows = document.getElementsByTagName('tr');
	x = 0;
	for (i=0; i<rows.length; i++) {
		if (rows[i].style.display != 'none') {
			if (x % 2 == 0) {
				rows[i].className = 'odd';
			} else {
				rows[i].className = '';
			}
			x++;
		}
	}
}

function deleteListing(id,row) {
	if (confirm('Are you sure you want to remove this listing?')) {
		var myAjax = new Ajax.Request(
			'/delete-listing/'+id+'/'+row, 
			{
				method: 'get', 
				parameters: 'dummy=' + new Date().getTime(),
				onComplete: function(response) { eval(response.responseText); }
		});
	}
	return false;
}

function hideMap() {
	setTimeout("Effect.toggle('mapWrap','slide')",1000);
	document.cookie = "mapStatus=hide";
}


function showErrorIcon(element) {
	var p = element.parentNode;
	if (document.getElementsByClassName('errorIcon',p)[0]) return false;
	var b = document.createElement("img");
	b.className = 'errorIcon';
	b.src = '/images/exclamation.gif';
	b.alt = '*';
	p.insertBefore(b,element);
	element.onchange = function() {
		p.removeChild(document.getElementsByClassName('errorIcon',p)[0]);
		this.onchange = '';
	}
	
}


function validateReportItem() {
	
	fail = 0;
	
	if ($('phone')) {
		/*
		if ($('phone').value == '') {
			showErrorIcon($('phone'));
			fail = 1;
		}
		*/
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/).test($('email').value)) {
			showErrorIcon($('email'));
			//alert('Please enter your email address');
			fail = 1;
		}
		
		if (document.getElementsByName('password')[0].value.length < 8) {
			showErrorIcon(document.getElementsByName('password')[0]);
			//alert('Please create a password at least 8 characters long.');
			fail = 1;
		}
		
		if (document.getElementsByName('password2')[0].value != document.getElementsByName('password')[0].value) {
			showErrorIcon(document.getElementsByName('password2')[0]);
			//alert('Please make sure both passwords match');
			fail = 1;
		}
	}
	
	// Item Information
	
	if ($('subCategorySelect').value == 0 || $('subCategorySelect').value == '<option value=""></option>') {
		showErrorIcon($('subCategorySelect'));
		//alert('Please select a sub category for your item');
		fail = 1;
	}
	
	if (document.getElementsByName('listingTitle')[0].value == '') {
		showErrorIcon(document.getElementsByName('listingTitle')[0]);
		//alert('Please enter a title for your listing');
		fail = 1;
	}
	
	if (document.getElementsByName('details')[0].value == '') {
		showErrorIcon(document.getElementsByName('details')[0]);
		//alert('Please enter a detailed description of your item');
		fail = 1;
	}
	
	// Location Information
	/*if (!datecheck(document.getElementsByName('exactDate')[0].value)) {
		if (document.getElementsByName('avgDate')[0].value == '') {
			alert('Please enter a valid date');
		}
	}*/
	if (document.getElementsByName('location')[0].value == '') {
		showErrorIcon(document.getElementsByName('location')[0]);
		fail = 1;
	}
	
	if (fail == 1) {
		return false;
	} else {
		return true;	
	}
}

function toggleOption(optionDiv) {
	//Effect.toggle(optionDiv,'slide');
}