﻿//-------------frame
function CTIsPlayback() {
    try { return parent && parent.WebPlayer; }
    catch (e) { return false; }
}
if (!CTIsPlayback()) {
    if (window != top)
        top.location.href = location.href;
}


//--------------apartment_bar
function createSRnavigation(pageid, domainid, cityid, langid, search_phrase) {
    var url = '/Index.aspx?pageid={0}&domainid={1}&c={2}&l={3}';
    url = url.replace('{0}', pageid);
    url = url.replace('{1}', domainid);
    url = url.replace('{2}', cityid);
    url = url.replace('{3}', langid);

    var cookieParams = GetCookie('SearchData');
    cookieParams = cookieParams.replace('NOP', 'nop');
    cookieParams = cookieParams.replace('DateFrom', 'df');
    cookieParams = cookieParams.replace('DateTo', 'dt');
    url = url + '&' + cookieParams;

    if (document.cookie.indexOf('SearchData') != -1) {
        document.getElementById('navSearch').style.display = 'inline';
        document.getElementById('navSearch').children[0].href = url;
        document.getElementById('navSearch').children[0].innerHTML = search_phrase;
    }
    if (jQuery('ul#nav').length > 0) {
        var navLength = parseInt(document.getElementById('nav').offsetWidth);
        var iconsLength = parseInt(document.getElementById('content').offsetWidth);
        var bookingsLength = 815 - navLength - iconsLength;
        document.getElementById('latestBookings').style.width = bookingsLength + "px";
        jQuery('.scrollBox').css('width', bookingsLength - jQuery('.bookings')[0]['offsetWidth'] - jQuery('.desc>#nav_l').width() - jQuery('.desc>#nav_r').width() - 10);
    }
}

var movingMail = false;
var offXmail = 0;
var offYmail = 0;

function setMailWindowPos(e) {
    if (!movingMail) return;
    if (!e) e = window.event;

    var elem = document.getElementById('mailWindow');
    elem.style.left = e.clientX - offXmail + 'px';
    elem.style.top = e.clientY - offYmail + 'px';
}

function lockMailWindow(e) {
    var elem = document.getElementById('mailWindow');
    offXmail = e.clientX - elem.offsetLeft;
    offYmail = e.clientY - elem.offsetTop;

    movingMail = true;
    document.onmousemove = setMailWindowPos;
    document.onmouseup = unlockMailWindow;
}

function unlockMailWindow() {
    movingMail = false;
    document.onmousemove = null;
    document.onmouseup = null;
}

function buildMailWindow(langID) {
    var posx = 300;
    var posy = 100;
    var elem = document.getElementById('mailWindow');
    elem.style.display = 'block';
    elem.style.left = posx + 'px';
    elem.style.top = posy + 'px';

    window.frames["mailFrame"].location = 'http://www.apartmentsapart.com/IndexFrame.aspx?pageid=5892&domainid=1&own=1&l=' + langID;
    if (window.opera)
        document.getElementById("mailFrame").height = '278px';

}
//-----------
function hideMailWindow() {
    document.getElementById('mailWindow').style.display = 'none';
    window.frames["mailFrame"].location = 'about:blank';
}

function printUs() {
    if (navigator.appName == 'Microsoft Internet Explorer' && !window.XMLHttpRequest) {
        window.print();
        return false;
    }
    else {
        window.print();
        return true;
    }
}
function bookmarkUs() {
    if (window.sidebar) // firefox
        window.sidebar.addPanel(document.title, document.URL, "");
    else if (document.all)// ie
        window.external.AddFavorite(document.URL, document.title);
}
function saveAsPage() {
    document.execCommand('SaveAs');
}
function showButtons() {
    if (window.sidebar) {
        document.getElementById('bookmark').style.display = 'block';
    }
    if (window.opera) {
        document.getElementById('print').style.display = 'block';
        document.getElementById('mail').style.display = 'block';
    }
    if (navigator.appName == 'Microsoft Internet Explorer') {
        document.getElementById('bookmark').style.display = 'block';
        document.getElementById('save').style.display = 'block';
    }
}
//-----------
function buildSummaryWindow() {
    document.getElementById('mailWindowContent').style.display = 'none';
    document.getElementById('mailWindowSummary').style.display = 'block';
}

function ValidBarForm() {
    var error = false;

    document.MailFriendBoxForm.fromName.value = document.MailFriendBoxForm.fromName.value.replace(/[<]/g, '').replace(/[>]/g, '');
    document.MailFriendBoxForm.fromEmail.value = document.MailFriendBoxForm.fromEmail.value.replace(/[<]/g, '').replace(/[>]/g, '');
    document.MailFriendBoxForm.toEmail.value = document.MailFriendBoxForm.toEmail.value.replace(/[<]/g, '').replace(/[>]/g, '');
    document.MailFriendBoxForm.subject.value = document.MailFriendBoxForm.subject.value.replace(/[<]/g, '').replace(/[>]/g, '');
    document.MailFriendBoxForm.msg.value = document.MailFriendBoxForm.msg.value.replace(/[<]/g, '').replace(/[>]/g, '');

    if (document.MailFriendBoxForm.fromName.value == "") {
        document.getElementById('validName').style.display = 'block';
        error = true;
    }
    emailRegex = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if (!emailRegex.test(document.MailFriendBoxForm.fromEmail.value)) {
        document.getElementById('validEmail1').style.display = 'block';
        error = true;
    }
    if (!emailRegex.test(document.MailFriendBoxForm.toEmail.value)) {
        document.getElementById('validEmail2').style.display = 'block';
        error = true;
    }
    if (document.MailFriendBoxForm.subject.value == "") {
        document.getElementById('validSubject').style.display = 'block';
        error = true;
    }
    if (document.MailFriendBoxForm.msg.value == "") {
        document.getElementById('validMsg').style.display = 'block';
        error = true;
    }
    document.getElementById('mtfurl').value = parent.window.location.toString();

    if (error)
        return false;
    return true;
}
//-----------QuickRes2a
function CheckQuickRes(form) {

    var resultOK = true;
    if (form.ContactMeName.value == "") {
        returnObjById('ContactMeNameReq').style.visibility = 'visible';
        form.ContactMeName.focus();

        return false;
    }
    else if (form.ContactMeName.value != "") {
        returnObjById('ContactMeNameReq').style.visibility = 'hidden';
    }

    var reg = /\d{5}\d*/;

    if (!reg.test(form.ContactMePhone.value) && resultOK == true) {

        returnObjById('ContactMePhoneReq').style.visibility = 'visible';
        form.ContactMePhone.focus();
        return false;
    }
    else if (reg.test(form.ContactMePhone.value)) {
        returnObjById('ContactMePhoneReq').style.visibility = 'hidden';
    }

    var reEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

    if (!reEmail.test(form.ContactMeEmail.value) && resultOK == true) {
        returnObjById('ContactMeEmailReq').style.visibility = 'visible';
        form.ContactMeEmail.focus();
        return false;
    }
    else if (reEmail.test(form.ContactMeEmail.value)) {
        returnObjById('ContactMeEmailReq').style.visibility = 'hidden';
    }

    if (form.ContactMeCountry.value == "" && resultOK == true) {
        returnObjById('ContactMeCountryReq').style.visibility = 'visible';
        form.ContactMeCountry.focus();
        //resultOK = false;
        return false;
    }
    else if (form.ContactMeCountry.value != "") {
        if (returnObjById('ContactMeCountryeReq') != null)
            returnObjById('ContactMeCountryeReq').style.visibility = 'hidden';
    }

    return true;
}

function OnlyDecimal(e) {
    var key;
    var keychar;
    var reg;

    if (window.event) {
        // for IE, e.keyCode or window.event.keyCode can be used
        key = e.keyCode;
    }
    else if (e.which) {
        // netscape
        key = e.which;
    }
    else {
        // no event, so pass through
        return true;
    }

    if (key == 8) return true; // backspace

    keychar = String.fromCharCode(key);
    reg = /\d/;
    return reg.test(keychar);
}

function returnObjById(id) {
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function clock() {
    if (hours < 10 && new String(hours).length < 2) hours = "0" + hours;
    if (minutes < 10 && new String(minutes).length < 2) minutes = "0" + minutes;
    if (seconds < 10) seconds = "0" + seconds;

    //var time = hours + ":" + minutes + ":" + seconds +" CET";
    var time = hours + ":" + minutes + " CET";

    document.getElementById("clock").innerHTML = time;

    if (++minutes >= 60) {
        minutes = 0;
        hours++;
    }

    if (hours >= 24)
        hours = 0;

    setTimeout("clock()", 60000);
}
//-----------Menu
function Size(id) {
    var menu = mint.$(id);
    if (menu.style.display == '' || menu.style.display == 'block') {
        menu.style.display = 'none';
        mint.$(id + '_c').style.display = 'none';
        mint.$(id + '_e').style.display = 'block'

        SetSetting(id, "0");
    } else {
        menu.style.display = 'block';
        mint.$(id + '_c').style.display = 'block';
        mint.$(id + '_e').style.display = 'none';
        SetSetting(id, "1");
    }
}
function GetDispayStyle(id) {
    var menu = mint.$(id);
    ReadCookieSetting('Menu');
    if (GetSettings(id) == '1') {
        menu.style.display = 'block';
        mint.$(id + '_c').style.display = 'block';
        mint.$(id + '_e').style.display = 'none';
    } else {
        menu.style.display = 'none';
        mint.$(id + '_c').style.display = 'none';
        mint.$(id + '_e').style.display = 'block';
    }

}

/*var links = menu.getElementsByTagName('a');
var hide=true;
var toLongPhrase=0;

for(var i=0; i<links.length; i++)
{

var height = GetHeight(links[0])+1;
if(GetOpacity(links[i])=='100')
{
hide = true;	
mint.fx.Fade(links[i], 0, 20, 500);
links[i].style.display='none';
		
}else
{
hide = false;
if(links[i].innerHTML.length>32)
toLongPhrase++;

mint.fx.Fade(links[i], 100, 20, 500);
links[i].style.display='block';
    


}
}
if(!hide)
{
toLongPhrase = toLongPhrase*height;
mint.fx.Size(id, null, links.length*height+toLongPhrase, 20, 500);
		
}else
{
      
mint.fx.Size(id, null, 0, 20, 500);
}
switch(id)
{
case 'ddMenu4':
if(hide)        
apartmentsapart.Modules.Menu4.SetSetting("0");
else        
apartmentsapart.Modules.Menu4.SetSetting("1");
        
break;
case 'ddMenuShort':
if(hide)        
apartmentsapart.Modules.MenuShort.SetSetting("0");
else        
apartmentsapart.Modules.MenuShort.SetSetting("1");
break;
}
//SaveMenu(id);
*/


function GetIndex(id) {
    var index;
    switch (id) {
        case 'search3Content':
            index = 0;
            break;
        case 'ddMenu4':
            index = 1;
            break;
        case 'ddMenuShort':
            index = 2;
            break;
    }
    return index;
}

function GetSettings(id) {
    try {
        var index = GetIndex(id);
        return readCookie('Menu').substring(index, index + 1);
    } catch (err) {
        return '';
    }
}
function ReadCookieSetting(cookieID) {
    var tmp = readCookie('Menu');
    if (tmp == null || tmp.substring(0, 1) == null || tmp.substring(1, 2) == null || tmp.substring(2, 3) == null) //IE fix
    {
        tmp = '110';
        createCookie('Menu', tmp, 1);
    }

    return tmp;
}
function SetSetting(id, value) {
    var tmp = ReadCookieSetting('Menu');

    if (GetIndex(id) == 0)
        tmp = value + tmp.substring(1, 3);
    else if (GetIndex(id) == 1)
        tmp = tmp.substring(0, 1) + value + tmp.substring(2, 3);
    else if (GetIndex(id) == 2)
        tmp = tmp.substring(0, 2) + value;
    else
        tmp = '110';

    createCookie('Menu', tmp, 1);
}

function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}
//--------------ApartmentDetailsNavigation
var newHtml;
function saveCurrent(nr, listID, link) {
    window.location = apartmentsapart.Modules.ApartmentDetailsNavigation.saveCurrentListNr(nr, listID, link).value;
    
    /*var req = mint.Request();
    req.OnSuccess = function() {
    newHtml = this.responseText;       
    newHtml = newHtml.replace(/"controls"/gi, "\"controls\" style=\"opacity:0\"");
    }
    req.Send(url);
    var group = mint.fx.Group(null, 20, 500);
    group.Add("controls", "opacity", null, 0);
    group.OnDone = function(group){
    document.body.innerHTML=newHtml; 
    mint.fx.Fade("controls", 100, 20, 500);  
    }
 
 group.Run();*/
}
function show() {
    document.getElementById('ApartmentDetailsNavigation').style.display = 'block';
}
function ColorIn(obj) {
    mint.fx.Color(obj, "backgroundColor", null, "975821", 20, 500);
    mint.fx.Color(obj, "borderColor", null, "975821", 20, 500);

}

function ColorOut(obj) {
    mint.fx.Color(obj, "backgroundColor", null, "4a5889", 20, 500);
    mint.fx.Color(obj, "borderColor", null, "4a5889", 20, 500);
}

function setNavigationMarginTop() {
    var margintop;
    if(screen.availHeight >= 800)
        margintop = (screen.availHeight / 2)-310;
    else
        margintop = 100;
    document.getElementById('left_but').style.marginTop = (margintop+13).toString() + "px";
    document.getElementById('right_but').style.marginTop = margintop + "px";
}
function navigationOver(direction,phrase) {
    switch (direction) {
        case 'left':
            document.getElementById('left_but').style.background = 'url("http://cachefly.apartmentsapart.com/aa/img_modules/aptarrows.gif") no-repeat scroll -46px 0 transparent';
            break;
        case 'right':
            document.getElementById('right_but').style.background = 'url("http://cachefly.apartmentsapart.com/aa/img_modules/aptarrows.gif") no-repeat scroll -137px 0 transparent';
            break;
    }
    if(typeof phrase != "undefined")
        ShowToolTip(phrase,'KeyboardEvent');
}
function navigationOut(direction) {
    switch (direction) {
        case 'left':
            document.getElementById('left_but').style.background = 'url("http://cachefly.apartmentsapart.com/aa/img_modules/aptarrows.gif") no-repeat scroll 0px 0 transparent';
            break;
        case 'right':
            document.getElementById('right_but').style.background = 'url("http://cachefly.apartmentsapart.com/aa/img_modules/aptarrows.gif") no-repeat scroll -91px 0 transparent';
            break;
    }
    HideToolTip();
}
//---------------ratingswindow
function showWindow(e, url) {
    if (!e) e = window.event;

    var posx = 0;
    var posy = 0;

    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('ratingsWindow');

    posx -= elem.offsetWidth;

    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;
    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;

    elem.style.visibility = 'visible';
    elem.style.left = posx + 'px';
    elem.style.top = posy + 'px';
    elem.style.width = 337 + 'px';
    elem.style.height = 400 + 'px';
    elem.style.borderBottomStyle = "solid";
    elem.style.borderBottomWidth = "1px";

    window.frames["ifRatings"].location = url;
    document.getElementById("ifRatings").scrolling = 'auto';
    document.getElementById("ifRatings").width = "337";
    document.getElementById("ifRatings").height = "385";

    if (document.getElementById("bing") != undefined)
        document.getElementById("bing").style.display = 'none';
}

function showHiddenApartmentsWindow(e, url, wth, hth) {
    if (!e) e = window.event;

    var posx = 0;
    var posy = 0;
    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('ratingsWindow');

    posx -= elem.offsetWidth;
    //posy -= elem.offsetHeight;

    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;
    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;

    elem.style.visibility = 'visible';
    elem.style.left = posx + 'px';
    elem.style.top = posy + 'px';

    elem.style.width = wth + 'px';
    elem.style.height = 15 + parseInt(hth) + 'px';
    elem.style.borderBottomStyle = "solid";
    elem.style.borderBottomWidth = "1px";

    window.frames["ifRatings"].location = url;
    document.getElementById("ifRatings").style.background = '#EFF4FA';
    document.getElementById("ifRatings").scrolling = 'no';
    document.getElementById("ifRatings").width = parseInt(wth);
    document.getElementById("ifRatings").height = parseInt(hth);

    if (document.getElementById("bing") != undefined)
        document.getElementById("bing").style.display = 'none';
}

function showPriceWindow(e, url) {
    if (!e) e = window.event;

    var posx = 0;
    var posy = 0;

    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('ratingsWindow');

    posx -= elem.offsetWidth;
    posy -= elem.offsetHeight;

    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;
    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;

    elem.style.visibility = 'visible';
    elem.style.left = posx + 'px';
    elem.style.top = posy + 'px';
    elem.style.width = 435 + 'px';
    elem.style.height = 400 + 'px';
    elem.style.borderBottomStyle = "double";
    elem.style.borderBottomWidth = "8px";

    window.frames["ifRatings"].location = url;

    document.getElementById("ifRatings").width = "435";
    document.getElementById("ifRatings").height = "385";

    if (document.getElementById("bing") != undefined)
        document.getElementById("bing").style.display = 'none';
}

function showServiceWindow(e, url) {
    if (!e) e = window.event;

    var posx = 0;
    var posy = 0;

    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('ratingsWindow');

    posy -= elem.offsetHeight / 2;

    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;
    //if(posy + elem.offsetHeight > document.body.offsetHeight)
    //	posy = document.body.offsetHeight - elem.offsetHeight;

    elem.style.visibility = 'visible';
    elem.style.left = posx + 'px';
    elem.style.top = posy + 'px';
    elem.style.width = 510 + 'px';
    elem.style.height = 245 + 'px';
    elem.style.borderBottomStyle = "solid";
    elem.style.borderBottomWidth = "1px";

    window.frames["ifRatings"].location = url;

    document.getElementById("ifRatings").width = "510";
    document.getElementById("ifRatings").height = "230";

    if (document.getElementById("bing") != undefined)
        document.getElementById("bing").style.display = 'none';    
}

function showBookingWindow(e, url) {
    if (!e) e = window.event;

    var posx = 0;
    var posy = 0;

    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('ratingsWindow');

    posy -= elem.offsetHeight / 2;
    posx -= elem.offsetWidth;

    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;
    //if(posy + elem.offsetHeight > document.body.offsetHeight)
    //	posy = document.body.offsetHeight - elem.offsetHeight;

    elem.style.visibility = 'visible';
    elem.style.left = posx + 'px';
    elem.style.top = posy + 'px';
    elem.style.width = 510 + 'px';
    elem.style.height = 245 + 'px';
    elem.style.borderBottomStyle = "solid";
    elem.style.borderBottomWidth = "1px";

    window.frames["ifRatings"].location = url;

    document.getElementById("ifRatings").width = "510";
    document.getElementById("ifRatings").height = "230";

    if (document.getElementById("bing") != undefined)
        document.getElementById("bing").style.display = 'none';
}

function showGWindow(e, url, wth, hth) {
    if (!e) e = window.event;

    var posx = 0;
    var posy = 0;
    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('ratingsWindow');

    posx -= elem.offsetWidth;
    //posy -= elem.offsetHeight;

    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;
    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;

    elem.style.visibility = 'visible';
    elem.style.left = posx + 'px';
    elem.style.top = posy + 'px';

    elem.style.width = wth + 'px';
    elem.style.height = 15 + parseInt(hth) + 'px';
    elem.style.borderBottomStyle = "solid";
    elem.style.borderBottomWidth = "1px";

    window.frames["ifRatings"].location = url;
    document.getElementById("ifRatings").width = parseInt(wth);
    document.getElementById("ifRatings").height = parseInt(hth);
    
    if(document.getElementById("bing") != undefined)
        document.getElementById("bing").style.display = 'none';
}
var distMarkers = 0;
function showGWindowOnList(e, url, wth, hth, bing) {

    // functions from interactivemap.js
    if (typeof (im_ApartmentsOnMap) == 'undefined' || im_ApartmentsOnMap == null) {
        if (!e) e = window.event;

        var posx = 0;
        var posy = 0;
        if (e.pageX || e.pageY) {
            posx = e.pageX;
            posy = e.pageY;
        }
        else if (e.clientX || e.clientY) {
            posx = e.clientX + document.body.scrollLeft
		+ document.documentElement.scrollLeft;
            posy = e.clientY + document.body.scrollTop
		+ document.documentElement.scrollTop;
        }

        var elem = document.getElementById('ratingsWindow');

        posx -= elem.offsetWidth;
        //posy -= elem.offsetHeight;

        if (posx + elem.offsetWidth > document.body.offsetWidth)
            posx = document.body.offsetWidth - elem.offsetWidth;
        if (posy + elem.offsetHeight > document.body.offsetHeight)
            posy = document.body.offsetHeight - elem.offsetHeight;

        elem.style.visibility = 'visible';
        elem.style.left = posx + 'px';
        elem.style.top = posy + 'px';

        elem.style.width = wth + 'px';
        elem.style.height = 15 + parseInt(hth) + 'px';
        elem.style.borderBottomStyle = "solid";
        elem.style.borderBottomWidth = "1px";

        document.getElementById("bing").style.display = 'block';
        document.getElementById("bing").children[0].href = "javascript:MapWindow('" + bing + "')";

        window.frames["ifRatings"].location = url;
        document.getElementById("ifRatings").width = parseInt(wth);
        document.getElementById("ifRatings").height = parseInt(hth);         
    }
    else if (im_ApartmentsOnMap != null) {
        try {
            var start = url.toString().indexOf("apts=", 0) + 5;
            var end = url.toString().indexOf("&c=", start);
            var aptid = url.toString().slice(start, end);

            if (MapEngine == null)
                im_Start();
            MapEngine.ShowMap(e, aptid);
            
            
            if (typeof(distancesASCX) != 'undefined') {
                if (distMarkers % 2 == 0) {
                    MapEngine.GetAndOrganizeMapObjects();
                    MapEngine.CreateMapObjectIcons(MO_Icons);

                    var a = new Object();
                    a.checked = true;
                    for (var type in MapEngine.MapObjects) {
                        MapEngine.MarkersCat(type, a);
                    }
                }
                else {
                    MapEngine.GetAndOrganizeMapObjects();

                    var a = new Object();
                    a.checked = false;
                    for (var type in MapEngine.MapObjects) {
                        MapEngine.MarkersCat(type, a);
                    }
                    if (MapEngine.MapObjects[1] != null) {
                        a.checked = true;
                        MapEngine.MarkersCat(1, a);
                    }
                }
            }

            distMarkers++;

            e.returnValue = false;
            return false;
        } catch (excia) { }
    }
}

function showPricePromiseWindow(e, url) {
    if (!e) e = window.event;

    var wth = '735';
    var hth = '500';

    if (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1 && window.XMLHttpRequest) {
        wth = '745';
        hth = '535';
    }

    var posx = 0;
    var posy = 0;
    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('ratingsWindow');

    posx -= elem.offsetWidth;
    //posy -= elem.offsetHeight;

    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;
    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;

    elem.style.visibility = 'visible';
    elem.style.left = '400px';
    elem.style.top = posy + 'px';

    elem.style.width = wth + 'px';
    elem.style.height = 15 + parseInt(hth) + 'px';
    elem.style.borderBottomStyle = "solid";
    elem.style.borderBottomWidth = "1px";

    window.frames["ifRatings"].location = url;
    document.getElementById("ifRatings").scrolling = 'no';
    document.getElementById("ifRatings").width = parseInt(wth);
    document.getElementById("ifRatings").height = parseInt(hth);
    // AddEvent(window.document, 'click', hideWindow);
    if (document.getElementById("bing") != undefined)
        document.getElementById("bing").style.display = 'none';
}
function showCrazyOfferWindow(e, url) {
    if (!e) e = window.event;

    var wth = '735';
    var hth = '420';

    if (navigator.userAgent.toLowerCase().indexOf('msie 8') > -1) {
        wth = '755';
        hth = '440';
    }
    else if (navigator.userAgent.toLowerCase().indexOf('msie') > -1) {
        wth = '765';
        hth = '480';
    }
    
    var posx = 0;
    var posy = 0;
    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('ratingsWindow');

    posx -= elem.offsetWidth;
    //posy -= elem.offsetHeight;

    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;
    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;

    elem.style.visibility = 'visible';
    elem.style.left = '400px';
    elem.style.top = posy + 'px';

    elem.style.width = wth + 'px';
    elem.style.height = 15 + parseInt(hth) + 'px';
    elem.style.borderBottomStyle = "solid";
    elem.style.borderBottomWidth = "1px";

    window.frames["ifRatings"].location = url;
    document.getElementById("ifRatings").scrolling = 'no';
    document.getElementById("ifRatings").width = parseInt(wth);
    document.getElementById("ifRatings").height = parseInt(hth);
    // AddEvent(window.document, 'click', hideWindow);
    if (document.getElementById("bing") != undefined)
        document.getElementById("bing").style.display = 'none';
}
function showGRWindow(e, url, wth, hth) {
    if (!e) e = window.event;

    var posx = 0;
    var posy = 0;
    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('ratingsWindow');

    //  posx -= elem.offsetWidth;
    //posy -= elem.offsetHeight;

    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;
    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;


    elem.style.visibility = 'visible';
    elem.style.left = posx + 'px';
    elem.style.top = posy + 'px';


    elem.style.width = wth + 'px';
    elem.style.height = 15 + parseInt(hth) + 'px';
    elem.style.borderBottomStyle = "solid";
    elem.style.borderBottomWidth = "1px";

    window.frames["ifRatings"].location = url;
    document.getElementById("ifRatings").scrolling = 'yes';
    document.getElementById("ifRatings").width = parseInt(wth);
    document.getElementById("ifRatings").height = parseInt(hth);

    if (document.getElementById("bing") != undefined)
        document.getElementById("bing").style.display = 'none';    
}

function showSVWindow(e, url, wth, hth) {
    if (!e) e = window.event;

    var posx = 0;
    var posy = 0;
    if (e.pageX || e.pageY) {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('ratingsWindow');

    posx -= elem.offsetWidth;
    //posy -= elem.offsetHeight;

    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;
    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;

    elem.style.visibility = 'visible';
    elem.style.left = posx + 'px';
    elem.style.top = posy + 'px';

    elem.style.width = wth + 'px';
    elem.style.height = 15 + parseInt(hth) + 'px';
    elem.style.borderBottomStyle = "solid";
    elem.style.borderBottomWidth = "1px";

    window.frames["ifRatings"].location = url;
    document.getElementById("ifRatings").width = parseInt(wth);
    document.getElementById("ifRatings").height = 20 + parseInt(hth);

    if (document.getElementById("bing") != undefined)
        document.getElementById("bing").style.display = 'none';    
}

function hideWindow() {

    document.getElementById('ratingsWindow').style.visibility = 'hidden';
    window.frames["ifRatings"].location = 'about:blank';
    try {
        // RemoveEvent(window.document, 'click', hideWindow);
    } catch (err1) { }

}

var moving = false;
var offX = 0;
var offY = 0;

function setWindowPos(e) {
    if (!moving) return;
    if (!e) e = window.event;

    var elem = document.getElementById('ratingsWindow');
    elem.style.left = e.clientX - offX + 'px';
    elem.style.top = e.clientY - offY + 'px';
}

function lockWindow(e) {
    var elem = document.getElementById('ratingsWindow');
    offX = e.clientX - elem.offsetLeft;
    offY = e.clientY - elem.offsetTop;

    moving = true;
    document.onmousemove = setWindowPos;
    document.onmouseup = unlockWindow;
}

function unlockWindow() {
    moving = false;
    document.onmousemove = null;
    document.onmouseup = null;
}

function MapWindow(mypage) {
    var win = null;
    var w = 800;
    var h = 600;
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    myname = "MAP";

    settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=no, resizable=yes';
    win = window.open('', myname, settings);
    win.location.href = mypage;
    //win.onload = sc;
    //window.scrollTo(0,500);
}

function FitWindow(mypage) {
    myname = "MAP";

    settings = 'height=' + screen.height + ',width=' + screen.width + ',scrollbars=no, resizable=yes';
    win = window.open('', myname, settings);
    mypage = mypage.toString().replace('mapwidth=0', 'mapwidth='+ screen.width);
    mypage = mypage.toString().replace('mapheight=0', 'mapheight='+ screen.height);
    win.location.href = mypage;
}

function FullScreenWindow(event, mypage) {
    // functions from interactivemap.js
    try {
        var start = mypage.toString().indexOf("apts=", 0) + 5;
        var end = mypage.toString().indexOf("&c=", start);
        var aptid = mypage.toString().slice(start, end);

        MapEngine.IsFullScreen = true;
        MapEngine.ShowMap(null, aptid);

        im_FullScreen();

        for (var type in MapEngine.MapObjects) {
            var a = new Object();
            a.checked = true;
            MapEngine.MarkersCat(type, a);
        }

        event.returnValue = false;
        return false;
    } catch (excia) { }
}

function NewWindow(mypage, w, h, myname, scroll) {
    var win = null;
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;

    settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable=no';

    win = window.open(mypage, myname, settings).focus();
}
//------------------splashscreen
var isIE6 = (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) && (navigator.userAgent.toLowerCase().indexOf('msie 7') == -1);
var isIE = window.addEventListener ? false : true;
try {
    AddEvent(window.document, 'click', HideSplash);
} catch (err1) { }
function HideSplash() {
    try {
        mint.$('modSplashScreen').style.display = 'none';
        RemoveEvent(window.document, 'click', HideSplash);
        if (isIE6) {
            IE6SelectFix('visible');
        }
    } catch (err1) { }
}
function SplashScreen() {
    var userAgent = navigator.userAgent.toLowerCase();
    if ((userAgent.search("blackberry") > -1 || userAgent.search("mobile") > -1 ||
       userAgent.search("windows ce") > -1 || userAgent.search("opera mini") > -1 || userAgent.search("palm") > -1) ||
       userAgent.search("avantgo") > -1 || userAgent.search("docomo") > -1 || userAgent.search("vodafone") > -1 ||
       userAgent.search("netfront") > -1 || userAgent.search("midp") > -1 ||
       userAgent.search("symbian") > -1) {
        return; // mobile version
    }
    var marginLeft = 0;
    var splashscreen = mint.$('modSplashScreen');
    if (isIE6) {
        IE6SelectFix('hidden');
    }
    if (isIE) {
        marginLeft = document.body.clientWidth - 660;
    }
    else {
        marginLeft = window.outerWidth - 660;
    }

    splashscreen.style.left = marginLeft / 2 + 'px';

    var wheight = GetWindowHeight();
    var marginTop = wheight - 275;
    if (marginTop > 0) {
        splashscreen.style.top = marginTop / 2 + 'px';
    } else {
        splashscreen.style.top = '30px';
    }
    splashscreen.style.display = 'block';
}
function GetWindowHeight() {
    var windowHeight = 0;
    if (self.innerHeight) {	// all except Explorer
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowHeight = document.body.clientHeight;
    }
    return windowHeight;
}
function IE6SelectFix(newState) {

    var elements = document.documentElement.getElementsByTagName('select');

    for (var i = 0; i < elements.length; i++) {
        elements[i].style.visibility = newState;
    }
}
//autoscrolling ajaxapartmentlist
function Scroller(len, width, height, version, name) {
    this.lenCounter = len;
    this.scrollerwidth = width;
    this.scrollerheight = height;
    this.tab = new Array();
    this.scrollerspeed = 1;
    this.lefttime = 0;
    this.ifmove = 0;
    this.pauseit = 1;
    this.copyspeed = 0;
    this.iedom = document.all || document.getElementById;
    this.actualSize = '';
    this.cross_scroller;
    this.ns_scroller;
    this.pausespeed = (this.pauseit == 0) ? this.copyspeed : 0;
    this.VersionScroller = version;
    this.name = name;

    this.runSpeed = function(speed, scrollname, idd) {
        if (this.tab[scrollname + idd] == undefined)
            this.tab[scrollname + idd] = 0;
        this.copyspeed = speed;
        if (this.copyspeed == this.scrollerspeed) {
            this.populate(scrollname, idd);
        }
        else {
            clearInterval(this.lefttime);
        }
    }

    this.populate = function(scrollname, id) {
        var scrollercontent = document.getElementById(scrollname + id).innerHTML;
        if (this.iedom) {
            this.cross_scroller = document.getElementById ? document.getElementById(scrollname + id) : document.all.iescroller
            if (this.VersionScroller == 1) {
                if (this.tab[scrollname + id] == 0) this.cross_scroller.style.top = "0px"
                this.actualSize = this.cross_scroller.offsetHeight;
            }
            else if (this.VersionScroller == 2) {
                if (this.tab[scrollname + id] == 0) this.cross_scroller.style.left = "0px"
                this.actualSize = this.cross_scroller.offsetWidth;
            }
        }
        else if (document.layers) {
            this.ns_scroller = document.ns_scroller.document.ns_scroller2
            if (this.VersionScroller == 1) {
                if (this.tab[scrollname + id] == 0) this.ns_scroller.top = "0px"
            }
            else if (this.VersionScroller == 2) {
                if (this.tab[scrollname + id] == 0) this.ns_scroller.left = "0px"
            }
            this.ns_scroller.document.write(scrollercontent)
            this.ns_scroller.document.close()
            if (this.VersionScroller == 1) {
                this.actualSize = this.ns_scroller.document.height;
            }
            else if (this.VersionScroller == 2) {
                this.actualSize = this.ns_scroller.document.width;
            }
        }
        this.tab[scrollname + id] = this.tab[scrollname + id] + 1;

        this.lefttime = setInterval(this.name + ".scrollscroller()", 40);      
    }

    this.scrollscroller = function() {
        if (this.cross_scroller != undefined && this.copyspeed == this.scrollerspeed) {
            if (this.iedom) {
                if (this.VersionScroller == 1) {
                    if (parseInt(this.cross_scroller.style.top) > (this.actualSize * (-1 * this.lenCounter) + 8))
                        this.cross_scroller.style.top = parseInt(this.cross_scroller.style.top) - this.copyspeed + "px"
                    else
                        this.cross_scroller.style.top = this.scrollerheight;
                }
                else if (this.VersionScroller == 2) {
                    if (parseInt(this.cross_scroller.style.left) > (this.actualSize * (-1 * (this.lenCounter/70)) + 8))
                        this.cross_scroller.style.left = parseInt(this.cross_scroller.style.left) - this.copyspeed + "px"
                    else
                        this.cross_scroller.style.left = this.scrollerwidth;
                }
            }
            else if (document.layers) {
                if (this.VersionScroller == 1) {
                    if (this.ns_scroller.top > (this.actualSize * (-1 * this.lenCounter) + 8))
                        this.ns_scroller.top -= this.copyspeed
                    else
                        this.ns_scroller.top = this.scrollerheight;
                }
                else if (this.VersionScroller == 2) {
                    if (this.ns_scroller.left > (this.actualSize * (-1 * (this.lenCounter/70)) + 8))
                        this.ns_scroller.left -= this.copyspeed
                    else
                        this.ns_scroller.left = this.scrollerwidth;
                }
            }
        }
    }
}




function _467_hideElem(id, source) {
    var catcont = document.getElementById(id);
    var catheader = document.getElementById(id.replace('cont', ''));
    if (catcont.style.display == 'none' || catcont.style.display == '') {
        catcont.style.display = 'block';
    } else {
        catcont.style.display = 'none';
    }
}
function _467_backgroundChange(id, type) {
    if (type == 'over')
        document.getElementById(id).style.background = '#EEF3F8';
    else if (type == 'out')
        document.getElementById(id).style.background = '#DDE7F1';
}
//----------------------------- banners.ascx
function showBannerWindow(e) {
    var elem = document.getElementById('virtualConcierge');
    elem.style.display = 'block';
    var posy = 0;
    if (e.pageX || e.pageY) {
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;    
    
    elem.style.top = posy + "px"

}
var movingConc = false;
var offXconc = 0;
var offYconc = 0;

function setVirtualConciergePos(e) {
    if (!movingConc) return;
    if (!e) e = window.event;

    var elem = document.getElementById('virtualConcierge');
    elem.style.left = e.clientX - offXconc + 'px';
    elem.style.top = e.clientY - offYconc + 'px';
}

function lockVirtualConcierge(e) {
    var elem = document.getElementById('virtualConcierge');
    offXconc = e.clientX - elem.offsetLeft;
    offYconc = e.clientY - elem.offsetTop;

    movingConc = true;
    document.onmousemove = setVirtualConciergePos;
    document.onmouseup = unlockVirtualConcierge;
}

function unlockVirtualConcierge() {
    movingConc = false;
    document.onmousemove = null;
    document.onmouseup = null;
}
//---------------------------------------keyboard list paging
function keyboardPaging() {
    AddEvent(window, 'load', function() {
        AddEvent(document, 'keydown', function(e) {
            if (!e) e = window.event;
            var keyCode = e.keyCode;
            switch (keyCode) {
                case 37:
                    getPage(als.currentPage - 1);
                    break;

                case 39:
                    getPage(als.currentPage + 1); 
                    break;
            }
        });
    });
}
//------------------------------------customer surveys results
var movingSurvey = false;
var movingU = false;

var offXsur = 0;
var offYsur = 0;

var offXU = 0;
var offYU = 0;

var movingElem = '';

function setSurveyWindowPos(e) {
    if (!movingSurvey) return;
    if (!e) e = window.event;

    var elem = document.getElementById('surveyResults');
    elem.style.left = e.clientX - offXsur + 'px';

    elem.style.top = e.clientY - offYsur + 'px';
}
function setWindowPosU(e) {
    if (!movingU) return;
    if (!e) e = window.event;
    var elem = document.getElementById(movingElem);
    elem.style.left = e.clientX - offXU + 'px';
    elem.style.top = e.clientY - offYU + 'px';    
}
function lockWindowU(e, elemID) {
    movingElem = elemID;
    var elem = document.getElementById(movingElem);   
    offXU = e.clientX - elem.offsetLeft;
    offYU = e.clientY - elem.offsetTop;


    movingU = true;
    document.onmousemove = setWindowPosU;
    document.onmouseup = unlockWindowU;
}
function adddebuguinfo() {
    document.write('<div id="debuginfo" style="display:block; position:absolute;left:0px;top:800px; color:red;border:2px solid red; color:red; font-size:10pt;">&nbsp;</div>');

}
function lockSurveyWindow(e) {
    var elem = document.getElementById('surveyResults');
    offXsur = e.clientX - elem.offsetLeft;
    offYsur = e.clientY - elem.offsetTop;


    movingSurvey = true;
    document.onmousemove = setSurveyWindowPos;
    document.onmouseup = unlockSurveyWindow;
}
function unlockWindowU() {
    movingU = false;
    document.onmousemove = null;

    document.onmouseup = null;
}
function unlockSurveyWindow() {
    movingSurvey = false;
    document.onmousemove = null;

    document.onmouseup = null;
}
function showWindowU(e, url, elemid, frameid) {
    var elem = document.getElementById(elemid);
    if (elem.style.display != 'none')
        return;
    if (!e) e = window.event;
    window.frames[frameid].location = 'about:blank';
    var posx = 0;
    var posy = 0;
    if (e.pageX || e.pageY) {
        posx = e.pageX;

        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

   


    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;

    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;
    if (elemid = 'listPropWindow') {
        var winW = 0;
        if (document.body && document.body.offsetWidth) {
            winW = document.body.offsetWidth;
        }
        if (document.compatMode == 'CSS1Compat' &&
    document.documentElement &&
    document.documentElement.offsetWidth) {
            winW = document.documentElement.offsetWidth;
        }
        if (window.innerWidth && window.innerHeight) {
            winW = window.innerWidth;
        }
        if (winW < 760) {
            posx = 0;
        } else {
            posx = winW - 760;
        }
        if (posy < 125)
            posy = 125;
    }

    elem.style.display = 'block';

    elem.style.left = posx / 2 + 'px';    
    elem.style.top = posy + 'px';
    

    window.frames[frameid].location = url;
    //jQuery('#'+elemid).draggable();
}

function showSurveyWindow(e,url) {
    if (!e) e = window.event;
    window.frames["surveyFrame"].location = 'about:blank';
    var posx = 0;
    var posy = 0;
    if (e.pageX || e.pageY) {
        posx = e.pageX;

        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
    }

    var elem = document.getElementById('surveyResults');


    if (posx + elem.offsetWidth > document.body.offsetWidth)
        posx = document.body.offsetWidth - elem.offsetWidth;

    if (posy + elem.offsetHeight > document.body.offsetHeight)
        posy = document.body.offsetHeight - elem.offsetHeight;

    elem.style.display = 'block';

    elem.style.left = posx/2 + 'px';

    elem.style.top = posy + 'px';

    window.frames["surveyFrame"].location = url;
}
function opinionSelector() {
    var ddl = document.getElementById('ddlOpinions');
    var comments = document.getElementById('scrollcomments');
    switch (ddl.options[ddl.selectedIndex].value) {
        case "0":
            {
                var p = comments.getElementsByTagName('tr');
                for (i = 0; i < p.length; i++) {
                    if (p[i].className == 'positivecomments')
                        p[i].style.display = '';
                    else if (p[i].className == 'negativecomments')
                        p[i].style.display = '';
                }
            } break;
        case "1":
            {
                var p = comments.getElementsByTagName('tr');
                for (i = 0; i < p.length; i++) {
                    if (p[i].className == 'positivecomments')
                        p[i].style.display = '';
                    else if (p[i].className == 'negativecomments')
                        p[i].style.display = 'none';
                }
            } break;
        case "2":
            {
                var p = comments.getElementsByTagName('tr');
                for (i = 0; i < p.length; i++) {
                    if (p[i].className == 'positivecomments')
                        p[i].style.display = 'none';
                    else if (p[i].className == 'negativecomments')
                        p[i].style.display = '';
                }
            } break;
    }
}
function ConvertPrice(amount, curr) {
    if (curr == null) {
        curr = orgC;
    }
    var zlval = currrates[curr] * amount;
    if (typeof (document.sortform) == 'undefined') {
        zlval = currrates[orgC] * amount;
        return Math.round(zlval / currrates[curr]);
    }
    return Math.round(zlval / currrates[document.sortform.currencydd.options[document.sortform.currencydd.selectedIndex].text]);
}
function ConvertUnit(value, oldUnit) {
    //var unitConv = new Array();
    //unitConv[0] =0.0929;
    //unitConv[1] = 10.7643;
    if (typeof (document.sortform) == 'undefined') {
        if (oldUnit == 1) {
            return Math.round(value * 10.7643);
        }
        else {
            return value;
        }
    }
    var index = document.sortform.unitdd.options[document.sortform.unitdd.selectedIndex].value;

    if (oldUnit) {
        if (oldUnit != index) {
            if (oldUnit == 0)
                return Math.round(value * 10.7643);
            else
                return Math.round(value * 0.0929);
        }


    } else {
        if (index == 1) {
            return Math.round(value * 10.7643);
        } else
            return value;
    }
}
//--- AA Promotion Video
function showPromo() {
    jQuery("#ytplayer").append('<div id="aaplayer" style="margin-left:15px;"><object width="700" height="420"> <param name="movie" value="http://www.youtube.com/v/AUsF02MOA5s?version=3&autohide=0&showinfo=0&autoplay=1&theme=light"></param> <param name="allowScriptAccess" value="always"></param> <embed src="http://www.youtube.com/v/AUsF02MOA5s?version=3&autohide=0&showinfo=0&autoplay=1&theme=light" type="application/x-shockwave-flash" allowscriptaccess="always" allowFullScreen="true" width="700" height="420"></embed> </object></div>');
    jQuery('#modTVpromo').css('position', 'static');

    jQuery('#blockScreen').css('display', 'block');
    var left = -1 * (screen.width / 2 - (jQuery('#commercial').width() / 5));
    var top = -1 * (screen.height / 2 - (jQuery('#commercial').height() / 3));
    jQuery('#commercial').css('display', 'block');
    jQuery('#commercial').css('margin-left', left);
    jQuery('#commercial').css('margin-top', top);
}
function closePromo() {
    jQuery("#aaplayer").remove();
    jQuery('#modTVpromo').css('position', 'relative');

    jQuery('#blockScreen').css('display', 'none');
    jQuery('#commercial').css('display', 'none');
}
//--- City Description
function showCityDescription(more, less) {
    var text = jQuery('#text');
    var moreless = jQuery('#moreless');
    var textoverflow = document.getElementById('text').style.overflow;
    if (textoverflow == 'visible' || textoverflow == '') {
        text.css('overflow', 'hidden');
        text.animate({ 'height': '122px' }, 300);
        moreless.html(more);
        moreless.css('margin-left', '235px');
    }
    else {
        text.css('overflow', 'visible');
        text.css('height', 'auto');
        moreless.html(less);
        moreless.css('margin-left', '0px');
    }
}
var AjaxLoaders = new Object();
function AjaxLoader(targetelem, modDefID, ver, css, queryStr, before, after) {
    this.targetElemID = targetelem;
    this.result = null;
    this.ModuleDefID = modDefID;
    this.Version = ver;
    this.QueryString = queryStr;
    this.PreLoad = before;
    this.AfterLoad = after;
    this.UniqueID = new Date().getTime().toString() + modDefID + ver;
    this.loadCss = css;
    AjaxLoaders[this.UniqueID] = this;
    this.Request = function() {
        if (this.PreLoad != null) {
            eval(this.PreLoad);
        }
        apartmentsapart.Index.LoadUserControl(this.UniqueID, this.ModuleDefID, this.Version, this.QueryString, this.loadCss, this.LoadControlCallBack);
        return true;
    }
    this.LoadControlCallBack = function(res) {
        if (res != null && res.value != null) {
            var loader = AjaxLoaders[res.value[0]];
            loader.result = res;

            var css = res.value[2];
            if (css.length > 0) {
                if (document.createStyleSheet) {
                    document.createStyleSheet(css);
                }
                else {
                    jQuery('head').append(jQuery("<link rel='stylesheet' href='" + css + "' type='text/css' media='screen' />"));
                }
            }
            document.getElementById(loader.targetElemID).innerHTML += res.value[1];
            try {
                var re = new RegExp('<script>.*?<\\/script>', 'g');
                var tmpscript = res.value[1];
                tmpscript = tmpscript.replace(new RegExp("\\r\\n", "g"), " ");
                var a = tmpscript.match(re);
                if (a != null) {
                    for (var i = 0; i < a.length; i++) {
                        if (window.execScript) {
                            window.execScript(a[i].replace('<script>', '').replace('<\/script>', ''));
                        } else {
                            window.eval(a[i].replace('<script>', '').replace('<\/script>', ''));
                        }
                    }
                }

            } catch (err) { alert(err); }

        }
        if (loader.AfterLoad != null && loader.AfterLoad != '') {
            eval(loader.AfterLoad);
        }
    }
}

function CalendarPicker(df, dt, lang) {
    jQuery.datepicker.setDefaults(jQuery.datepicker.regional[lang]);
    jQuery('#' + df).data('df', df);
    jQuery('#' + df).data('dt', dt);
    jQuery('#' + df).datepicker(
            {
                dateFormat: 'dd/mm/yy'
              , firstDay: 1
              , minDate: 0
              , numberOfMonths: 2
              , constrainInput: true
              , changeMonth: true
              , changeYear: true
              , showOn: 'both'
              , onSelect: function(selectedDate) {
                  var minDate = jQuery(this).datepicker('getDate');
                  if (minDate) {
                      minDate.setDate(minDate.getDate() + 1);
                  }
                  jQuery('#' + jQuery(this).data('dt')).datepicker('option', 'minDate', minDate || new Date()); // Date + 1 or tomorrow by default
                  var tmp = '#' + jQuery(this).data('dt');
                  setTimeout('jQuery(\'' + tmp + '\').focus()', 100);
              }
              , beforeShow: function(input, inst) {
                  input.disabled = true;
              }
              , beforeShowDay: function(date) {
                  return [true, (typeof (jQuery(this).datepicker('option', 'dateTo')) != 'undefined' && (date.getDate() == jQuery(this).datepicker('option', 'dateTo').getDate() + 1) && (date.getMonth() == jQuery(this).datepicker('option', 'dateTo').getMonth())) ? 'selectedDate' : ''];
              }
              , onClose: function(dateText, inst) { inst.input.removeAttr('disabled'); }
            });
    jQuery('#' + dt).data('df', df);
    jQuery('#' + dt).data('dt', dt);
    jQuery('#' + dt).datepicker(
            {
                dateFormat: 'dd/mm/yy'
              , firstDay: 1
              , numberOfMonths: 2
              , constrainInput: true
              , changeMonth: true
              , changeYear: true
              , showOn: 'both'
              , onSelect: function(selectedDate) {
                  var maxDate = jQuery(this).datepicker('getDate');
                  if (maxDate) {
                      maxDate.setDate(maxDate.getDate() - 1);
                      jQuery('#' + jQuery(this).data('df')).datepicker('option', 'dateTo', maxDate);
                  }
              }
              , beforeShow: function(input, inst) {
                  input.disabled = true;
                  var minDate = jQuery('#' + jQuery(this).data('df')).datepicker('getDate');
                  if (minDate) {
                      minDate.setDate(minDate.getDate() + 1);
                  }
                  jQuery(this).datepicker('option', 'minDate', minDate || new Date()); // Date + 1 or tomorrow by default                  
              },
              beforeShowDay: function(date) {
              return [true, (typeof(jQuery(this).datepicker('option', 'minDate')) != 'undefined' && (date.getDate() == jQuery(this).datepicker('option', 'minDate').getDate() - 1) && (date.getMonth() == jQuery(this).datepicker('option', 'minDate').getMonth())) ? 'selectedDate' : '']; 
              }
              , onClose: function(dateText, inst) { inst.input.removeAttr('disabled'); }
            });
}

 	
