function O(i){return document.getElementById(i);}
function Os(i){return O(i).style;}
function Rnd(n){ return Math.floor(Math.random(n));}  

var MnItm={groups:new Array('HOME MENU','MARKETING','RESEARCH','','Data Entry','Admin')
 ,items:new Array(Array('HOME MENU','Home!Home','My&nbsp;Department!MyDepartment','Co.&nbsp;Properties!Ours','Register Check!RegisterCheck')
     ,Array('MARKETING','Enquiry <span class=r>SEARCH</span>!FastSearches','My&nbsp;Searches!MySearches','<span class=r>ADD</span>&nbsp;Requirement!Requirement.aspx?q=1!Requirement.!','My&nbsp;Requirements!Requirement/list','<span class=r>ADD</span>&nbsp;Property!Property!Property.','My&nbsp;Properties!Property/list','Email Agents!Email2Agents')
     ,Array('ARCHIVE/RSRCH','Comparables/Find!InstantSearchNew','PROFILES!LocationProfile','Business Search!BusinessSearch/PropertySearch')
     ,Array('','User Guides!UserGuides','LISTINGS!Listings','EACH Alert!Alert/CODE/CID/BID/DID/NID/Listing','Suggestions!Suggestions','Logout!abu/Logout','Agent AB!AgencyWebsite')
     ,Array('Data Entry','Switch User!admin/SwitchUser','Upload Property!admin/UploadPropDet','Tally!admin/Tally')
	 ,Array('Admin'
	        ,'Centres/Estates!ShoppingCenters/ListProperties','Shopping Centre!propertySC.aspx?each=true!propertySC!','Town Profile!TownProfile','XML Upload!XMLUpload'
	        ,'4PROP Statistics!admin/4prop','Trace Users!admin/TraceUsers','Site Statistics!admin/SiteStatistics','Data Statistics!admin/DataStatistics','Site Abuse!admin/SiteAbuse','Alter Types!admin/PropertyTypes','Licencing!admin/Licences','Alter Costs!admin/CostAlter','Get Coordinates!admin/GetCoordinates','News!News')
            )   
  ,
  
  help:new Array(Array('HOME MENU','Update Contact Information and Password','Department Staff Summary and SWITCH to their ACCOUNT','Lists all AVAILABLE Properties you marketing via EACH with FAST rent/price/size REVIEW & UPDATE','Lists all your Instructions needing STATUS update')
     ,Array('MARKETING','Find Properties that match without ADVERTISING your Search','Where all your Enquiry Searches are STORED with the latest matching Properties','Find Properties that match your Search ADVERTISED with ACE emails, EACH Alert, EACH Listings, EACH Database.','Where all your Requirements are STORED matched to the latest matching Properties. Update your Requirement, attachments, transfer them to another Agent, update status.','Find Requirements that match your Property ADVERTISED with ACE emails, EACH Alert, EACH Listings, EACH Database, and on www.4prop.com.','Where all your Properties are STORED matched to the latest matching Requirements. Update your Properties, attachments, transfer them to another Agent, update status.','Select, amend, and save lists of Agents, or generate from Department Names.')
     ,Array('ARCHIVE/RSRCH','Search for Current and Archive Properties and Requirements by any criteria','Occupiers, Ownership, Availability, Archive by Town, Street, Shopping Centre, Industrial Estate, etc','Business Search!BusinessSearch/PropertySearch')
     ,Array('','PDFs with brief instructions on how to use the services','Set up relevant listings that you want to view or print time and again, including YOUR DEPARTMENT\'s list of Properties','The daily list of new Properties and Requirements, according to your Settings for your broad or every specific areas of interest','we appreciate your suggesstions which could improve our service.','logs you out','runs the Property Search button on your website with a difference, that we almost guarantee will win you new clients.')
     ,Array('Data Entry','Switch User!admin/SwitchUser','Upload Property!admin/UploadPropDet','Tally!admin/Tally')
	 ,Array('Admin','4PROP Statistics!admin/4prop'
	    ,'Centres/Estates!ShoppingCenters/ListProperties','Shopping Centre!propertySC.aspx?each=true!!','Town Profile!TownProfile','XML Upload!XMLUpload'
	    ,'Trace Users!admin/TraceUsers','Site Statistics!admin/SiteStatistics','Data Statistics!admin/DataStatistics','Site Abuse!admin/SiteAbuse','Alter Types!admin/PropertyTypes','Licencing!admin/Licences','Alter Costs!admin/CostAlter','Get Coordinates!admin/GetCoordinates','News!News')
            )  

    ,htmTit:'<span name=NAMEID class=t>MENU</span>'
    ,htm:'<a class=amenNAMEID style="background:#ecf8ff;color:#225;border:2px solid #ECF8FF" href="/HREF.aspx">MENU</a>'
    ,htmAlt:'<a class=amenNAMEID style="background:#cde7ff;border:2px solid #cde7ff;color:#225" href="/HREF.aspx">MENU</a>'
	,htm0:'<a class=amenNAMEID style="background:#fff;color:gray" href="/HREF.aspx">MENU</a>'
	,htm1:'<a class=amenNAMEID href="/HREF.aspx" style="background:#7C9DDB;border:0px black solid;border-left:1px #7C9DDB solid;border-right:1px #7C9DDB solid;color:#fff;padding:5px 2px 5px 6px">MENU</a>'
	,htmFoot:'<div style="background-image:url(/images/Menus.gif);background-repeat:no-repeat;border:0px solid black">&nbsp;</div>' ///<img src="images/Menus.gif" / >
	,zero:'border-top:1px dotted #fff;border-bottom:1px dotted #fff;color:#aaa;background:#fff;padding:5px 2px 5px 6px;border-left:1px #fff solid;border-right:1px #fff solid'
	,zerodep:'border-top:1px dotted #aaa;border-bottom:1px dotted #aaa;color:#aaa;background:#eef;padding:5px 2px 5px 6px;border-left:1px #fff solid;border-right:1px #fff solid'
	,none:'display:none'
	,instHelp:'<span class=INSTANThelp onmouseover="INSTANThelpOv();" onmouseout="INSTANThelpOu();">INSTANT&nbsp;HELP</span>'
	           
}
var COLORS={r:50+Rnd(6)*30,g:50+Rnd(6)*30,b:50+Rnd(6)*30,uni:''
	,aHex:new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F")
	,X:function(){this.r=255-this.r;this.g=255-this.g;this.b=255-this.b;}
	,Ad:function(v){this.AdR(v);this.AdG(v);this.AdB(v);}
	,AdR:function(v){this.r=(this.r+v)%255;if(this.r<0)this.r=255+this.r;}
	,AdG:function(v){this.g=(this.g+v)%255;if(this.g<0)this.g=255+this.g;}
	,AdB:function(v){this.b=(this.b+v)%255;if(this.b<0)this.b=255+this.b;}
	,RGB:function(r,g,b){return '#'+this.HEX2((r<0 ? 0 : r)%256)+this.HEX2((g<0 ? 0 : g)%256)+this.HEX2((b<0 ? 0 : b)%256);}
	,RGB0:function(){return this.RGB(this.r,this.g,this.b);}
	,RGB0x:function(){return this.RGB(255-this.r,255-this.g,255-this.b);}
	,HEX2:function(v){return this.aHex[parseInt(v/16)]+this.aHex[v%16];}
	,Bd:function(id){Os(id).borderColor=this.RGB0();}
	,Bg:function(id){Os(id).backgroundColor=this.RGB0();}
	,Tx:function(id){Os(id).color=this.RGB0();}
	,Tx2:function(id,i){Os(id).color=this.RGB((i==0 ? 100:0),(i==1 ? 100:0),(i==2 ? 100:0));}	
	,Add:function(col,add){	    
	  if($.browser.msie)
	     this.uni=new Array(this.h2d(col.substring(0,2)),this.h2d(col.substring(2,4)),this.h2d(col.substring(4,6)));//return '#'+this.d2h(this.h2d(col.substring(0,2))+add)+this.d2h(this.h2d(col.substring(2,4))+add)+this.d2h(this.h2d(col.substring(4,6))+add);//+this.d2h(this.h2d(col.substring(0,2))+this.h2d(col.substring(2,4))+this.h2d(col.substring(4,6)));
	  else 
	    this.uni=col.split('rgb(')[1].replace(')','').replace(/, /g,',').split(',');
	  
	  return '#'+this.d2h(parseFloat(this.uni[0])+parseFloat(add))+this.d2h(parseFloat(this.uni[1])+parseFloat(add))+this.d2h(parseFloat(this.uni[2])+parseFloat(add));
	}
	
	,d2h:function(d){return d.toString(16);}
	,h2d:function(h){return parseInt(h,16);}
	,max:function(v,mx){return v<=mx ? v : mx;}
}
	
	function MENUs(admin,code,cid,bid,did,nid,name,company,url,Mydepart,CoProps,Regcheck,Mysearch,Reqs,Props,msg){
	    var UNI,aUni, w=window.location+'';
        w=w.toLowerCase();        
	if(admin>0)MnItm.items[3][3]="EACH Alert!Alert/CODE/CID/BID/DID/NID/Listing.aspx?each!!";
        MnItm.items[3][3]=MnItm.items[3][3].replace('CODE',code).replace('CID',cid).replace('BID',bid).replace('DID',did).replace('NID',nid);
        if(url.length<5)
            O('statusbar').innerHTML=statusBar.replace('NAME',name.replace(/XX/g,"'")).replace('COMPANY',company.replace(/XX/g,"'"));
        else{
           var aCm=company.split(',');
           O('statusbar').innerHTML=statusBarUrl.replace('NAME',name.replace(/XX/g,"'")).replace('URL',url).replace('COMPANY',aCm[1].replace(/XX/g,"'")).replace('REST',", "+aCm[2]+", "+aCm[3]).replace('DEP',aCm[0].replace(/XX/g,"'"));
        }   
        
        if(msg>0)
            O('statusbar').innerHTML+='<div style="background:#cfc;padding:5px;display:block;position:relative;z-index:1000">'+aMsg[msg]+'</div>';

        var Uniloc;
        UNI='<div class=dMn>';
        for(var g=0;g<MnItm.items.length-2;g++){
            Uniloc=MnItm.htm;
            if(g==1)Uniloc=MnItm.htmAlt;
            for(var i=0;i<MnItm.items[g].length;i++){
              aUni=MnItm.items[g][i].split('!');
              if(i==0){
                UNI+=(g==0 ? '' : '</div><br>')+MnItm.htmTit.replace('NAMEID',g).replace('MENU',MnItm.items[g][0])+'<div class=gMen'+g+'>';
                if(g==0)
                    UNI+=MnItm.instHelp;
              }  
              else{                    
                if(w.indexOf(aUni[1].replace('.aspx?q=1','').toLowerCase())>-1){    
                    if(aUni.length==2 || (aUni.length>=3 && w.indexOf(aUni[2].toLowerCase())>-1)) 
                        UNI+=MnItm.htm1.replace('NAMEID',g+''+i).replace('MENU',aUni[0]).replace((aUni.length<4 ? 'HREF' : 'HREF.aspx'),aUni[1]);
                    else
                        UNI+=Uniloc.replace('NAMEID',g+''+i).replace('MENU',aUni[0]).replace((aUni.length<4 ? 'HREF' : 'HREF.aspx'),aUni[1]);                 
                }    
                else
                    UNI+=Uniloc.replace('NAMEID',g+''+i).replace('MENU',aUni[0]).replace((aUni.length<4 ? 'HREF' : 'HREF.aspx'),aUni[1]); 
		      }
		      //if(i==MnItm.items[g].length-1)UNI+=MnItm.htmFoot;		        
           }   
        }
    O('lhs').innerHTML=UNI+'</div></div><div id=MenuDesc style="display:none"></div><div id=rhs></div>';
				
	$('#lhs').find('div.gMen3').attr('style','background:#fff');	
	if(w.indexOf('guides')==-1){
	    $('#lhs').find('div.gMen3').find('a.amen31').attr('style','background:#CDE7FF');
	    $('#lhs').find('div.gMen3').find('a.amen31').css('border','2px solid #C0E0FF');
    }	    

	$('#lhs').find('div.gMen3').find('a.amen33').attr('style','background:#F3E67B');
	$('#lhs').find('div.gMen3').find('a.amen33').attr('target','_blank');
	//suggestions
  	$('#lhs').find('div.gMen3').find('a.amen34').attr('style',
    	  w.indexOf('suggestions')==-1 ? 'background:#ACE6B9' : 'background:#009900;color:#fff;border:1px #009900 solid'
   	);
	//Agent AB
    $('#lhs').find('div.gMen3').find('a.amen36').attr('style',
        w.indexOf('agency')==-1 ? 'background:#F1D8CB;color:#294361;margin-top:14px' :
        'color:#f0f0f0;background:#B19C88;margin-top:14px;border:1px solid #ECF8FF'
    );	    
    $('#lhs').find('div.gMen3').find('a.amen32').attr('style',
        w.indexOf('listings')==-1 ? 'background:#bb88ee' :
        'background:#9040cc;color:#ffffff'
    );	
		
	
	$('#lhs').find('div.gMen3').find('a.amen35').attr('style','background:#FFC0CB');	

    if(Mydepart<2)$('#lhs').find('div.gMen0').find('a.amen02').attr('style',MnItm.zerodep);
    if(CoProps==0)$('#lhs').find('div.gMen0').find('a.amen03').attr('style',MnItm.zero);
    if(Mysearch==0)$('#lhs').find('div.gMen1').find('a.amen12').attr('style',MnItm.zero);    
    if(Regcheck==0)$('#lhs').find('div.gMen0').find('a.amen04').attr('style',MnItm.zero);
    if(Reqs==0)$('#lhs').find('div.gMen1').find('a.amen14').attr('style',MnItm.zero);
    if(Props==0)$('#lhs').find('div.gMen1').find('a.amen16').attr('style',MnItm.zero);

    if(cid!=95){
        $('#lhs').find('div.gMen2').find('a.amen23').attr('style',MnItm.none);
    }


 	var pageY0;
	$('#lhs').find('a').mouseover(function(e){
	        UNI=$(this).attr('class').replace('amen','').split('');
	        if(MnItm.help[UNI[0]][UNI[1]].indexOf('!')>-1)
	            $('#MenuDesc').attr('style','display:none')
	        else{
	            $('#MenuDesc').html(MnItm.help[UNI[0]][UNI[1]]);	        
	            $('#MenuDesc').attr('style','top:'+(e.pageY-20+((pageY0-e.pageY)>0 ? -10:5))+'px');														 
                    pageY0=e.pageY;	
                    $('#MenuDesc').mouseout(function(){$('#MenuDesc').attr('style','display:none')});
            }
        } 														 
    )
    

    if(admin>0){
        UNI='<div class=dMn>';
        for(var g=4;g<MnItm.items.length;g++){
            for(var i=0;i<MnItm.items[g].length;i++){
               aUni=MnItm.items[g][i].split('!');
              if(i==0)
                UNI+=(g==4 ? '' : '</div><br>')+MnItm.htmTit.replace('NAMEID',g).replace('MENU',MnItm.items[g][0])+'<div class=gMen'+g+'>';
              else{
                if(w.indexOf(aUni[1].replace('.aspx?each=true','').toLowerCase())>-1)                
                   UNI+=MnItm.htm1.replace('NAMEID',g+''+i).replace('MENU',aUni[0]).replace((aUni.length<4 ? 'HREF' : 'HREF.aspx'),aUni[1]);                    
                else
                    UNI+=MnItm.htm.replace('NAMEID',g+''+i).replace('MENU',aUni[0]).replace((aUni.length<4 ? 'HREF' : 'HREF.aspx'),aUni[1]); 
		      }
           }   
        }
        
        O('rhs').innerHTML=UNI+'</div></div>';    
	}		
    var locUni;
	$('#lhs').find('span.t').mouseover(function(){$(this).attr('style','background:#aaa;color:#900');$('#MenuDesc').attr('style','display:none');})
	$('#lhs').find('span.t').mouseout(function(){$(this).attr('style','background:#eee;color:red');})
	$('#lhs').find('span.t').click(function(){			
			try{
			if($('#lhs').find('div.gMen'+$(this).attr('name')).attr('style')==undefined || $('#lhs').find('div.gMen'+$(this).attr('name')).attr('style').toLowerCase().indexOf('none')==-1){
				$('#lhs').find('div.gMen'+$(this).attr('name')).slideUp('slow');
				locUni='+&nbsp;'+$(this).html();				
			}
			else{
				$('#lhs').find('div.gMen'+$(this).attr('name')).slideDown('fast');
				locUni=$(this).html().replace('+&nbsp;','');
			}	
			$(this).html(locUni);																
			}catch(e){alert(e.message);}
		})    
    $('#middle').mouseover(function(e){$('#MenuDesc').attr('style','display:none;left:-100px');})
    
	$('#lhs').find('div.dMn').find('a').mouseover(function(){
	    try{  
	    locUni=COLORS.Add($(this).css('background').toLowerCase().replace('#',''),-30);
	    $(this).css('border-color',locUni);
	    $(this).css('background',locUni);
	    }catch(e){ }
	   
	});
	$('#lhs').find('div.dMn').find('a').mouseout(function(){
	    try{
	    locUni=COLORS.Add($(this).css('background').toLowerCase().replace('#',''),+30);	    
	    $(this).css('border-color',locUni);
	    $(this).css('background',locUni);
	    }catch(e){  }
	});    
}										

var statusBar='<p>&nbsp;Login:&nbsp;<span style="color:#504030;color:red;"><b>NAME</b>, <font style="font-size:9px;color:black;">COMPANY</font></span><span name=countdown id=Countdown>20:00</span></p>';			
var statusBarUrl='<p>&nbsp;Login:&nbsp;<span style="color:#504030;color:red;"><b>NAME</b>, <font style="font-size:9px;color:black;">&nbsp;DEP,</font> <a style="color:blue" target=_blank href="http://URL">COMPANY</a><font style="font-size:9px;color:black;">&nbsp;REST</font></span><span name=countdown id=Countdown>20:00</span></p>';			
var aMsg=new Array(''
                ,'Your identity has been changed...'
                ,'You must now do a Register Check due to inactive instructions nearing archive date'
                ,'You must now do a Register Check due to inactive instructions nearing archive date'
                ,'');			
function loadMenuMsg(admin,code,cid,bid,did,nid,name,company,url,Mydepart,CoProps,Regcheck,Mysearch,Reqs,Props,msg){
    MENUs(admin,code,cid,bid,did,nid,name,company,url,Mydepart,CoProps,Regcheck,Mysearch,Reqs,Props,msg);

}

function loadMenu(admin,code,cid,bid,did,nid,name,company,url,Mydepart,CoProps,Regcheck,Mysearch,Reqs,Props){
    loadMenuMsg(admin,code,cid,bid,did,nid,name,company,url,Mydepart,CoProps,Regcheck,Mysearch,Reqs,Props,0);
}
function SwAcc(i,n){//window.location='www.each.co.uk/Home.aspx?NID_ORIG='+i;
    O('statusbar').innerHTML+="<a href='/Home.aspx?NID_ORIG="+i+"'>« return to "+n+"</a>";
}


var gLogOut, cDate,cDate2,SecondsAlreadyUsed=0,wasSetTimeOut=false;
var milisec=0,seconds=30, sec = 0, min = 20, LIMIT=5;   // set the minutes

function LogOut(){window.location="http://www.each.co.uk/abu/Logout.aspx";}
function prolong(){
        sec = 0;min = 20;
        O('Countdown').style.background="#efef00";
        O('Countdown').style.color="#bb1100";      
        $.post('http://www.each.co.uk/abu/ProlongSession.aspx', {}, function() { });    
}

function countDown() {
      sec--;
      if (sec == -01) {
        sec = 59;
        min = min - 1;
      } else min = min;
  
    
    if (sec<=9) { sec = "0" + sec; }
        time = (min<=9 ? "0" + min : min) + ":" + sec;
  try{  
      if(min<LIMIT){
          if(sec%2==0){
            O('Countdown').style.background="#bb1100";
            O('Countdown').style.color="#efef00";
          }
          else{
            O('Countdown').style.background="#efef00";
            O('Countdown').style.color="#bb1100";  
          }               
          O('Countdown').innerHTML = time+"<a href='javascript:prolong();'>prolong</a>"; 
      } 
      else O('Countdown').innerHTML = time; 
  }catch(e){}               
  if (min == 0 && sec == 0)LogOut();        
  else setTimeout(countDown,1000);     
}
if(!wasSetTimeOut) setTimeout("countDown();",1000);    


// Don't allow site to be framed
if (top.frames.length!=0) {
   top.location=self.document.location;
}

var IE_all_cache = new Object();
//function IE_getElementById(id) { if (IE_all_cache[id] == null) { IE_all_cache[id] = document.all[id]; } return IE_all_cache[id]; }
//function NS_getElementById(id) { if (IE_all_cache[id] == null) { IE_all_cache[id] = document.layers[id]; } return IE_all_cache[id]; }
//if (document.all) { document.getElementById = IE_getElementById; is_ie = 1; } else { is_ie = 0; }
//if (document.layers) { document.getElementById = NS_getElementById; }
var agt = navigator.userAgent.toLowerCase();
var is_ie = (agt.indexOf("msie") != -1);
var is_opera = (agt.indexOf("opera") != -1);
var is_mac = (agt.indexOf("mac") != -1);
var is_netscape = (agt.indexOf("netscape") != -1);
var is_gecko = (agt.indexOf("gecko") != -1);
var is_safari = (agt.indexOf("safari") != -1);
var scrolldef = "", loaddef = "", resizedef = "", d = "", t = 60, p = 0;

function ss(w) { window.status=w; return true; }
function cs() { window.status=''; }

function addLoadEvent(func) {
  var old = window.onload;
  if (typeof window.onload != 'function') { window.onload = func; }
  else { window.onload = function() { if (old) { old(); } func(); } }
}

function addUnLoadEvent(func) {
  var old = window.onunload;
  if (typeof window.onunload != 'function') { window.onunload = func; }
  else { window.onunload = function() { if (old) { old(); } func(); } }
}

function addScrollEvent(func) {
  var old = window.onscroll;
  if (typeof window.onscroll != 'function') { window.onscroll = func; }
  else { window.onscroll = function() { if (old) { old(); } func(); } }
}

function addClickEvent(func) {
  var old = window.onclick;
  if (typeof window.onclick != 'function') { window.onclick = func; }
  else { window.onclick = function() { if (old) { old(); } func(); } }
}

function addKeyPressEvent(func) {
  var old = window.onkeypress;
  if (typeof window.onkeypress != 'function') { window.onkeypress = func; }
  else { window.onkeypress = function() { if (old) { old(); } func(); } }
}

function addResizeEvent(func) {
  var old = window.onresize;
  if (typeof window.onresize != 'function') { window.onresize = func; }
  else { window.onresize = function() { if (old) { old(); } func(); } }
}

function show() {
  for (var i=0,j=arguments.length; i<j; ++i) {
		_show(arguments[i] + "_open");
		_hide(arguments[i] + "_closed");
	}
}

function hide() {
  for (var i=0,j=arguments.length; i<j; ++i) {
		_show(arguments[i] + "_closed");
		_hide(arguments[i] + "_open");
	}
}

function toggle() {
  for (var i=0, j = arguments.length; i<j; ++i) {
		var o = document.getElementById(arguments[i]);
		if (o) o.style.display = o.style.display == "block" ? "none" : "block";
	}
}

function _hide() {
  for (var i=0,j=arguments.length; i<j; ++i) {
		var o = document.getElementById(arguments[i]);		
		if (o) o.style.display = "none";
	}
}

function _show() {
  for (var i=0,j=arguments.length; i<j; ++i) {
		var o = document.getElementById(arguments[i]);		
		if (o) o.style.display = "block";
	}
}

function set_check() {
  for (var i=0,j=arguments.length; i<j; ++i) {
		var o = document.getElementById(arguments[i]);
		if (o && o.type == "checkbox") { o.checked = true; }		
	}
}

function get_check() {
	var rv = true, o;
	for (var i=0,j=arguments.length; i<j; ++i) {
		o = document.getElementById(arguments[i]);
		if (o) { rv &= o.checked; }
	}
	return rv;
}

function getOptions() {
  var output = "";
  for (var i=0,part="",l_args=arguments.length; i<l_args; ++i, part = "") {
    var x = document.getElementById(arguments[i]);
		if (x) {
			var x_t = x.type;
			if (x_t == "select-one" || x_t == "select-multiple") {
				var x_o = x.options;
				for (var j = 0, l_x_o = x_o.length; j < l_x_o; ++j) {
					var o = x_o[j];
					if (o.selected && o.value != "__NO_VALUE__") { if (part != "") part += ','; part += o.value; }
				}
			} else if (x_t == "textarea" || x_t == "text") {
				if (part != "") part += ','; part += x.value;
			} else if (x_t == "radio") {
				if (x.checked) { if (part != "") part += ','; part += x.value; }
			}
		}
		if (part != "") output += part;
		if (i < l_args-1) output += '|';
  }
	return output
}

var popupwindow = '';
var popup_width = 570;
var popup_height = 480;

function popitup(url) {
try{
    if(url.match("Property")=="Property")
    {
        popup_width = 580;
        popup_height = 800;
    }
    else //requirement
    {
        popup_width = 580;
        popup_height = 480;
    }
	if (popupwindow.location && !popupwindow.closed) { popupwindow.location.href = url; popupwindow.centre(); if (window.focus) popupwindow.focus(); }
	else { popupwindow = window.open(url, 'popupwindow', 'width=' + popup_width + ',height=' + popup_height + ',resizable=1,scrollbars=1');  }
	if (!popupwindow || popupwindow.closed) alert('Unable to open popup - please disable popup blocking and try again');
	}
	catch (e)
	{}
	return false; 
}
 
function popitup1(url, name, scrollResize, size) {
	var features = "" + size;
	features += scrollResize ? ",scrollbars=yes,resizeable=yes" : "";
	
	var popup = window.open(url, name, features);
	if (!popup || popup.closed) {
		alert('Unable to open popup - please disable popup blocking and try again');
		return false; 
	}
	
	var strpostcode = popup.opener.document.getElementById('postcode').value;
	var arrpostcode = strpostcode.split(' ');
	var strtowncity = popup.opener.document.getElementById('towncity').value;
	
	if (arrpostcode[0].length > 0) {
		popup.document.getElementById('search_text').value = arrpostcode[0];		
	}
	else if (strtowncity.length > 0) {
		popup.document.getElementById('search_text').value = strtowncity;
	}
	popup.focus();
	return true;
}


function fullScreen() {
  window.moveTo(0,0);
  window.resizeTo(screen.availWidth,screen.availHeight);
};


function centre() {
  if (parseInt(navigator.appVersion) >= 4) {
	  window.moveTo((screen.availWidth/2)-(popup_width/2-5),(screen.availHeight/2)-(popup_height/2-5));
	}
};

   
            var fav=0;            
            var enableCache = false;
            var jsCache = new Array();
            var AjaxObjects = new Array();        
            


      function ShowContent(divId,ajaxIndex,url)
        {
	        //alert(AjaxObjects[ajaxIndex].response);
	        /*document.getElementById(divId).innerHTML = AjaxObjects[ajaxIndex].response;
	        
	        if(enableCache){
		        jsCache[url] = 	AjaxObjects[ajaxIndex].response;
	        }
	        AjaxObjects[ajaxIndex] = false;
	        */
        }
        
        function Ajax(divId,url)
        {
	        /*if(enableCache && jsCache[url]){
		        document.getElementById(divId).innerHTML = jsCache[url];
		        return;
	        }	
	        */
	        var ajaxIndex = AjaxObjects.length;
	        //document.getElementById(divId).innerHTML = '<img src=images/movewait.gif width=16 height=16 hspace=10 vspace=10 />';
	        AjaxObjects[ajaxIndex] = new sack();
	        AjaxObjects[ajaxIndex].requestFile = url;
	        //AjaxObjects[ajaxIndex].onCompletion = function(){ShowContent(divId,ajaxIndex,url); };
	        //AjaxObjects[ajaxIndex].onLoading = function(){alert('onLoading');};
	        //AjaxObjects[ajaxIndex].onInteractive=function(){alert('onInteractive');};
	        AjaxObjects[ajaxIndex].runAJAX();}
           
        function AjaxSave(dv,note)//,bid
        {
            //alert(dv);
	        var ajaxIndex = AjaxObjects.length;
	        //document.getElementById(divId).innerHTML = '<img src=images/movewait.gif width=16 height=16 hspace=10 vspace=10 />';
	        AjaxObjects[ajaxIndex] = new sack();
	        AjaxObjects[ajaxIndex].requestFile = "async/AsyncHandler.aspx?t=an_save_note&note="+note;//+"&bid="+bid
	        AjaxObjects[ajaxIndex].onCompletion = function(){ShowMsg(dv); };
	        //AjaxObjects[ajaxIndex].onLoading = function(){alert('onLoading');};
	        //AjaxObjects[ajaxIndex].onInteractive=function(){alert('onInteractive');};
	        AjaxObjects[ajaxIndex].runAJAX();
        }               
    
function ShowMsg(div)
{    
    //getElementById(dv).style.display='block';
}
function sack(id) {//file,
	this.xmlhttp = null;
    this.xmlhttp2 = null;
    
	this.resetData = function() {
		//alert('this.resetData');
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = null;//file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}

		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
	    //alert('urlstring='+this.URLString);
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rf", new Date().getTime());//rndval

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
			//alert(key + "=" + this.vars[key][0]);
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
		//alert('urlstring='+this.URLString);
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		//alert(urlstring);
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
			    alert('this.element');
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				//alert(this.xmlhttp);
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					//alert(totalurlstring );
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					//alert(self.xmlhttp.readyState);
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
							    //alert(self.xmlhttp.responseText);
								self.onCompletion();
							} else {
								self.onError();
							}

							self.URLString = "";
							break;
					}
				};
               //alert(this.URLString);
				this.xmlhttp.send(555);//this.URLString
			}
		}
	};

	this.reset();
	this.createAJAX();
}

function select_filter()
{
    mywindow=window.open('Settings.aspx',"mywindow","menubar=0,scrollbars=1,resizable=1,width=815,height=825");        
    mywindow.moveTo(45,0);  
}

function o(o){o.className=o.className+"Over";} 
function u(o){o.className=o.className.replace(/Over/,'');} 




    function focused(object)
    {       
            object.style.background="yellow";  
            //alert(1);        
    }
    function focused(object,selected)
    {       
        //selected_FID.className
        //alert(object.className);
        if(object.className!="NEW")
        {
            object.style.background="yellow";  
            //document.getElementById("selected_FID").value=selected;
        }
        
    }    
    function blured(object, available, numeric, floorname)
    {       
        var i=1;
       // alert(0);
       object.style.background="#FFFFFF";
        object.value=object.value.replace(/ /g,"");
        object.value=object.value.replace(/,/g,".");
        if(floorname)
        {
            //alert(object.value.substring(0,1));      
            for(i=1;i<object.value.length;i++)
            {
                if(isNaN(object.value.substring(0,i)))
                    break;
            
            }      
            /*while(!isNaN(object.value.substring(0,i)))
            {
                
                i++;
            }   */
            //alert(i);
            if(i==1 && object.value.length>1)
            {
                object.style.background="#FF8081";
                object.value=1+" "+object.value;
                alert("the first letter (=floor number) of the floor name must be numeric!");
                return;
            }
            else
            {
                
                if(object.value.length>1)
                object.value=object.value.substring(0,i-1)+" "+object.value.substring(i-1,object.value.length);
            }
        }
        
        if(numeric)
        {
                if(isNaN(object.value))
                {
                  
                  
                  object.style.background="#FF8081"; 
                  alert("The red box value must be numeric, please correct!");  
                  object.value=0;
                  return;
                }            
        
        }
        if(available)
        {             
             //alert(object.value.length);
             if(object.value.length==0)
             {
                setColor(object);
                return;
             }
             
             if(object.value.length<4 || object.value.length>6)
             {
                
                object.style.background="#FF8081"; 
                alert('Check entered Available Date Format, it should be: mm.yy');
                return;
             }
            
            var month, arValidMonth=Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
            //alert(arValidMonth);
            try
            {
                //var intMM=parseInt(object.value);
                
                var year=object.value.substr(3,2);
                if(object.value.length==4)
                    year=object.value.substr(2,2);
                
                if(isNaN(object.value.substr(0,2)))
                {
                    //year=alert(object.value.substr(0,3).toLowerCase());
                    month=object.value.substr(0,3).toLowerCase();
                    for(i=0;i<arValidMonth.length;i++)//arValidMonth=;
                    {
                        if(month==arValidMonth[i])
                            break;
                        
                    }
                    if(i==12)
                    {
                        month=object.value.substr(0,2).toLowerCase();
                        for(i=0;i<arValidMonth.length;i++)//arValidMonth=;
                        {
                            if(month==arValidMonth[i].substr(0,2))
                            {
                                object.value=arValidMonth[i].substr(0,1).toUpperCase()+arValidMonth[i].substr(1,2)+"."+year;
                                break;
                            }    
                        }                        
                            //alert(i);
                            if(i==12)
                            {
                                object.style.background="#FF8081"; 
                                alert('Check enetered Available Date Format, it should be: mm.yy');                                                    
                                return;
                            }                                
                    }
                    
                }
                else
                {
                    switch(object.value.substr(0,2))
                    {
                        case "1":
                        case "01":
                            object.value="Jan."+year;
                            break;
                        case "2":
                        case "02":
                            object.value="Feb."+year;
                            break;                        
                        case "3":
                        case "03":
                            object.value="Mar."+year;
                            break;                        
                        case "4":
                        case "04":
                            object.value="Apr."+year;
                            break;                 
                        case "5":
                        case "05":
                            object.value="May."+year;
                            break;  
                        case "6":
                        case "06":
                            object.value="Jun."+year;
                            break;  
                        case "7":
                        case "07":
                            object.value="Jul."+year;
                            break;  
                        case "8":
                        case "08":
                            object.value="Aug."+year;
                            break;  
                        case "9":
                        case "09":
                            object.value="Sep."+year;
                            break;  
                        case "10":
                            object.value="Oct."+year;
                            break;  
                        case "11":
                            object.value="Nov."+year;
                            break;  
                        case "12":
                            object.value="Dec."+year;
                            break;        
                        default:
                            object.style.background="#FF8081";
                            alert('Check entered Available Date Format, it should be: mm.yy');                        
                            break;                                                                                                                                                                                          
                    }
                }                
                //object.value+=year;
            }            
            catch(e)
            {
                //alert(0);
            }
        }


        //setColor(object);//object.className,object.style.background);
    }    
    
    
    function setColor(obj)
    {
        switch(obj.className)
        {        
        case "COMPLETED":
            obj.style.background="#FFE6CC";        
            break;
        case "AVAILABLE":
            obj.style.background="#d6eac2";        
            break;
        case "UNDER_OFFER":
            obj.style.background="#FFFFCC";        
            break;
        case "WITHDRAWN":
            obj.style.background="#FFE6CC";        
            break;                                
        
        
        }            
    
    }


function over_css(obj)
{
    obj.className="btOver"
}
function out_css(obj)
{
    obj.className="bt"
    
}
 

//-->


function getSERVER_URL()
{
    return "http://www.each.co.uk/"
   // return "http://localhost/";
}
function get4PropServer_URL() {
    return "http://www.4prop.com/";
}
/* -- STREET PROFILE  -- START ---*/
 
 var _NID=0;
function getStreetProfile(_st,_pc,_type) { 

        if(_type == 0) return;
        // note : if   make any change , please do same in Alert - Listing.aspx as well
        _pc = _pc.replace(' ',"05550");  //convert Empty space to "05550" string
        _st = _st.replace(',',"04440"); 
        _st = _st.replace('/',"03330");  
        _st = _st.replace('&',"02220"); 
        _st = _st.replace('-',"010"); 
        _st = _st.replace('(',"020"); 
        _st = _st.replace(')',"030"); 
        _st = _st.replace(':',"040"); 
         
        while(_st.indexOf(' ')>0)
        {
            _st = _st.replace(' ',"05550");
        }
        
        if(_st.length <=1 )
            _st = "05550";
        
        try{
         //  alert($('#NIDc').val());
            _NID=$('#NIDc').val();//document.getElementById('hNID');
        }catch(e){}
        //alert(_NID);
        var win;
        
        if(_type ==2)
            win = window.open(getSERVER_URL() + 'abu/' +_pc + '/'+ _st  +'/CentreEstateInfo.aspx?NID='+_NID, 'StProfile','width=900,height=700,scrollbars=1,resizable=1');          
        else
            win = window.open(getSERVER_URL() + 'abu/' + _pc + '/' + _st + '/streetinfo.aspx?NID=' + _NID, 'StProfile', 'width=900,height=700,scrollbars=1,resizable=1'); 
         win.focus();
    }
    
    
    function getTownProfile(_town,_pc)
    {
     // note : if   make any change , please do same in Alert - Listing.aspx as well
        _pc = _pc.replace(' ',"05550");  //convert Empty space to "05550" string
        _town = _town.replace(',',"04440"); 
        _town = _town.replace('/',"03330");  
        _town = _town.replace('&',"02220");  
        _town = _town.replace('-',"010"); 
        _town = _town.replace('(',"020"); 
        _town = _town.replace(')',"030"); 
        
    
        while(_town.indexOf(' ')>0)
        {
            _town = _town.replace(' ',"05550");
        }
        
        if(_town.length <=1 )
            _town = "05550";
        
        try{
           //alert($('#NIDc').val());
            _NID=$('#NIDc').val();//document.getElementById('hNID');
          //  alert(_NID);
        }catch(e){}
        //alert(_NID);
        var win;
            win = window.open(getSERVER_URL() + 'abu/' +_pc + '/'+ _town  +'/TownInfo.aspx?NID='+_NID, 'TownProfile','width=600,height=700,scrollbars=1,resizable=1');          
            win.focus();
    }
    
    
    function getFloor(_id,_did)
    {
    var win ;
    if (_id>0)
        {
             win = window.open(getSERVER_URL() + 'abu/' +_id +'/'+_did +'/FloorInfo.aspx', 'FloorInfo','width=682,height=555,left=150,top=200,scrollbars=1,resizable=1'); 
            win.focus();
        }
    }
    
    var gHELP;
    function INSTANThelpOv(){
        //alert(1);
        clearInterval(gHELP);
       var helpText="1) There is a Need HELP BAR just below<br>";
        //helpText+="below and to the right <br>";
        helpText+="2) Have you seen the user guides below <br>";
        helpText+="otherwise, do call 020 7602 5947 <br>";
        helpText+="Anthony, Jeremy, or Jamie will be glad to help<br>";
        //helpText+="";
        document.getElementById('INSTANThelpText').innerHTML=helpText;
        document.getElementById('INSTANThelpText').style.display="block";
    }
    function INSTANThelpOu(){
        gHELP=setTimeout(INSTANThelpOFF,2000);
        
        //document.getElementById('INSTANThelpText').innerHTML="";
        //alert(10);
    }
    function INSTANThelpOFF(){
        document.getElementById('INSTANThelpText').innerHTML="";
        document.getElementById('INSTANThelpText').style.display="none";
    }
    
    function loadPropImage(_id,_found)
    {
    var win ;
    if (_id>0 && _found >0)
        {
             win = window.open(getSERVER_URL() + 'abu/Property/' +_id +'/Image.aspx', 'propImage','width=682,height=555,left=150,top=200,scrollbars=1,resizable=1'); 
            win.focus();
        }
    }
/* -- STREET PROFILE  -- END ---*/
    
function Clicks(pid){

    //alert(pid);
    var url=location.href+'';
    
    url=url.toLowerCase();//alert(url);
    if(url.indexOf('requirement')>0)url='&r=1';else url='';
    
    mywindow=window.open(getSERVER_URL()+'AttachmentClicked.aspx?p='+pid+url,"mywindow","menubar=0,scrollbars=1,resizable=1,width=1000,height=505");        
 //   alert(pid);
    mywindow.moveTo(45,0);  

}

/* ---- Call VOA site -start-- */
function callVOA(_postcode)
{
    var agt = navigator.userAgent.toLowerCase();
        if (agt.indexOf("msie") >=0 )
            window.clipboardData.setData("text",_postcode );
    winVOA = window.open("http://www.2010.voa.gov.uk/rli/en/advanced","winVOAsite");
    winVOA.focus();
}

/*--Call VOA site End- */
/* -- Matches Page */
function CallEmailAgent(_page) {
    window.location.href = getSERVER_URL() + _page;
}
/* -- Matches Page -- End --*/