﻿/// <reference path="/js/jquery-1.4.2.js" />
/// <reference path="/js/jquery.easyui.min.js" />
function keypressup() {

}

function initsearch(obj) {
    if (obj.value == "输入关键词") {
        obj.value = "";
   }

}

 

function sethomepage(obj)  {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage('http://www.tvswt.com/');
        return;
    }
    else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                //alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
            }

        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', 'http://www.tvswt.com/');        
    }

} 


function addpagetofav(obj) {
    var sURL="http://www.tvswt.com/";
    var sTitle="世文通文化交流平台";
    try {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e) {
            alert("浏览器不支持，请按 Ctrl+D 快捷键收藏");
        }
    }
}

 

function register() {
    var emailstatus = CheckEmailMsg($("#emailreg"));
    var passwordstatus = false;
    if ($("#registerform #password").val() == $("#confirmpassword").val() && $("#registerform #password").val() != "") {
        passwordstatus = true;
    }
    else {
        $("#passwordmsg").html("* 两次密码不一致");
        return false;
    }

    if ($("#checkbox").attr("checked")!=true) {
        alert("必须同意服务条款后才能注册");
        return false; 
    }

    if (emailstatus == true && passwordstatus == true) {
        var param = "";
        $("#registerform :input").each(function () {
            param += $(this).attr("name") + "=" + $(this).val() + "&";
        });

        $.post("/ajax.aspx", param, function (x) {
            if (x == "1") {
                alert("注册成功");
            }
            else {
                alert(x);
            }
        }, "html");
    }

}

function CheckEmailMsg(obj) {
    var status = checkemail($(obj).val());
    if (status != true) {
        $(obj).parent().find(".errmsg").html("* 邮箱格式不正确");
    }
    else {
        $(obj).parent().find(".errmsg").html("");
    }
    return status;
}

function checkemail(str) {
    var emailreg = /^[a-z]([a-z0-9]*[-_]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?$/i;
    var status = emailreg.test(str);
    return status;

}


function login(obj) {
    var param = "";
    $("#loginform :input").each(function () {
        param += $(this).attr("name") + "=" + $(this).val() + "&";
    });
    $.post("/ajax.aspx", param, function (x) {
        if (x == "1") {
            if (obj != null && $(obj).attr("name") == "softlogin") {             
                window.parent.location.href = "/index.html";
            }
            else {
                window.location.href = "/?action=mycount";
            }
        }
        else {
            alert(x);
        }
    }, "html");
}


function showsplitpagelink(currentpage, totalpage, url) {

    var num = parseInt(totalpage);
    var page = parseInt(currentpage);
    for (i = 1; i <= num; i++) {
        if (page == i) {
            document.write("<a href='" + url + "&page=" + i + "' class='cur'>" + i + "</a>");
        }
        else {
            document.write("<a href='" + url + "&page=" + i + "'>" + i + "</a>");
        }
    }

}


function thumbnailno(obj) {

    $(obj).attr("src", "/theme/theme01/images/event/theatre_54.jpg");

}

function toggledetailhtml(obj) {

    $("#vintro").toggle();
    $("#vdetail").toggle();
}


function togglemovietab(obj, _class) {
     
    $("#movietabul li").each(
      function (index) {
        $(this).attr("class","off");
        $("#R_lr"+index).hide();
        if($(this).text()==$(obj).text())
        {
           $("#R_lr"+index).show();
        }
      }
    )
   $(obj).attr("class", _class);
}


function ShowMovieBigImg(obj) {

    var imgobj = $(obj).find("img");
    $("#thumbnaillink").text(imgobj.attr("alt"));
    $("#thumbnaillink").attr("href", "/MovieTv/?action=detail&id=" + imgobj.attr("id"));
    $("#thumbnaillink").css("float", "left");
    $(".jiaodian_tu ul li").each(function () { $(this).attr("class", "") });
    $(obj).attr("class", "on");
    if (imgobj.attr("bigimg") != "") {
        $("#thumbnailbig").attr("src", imgobj.attr("bigimg"));
    }
}

function shownewsbigimg(obj) {

    var imgobj = $(obj).find("img");     
    $("#newsbigimg").attr("href", "/News/?action=detail&id=" + imgobj.attr("id"));
    $(".jiaodian_right ul li").each(function () { $(this).attr("class", "") });
    $(obj).attr("class", "on");
    $("#newsbigimg").find("img").attr("src", imgobj.attr("src"));

}

function showvarietybigimg(obj,boxid) {

    $(".pics").each(function () { $(this).hide() });
    $(obj).attr("class", "on");
    $("#" + boxid).show();

}


function showqunyibigimg(obj, boxid) {

    var objbox=$(obj);
    $(".Number_anli li").each(function () { $(this).attr("class","") });
    objbox.attr("class", "Number_anli_on");
    if (objbox.attr("photo") != "") {
        $("#bigimgqunyi").attr("src", objbox.attr("photo"));
    }
    $("#hanggao").html("<strong class='Size14'>" + objbox.attr("title") + "</strong><br />" + objbox.attr("intro"));
}

function refresh(obj) {     
    $("#codeimg").attr("src", "/code.aspx?" + Math.random());
}

function showproductbigimg(obj) {
    $("#bigproductimg").attr("src", $(obj).attr("src"));
}

function deletecartitem(obj, id) {
    var param = "action=deletecartitem&id="+id;
    $.post("/ajax.aspx", param, function (x) {
        if (x == "1") {
            $(obj).parent().parent().remove();
        }
        else {
            alert("删除失败");
        }
    }, "html")
}


function updateshoppingcart(obj) {


}

function clearshoppingcart(obj) {

}

function homesearchtab(obj) {

    $(".index_search_title li").each(function () { $(this).removeAttr("class") });
    $(obj).attr("class", "search_on");

}

function clearsearchkey(obj) {
    if ($(obj).val() == "输入关键词 搜索整站资讯") {
        $(obj).val("");
    }
}

function searchinfo(obj) {
    var key = $(".index_banner input:eq(0)").val();
    var foldertxt =$.trim($(".index_search_title .search_on").text());
    var folder = "/Theatre/";
    if (foldertxt == "资讯")
    {
        folder="/News/";
    }
    if (foldertxt == "产品")
    {
        folder="/Product/";
    }
    window.location.href = folder+"?action=list&searchkey=" + escape(key) + "&x=15&y=13";
    
}

function homescollnext(obj) {
   
    

}

function homescollpre(obj) {

}

function showtuanti(obj, showid, hiddenid, parentclass) {

    $(obj).parent().attr("class", parentclass);
    $("#" + showid).attr("class", "cur");
    $("#" + hiddenid).removeAttr("class");
    $("#" + showid + "box").show();
    $("#" + hiddenid + "box").hide();

}

function showcathomelist(obj,id) {

    $(obj).parent().find("li").each(
    function (i) {
        if (i > 0) {
            if ($(this).find("img").length == 0) {
                $(this).attr("class", "titles");
            }
        }
    }
    );
    $(obj).attr("class", "titles_on2");
    $(obj).parent().parent().parent().find(".list_tu,.text_list").each(
        function (i) {
            $(this).hide();
        }
    );
    $("#" + id).show();
    $("#txt" + id).show();


}


function editvideos(obj, videoid) {
    window.location.href = "/?action=showuploadvideo&id=" + videoid;
}


function deletevideo(obj, id) {
    if (window.confirm("确定删除此视频？")) {
        var param = "action=deletevideos&id=" + id;
        $.post("/ajax.aspx", param, function (x) {
            if (x == "1") {
                alert("删除成功");
                $(obj).parent().parent().remove();
            }
            else {
                alert(x);
            }
        }, "html");
    }
}


function UploadFilesWin(objid, subfolder) {
    var url = "/adminmanage/index.aspx?action=showuploadcontrol";
    if (subfolder != null) {
        url = url + "&subfolder=" + subfolder;
    }
    var result = window.showModalDialog(url, window, "dialogHeight:200px,dialogWidth:560px;");
    if (result != null) {
        $("#" + objid).val(result);
    }
}


function saveusers(obj, formid) {

    var param = "";
    $("#" + formid + " :input").each(function () {
        if ($(this).attr("type") == "radio" || $(this).attr("type") == "checkbox") {
            if ($(this).attr("checked") == true) {
                param += $(this).attr("name") + "=" + $(this).val() + "&";
            }
        }
        else {
            param += $(this).attr("name") + "=" + $(this).val() + "&";
        }
    });

    $.post("/ajax.aspx", param, function (x) {
        if (x == "1") {
            alert("保存成功");
        }
        else {
            if (x == "2") {
                alert("旧密码不正确");
            }
        }
    }, "html");


}

function updatepassword(obj, formid) {

    if ($("#oldpassword").val() != "") {
        if ($.trim($("#password").val()) != "" && $("#password").val() == $("#newpassword").val()) {
            saveusers(obj, formid);
        }
        else {
            if ($.trim($("#password").val()) == "") {
                alert("新密码不能为空");
            }
            else {
                alert("输入的新密码不一致");
            }
        }
    }
    else {
        alert("请输入旧密码");
    }


}

function GetCompanyInfoByCode(objid) {
    var code = $("#" + objid).val();
    var param = "action=getcompanyinfobycode&authcode=" + code;
    $.post("/ajax.aspx", param, function (x) {
        if (x != "") {
            eval("var json_=" + x);
            $("#companyid").val(json_.id);
            $("#companyphone").val(json_.phone);
            $("#companytitle").val(json_.title);
            $("#companyaddress").val(json_.address);
            $("#bannerurl").val(json_.banner);
            $("#url").val(json_.url);
            $("#contacter").val(json_.contacter);
            alert("认证成功");
        }
        else {
            alert("认证码不正确");
        }
    }, "html")
} 
