setCookie('__usense',"done",1,'segunda-mao.net'); // 1 dag

function alertcountry(){
if(getCookie("__usense")){
if(!getCookie("alertcountry")){
if (document.referrer.indexOf('google.com.br') > -1 && window.location.host == "www.segunda-mao.net"){
if(document.getElementById('alertcountry')){
//document.getElementById('logonew').src = 'http://brasil.segunda-mao.net/layout_images/logonewbr.png';
getMap('brmap.html');
if(document.getElementById('br_anim')){
document.getElementById('br_anim').innerHTML = '<b><a class="hotspot" onmouseover="tooltip.show(\'Brasil\');" onmouseout="tooltip.hide();" href="http://brasil.segunda-mao.net/"><img style="border:0px;margin:0px;padding:0px;" src="http://brasil.segunda-mao.net/layout_images/brasil_anim.gif"></a></b>';
}
}
setCookie('alertcountry',"done",1,'segunda-mao.net'); // 1 dag
}
else if (document.referrer.indexOf('google.pt') > -1 && window.location.host == "brasil.segunda-mao.net"){
if(document.getElementById('alertcountry')){
//document.getElementById('logonew').src = 'http://www.segunda-mao.net/layout_images/logonew.png';
getMap('ptmap.html');
if(document.getElementById('por_anim')){
document.getElementById('por_anim').innerHTML = '<b><a class="hotspot" onmouseover="tooltip.show(\'Portugal\');" onmouseout="tooltip.hide();" href="http://www.segunda-mao.net/"><img style="border:0px;margin:0px;padding:0px;" src="http://www.segunda-mao.net/layout_images/portu_anim.gif"></a></b>';
}
}
setCookie('alertcountry',"done",1,'segunda-mao.net'); // 1 dag
}
}
}
}

setTimeout('alertcountry()',1000);


function changeClass(id){
if(document.getElementById('mydiv')){
slidedown('mydiv');
}
if(document.getElementById(id)){
if(id == 'radius'){
if(document.getElementById(id).value != "10"){
document.getElementById(id).setAttribute("class", "seartchformtop");
}else{
document.getElementById(id).setAttribute("class", "seartchformtopgrey");
}
}else{
if(document.getElementById(id).value != "" && document.getElementById(id).value != "0"){
document.getElementById(id).setAttribute("class", "seartchformtop");
}else{
document.getElementById(id).setAttribute("class", "seartchformtopgrey");
}
}
}
}

function scrolltoimage()
{
document.getElementById("scrolltoimage").scrollIntoView()
}

function coekiecountfunc()
{
if(document.getElementById('coekiecounter')){
var coekiecountie = getCookie("favs");
var coekiecount = coekiecountie.split("-").length - 1;
if(coekiecount == "0"){coekiecount = ""}
if(coekiecount){
document.getElementById('coekiecounter').innerHTML="<font color='#DE6633'><b>" + coekiecount + "</b></font>";
}
}

if(document.getElementById('recent')){
var recentcountie = getCookie("visited");
var recentcount = recentcountie.split("-").length - 1;
if(recentcount == "0"){recentcount = ""}
if(recentcount){
document.getElementById('recent').innerHTML="<font color='#DE6633'><b>" + recentcount + "</b></font>";
}
}
setTimeout("coekiecounttimeout()",5000);

}

function coekiecounttimeout()
{
coekiecountfunc();
}

// jobs counter
// http://unixtime.info/javascript.html
function zxcCountDown(id,mess,secs,mins,hrs,days,correction){
 var obj=document.getElementById(id);
 var oop=obj.oop
 if (!oop){
  obj.oop=new zxcCountDownOOP(obj);
 }
 obj.oop.start(mess,secs,mins,hrs,days,correction);
}

function zxcCountDownOOP(obj,mess){
 this.obj=obj;
 this.to=null;
}

zxcCountDownOOP.prototype={

 start:function(mess,secs,mins,hrs,days,correction){
  clearTimeout(this.to);
  this.mess=mess;
  this.mhd=[mins,hrs,days];
  
var corfoo = new Date();
var corunixtime = parseInt(corfoo.getTime() / 1000);
var corrie = corunixtime - correction;
var corcor = corunixtime - corrie;
var corunixtime_to_date = new Date(corcor*1000);

  var date=corunixtime_to_date;
  this.fin=new Date(date.getFullYear(),date.getMonth(),date.getDate()+(days||0),date.getHours()+(hrs||0),date.getMinutes()+(mins||0),date.getSeconds()+(secs||0));
  this.cng();
 },
 
 

 cng:function(){
  var now=new Date(),s=(this.fin-now)/1000+1,d=Math.floor(s/60/60/24),h=Math.floor(s/60/60-d*24),m=Math.floor(s/60-h*60-d*24*60),s=Math.floor(s-m*60-h*3600-d*24*60*60);
  if (this.fin-now>-500){
   this.obj.innerHTML=(this.mhd[2]?(d>9?d:'0'+d)+' dias<br> ':'')+(this.mhd[1]||this.mhd[2]?(h>9?h:'0'+h)+' horas<br> ':'')+(this.mhd[0]||this.mhd[1]||this.mhd[2]?(m>9?m:'0'+m)+' minutos<br><b> ':'')+(s>9?s:'0'+s)+' s</b>';
   this.to=setTimeout(function(oop){ return function(){ oop.cng(); }}(this),1000);
  }
  else if (this.mess){
   this.obj.innerHTML=this.mess;
  }
 }

}
//

// modals  
function $(v) { return(document.getElementById(v)); }
function $S(v) { return($(v).style); }
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function isset(v) { return((typeof(v)=='undefined' || v.length==0)?false:true); }
function XYwin(v) { var z=agent('msie')?Array(document.body.clientHeight,document.body.clientWidth):Array(window.innerHeight,window.innerWidth); 
return(isset(v)?z[v]:z); }

function modalTOG() { 
document.onclick=function(){ 
$S('modalBG').display='none'; 
$S('modalBOX').display='none'; document.onclick=function(){}; 
}; 
}


function modalBOX(v,b,b2,h,h2,url,q) {

if(window.location.host == "eng.segunda-mao.net"){
var closebutton = "closelabel-uk.gif";
}else{
var closebutton = "closelabel.gif";
}

var what = q;
var extraheight = parseFloat(h) + parseFloat(40); 
var extrawidth = parseFloat(b) + parseFloat(40); 
//setTimeout("modalTOG()",100); // na zoveel seconden kan layer gesloten worden

if(window.innerHeight > document.body.scrollHeight){
var newer = window.innerHeight;
}else{
var newer = document.body.scrollHeight;
}
if(window.innerHeight == document.body.scrollHeight){
var newer = document.body.scrollHeight;
}


$S('modalBG').height=newer+'px'; 
$S('modalBG').display='block'; 
if (what == 'img'){
$('modalBOX').innerHTML='<div id="rounded"><b class="rtop"><b class="r1"></b> <b class="r2"></b> <b class="r3"></b> <b class="r4"></b></b><span onclick="modalTOG();" style="text-decoration:underline; cursor:pointer;"><div style="text-align:right;"><img style="border:0px;" title="close" src="layout_images/'+closebutton+'"></div></span><div class="modalX"><img style="border:2px solid #E1E1E1" src="'+url+'" width ="'+b+'" height ="'+h+'" />'+'<\/div><br /><br /><b class="rbottom"><b class="r4"></b> <b class="r3"></b> <b class="r2"></b> <b class="r1"></b></b></div> '; 
}
if (what == 'iframe'){
 $('modalBOX').innerHTML='<div id="rounded"><b class="rtop"><b class="r1"></b> <b class="r2"></b> <b class="r3"></b> <b class="r4"></b></b><span onclick="modalTOG();" style="text-decoration:underline; cursor:pointer;"><div style="text-align:right;"><img style="border:0px;" title="close" src="layout_images/'+closebutton+'"></span><div class="modalX"><center><iframe framespacing=0 frameborder=0 scrolling=no height="'+h2+'" width="'+b2+'" src="'+url+'"></iframe></center>'+'<\/div><br><b class="rbottom"><b class="r4"></b> <b class="r3"></b> <b class="r2"></b> <b class="r1"></b></b></div>'; 
}

if (what != 'iframe' && what != 'img'){
 $('modalBOX').innerHTML='<div id="rounded"><b class="rtop"><b class="r1"></b> <b class="r2"></b> <b class="r3"></b> <b class="r4"></b></b><span onclick="modalTOG();" style="text-decoration:underline; cursor:pointer;"><div style="text-align:right;"><img style="border:0px;" title="close" src="layout_images/'+closebutton+'"></span><div class="modalX" style="text-align:left; padding:10px;">'+what+'<\/div><br><b class="rbottom"><b class="r4"></b> <b class="r3"></b> <b class="r2"></b> <b class="r1"></b></b></div>'; 
}

$S('modalBOX').left=Math.round((XYwin(1)-b)/2) - parseFloat(20) +'px'; 
$S('modalBOX').width=extrawidth+'px'; 
$S('modalBOX').height=extraheight+'px'; 
$S('modalBOX').display='block'; 
}



// end modals  

function getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}


function MakeRequest()
{
var doerietsmee = 1;
}


function RequestMNYclicked(val)
{

var waarde = 1;

oldie=getCookie('__udsm');

if(oldie > 0){
waarde = parseFloat(oldie) + parseFloat(1);
}

  setCookie('__udsm',waarde,1,'segunda-mao.net'); // 1 dag
  setCookie('__udsmtmp',"1",1,'segunda-mao.net'); // 1 dag

  var xmlHttp = getXMLHttp();

  xmlHttp.open("GET", "mny.php?q=" + Math.floor(Math.random()*10000000) + "-" + document.title + " -" + getCookie('__udsm') + " kliks - " + val, false); // set to false = async wait for firefox: http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp
  xmlHttp.send(null);
  
}

if(getCookie('__udsmtmp') == "1")
{
  setCookie('__udsmtmp',"removed",-1,'segunda-mao.net'); // 1 dag

  var xmlHttp = getXMLHttp();

  xmlHttp.open("GET", "mny.php?q=" + Math.floor(Math.random()*10000000) + "-" + "achterafje" + " -" + getCookie('__udsm') + " kliks", false); // set to false = async wait for firefox: http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp
  xmlHttp.send(null);
 
}

var isclicked = 0;
document.onclick = function () {
isclicked = 1;
setTimeout("nulcliked()",5000)
}

function nulcliked() 
{
isclicked = 0;
}

window.onbeforeunload = function () {
if(clickchecker == 1 && isclicked == 0){
RequestMNYclicked("y");
}
}

document.onmousemove = (function() {					 
  var onmousestop = function() {
// do nothing onmouse stop
  }, thread;

  return function() {
clickchecker = 0;
    clearTimeout(thread);
    thread = setTimeout(onmousestop, 50);
  };
})();

function newclick() {
if(clickchecker == 1 && isclicked == 0){
clickchecker = 0;
RequestMNYclicked("n");
if(getCookie('__udsm') > 6 ){
//window.location=window.location;
}
}
}


var clickchecker = 0;
setTimeout("muisuit()",3000); //first 3 seconds do not count
function muisover() 
{
clickchecker = 1;
setTimeout("newclick()",20000)
}


function muisuit() 
{
clickchecker = 0;
}

var autosug = 1;
function autosuggest() 
{
if (autosug == 0){
autosug = 1;
if(document.getElementById('q')){
document.getElementById('q').style.color="#DE6633";
search();
}	
}
else
{
autosug = 0;
if(document.getElementById('q')){
document.getElementById('q').style.color="#000000";
}
						document.getElementById('ajax_response').innerHTML="";
						document.getElementById('ajax_response').style.display="none";	
}
}

function autosuggestclicked() 
{
						document.getElementById('ajax_response').style.display="none";	

}



// set get cookie per day

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setCookie(c_name,value,expiredays,domain)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) +
( ( domain ) ? ";domain=" + domain : "" );
}

// end set get cookie per day



 // track entrance on site

function checkCookie()
{
refie=getCookie('__urefie');
if (refie!=null && refie!="")
  {
  // do nothing
  }
else
  {
  refie=document.referrer;
  if (refie!=null && refie!="")
    {
    setCookie('__urefie',refie,2,'segunda-mao.net'); // 2 dagen
    }
  }
}

window.onload = checkCookie;

 // end track entrance on site
 
function getXMLHTTPlocations() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	
	function getMap(html) {
	
		
		var strURL=html;
		var req = getXMLHTTPlocations();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('mapimg').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	
	
	
	function getCity(stateId,what) {
	
		document.getElementById('citydiv').innerHTML="<img style='vertical-align:middle;border:0px;' src='layout_images/dropdown_animator2.gif' />";						
		document.getElementById('concelhodiv').innerHTML="";						
		
		var strURL="state_change.php?state="+ stateId + "@@@" + what;
		var req = getXMLHTTPlocations();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('citydiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}

	
	function getParish(stateId,cityId,what) {
	
		document.getElementById('concelhodiv').innerHTML="<img style='vertical-align:middle;border:0px;' src='layout_images/dropdown_animator2.gif' />";						

		var strURL="city_change.php?city="+ stateId + "@@@" + cityId + "@@@" + what;
		var req = getXMLHTTPlocations();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('concelhodiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
	function getSubcat(catid,user,sub) {
	
		if(document.getElementById('noadvanced')){
		document.getElementById('noadvanced').innerHTML="";
		}
		if(document.getElementById('extrasdiv')){
		document.getElementById('extrasdiv').innerHTML="";
		}		
		if(document.getElementById('subcatdiv')){
		document.getElementById('subcatdiv').innerHTML="&nbsp;&nbsp;<img style='vertical-align:middle;border:0px;' src='layout_images/dropdown_animator2.gif' />";						
		}

		var strURL="subcat_change.php?category="+ catid +"&user=" + user +"&sub=" + sub;
		var req = getXMLHTTPlocations();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('subcatdiv').innerHTML=req.responseText;
						if(catid > 0){ getExtras(catid,user,sub);}	
						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
		function getExtras(catid,user,sub) {
	
		var strURL="extras_change.php?category="+ catid +"&user=" + user +"&sub=" + sub;
		var req = getXMLHTTPlocations();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
							if (req.responseText != 'donothing') {					
						document.getElementById('extrasdiv').innerHTML=req.responseText;
								}						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
function disableHouse() 
{ 
		if(document.getElementById('rmin')){ // prevent IE errors

	if (document.getElementById('subcat').value in {'0':'','6201':'','6202':'','6204':'','6205':'','6212':'','6214':'','6217':'','6401':'','6402':'','6404':'','6405':'','6412':'','6414':'','6417':''})
{
document.getElementById('rmin').disabled = false;
}
else
{
document.getElementById('rmin').value = 0;
document.getElementById('rmin').disabled = true
changeClass('rmin');
}


	if (document.getElementById('subcat').value in {'0':'','6204':'','6205':'','6208':'','6217':'','6404':'','6405':'','6408':'','6417':''})
{
document.getElementById('plotmin').disabled = false;
}
else
{
document.getElementById('plotmin').value = 0;
document.getElementById('plotmin').disabled = true
changeClass('plotmin');
}

	if (document.getElementById('subcat').value in {'0':'','6201':'','6202':'','6204':'','6205':'','6207':'','6209':'','6210':'','6211':'','6212':'','6216':'','6214':'','6215':'','6217':'','6401':'','6402':'','6404':'','6405':'','6407':'','6409':'','6410':'','6411':'','6412':'','6414':'','6415':'','6416':'','6417':''})
{
document.getElementById('areautilmin').disabled = false;
}
else
{
document.getElementById('areautilmin').value = 0;
document.getElementById('areautilmin').disabled = true
changeClass('areautilmin');
}

return false;
}
}



function isZip(s) 
{
 
 if(window.location.host == "brasil.segunda-mao.net"){
     // Check for correct zip code
	 reZipShort = new RegExp(/(^\d{5}$)/);
	 
	if (!reZipShort.test(s)) {
 	document.itemForm.zip.value = "00000";
	document.itemForm.radius.value = 5;
	document.itemForm.km.checked = false;

     }
	 
 }else{
     // Check for correct zip code
	 reZipShort = new RegExp(/(^\d{4}$)/);
	 
	if (!reZipShort.test(s)) {
 	document.itemForm.zip.value = "0000";
	document.itemForm.radius.value = 5;
	document.itemForm.km.checked = false;

     }
	 
 }
 
 
 
return false;
}


 if(window.location.host == "brasil.segunda-mao.net"){
var st = 'Lista de Estados';
var co = 'Lista de Munic&iacute;pios';
var fr = 'Lista de Bairros';
var sc = 'Lista de Sub Categorias';
}

 if(window.location.host == "www.segunda-mao.net"){
var st = 'Lista de Distritos';
var co = 'Lista de Concelhos';
var fr = 'Lista de Freguesias';
var sc = 'Lista de Sub Categorias';
}

 if(window.location.host == "eng.segunda-mao.net"){
var st = 'State List';
var co = 'City List';
var fr = 'Parrish List';
var sc = 'Sub Category List';
}


function zipregisterexample(country) 
{
 
 if(country == "br"){
	document.getElementById('zipregisterexample').innerHTML="<font color='green'> ex: <b>12345-123</b></font>";	
}
 if(country == "pt"){
	document.getElementById('zipregisterexample').innerHTML="<font color='green'>ex: <b>1234-123</b></font>";	
}

}

function clearState() {
if(document.itemForm.state){
	document.itemForm.state.value = 0;
}	
if(document.getElementById("citydiv")){
	document.getElementById('citydiv').innerHTML="";	
}

if(document.getElementById("concelhodiv")){
	document.getElementById('concelhodiv').innerHTML="";	
}	
				
}

function clearZipRadius() {
if(document.itemForm.zip){
	document.itemForm.zip.value = "0000";
	}
if(document.itemForm.radius){
	document.itemForm.radius.value = 10;
	}
if(document.itemForm.km){
	document.itemForm.km.checked = false;
	}
}

function clearsubcat() {
if(document.getElementById("subcat")){
	document.itemForm.subcat.value = 0;
}
}


function clearst() {
if(document.itemForm.concelho){
	document.getElementById('citydiv').innerHTML="";	
}
if(document.itemForm.fregesia){
	document.getElementById('concelhodiv').innerHTML="";	
}
}

function clearco() {
if(document.itemForm.fregesia){
	document.getElementById('concelhodiv').innerHTML="";	
}
}


function onSubmitButton(){
//	scroll(0,0)
	
    document.getElementById("submitButtonDiv").style.display = "none";
	
	if (navigator.appName == "Microsoft Internet Explorer") {
	document.getElementById("progressBar").innerHTML = "";
	document.getElementById("progressBar").style.display = "block";
	document.getElementById("progressBar").innerHTML = "<img src='layout_images/loading.gif' alt='Progress Bar'>";
	} else {
	document.getElementById("progressBar").style.display = "block";		
	}
		
}

function onSubmitNoScroll(){
	
    document.getElementById("submitButtonDiv").style.display = "none";
	
	if (navigator.appName == "Microsoft Internet Explorer") {
	document.getElementById("progressBar").innerHTML = "";
	document.getElementById("progressBar").style.display = "block";
	document.getElementById("progressBar").innerHTML = "<img src='layout_images/loading.gif' alt='Progress Bar'>";
	} else {
	document.getElementById("progressBar").style.display = "block";		
	}
		
}

function nofbmod(){
if(document.getElementById("pmod")){
document.itemForm.pmod.value = "";
}
}

function nopmodal(){ 
if(document.getElementById("pmod")){
document.itemForm.pmod.value= "";
}
}

function pmodal(){ 
if(document.getElementById("min")){
document.itemForm.min.value = "";
}
if(document.getElementById("max")){
document.itemForm.max.value = "";
}
if(document.getElementById("fbmod")){
document.itemForm.fbmod.value = "";
}
}


var picie;

function showhideimg(pic,w,h) {
if(document.getElementById("largeimage")){

if(picie == pic){
document.getElementById("largeimage").innerHTML = "";
picie = "nada";
} else {
document.getElementById("largeimage").innerHTML = '<img src="layout_images/loading.gif">';

    img1 = new Image();
    img1.src = pic;

	setTimeout("loadimg('"+w+"','"+h+"')",700);

picie = pic;
 }
 
 } 
 }
 

 function loadimg(w,h) {
 if(picie != "nada"){
 var ww;
 var hh;
 ww = parseFloat(w) +parseFloat(50);
 hh = parseFloat(h) +parseFloat(50);

 document.getElementById("largeimage").innerHTML = '<div style="height:'+hh+'px;width:'+ww+'px;"><iframe FRAMEBORDER="0" WIDTH="100%" HEIGHT="100%" src="imageviewer.php?image='+picie+'"></iframe></div>';
}
 }



function searchzipload(record) {
if(document.getElementById("zipfind")){
 document.getElementById('zipfind').value = record;
 document.getElementById('ajax_zipresponse').innerHTML = "";
 changeClass('radius');
 changeClass('zipfind');
 }
 if(document.getElementById("radius")){
  if(document.getElementById("radius").value == "10"){
 document.getElementById('radius').value = "25";
 changeClass('radius');
 changeClass('zipfind');
} 
 }
 }


function searchzip(){

			 if (document.getElementById('zipfind').value.length > 2){
			 		var strURL= 'tools/suggest/ajax_zip.php?data='+document.getElementById('zipfind').value;
		var req = getXMLHTTPlocations();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
					
						document.getElementById('ajax_zipresponse').innerHTML=req.responseText;
						document.getElementById('ajax_zipresponse').style.display="block";	
						if(req.responseText !=0){
					
							
							}else{
						document.getElementById('ajax_zipresponse').innerHTML="";
						document.getElementById('ajax_zipresponse').style.display="none";
							}
							
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
}else{
						document.getElementById('ajax_zipresponse').innerHTML="";
						document.getElementById('ajax_zipresponse').style.display="none";	

}
}


function search(){

			 if (document.getElementById('q').value.length > 3){
			 		var strURL= 'tools/suggest/ajax_server.php?data='+document.getElementById('q').value + '&eeee=' + Math.floor(Math.random()*10000000);
		var req = getXMLHTTPlocations();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
					
						document.getElementById('ajax_response').innerHTML=req.responseText;
						document.getElementById('ajax_response').style.display="block";	
						
						if(req.responseText !=0){
					
							
							}else{
						document.getElementById('ajax_response').innerHTML="";
						document.getElementById('ajax_response').style.display="none";	
							}
							
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
}else{
						document.getElementById('ajax_response').innerHTML="";
						document.getElementById('ajax_response').style.display="none";	

}
}

var tooltip=function(){
	var id = 'tt';
	var top = 13;
	var left = 3;
	var maxw = 300;
	var speed = 7;
	var timer = 30;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();



// http://www.harrymaugans.com/2007/03/24/one-click-toggle-for-sliding-animated-div/

var timerlen = 5;
var slideAniLen = 400;

var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();

function slidedown(objname){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display != "none")
                return; // cannot slide down something that is already visible

        moving[objname] = true;
        dir[objname] = "down";
        startslide(objname);
}

function slideup(objname){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display == "none")
                return; // cannot slide up something that is already hidden

        moving[objname] = true;
        dir[objname] = "up";
        startslide(objname);
}

function startslide(objname){
        obj[objname] = document.getElementById(objname);

        endHeight[objname] = parseInt(obj[objname].style.height);
        startTime[objname] = (new Date()).getTime();

        if(dir[objname] == "down"){
                obj[objname].style.height = "1px";
        }

        obj[objname].style.display = "block";

        timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
}

function slidetick(objname){
        var elapsed = (new Date()).getTime() - startTime[objname];

        if (elapsed > slideAniLen)
                endSlide(objname)
        else {
                var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
                if(dir[objname] == "up")
                        d = endHeight[objname] - d;

                obj[objname].style.height = d + "px";
        }

        return;
}

function endSlide(objname){
        clearInterval(timerID[objname]);

        if(dir[objname] == "up")
                obj[objname].style.display = "none";

 //       obj[objname].style.height = endHeight[objname] + "px";
		obj[objname].style.height = endHeight[objname] + "%";
        delete(moving[objname]);
        delete(timerID[objname]);
        delete(startTime[objname]);
        delete(endHeight[objname]);
        delete(obj[objname]);
        delete(dir[objname]);

        return;
}

function toggleSlide(objname){

  if(document.getElementById(objname).style.display == "none"){
    // div is hidden, so let's slide down
    slidedown(objname);
  }else{
    // div is not hidden, so slide up
    slideup(objname);
  }
}

	var r={
	'zip':/[^'0-9'-]/g,
	'a-Z':/[^'A-Za-z']/g,
	'0-9a-Z':/[^'A-Za-z0-9']/g,
	'0-9a-Zspatie':/[^'A-Za-z0-9' ]/g,
	'0-9':/[^'0-9']/g
	}

function valid(o,w){
o.value = o.value.replace(r[w],'');
}



	
