﻿
function FormatDate(date) {
    var arr = date.split('/');

    return arr[2] + '-' + arr[0] + '-' + arr[1];
}
//search column
function SearchColumn(id) {
    $("#column").val(id);
    if ($("#keyword").val() == "请输入关键词") {
        $("#keyword").val("");
    }
    var column = $("#hd-column").val();
    var date = $("#menuDatePicker").val();
    $("#hd-datepicker").val(date);
    $("#page").val("1");
    $("#myform").submit();
}
//search and pagination
function Search(currect_page) {
    if ($("#title_content").val() == "1") {
        if ($("#keyword").val() == "请输入关键词") {
            $("#keyword").val("");
        }
        var column = $("#hd-column").val();
        var date = $("#menuDatePicker").val();
        $("#hd-datepicker").val(date);
        if (currect_page != "0") {
            $("#page").val(currect_page);
            $("#column").val(column);
        } else {
            $("#page").val("1");
        }
        $("#myform").submit();

    }
    else {
        window.open("http://search.bhi.com.cn/default.aspx?keyword=" + escape($("#keyword").val()) + "&cbcolumns=" + escape("项目标讯"), "_blank");  
    }
}
function SearchKeyword(word){
    $("#keyword").val(word);
    Search(1);
}

//js about the bidding column
$(document).ready(function() {
//关键词输入框的提示//   
     if($("#keyword").val()==""){
        $("#keyword").val("请输入关键词");
        $("#keyword").css("color","#727272");
    }
        $("#keyword").click(function(){
            var word = $(this).val();
            if(word=="请输入关键词"){
                $(this).val("");
                $(this).css("color","#000000");
            }
        });
           $("#keyword").blur(function(){
                var word = $(this).val();
                if(word==""){
                   $(this).val("请输入关键词");
                    $(this).css("color","#727272");
                }
           });
    //地区选择部分 
   $("#menuArea").click(function(){
        var top = $("#menuArea").position().top + 22;
        var left = $("#menuArea").position().left;
        $("#areapicker").css("top",top).css("left",left);
        $("#industrypicker").hide();
        $("#phasepicker").hide();
        $("#datepicker").hide();
        $("#areapicker").show();
        return false;
    });
    //行业选择部分
    $("#menuIndustry").click(function(){
        var top = $("#menuIndustry").position().top + 22;
        var left = $("#menuIndustry").position().left;
        $("#industrypicker").css("top",top).css("left",left);
        $("#areapicker").hide();
        $("#phasepicker").hide();
        $("#datepicker").hide();
        $("#industrypicker").show();
        return false;
    });
    
    //进展阶段选择
    $("#menuPhase").click(function(){
        var top = $(this).position().top + 22;
        var left = $(this).position().left;
        $("#phasepicker").css("top",top).css("left",left);
        $("#areapicker").hide();
        $("#industrypicker").hide();
        $("#datepicker").hide();
        $("#phasepicker").show();
        return false;
    
    });
    
    $("#areapicker").click(function(eventObj){
        eventObj.stopPropagation();
    });
    $("#industrypicker").click(function(eventObj){
        eventObj.stopPropagation();
    });
    $("#phasepicker").click(function(eventObj){
        eventObj.stopPropagation();
    });
    
    //load the rightcolumn data
    if(location.href.indexOf("BiddingList")>0){
    var arr = new Array("tags","projects-pre","construction-pre","specialtopic-pre");
    LoadRightColumns(arr);
    }else{
    var arr = new Array("tags","construction-pre","investment-pre", "projects-pre", "specialtopic-pre","reporting-pre");
    LoadRightColumns(arr);
    }
    //the tab info
    $("#tabItemPre").tabs({
        event: 'mouseover'
    });
    //the css of the content of the main table
//    $(".listTable td").hover(function() {
//        $(this).parent().children().css("background-color", "#F9E1C5");
//    }, function() {
//        $(this).parent().children().css("background-color", "#ffffff");
//    });
    //the css of the content of the tab
    $(".tabTable td").hover(function() {
        $(this).parent().children().css("background-color", "#F9E1C5");
    }, function() {
        $(this).parent().children().css("background-color", "#ffffff");
    });
    $(".td_title").hover(function() {
        $(this).css("text-decoration", "underline");
    }, function() {
        $(this).css("text-decoration", "none");
    });
});
function output() {
    var infoid = "";
    $("input[name='selectedID']:checked").each(function() {
        infoid += $(this).val() + ",";
    });

    if (infoid.length > 0) {
        infoid = infoid.substring(0, infoid.length - 1);
    }
    window.open("/Generate/Generate_Bidding.aspx?id=" + infoid);
}

function printlist() {
    var infoid = "";
    $("input[name='selectedID']:checked").each(function() {
        infoid += $(this).val() + ",";
    });

    if (infoid.length > 0) {
        infoid = infoid.substring(0, infoid.length - 1);
    }
    window.open("printlist.aspx?id=" + infoid);
}
//查看所选
function LookSelected(){
    var infoid = "";
    $("input[name='selectedID']:checked").each(function(){ 
        infoid += $(this).val()+",";
    });
    if(infoid.length>0){
        infoid=infoid.substring(0,infoid.length-1);
        window.open("/bidding/show_bidding.aspx?id="+infoid);
    }
    else{
        alert("请先选择要查看的信息...");
    }
}
