﻿function getHTMLValue(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 (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='#BE1AD2'>" + name + "</font></b></a>";
        }
        else {
            if (website != null && website != '' && website.indexOf("http:") == -1) {
                namehtml = "<a href='javascript:openMapLocatorPopup(\"/seasia/" + website + "\")' style='color:#BE1AD2'><b><font color='#BE1AD2'>" + name + "</font></b></a>";
            }
            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>";
                }
            
        }
    }
    
    var imghtml = "";
    
    if (image != "" && image != null) {
        imghtml = "<img src=\"images/gmap/" + image + "\" width=\"80\" 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 + "<table border='0'>";
    
    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="+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 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 openMapLocatorPopup(url){
    var mapLocatorPopup = window.open(url, "MapLocatorPopup");
    mapLocatorPopup.focus();
}

