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', 'Testing / Release')
 , 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'
            , 'Props we own!Owner', 'Props we occupy!Occupier'
    //, 'Comments!PropertyComments', 'Favourites!PropFavourite'
            )
     , Array('IDEAS INFO'
            , 'Email Agents!Email2Agents'
    //, 'Props we own!Owner', 'Props we occupy!Occupier'
            , 'Comments!PropComments', 'Favourites!PropFavourite'

            )
     , Array('ARCHIVE/RSRCH', 'Comparables/Find!InstantSearchNew'
            , 'PROFILES!LocationProfile'
            , 'Business Search!BusinessSearch/PropertySearch', 'EACH Listings!Listings'
            , 'MAP!JSON/MAP.htm?W1!!'
            , 'Property Archive!PropertyArchive'
            )
     , Array('', 'User Guides!UserGuides', 'EACH Alert!Alert/CODE/CID/BID/DID/NID/Listing', 'Suggestions!Suggestions', 'Logout!abu/Logout', 'Agent AB!AgencyWebsite'
	//, 'REMOTE viewer!REMOTEViewer', 'Customize!Customize'
)
     , 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'
	        , 'Owner!Owner', 'Occupier!Occupier', 'Others Property!Property_OtherCompany', 'Occupier Control!OccupierCnt', 'Agent AB Invoice!AgentABInvoice'
	        )


    , Array('Testing / Release'
	        , '4prop!http://www.osidil.com/JSON/4prop/test/index.html'
	        , 'Agent&nbsp;AB/Councils...!http://www.osidil.com/JSON/AgentAB/test/AgentAB.html'
		, 'New&nbsp;Requirement...!http://www.each.co.uk/ListNew.aspx?Req'
		, 'New&nbsp;Property!http://www.each.co.uk/ListNew.aspx'
		//, 'My/Our&nbsp;Props!http://www.each.co.uk/ListNew.aspx?|NDBC'
		//, 'My/Our&nbsp;Reqs!http://www.each.co.uk/ListNew.aspx?requirement|NDBC'
		//, 'Register&nbsp;Check!http://www.each.co.uk/ListNew.aspx?register|NDBC'
	        )
      )
  ,

    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.'
        , 'List of Properties<br>that my Company owns', 'List of Properties<br>that my Company occupies')

     , Array('IDEAS INFO'
            , 'Select, amend, and save lists of Agents, or generate from Department Names.'
    //, 'Props we own!Owner', 'Props we occupy!Occupier'
            , 'Record your comments on Properties you have seen'
            , 'Interesting Properties, Requirements you saved'

            )
     , 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', 'Set up relevant listings that you want to view or print time and again, including YOUR DEPARTMENT\'s list of Properties'

            , 'Shows your selected properties on a map', 'Search in Property Archive')
     , Array('', 'PDFs with brief instructions on how to use the services', 'The daily list of new Properties and Requirements, according to your Settings for your broad or 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.', 'REMOTE Viewer', 'Enables to customize your page look', 'Shows pages for Owner/Occupier')
     , 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'
	         , 'List of Properties<br>that my Company owns', 'List of Properties<br>that my Company occupies'

	         )
            )

    , htmTit: '<span name=NAMEID class=t>MENU</span>'
    , htm: '<span><a class=amenNAMEID style="background:#ecf8ff;color:#225;border:2px solid #ECF8FF" target href="/HREF.aspx">MENU</a><span class=dsc></span></span>'
    , htmAlt: '<span><a class=amenNAMEID style="background:#cde7ff;border:2px solid #cde7ff;color:#225" href="/HREF.aspx">MENU</a><span class=dsc></span></span>'
	, htm0: '<span><a class=amenNAMEID style="background:#fff;color:gray" href="/HREF.aspx">MENU</a><span class=dsc></span></span>'//
	, htm1: '<span><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><span class=dsc></span></span>'
	, 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; }
}



//var BranchDelivery;
var _gNid = 0, _gDid = 0, _gBid = 0, _gCid = 0,nbdc='';
function MENUs(admin, code, cid, bid, did, nid, name, company, url, Mydepart, CoProps, Regcheck, Mysearch, Reqs, Props, msg, branch, NegotiatorType, BranchDelType, webaccess) {
    //alert(BranchDelType);//;&#44;

    _gNid = nid;
    _gBid = bid;
    _gDid = did;
    _gCid = cid;
    nbdc=nid+'|'+did+'|'+bid+'|'+cid;
    //alert(nbdc);
//|n|d|b|c    
    var UNI, aUni, w = window.location + '';
    w = w.toLowerCase();
    //alert(MnItm.items[4][2]);
    if (admin > 0) MnItm.items[4][2] = "EACH Alert!Alert/CODE/CID/BID/DID/NID/Listing.aspx?each!!";
    MnItm.items[4][2] = MnItm.items[4][2].replace('CODE', code).replace('CID', cid).replace('BID', bid).replace('DID', did).replace('NID', nid);
    if (branch == undefined || branch.length < 1)
        branch = '';
    var aCm = company.split(',');
    if (url.length < 5) {
        O('statusbar').innerHTML = statusBar.replace('NAME', name.replace(/XX/g, "'")).replace('COMPANY', aCm[1].replace(/XX/g, "'")).replace('REST', ", " + aCm[3]).replace('DEP', aCm[0].replace(/XX/g, "'")).replace('Branch', branch);
    }
    else {
        O('statusbar').innerHTML = statusBarUrl.replace('NAME', name.replace(/XX/g, "'")).replace('URL', url).replace('COMPANY', aCm[1].replace(/XX/g, "'")).replace('REST', ", " + aCm[3]).replace('DEP', aCm[0].replace(/XX/g, "'")).replace('Branch', branch);
    }

    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 - 3; 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=rhs></div>';
    //if(NegotiatorType=='A')<div id=MenuDesc style="display:none"></div>
    //  O('lhs').innerHTML='Occupier';

   try{	
    $('#lhs').find('div.gMen4').attr('style', 'background:#fff');


    if (w.indexOf('guides') == -1) {
        $('#lhs').find('div.gMen4').find('a.amen41').attr('style', 'background:#CDE7FF').css('border', '2px solid #C0E0FF');
        //$('#lhs').find('div.gMen4').find('a.amen41');
    }

    $('#lhs').find('div.gMen4').find('a.amen42').attr('style', 'background:#F3E67B');
    $('#lhs').find('div.gMen4').find('a.amen42').attr('target', '_blank');
    //suggestions
    $('#lhs').find('div.gMen4').find('a.amen43').attr('style',
    	      w.indexOf('suggestions') == -1 ? 'background:#ACE6B9' : 'background:#009900;color:#fff;border:1px #009900 solid'
   	    );
    //Agent AB
    $('#lhs').find('div.gMen4').find('a.amen45').attr('style',
            w.indexOf('agency') == -1 ? 'background:#F1D8CB;color:#294361;margin-top:14px' :
            'color:#f0f0f0;background:#B19C88;margin-top:14px;border:1px solid #ECF8FF'
        );
    // -- Problem Solve
    //if (cid != 95) $('#lhs').find('div.gMen3').find('a.amen36').css('display', 'none');   
    //Customize
    $('#lhs').find('div.gMen4').find('a.amen47').attr('style',
            w.indexOf('customize') == -1 ? 'background:#aaffaa;color:#009900;margin-top:20px' :
            'color:#99ff99;background:#009900;margin-top:20px;border:1px solid #ECF8FF'
        );


    if (admin == 0){//cid != 95){//Customize
        $('#lhs').find('div.gMen4').find('a.amen47').css('display', 'none');
	$('#lhs').find('div.gMen2').find('a.amen21').css('display', 'none');
    }
  // $('#lhs').find('div.gMen2').find('a.amen21').css('display', 'none');
    //D,I,O, 
    //Listings...
    $('#lhs').find('div.gMen3').find('a.amen34').attr('style', w.indexOf('listings') == -1 ? 'background:#b8e' : 'background:#94c;color:#fff');


    $('#lhs').find('div.gMen4').find('a.amen44').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);

//admin == 0 && 
    if ((NegotiatorType == 'D' || NegotiatorType == 'I' || NegotiatorType == 'O')) {		
        $('span[name=1],span[name=2],span[name=3]').css('display', 'none');
        $('#lhs').find('div.gMen0').find('a.amen03').attr('style', MnItm.none);
        $('#lhs').find('div.gMen0').find('a.amen04').attr('style', MnItm.none);
        //req
        $('#lhs').find('div.gMen1').find('a.amen13').attr('style', MnItm.none);
        $('#lhs').find('div.gMen1').find('a.amen14').attr('style', MnItm.none);
        //prop
        $('#lhs').find('div.gMen1').find('a.amen15').attr('style', MnItm.none);
        $('#lhs').find('div.gMen1').find('a.amen16').attr('style', MnItm.none);
        //email 2 ag
        $('#lhs').find('div.gMen2').find('a.amen21').attr('style', MnItm.none);
        $('#lhs').find('div.gMen3').find('a.amen31').attr('style', MnItm.none);
        $('#lhs').find('div.gMen3').find('a.amen32').attr('style', MnItm.none); //-- Profile
        $('#lhs').find('div.gMen3').find('a.amen23').attr('style', MnItm.none);
        $('#lhs').find('div.gMen3').find('a.amen34').attr('style', MnItm.none);

        //guides
        $('#lhs').find('div.gMen4').find('a.amen41').attr('style', MnItm.none);
        //Agent AB
        $('#lhs').find('div.gMen4').find('a.amen45').attr('style', MnItm.none);

        $('#lhs').find('div.gMen1').css('background', '#fff');
        $('#lhs').find('div.gMen1').find('a.amen12').css('borderBottom', "1px solid #aaa");
        //Props we own...
        $('#lhs').find('div.gMen1').find('a.amen17').css('marginTop', 15);
        $('#lhs').find('div.gMen1').find('a.amen18').css('marginTop', 7);
        //target blank for map....
        $('#lhs').find('div.gMen3').find('a.amen35').attr('target', '_blank');

        try {
            //given branch location to the map...
            var urlmap = $('#lhs').find('div.gMen3').find('a.amen35').attr('href') + '';
            var urlmapAd = branch.split('#44;');
            var newpc = urlmapAd[urlmapAd.length - 1].split('&nbsp;')[0];
            if (newpc.length == 0) newpc = urlmapAd[urlmapAd.length - 1].split('&nbsp;')[1];
            if (newpc.length > 0)
                $('#lhs').find('div.gMen3').find('a.amen35').attr('href', urlmap.replace('?W1', '?' + newpc));
        } catch (e) {
            //alert(e.message);
        }
    }
    else {
        //Props we own...
        $('#lhs').find('div.gMen1').find('a.amen17').attr('style', MnItm.none);
        $('#lhs').find('div.gMen1').find('a.amen18').attr('style', MnItm.none);
        //MAP
        $('#lhs').find('div.gMen3').find('a.amen35').attr('style', MnItm.none);
    }
    if (cid != 95) {
        $('#lhs').find('div.gMen3').find('a.amen33').attr('style', MnItm.none);
    }

  }catch(eee){
	return;
}
    $('#lhs').find('a').mouseover(function(e) {
        UNI = $(this).attr('class').replace('amen', '').split('');
        if (MnItm.help[UNI[0]][UNI[1]].indexOf('!') > -1)
            $(this).parent().find('span.dsc').css('display', 'none').html('');
        else {
            $(this).parent().find('span.dsc'
	            ).css('opacity', 0
	            ).attr('name', 0
	            ).css('margin-top', -25 * (1 + parseInt(MnItm.help[UNI[0]][UNI[1]].length / 75) / 2)
	            ).css('display', 'none'
	            ).html(MnItm.help[UNI[0]][UNI[1]]
	            ).animate({ opacity: 1 }, 1000, function() {
	                if ($(this).attr('name') == 0)
	                    $(this).css('display', 'block'); //.attr('name',1);
	            });
        }
    }
    ).mouseout(
        function(e) {
            $(this).parent().find('span.dsc').attr('name', 2);
            $(this).parent().find('span.dsc'
            ).animate({ opacity: 0 }, 500, function() { $(this).css('display', 'none'); })
        }
    )
//admin == 0 && 
    //disabling menu items for user with ceratin Delivery types...
        if ((BranchDelType == 'H' || BranchDelType == 'N') && webaccess != '1') {
        //req
        $('#lhs').find('div.gMen1').find('a.amen11').attr('style', MnItm.zero).attr('href', '').attr('disabled', true);
        $('#lhs').find('div.gMen1').find('a.amen12').attr('style', MnItm.zero).attr('href', '').attr('disabled', true);
        //prop
        //email 2 ag
        $('#lhs').find('div.gMen2').find('a.amen21').attr('style', MnItm.zero).attr('href', '').attr('disabled', true);
        $('#lhs').find('div.gMen2').find('a.amen22').attr('style', MnItm.zero).attr('href', '').attr('disabled', true);
        $('#lhs').find('div.gMen2').find('a.amen23').attr('style', MnItm.zero).attr('href', '').attr('disabled', true);

        $('#lhs').find('div.gMen3').find('a.amen31').attr('style', MnItm.zero).attr('href', '').attr('disabled', true);
        $('#lhs').find('div.gMen3').find('a.amen32').attr('style', MnItm.zero).attr('href', '').attr('disabled', true); //-- Profile
        $('#lhs').find('div.gMen3').find('a.amen33').attr('style', MnItm.zero).attr('href', '').attr('disabled', true);
        $('#lhs').find('div.gMen3').find('a.amen34').attr('style', MnItm.zero).attr('href', '').attr('disabled', true);
        $('#lhs').find('div.gMen3').find('a.amen35').attr('style', MnItm.zero).attr('href', '').attr('disabled', true);
        $('#lhs').find('div.gMen3').find('a.amen36').attr('style', MnItm.zero).attr('href', '').attr('disabled', true);
        /*
        $('#lhs').find('div.gMen4').find('a.amen42').attr('style', MnItm.zero).attr('href','').attr('disabled',true); 
        $('#lhs').find('div.gMen4').find('a.amen43').attr('style',MnItm.zero).attr('href','').attr('disabled',true);
        $('#lhs').find('div.gMen4').find('a.amen44').attr('style',MnItm.zero).attr('href','').attr('disabled',true);
        $('#lhs').find('div.gMen4').find('a.amen45').attr('style',MnItm.zero).attr('href','').attr('disabled',true);
        $('#lhs').find('div.gMen4').find('a.amen46').attr('style',MnItm.zero).attr('href','').attr('disabled',true);	    
        */

    }
    if (admin > 0) {
        UNI = '<div class=dMn>';
        for (var g = 5; 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 == 5 ? '' : '</div><br>') + MnItm.htmTit.replace('NAMEID', g).replace('MENU', MnItm.items[g][0]) + '<div class=gMen' + g + '>';
                else {
                    if (g == MnItm.items.length - 1) {
                         UNI += MnItm.htm.replace('target', (aUni[1].indexOf('Form')>-1 || aUni[1].indexOf('ListNew.')>-1 ? '' : 'target=_blank')).replace('NAMEID', g + '' + i).replace('MENU', aUni[0]).replace('/HREF.aspx', aUni[1].replace('NDBC',nbdc));
                    }
                    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');
    })
    $('#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);
        }
    })
    $('#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&nbsp;REST</font></span><span name=countdown id=Countdown>40:00</span><br /> <font style="font-size:9px;color:black;">&nbsp;DEP Dept.,</font>&nbsp;<span  style="font-size:9px;color:black;">Branch</span> </p>';
var LatLong='';
var statusBarUrl = '<p >&nbsp;Login:&nbsp;<span style="color:#504030;color:red;"><b>NAME</b>, <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>40:00</span><br /> <font style="font-size:9px;color:black;">&nbsp;DEP Dept.,</font>&nbsp;<span  style="font-size:9px;color:black;">Branch</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, Branch, NegotiatorType, BranchDelType, webaccess,latlong) {
    if(latlong!=undefined)LatLong=latlong;
    MENUs(admin, code, cid, bid, did, nid, name, company, url, Mydepart, CoProps, Regcheck, Mysearch, Reqs, Props, msg, Branch, NegotiatorType, BranchDelType, webaccess);

}

function loadMenu(admin, code, cid, bid, did, nid, name, company, url, Mydepart, CoProps, Regcheck, Mysearch, Reqs, Props, Skins, Branch, NegotiatorType, BranchDelType,webaccess,latlong) {
    
    loadMenuMsg(admin, code, cid, bid, did, nid, name, company, url, Mydepart, CoProps, Regcheck, Mysearch, Reqs, Props, 0, Branch, NegotiatorType, BranchDelType, webaccess);
    if(latlong!=undefined)LatLong=latlong;
    try{
    var SKINS = Skins.split('!');
    if (SKINS[0].length > 0 && SKINS[0] != '0') {
        SKINS = SKINS[SKINS[0]].split('|');
        $('body').css('background', SKINS[1]).css('color', SKINS[2]).css('fontSize', SKINS[3]).css('fontFamily', SKINS[4]);
        if (SKINS[5] == 1) {
            $('#middle').css('left', '0px');
            $('#lhs').css('left', '563px');
            $('#rhs').css('left', '120px');
        }
    }
    }catch(e){}	
}
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 = 40, LIMIT = 5;   // set the minutes

function LogOut() { window.location = "http://www.each.co.uk/abu/Logout.aspx"; }

function prolong() {
    sec = 0; min = 40;
    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();
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) {
    //alert(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) {
}

function Ajax(divId, url) {
    var ajaxIndex = AjaxObjects.length;
    AjaxObjects[ajaxIndex] = new sack();
    AjaxObjects[ajaxIndex].requestFile = url;
    AjaxObjects[ajaxIndex].runAJAX();
}

function AjaxSave(dv, note)//,bid
{
    var ajaxIndex = AjaxObjects.length;
    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].runAJAX();
}

function ShowMsg(div) { }
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 open4prop() {
    window.open(get4PropServer_URL(), "4prop");
}

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(':', "x4x");
    _st = _st.replace('@', "050");

    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');
	   win = window.open('http://www.each.co.uk/abu/popup/LocationProfile.aspx?pc=' + _pc + '&st=' + _st + '&type=CentreEstateInfo&NID=' + _NID, '', '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 = window.open('http://www.each.co.uk/abu/popup/LocationProfile.aspx?pc=' + _pc + '&st=' + _st + '&type=streetinfo&NID=' + _NID, '', 'width=900,height=700,scrollbars=1,resizable=1');
    win.focus();
}


function getTownProfile(_town, _pc) {

    //alert(_town);
    // 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");
    _town = _town.replace('@', "040");
    //alert(_town);
    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 = window.open('http://www.each.co.uk/abu/popup/TownProfile.aspx?pc=' + _pc + '&tn=' + _town + '&NID=' + _NID, '', '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 --*/

var aMEs = new Array(), iEnquiryClose = 0, MEenq = '';
function MakeEnquiry(i, mails) {
    MEmails = mails;
    $('#ME' + i).html('<table class=Enq cellspacing=0 cellpadding=0 width=100%><tr><td>Your enquiry:</td><td align=right><a href="javascript:EnquiryClose3(' + i + ')">close</a></td></tr><tr><td colspan=2><textarea id=MEt' + i + ' rows=2 cols=75></textarea></td></tr><tr><td colspan=2><input style="background:#ffffff;color:navy;text-align:right;cursor;hand;" onclick="Enquiry(' + i + ');" type=button value=Send /></td></tr></table>');
    $('#ME' + i).attr('style', 'background:#ddeeff'); //;padding:2px;
    $('#ME0' + i).attr('style', 'display:none');

}
function Enquiry(i) {
    var tt = $('#MEt' + i).val().replace(new RegExp("\n", "gi"), "XYQ");
    var url = window.location + '';
    url = url.toLowerCase();
    $('#ME' + i).html('<center><b>I am sending your enquiry...</b></center>');
    iEnquiryClose = i;
    setTimeout(EnquiryClose, 1700);
    scLoad('http://www.each.co.uk/Alert/7E7F747E/95/75/430/' + $('#NIDc').val() + '/AjaxListings.aspx?Enq2=1&M=' + tt + '&Ids=' + i + '&TO=' + MEmails + '&Prop=' + (url.indexOf('property') > 0 ? 0 : 1));
}
function EnquiryClose() {
    $('#ME' + iEnquiryClose).html('&nbsp;Your enquiry was sent...');
    setTimeout(EnquiryClose2, 250);
}
function EnquiryClose2() {
    EnquiryClose3(iEnquiryClose);
}
function EnquiryClose3(i) {
    $('#ME' + i).html('');
    $('#ME' + i).attr('style', '');
    $('#ME0' + i).attr('style', 'display:block');
    window.location = window.location;
}

function scLoad(url) {
    script = document.createElement("script");
    script.setAttribute("src", url);
    script.setAttribute("type", "text/javascript");
    document.body.appendChild(script);
}



function waitSometime() {
    return "<table style='width:100%'><tr><td align='center'><img src='/images/common/wait.gif' /></td></tr> </table>";
}


 
