﻿//--------------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;
    }
}

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() {
    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://localhost:3317/IndexFrame.aspx?pageid=5892&l=1&domainid=1';
    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 = re = /^([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);
}
//---------------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").width = "337";
    document.getElementById("ifRatings").height = "385";
    
    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';    
}

function showGWindowOnList(e, url, wth, hth, bing) {
    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);
}

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").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';
}

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 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() {
    mint.$('modSplashScreen').style.display = 'none';
    RemoveEvent(window.document, 'click', HideSplash);
    if (isIE6) {
        IE6SelectFix('visible');
    }
}
function SplashScreen() {
    if ((userAgent.search("iphone") > -1 || 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("android") > -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;
    }
}
//---------------------------------------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
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 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'); }
            });
}

