﻿function Model_1(item) {
    var link = item.link;
    
    if (link.indexOf("http") > -1) {
        link = item.link;
        //alert(link);
    } else {
        link = "http://www.ftstour.com.tw" + item.link;
    }
    var id = item.sort;

    var aa = "<img src=\"" + link + "\"></img>";
    return aa;
}

function Model_11(item) {
    var link = checkURL(item.link);

    var css = "";
    if (item.id == "3") {
        css = "model_11_iframe1";
    }
    else {
        css = "model_11_iframe2";
    }
    var id = item.sort;
    var aa = "<iframe class=\""+css+"\" frameborder=\"0\" scrolling=\"no\" align=\"middle\" src=\"" + link + "\" ></iframe>";
    return aa;
}



//卡友獨享,最新好康&News 
function Model_7(item) {
    var aa = "";
    var id = item.sort;

    if (item.title.length > 0) {
        aa += "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
        aa += "<tr>";
        aa += "<td width=\"17\"><img src=\"http://www.ftstour.com.tw/eWeb_ftstour/images/fts/title_001.gif\"></td>";
        aa += "<td background=\"http://www.ftstour.com.tw/eWeb_ftstour/images/fts/title_002.gif\" class=\"main-title\">" + item.title + "</td>";
        aa += "<td width=\"80\"><img src=\"http://www.ftstour.com.tw/eWeb_ftstour/images/fts/title_003.gif\"></td>";
        aa += "</tr>";
        aa += "</table>";
    }
    aa += "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"model_07_content\">";
    var i = 1;
    var position = "L";
    //alert(item.items.length);
    if (item.items.length > 0) {
        $.each(item.items, function(k, detail) {

            if (position == "L") {
                aa += "<tr>";
            }
            aa += "<td width=\"50%\" align=\"left\"><a class=\"m7-link\" href=\"" + checkURL(detail.LINK_URL) + "\">" + detail.LINK_NM + "</a></td>";

            if (position == "R") {
                aa += "</tr>";
            }

            if (position == "L") {
                position = "R"
            }
            else {
                position = "L"
            }
        })
    }
    aa += "</table>";
    return aa;
}




//即時熱票,各區行程
function Model_9(item) {
    var position = item.item_position;
    //alert(item.title);
    var aa = "";

    //判斷是否有圖在DTL_IMG_URL,沒有就從資料庫抓取
    var title_img = item.DTL_IMG_URL;
    if (title_img.length > 0) {

        title_img = checkURL(item.DTL_IMG_URL);
    }
    else {
        title_img = item.image;
    }

        
    var id = item.sort;
    //M9版型是連續兩個M9組合而成,所以用一個div包兩個div 
    if (position == "L") {
        //aa += "<div id=\"model" + id + "\" style=\"width:400px;\" class=\"model_09\">";
        aa += "<div id=\"model" + id + "_left\" class=\"model_9_left\">";
    }
    else {
        aa += "<div id=\"model" + id + "_right\" class=\"model_9_right\">";
    }
    if (title_img.length > 0) {
        aa += "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
        aa += "<tr>";
        aa += "<td><a href=\"" + checkURL(item.DTL_IMG_LINK) + "\"><img src=\"" + title_img + "\"></a></td>";
        aa += "</tr>";
        aa += "</table>";

    }
    aa += "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
    var i = 1;
    var position = "L";
    if (item.items.length > 0) {
        $.each(item.items, function(k, detail) {
            aa += "<tr>";
            aa += "<td width=\"12\" valign=\"top\" class=\"m9-td\"><img src=\"http://www.ftstour.com.tw/eWeb_ftstour/images/right_icon.gif\"></td>";
            aa += "<td valign=\"top\" class=\"m9-td\"><a class=\"m9-link\" href=\"" + checkURL(detail.LINK_URL) + "\">" + detail.LINK_NM + "</a></td>";
            //是否要顯示錢
            //是否要顯示錢
            if (title_img.length == 0) {
                aa += "<td width=\"40\" valign=\"top\" align=\"right\" class=\"m9-td\"><span class=\"m6-link02\"><nobr>$" + detail.LINK_NAMT + "</nobr></span></td>";
            }
            aa += "</tr>";
        })
    }
    aa += "</table>";

    if (position == "L") {
        aa += "</div>";
       
    }
    else {
        aa += "</div>";
        //aa += "</div>";
    }
    return aa;
}


//即時熱票,各區行程
function Model_9_old(item) {
    var position = item.item_position;
    //alert(item.title);
    var aa = "";

    //判斷是否有圖在DTL_IMG_URL,沒有就從資料庫抓取
    var title_img = item.DTL_IMG_URL;
    if (title_img.length > 0) {

        title_img = checkURL(item.DTL_IMG_URL);
    }
    else {
        title_img = item.image;
    }


    var id = item.sort;
    //M9版型是連續兩個M9組合而成,所以用一個div包兩個div 
    if (position == "L") {
        //aa += "<div id=\"model" + id + "\" style=\"width:400px;\" class=\"model_09\">";
        aa += "<div id=\"model" + id + "_left\" class=\"model_9_left\">";
    }
    else {
        aa += "<div id=\"model" + id + "_right\" class=\"model_9_right\">";
    }
    if (title_img.length > 0) {
        aa += "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
        aa += "<tr>";
        aa += "<td><a href=\"" + checkURL(item.DTL_IMG_LINK) + "\"><img src=\"" + title_img + "\"></a></td>";
        aa += "</tr>";
        aa += "</table>";

    }
    aa += "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
    var i = 1;
    var position = "L";
    if (item.items.length > 0) {
        $.each(item.items, function(k, detail) {
            aa += "<tr>";
            aa += "<td width=\"12\" valign=\"top\" class=\"m9-td\"><img src=\"http://www.ftstour.com.tw/eWeb_ftstour/images/right_icon.gif\"></td>";
            aa += "<td valign=\"top\" class=\"m9-td\"><a class=\"m9-link\" href=\"" + checkURL(detail.LINK_URL) + "\">" + detail.LINK_NM + "</a></td>";
            //是否要顯示錢
            if (title_img.length == 0) {
                aa += "<td width=\"40\" valign=\"top\" align=\"right\" class=\"m9-td\"><span class=\"m6-link02\"><nobr>$" + detail.LINK_NAMT + "</nobr></span></td>";
            }
            aa += "</tr>";
        })
    }
    aa += "</table>";

    if (position == "L") {
        aa += "</div>";

    }
    else {
        aa += "</div>";
        //aa += "</div>";
    }
    return aa;
}

function Model_10_1(item) {
    var aa = "";
    var id = item.sort;
    if (item.DTL_IMG_URL.length > 0) {
        
        if (item.title.length > 0) {
            aa += "<div class=\"model_10_top\">";
            aa += item.title;
            aa += "</div>";
        }
        aa += "<div class=\"model_10_left\">";
        aa += "<a href=\"" + checkURL(item.DTL_IMG_LINK) + "\"><img src=\"" + checkURL(item.DTL_IMG_URL) + "\"></a>";
        aa += "</div>";
        aa += "<div class=\"model_10_right\">";
        aa += "<ul class=\"model_10_ul\">";
        $.each(item.items, function(k, detail) {
        aa += "<li class=\"model_10_li\"><a class=\"m10-link\" href=\"" + checkURL(detail.LINK_URL) + "\">" + detail.LINK_NM + "</a></li>";
        })
        aa += "</ul>";
        aa += "</div>";

    }

    return aa;
}


function Model_10(item) {
    var aa = "";
    var id = item.sort;
    if (item.DTL_IMG_URL.length > 0) {
        aa += "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
        if (item.title.length > 0) {
            aa += "<tr>";
            aa += "<td colpan=\"2\">" + item.title + "</td>";
            aa += "</tr>";
        }
        aa += "<tr valign=\"top\">";
        aa += "<td><a href=\"" + checkURL(item.DTL_IMG_LINK) + "\"><img src=\"" + checkURL(item.DTL_IMG_URL) + "\"></a></td>";
        aa += "<td>";
        aa += "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
        $.each(item.items, function(k, detail) {

        aa += "<tr class=\"m10-tr02\">";
            aa += "<td width=\"12\"><img align=\"absmiddle\" src=\"http://www.ftstour.com.tw/eWeb_ftstour/images/Module_icon/micon0.gif\"></td>";
            aa += "<td><a class=\"m10-link\"  href=\"" + checkURL(detail.LINK_URL) + "\">" + detail.LINK_NM + "</a></td>";
            aa += "</tr>";
        })
        aa += "</table>";


        aa += "</td>";
        aa += "</tr>";
        aa += "</tr>";
        aa += "</table>";

    }
    
    return aa;
}

function checkURL(url) {
    var link = url;
    if (link.indexOf("http") > -1) {
        link = url;
    } else {
    link = "http://www.ftstour.com.tw" + url;
    }
    return link;
    //return encodeURI(link);
}

function checkLinkFont(txt) {
    var title = txt;
    if (title.indexOf("<font color=") > -1) {
        if (title.indexOf("color=blue") == -1) {
            title = title.replace("color=", "color=#");
        }
    }
    else
    {
        title = title;
    }
    return title;
}

