﻿/*---------------------------------------cookie------------------------------------------*/
function createCookie(name, value, days, Tdom) {
    var Tdom = (Tdom) ? Tdom : "/";
    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=" + Tdom;
}
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 writeCompare(checkid, checkProName) {
    var compareList = readCookie("line");
    if (compareList == null) { compareList = ""; }
    var flag=0;
    var cootemp = compareList.split("|||");
    for (var i = 0; i < cootemp.length - 1; i++) {
        if (cootemp[i].split("||")[0] == checkid) {
            flag = 1;
        }
    }
    if (flag == 0) {
        compareList += checkid + "||" + escape(checkProName) + "|||";
        createCookie("line", compareList);
    }
}
function isCoo() {
    var proIDs = new Array();
    var compareListTemp = "";
    var coo = readCookie("line");
    if (coo) {
        var cootemp = coo.split("|||");
        for (var i = 0; i < cootemp.length - 1; i++) {
            //compareListTemp =compareListTemp+ "<li id='" + cootemp[i].split("||")[0] + "'><a  href=\"Line.aspx?id=" + cootemp[i].split("||")[0] + "\">" + (unescape(cootemp[i].split("||")[1]).length > 15 ? unescape(cootemp[i].split("||")[1]).substring(0, 15) : unescape(cootemp[i].split("||")[1])) + "</a></li>";
            if (unescape(cootemp[i].split("||")[1]) == "$model.lname") {
                continue;
             }
            else {
                compareListTemp += "<li id='check_" + cootemp[i].split("||")[0] + "'><a title='" + unescape(cootemp[i].split("||")[1]) + "' href=\"Line.aspx?id=" + cootemp[i].split("||")[0] + "\">" + unescape(cootemp[i].split("||")[1]) + "</a></li>";
            }
        }
        $("#cjlljlmc").html(compareListTemp);
    }
}

function doPrint() {
    bdhtml = window.document.body.innerHTML;
    sprnstr = "<!--startprint-->";
    eprnstr = "<!--endprint-->";
    prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
    prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
    window.document.body.innerHTML = prnhtml;
    window.print();
}


//获取URL参数
function GoToBackPage() {
    var parUrl = $.query.get("id");  

    self.location = "line.aspx?id=" + parUrl;

}

//获取URL参数
function checkurlpar() {
    var id = $.query.get("tID"); //表示专题
    if (id != "") {
        //有ID参数存在，处于编辑中
        $("#rarea").hide();
        gettname(id);
    }
    else {
        var sid = $.query.get("sid"); //表示景点ID
        if (sid != "") {
            //有ID参数存在，处于编辑中
            $("#rarea").hide();
            getsname(sid);
        }
    }   
    
}


//根据ID获取景点名称
function getsname(id) {
    $.ajax({
        type: "POST",
        url: "/Line/ajax.ashx",
        error: function() { alert('error'); },
        data: "type=s&id=" + id,
        success: function(data) {
        //
        document.title = "重庆到" + data + "旅游线路" + "--重庆新闻国际旅行社";
        $("#linepersitont").html("当前位置：首页>" + data + "专题旅游线路");
        $("#luxian").html("重庆到" + data + "旅游线路");
        }
    });
}

//根据ID获取主题名称
function gettname(id) {
    $.ajax({
        type: "POST",
        url: "/Line/ajax.ashx",
        error: function() { alert('error'); },
        data: "type=t&id=" + id,
        success: function(data) {
        document.title ="重庆"+data + "旅游线路" + "--重庆新闻国际旅行社";
        $("#linepersitont").html("当前位置：首页>重庆" + data + "旅游线路");
        //$("#luxian").html( $.query.get("name") + "专题旅游线路");
        $("#luxian").html("重庆"+data + "旅游线路");
        }
    });
}

//编辑线路
//function $(ele) {
//    if (typeof (ele) == 'string') {
//        ele = document.getElementById(ele)
//        if (!ele) {
//            return null;
//        }
//    }
//    return ele;
//}

function zOpen() {
    var lineid = $.query.get("id");
    //var lineid = 10001;
    var diag = new Dialog("Diag2");
    diag.Width = 900;
    diag.Height = 400;
    diag.Title = "修改线路";
    diag.URL = "http://www.766023.com/Manager/line/LineEX.aspx?lineId=" + lineid;
    diag.OKEvent = zAlert; //点击确定后调用的方法
    diag.show();
}
function zAlert() {
    //Dialog.alert("你点击了一个按钮");
}

