﻿// JavaScript Document

var classTag = "solutionsClass1";
function home_click() {
    location.href = "index.aspx";
}


function markets_click() {
    location.href = "LaundryMain.aspx";
}


function products_click() {
    location.href = "index.aspx";
}


function newsroom_click() {
    location.href = "index.aspx";
}

function Previous() {
    location.href = "SystemErrorCodesCorrective.aspx";
}
function history_click() {
    location.href = "History.aspx";
}


function support_click() {
    location.href = "CustomerSupport.aspx";
}

function contactus_click() {
    location.href = "ContactUs.aspx";
}

function Market_SmartCard() {
    location.href = "SmartCard.aspx";
}

function SmartCard_SystemFlow() {
    location.href = "SmartCardSystemFlow.aspx";
}

function SmartCard_SystemFlow_OneCard() {
    location.href = "RevalueStations.aspx#OneStop";
}

function SmartCard_SystemFlow_ClassicCash() {
    location.href = "RevalueStations.aspx#ClassicCash";
}

function SmartCard_SystemFlow_HighSecurity() {
    location.href = "RevalueStations.aspx#HighSecurity";
}

function SmartCard_SystemFlow_CodeBased() {
    location.href = "RevalueStations.aspx#CBR";
}

function SmartCard_SystemFlow_Plus() {
    location.href = "SmartCardReaders.aspx#Pulse";
}

function SmartCard_SystemFlow_Maytag() {
    location.href = "SmartCardReaders.aspx#Maytag";
}

function SmartCard_SystemFlow_Alliance() {
    location.href = "SmartCardReaders.aspx#Alliance";
}

function Corpoate_SystemFlow() {
    location.href = "CorporateCampusesSystemFlow.aspx";
}

function Corpoate_VengingDataSheet() {
    location.href = "Resources/Files/Laundry Data Sheets/CorporateCampuses_Flyer.pdf";
}

function WaveRider_WaveVision() {
    location.href = "WaveVision.aspx";
}

function WaveRider_WaveCenter() {
    location.href = "WaveCenter.aspx";
}

function WaveRider_WaveRider() {
    location.href = "SmartCardReaders.aspx#WaveRider";
}

function WaveRider_SystemFlow() {
    location.href = "SystemFlow.aspx";
}

function Market_WaverRider() {
    location.href = "WaveRider.aspx";
}

function Corporate_click() {
    location.href = "CorporateCampuses.aspx";
}
function CorrectionalFacilities_click() {
    location.href = "MainCorrectionsMarket.aspx";
}

function CorrectionsMarket_click() {
    location.href = "CorrectionsMarket.aspx";
}

function showmenu(obj1, obj2, state, location) {
    var btn = $("#" + obj1)[0];
    var obj = $("#" + obj2)[0];
    var h = btn.offsetHeight;
    var w = btn.offsetWidth;
    var x = btn.offsetLeft;
    var y = btn.offsetTop;

    obj.onmouseover = function() {
        showmenu(obj1, obj2, 'show', location);
    }
    obj.onmouseout = function() {
        hiddenmenu(obj2);
    }

    while (btn = btn.offsetParent) { y += btn.offsetTop; x += btn.offsetLeft; }

    var hh = obj.offsetHeight;
    var ww = obj.offsetWidth;
    var xx = obj.offsetLeft;
    var yy = obj.offsetTop;
    var obj2state = state.toLowerCase();
    var obj2location = location.toLowerCase();

    var showx, showy;

    if (obj2location == "left" || obj2location == "l" || obj2location == "top" || obj2location == "t" || obj2location == "u" || obj2location == "b" || obj2location == "r" || obj2location == "up" || obj2location == "right" || obj2location == "bottom") {
        if (obj2location == "left" || obj2location == "l") { showx = x - ww; showy = y; }
        if (obj2location == "top" || obj2location == "t" || obj2location == "u") { showx = x; showy = y - hh; }
        if (obj2location == "right" || obj2location == "r") { showx = x + w; showy = y; }
        if (obj2location == "bottom" || obj2location == "b") { showx = x; showy = y + h; }
    } else {
        showx = xx; showy = yy;
    }
    obj.style.left = showx + "px";
    obj.style.top = showy + "px";
    obj.style.display = "block";

}
function hiddenmenu(psObjId) {

    $("#" + psObjId).css("display", "none"); // .style.visibility = "hidden";
}



$(document).ready(function() {
    $.get(("Resources/xml/content.xml?code" + new Date().getDate()), function(data) {
        try {
            if (getBrowseType() != "MSIE") {
                var newsletterList = $("newsletter list", data);
                var newsletterContent1 = $("div[id=newslettercontent]>div:first>p:first");
                if (newsletterList[0].attributes.length != 0) {

                    newsletterContent1.append('<a href="' + newsletterList[0].attributes[0].value + '">' + newsletterList[0].textContent + '</a>');
                }
                else {
                    newsletterContent1.append(newsletterList[0].textContent);
                }

                var newsletterContent2 = $("div[id=newslettercontent]>div:last>p:first");
                if (newsletterList[1].attributes.length != 0) {
                    newsletterContent2.append('<a href="' + newsletterList[1].attributes[0].value + '">' + newsletterList[1].textContent + '</a>');
                }
                else {
                    newsletterContent2.append(newsletterList[1].textContent);
                }

                var soluctionsList = $(data).find("solutions[type=" + type + "]")[0];
                var soluctionClass = soluctionsList.attributes["class"].value; ;
                $("div[id=solutionscontent]").attr("class", soluctionClass);
                var soluction = $("div[id=solutionscontent]>ul");
                var soluctionLength = soluctionsList.childNodes.length;
                for (i = 0; i < soluctionLength; i++) {
                    if (soluctionsList.childNodes[i].nodeType == "1") {
                        var strContent = "";
                        if (soluctionsList.childNodes[i].getAttribute("type") == "image") {
                            if (soluctionsList.childNodes[i].getAttribute("link") == null) {
                                strContent += '<li> <img src="' + soluctionsList.childNodes[i].getAttribute("imageurl") + '"><ul>';
                            }
                            else {
                                strContent += '<li> <a href="' + soluctionsList.childNodes[i].getAttribute("link") + '"><img src="' + soluctionsList.childNodes[i].getAttribute("imageurl") + '"></a><ul>';
                            }
                        }
                        else {
                            if (soluctionsList.childNodes[i].getAttribute("link") == null) {
                                strContent += '<li>' + soluctionsList.childNodes[i].getAttribute("data") + "<ul>";
                            }
                            else {
                                strContent += '<li><a href="' + soluctionsList.childNodes[i].getAttribute("link") + '">' + soluctionsList.childNodes[i].getAttribute("data") + "</a><ul>";
                            }
                        }
                        childLength = soluctionsList.childNodes[i].childNodes.length;
                        for (j = 0; j < childLength; j++) {
                            if (soluctionsList.childNodes[i].childNodes[j].nodeType == "1") {
                                if (soluctionsList.childNodes[i].childNodes[j].getAttribute("link") == null) {
                                    strContent += "<li>" + soluctionsList.childNodes[i].childNodes[j].getAttribute("data") + "</li>";
                                }
                                else {
                                    strContent += "<li><a href=\"" + soluctionsList.childNodes[i].childNodes[j].getAttribute("link") + "\">" + soluctionsList.childNodes[i].childNodes[j].getAttribute("data") + "</a></li>";
                                }
                            }
                        }
                        strContent += " </ul> </li>"
                        soluction.append(strContent);
                    }
                }

                var TopRightContentList = $("toprightContent list", data);
                var trLength = TopRightContentList.length;
                var TopRight_ul = $("div[name=rightContent]>ul:first");
                for (i = 0; i < trLength; i++) {
                    TopRight_ul.append('<li>' + (TopRightContentList[i].text == undefined ? TopRightContentList[i].textContent : TopRightContentList[i].text) + '</li>');
                }
            }
            else {
                var newsletterList = $("newsletter list", data);
                var newsletterContent1 = $("div[id=newslettercontent]>div:first>p:first");
                if (newsletterList[0].attributes.length != 0) {

                    newsletterContent1.append('<a href="' + newsletterList[0].attributes[0].value + '">' + newsletterList[0].text + '</a>');
                }
                else {
                    newsletterContent1.append(newsletterList[0].text);
                }

                var newsletterContent2 = $("div[id=newslettercontent]>div:last>p:first");
                if (newsletterList[1].attributes.length != 0) {
                    newsletterContent2.append('<a href="' + newsletterList[1].attributes[0].value + '">' + newsletterList[1].text + '</a>');
                }
                else {
                    newsletterContent2.append(newsletterList[1].text);
                }

                var soluctionsList = $(data).find("solutions[type=" + type + "]")[0];
                var soluctionClass = soluctionsList.getAttribute("class");
                $("div[id=solutionscontent]").attr("class", soluctionClass);
                var soluction = $("div[id=solutionscontent]>ul");
                var soluctionLength = soluctionsList.childNodes.length;
                for (i = 0; i < soluctionLength; i++) {
                    var strContent = "";
                    if (soluctionsList.childNodes[i].getAttribute("type") == "image") {
                        if (soluctionsList.childNodes[i].getAttribute("link") == null) {
                            strContent += '<li> <img src="' + soluctionsList.childNodes[i].getAttribute("imageurl") + '"><ul>';
                        }
                        else {
                            strContent += '<li><a href="' + soluctionsList.childNodes[i].getAttribute("link") + '"> <img src="' + soluctionsList.childNodes[i].getAttribute("imageurl") + '"></a><ul>';
                        }
                    }
                    else {
                        if (soluctionsList.childNodes[i].getAttribute("link") == null) {
                            strContent += '<li>' + soluctionsList.childNodes[i].getAttribute("data") + "<ul>";
                        }
                        else {
                            strContent += '<li><a href=\"' + soluctionsList.childNodes[i].getAttribute("link") + '">' + soluctionsList.childNodes[i].getAttribute("data") + "</a><ul>";
                        }

                    }
                    childLength = soluctionsList.childNodes[i].childNodes.length;
                    for (j = 0; j < childLength; j++) {
                        if (soluctionsList.childNodes[i].childNodes[j].getAttribute("link") == null) {
                            strContent += "<li>" + soluctionsList.childNodes[i].childNodes[j].getAttribute("data") + "</li>";
                        }
                        else {
                            strContent += "<li><a href=\"" + soluctionsList.childNodes[i].childNodes[j].getAttribute("link") + "\">" + soluctionsList.childNodes[i].childNodes[j].getAttribute("data") + "</a></li>";
                        }
                    }
                    strContent += " </ul> </li>"
                    soluction.append(strContent);
                }

                var TopRightContentList = $("toprightContent list", data);
                var trLength = TopRightContentList.length;
                var TopRight_ul = $("div[name=rightContent]>ul:first");
                for (i = 0; i < trLength; i++) {
                    TopRight_ul.append('<li>' + (TopRightContentList[i].text == undefined ? TopRightContentList[i].textContent : TopRightContentList[i].text) + '</li>');
                }
            }
        }
        catch (e) {
        }
        try {
            $("#newsletterleft").css("height", $("#newslettercontent")[0].scrollHeight + "px");
            $("#newsletterright").css("height", $("#newslettercontent")[0].scrollHeight + "px");
            $("#marketleft").css("height", $("#marketcontent")[0].scrollHeight + "px");
            $("#marketrigth").css("height", $("#marketcontent")[0].scrollHeight + "px");
            $("#solutionsleft").css("height", $("#solutionscontent")[0].scrollHeight + "px");
            $("#solutionsright").css("height", $("#solutionscontent")[0].scrollHeight + "px");
        }
        catch (e) {
        }
        var browseType = getBrowseType();
        if (browseType == "Safari" || browseType == "Chrome") {
            if (soluctionClass == classTag) {
                if (document.getElementById("solutionsleft") != null && document.getElementById("solutionsright") != null && document.getElementById("solutionscontent") != null) {
                    document.getElementById("solutionsright").style.height = document.getElementById("solutionsleft").style.height = (document.getElementById("solutionscontent").offsetHeight + 75) + "px";
                }
            }
        }


        if (document.getElementById('btnpopup') != null) {
            topLength = document.getElementById('btnpopup').offsetTop;
            $("a#popup").fancybox({
                'zoomSpeedIn': 0,
                'zoomSpeedOut': 0
            });
        }
        $(function() {

            $('#rightContentID').kxbdMarquee({
                direction: 'up',
                controlBtn: { up: '#goU', down: '#goD' }
            });

        });

    });
});



function ControlMasgerStyle() {
    if (getBrowseType() != "MSIE" || getBrowseVersion() != "7.0") {
        var tagNames = document.getElementById("WaveReade").getElementsByTagName("li");
        for (var index = 0; index < tagNames.length; index++) {
            tagNames[index].style.marginLeft = "10px";
        }

    }
    else {
        if (getBrowseVersion() != "7.0") {
            var tagNames = document.getElementById("WaveReade").getElementsByTagName("li");
            for (var index = 0; index < tagNames.length; index++) {
                tagNames[index].style.marginLeft = "10px";
            }
        }

    }
}
function hiddenProuctionMenu() {
    hiddenmenu('production_menu');

}
function WaveRider_DownLoadPresentation() {

    var winNode = $("#WaveRiderPopup");
    winNode.fadeIn("slow");
}


function RoomKey_SystemFlow() {
    location.href = "LaundryRoomKeySystemFlow.aspx";
}

function Market_RoomKey() {
    location.href = "LaundryRoomKey.aspx";
}

function Market_RoomKeyVendingMine() {
    location.href = "VendingRoomKey.aspx";
}
function Market_RoomKeyArcadeMine() {
    location.href = "ArcadeRoomKey.aspx";
}
function Market_RoomKeyVending() {
    location.href = "RoomKeyVending.aspx";
}
function Market_RoomKeyArcade() {
    location.href = "RoomKeyArcade.aspx";
}

function hide() {
    var winNode = $("#WaveRiderPopup");
    //winNode.fadeOut("slow");
    winNode.hide("slow");
}


function hospitality_click() {
    location.href = "RoomKeyHospitalityMarket.aspx";
}
var divId;
var isOpen = false;
function DownLoad_MDC(obj, Id) {
    isOpen = false;
    //document.onclick = null;
    var winNode = $("#" + Id);
    var top = obj.offsetTop;
    var left = obj.offsetLeft;
    if (getBrowseVersion() == "7.0") {
        if (Id == "MDCDownLoad") {
            top = 386;
        }
        else {
            top = 628;
        }
        left = 495;
      }
      div_top = top;
      div_left = left;
    if (winNode != null && winNode.length > 0) {
        winNode.css({ 'position': 'absolute', 'top': top-50, 'left': left + 180 });
    }
    if (Id == "MDCDownLoad") {
        divId = "MDCDownLoad";
        DownLoad_MDC_hide("PRPDDownLoad");

    }
    else {
        divId = "PRPDDownLoad";
        DownLoad_MDC_hide("MDCDownLoad");

    }
    winNode.fadeIn("fast"); //document.onclick = CancelDiv;  
}

function DownLoad_MDC_hide(Id) {

    var winNode = $("#"+Id);
    winNode.hide("slow");

}

function mousePosition(ev) {
    if (ev.pageX || ev.pageY) {
        return { x: ev.pageX, y: ev.pageY };
    }
    return {
        x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
        y: ev.clientY + document.body.scrollTop - document.body.clientTop
    };
} 
