﻿function getHTMLValue(address, name, website, email, tel, fax, vhid, addrid, eventid, image, desc, category){
    if (category == "attractions") {
        return getAttractionsValue(address, name, website, email, tel, fax, vhid, addrid, eventid, image, desc, category);
    }
    else {
        var path = category;
        
        if (category == "shopDistrict") 
            path = "shopping";
        else {
            if (category == "diningistrict") 
                path = "dining";
        }
        return getCommonHTMLValue(address, name, website, email, tel, fax, vhid, addrid, eventid, image, desc, category, path);
    }
}


function addCol(html, colname, value, color){
    var htmlOut = html;
    var bgcolor = ((color % 2) == 0) ? "#ffffff" : "#ffffff";
    
    htmlOut = htmlOut + "<tr>";
    htmlOut = htmlOut + "<td bgcolor='" + bgcolor + "' width='70' valign='top' style='font-size:13px;letter-spacing:0px;'>";
    htmlOut = htmlOut + colname;
    htmlOut = htmlOut + "</td>";
    htmlOut = htmlOut + "<td bgcolor='" + bgcolor + "' width='230' valign='middle' align='left' style='font-size:13px;letter-spacing:0px;'>";
    htmlOut = htmlOut + value;
    htmlOut = htmlOut + "</td>";
    htmlOut = htmlOut + "</tr>";
    
    return htmlOut;
}

function getAttractionsValue(address, name, website, email, tel, fax, vhid, addrid, eventid, image, desc, category){
    var html = "<span style='margin-bottom: 20px;text-decoration: none;font-size: 1em;line-height: 16pt;word-spacing: 1pt;'>";
    
    html = html + "<table border='0'>";
    if (name == null) {
        name = "";
        
    }
    var namehtml = "";
    
    if (website !== "" && website != null && website.indexOf("http:") == -1) {
        namehtml = "<a href='javascript:openMapLocatorPopup(\"/tc/" + website + "\")' style='color:#53C5DF'><b><font color='#53C5DF'>" + name + "</font></b></a>";
    }
    else 
        if (website != null && website != "") {
            namehtml = "<b><a href='javascript:openMapLocatorPopup(\"" + website + "\")' style='color:#53C5DF'><font color='#53C5DF'>" + name + "</font></a></b>";
        }
        else {
            namehtml = "<b><font color='#53C5DF'>" + name + "</font></b>";
        }
    
    var imghtml = "";
    
    if (image != "" && image != null) {
        imghtml = "<img src=\"/eng/attractions/images/gmap/" + image + "\" width=\"70\" height=\"70\" border=\"0\" /><br/>";
    }
    
    if (imghtml != "") {
        html = html + "<tr>";
        html = html + "<td width='80px'>";
        html = html + imghtml;
        html = html + "</td>";
        html = html + "<td width='220' align='left'>";
        html = html + namehtml;
        html = html + "</td>";
        html = html + "</tr>";
    }
    else {
        html = html + "<tr>";
        html = html + "<td width='300'>";
        html = html + namehtml;
        html = html + "</td>";
        html = html + "</tr>";
    }
    
    html = html + "</table>";
    
    html = html + "</span>";
    
    return html;
}

function getCommonHTMLValue(address, name, website, email, tel, fax, vhid, addrid, eventid, image, desc, category, path){
    var html = "";
    var breakpt = 0;
    var breakpthtml = "";
    
    
    
    html = html + "<span style='margin-bottom: 20px;text-decoration: none;font-size: 1em;line-height: 16pt;word-spacing: 1pt;'><table border='0' width='300'>";
    if (name == null) 
        name = "";
    var namehtml = "";
    
    if (vhid != "" && vhid != null) {
        namehtml = "<a href='javascript:getHotelDetail(" + vhid + ", " + addrid + ")'><b><font color='#BE1AD2'>" + name + "</font></b></a>";
    }
    else 
        if (eventid != "" && eventid != null) {
            namehtml = "<a href='javascript:getEventDetail(" + eventid + ")'><b><font color='#6604B9'>" + name + "</font></b></a>";
        }
        else 
            if (category != null && category != "" && category == "hotels") {
                if (website != null && website != "" && website.indexOf("http:") == -1) {
                    namehtml = "<b><a href='javascript:openMapLocatorPopup(\"/tc/" + website + "\")' style='color:#BE1AD2'><font color='#BE1AD2'>" + name + "</font></a></b>";
                }
                else 
                    if (website != null && website != "") {
                        namehtml = "<b><a href='javascript:openMapLocatorPopup(\"" + website + "\")' style='color:#BE1AD2'><font color='#BE1AD2'>" + name + "</font></a></b>";
                    }
                    else {
                        namehtml = "<b><font color='#BE1AD2'>" + name + "</font></b>";
                    }
            }
            else 
                if (category != null && category != "" && category == "diningDistrict") {
                    if (website != null && website != "" && website.indexOf("http:") == -1) {
                        namehtml = "<b><a href='javascript:openMapLocatorPopup(\"/tc/" + website + "\")' style='color:#FF6101'><font color='#FF6101'>" + name + "</font></a></b>";
                    }
                    else 
                        if (website != null && website != "") {
                            namehtml = "<b><a href='javascript:openMapLocatorPopup(\"" + website + "\")' style='color:#FF6101'><font color='#FF6101'>" + name + "</font></a></b>";
                        }
                        else {
                            namehtml = "<b><font color='#FF6101'>" + name + "</font></b>";
                        }
                }
                else 
                    if (category != null && category != "" && category == "shopDistrict") {
                        if (website != null && website != "" && website.indexOf("http:") == -1) {
                            namehtml = "<b><a href='javascript:openMapLocatorPopup(\"/tc/" + website + "\")' style='color:#FE0D90'><font color='#FE0D90'>" + name + "</font></a></b>";
                        }
                        else 
                            if (website != null && website != "") {
                                namehtml = "<b><a href='javascript:openMapLocatorPopup(\"" + website + "\")' style='color:#FE0D90'><font color='#FE0D90'>" + name + "</font></a></b>";
                            }
                            else {
                                namehtml = "<b><font color='#FE0D90'>" + name + "</font></b>";
                            }
                    }
                    else 
                        if (category != null && category != "" && category == "events") {
                            if (website != null && website != "" && website.indexOf("http:") == -1) {
                                namehtml = "<b><a href='javascript:openMapLocatorPopup(\"/tc/" + website + "\")' style='color:#6604B9'><font color='#6604B9'>" + name + "</font></a></b>";
                            }
                            else 
                                if (website != null && website != "") {
                                    namehtml = "<b><a href='javascript:openMapLocatorPopup(\"" + website + "\")' style='color:#6604B9'><font color='#6604B9'>" + name + "</font></a></b>";
                                }
                                else {
                                    namehtml = "<b><font color='#6604B9'>" + name + "</font></b>";
                                }
                        }
    
    var imghtml = "";
    
    if (image != "" && image != null) {
        if (path != 'diningDistrict') {
            imghtml = "<img src=\"/eng/" + path + "/images/gmap/" + image + "\" width=\"70\" height=\"70\" border=\"0\" /><br/>";
        }
        else {
            imghtml = "<img src=\"/eng/dining/images/gmap/" + image + "\" width=\"70\" height=\"70\" border=\"0\" /><br/>";
        }
    }
    
    if (imghtml != "") {
        html = html + "<tr>";
        html = html + "<td width='80px'>";
        html = html + imghtml;
        html = html + "</td>";
        html = html + "<td align='left'>";
        html = html + namehtml;
        html = html + "</td>";
        html = html + "</tr>";
    }
    else {
        html = html + "<tr>";
        html = html + "<td width='300' align='left'>";
        html = html + namehtml;
        html = html + "</td>";
        html = html + "</tr>";
    }
    
    html = html + "</table>";
    
    
    html = html + "<table border='0' width='300'>";
    
    var colorIndex = 0;
    
    if (address != "" && address != null) 
        html = addCol(html, "Address : ", address, colorIndex++);
    
    if (website != "" && website != null) {
        if (category == "shopDistrict" || category == "diningDistrict") {
            //var websitehtml = "<a href=/tc/"+path+"/"+website+" target=_blank>Click here</a>";
            //html = addCol(html, "網址 : ", websitehtml , colorIndex++);
        }
        else {
            //var websitehtml = "<a href="+website+" target=_blank>"+ website +"</a>";
            //html = addCol(html, "網址 : ", websitehtml , colorIndex++);
        }
    }
    
    if (email != "" && email != null) 
        html = addCol(html, "Email : ", email, colorIndex++);
    
    if (tel != "" && tel != null) 
        html = addCol(html, "Phone : ", tel, colorIndex++);
    
    if (fax != "" && fax != null) 
        html = addCol(html, "Fax : ", fax, colorIndex++);
    
    if (desc != "" && desc != null) 
        html = addCol(html, "Description:", desc, colorIndex++);
    
    html = html + "</table></span>";
    
    
    return html;
}

function openMapLocatorPopup(url){
    var mapLocatorPopup = window.open(url, "MapLocatorPopup");
    mapLocatorPopup.focus();
}

