﻿//
//name: tools
//copyright: zhang
//date: 2011-7-1
var $G=function(obj){
    return document.getElementById(obj);
}
var colid = 2;  //默认搜索栏目
function GetSear() {
    searchFocus();
    if ($G("searchValue").value == "") {/// <reference path="searchPro.js" />
        alert("搜索关键词不能为空！");
        return false;
    }  
    switch(colid)
    {
        case 1:
            break;
        case 2:
            colid = 8;    //供求
            break;
        case 3:
            colid = 10;  //公司
            break;
        case 4:
            colid = 8;   //农资
            break;
        case 5:
            colid = 14;  //农技
            break;
        case 6:
            colid = "google";
            break;
        case 7:
            colid = "baidu";
            break;
    }
    var url = "/List.aspx?chid=" + colid + "&fieldname=title&keyword=" + encodeURI($G("searchValue").value) + "&Search=1";
    if (colid == "google")
        url = "http://www.google.com.hk/search?hl=zh-CN&q=" + encodeURI($G("searchValue").value);
    else if (colid == "baidu")
        url = "http://www.baidu.com/s?tn=zhangjjhua_pg&tr=iU-nPX0pWEC&tn=zhangjjhua_pg&word=" + encodeURI($G("searchValue").value);     
    
    window.open(url);
}
//首页搜索框得到焦点
function searchFocus() {
    if ($G("searchValue").value.indexOf("请输入关键字") > -1) {
        $G("searchValue").value = "";
    }
}

function setHomePage(obj) {   //this  设为首页
    obj.style.behavior = 'url(#default#homepage)';
    obj.setHomePage('http://www.seed-china.com/');
    //this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.seed-china.com');
}
function addFavorite() {         //添加收藏
    window.external.addFavorite('http://www.seed-china.com/', '种子网-天鸿种子网-首页');
}

function writeIndexAd() {
    var focus_width = 380;
    var focus_height = 160;
             var text_height = 0;
             var swf_height = focus_height; //+text_height
             pics = '/new/ad/banner01.jpg|new/ad/380-wh2012.jpg|new/ad/banner05.jpg|new/ad/banner06.jpg|new/ad/banner07.jpg|new/ad/banner08.jpg';
             var links = 'http://www.taoseed.com|http://seed-china.com/2012/|http://www.xyseed.com|http://www.alluxseed.com/|http://www.zsseed.com/|http://www.just-team.cn'
             var texts = '淘种网|2012武汉种子交易会|湘研种业|爱绿士种业|北京卓生农业|哈尔滨佳禾农业'
             document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + focus_width + '" height="' + swf_height + '">');
             document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="/images/Flash_.swf"><param name="quality" value="high"><param name="bgcolor" value="#ffffff">');
             document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
             document.write('<param name="FlashVars" value="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '">')
             document.write('<embed src="/images/Flash_.swf" wmode="opaque" FlashVars="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '" menu="false" bgcolor="#ffffff" quality="high" width="' + focus_width + '" height="' + swf_height + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
             document.write('</object>');
         
}

///  url:flash地址，width:flash宽度，height: flash高度
function writeFlash(url, width, height) {
    document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" ");
    document.write(" width=" + width + " height=" + height + "> ");
    document.write(" <param name=\"movie\" value=" + url + " /> ");
    document.write(" <param name=\"quality\" value=\"high\" /> ");
    document.write(" <param name=\"wmode\" value=\"transparent\" /> ");
    document.write(" <embed src=" + url + " quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=" + width + " height=" + height + "></embed> ");
    document.write(" </object>");
}

//    输出日期+时间+星期
function writeDate() {
    today = new Date();
    var d = new initArray(
     "星期日",
     "星期一",
     "星期二",
     "星期三",
     "星期四",
     "星期五",
     "星期六");
    //document.write(today.getYear()+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日   ");
    document.write(
     "",
  //   today.getYear(), "年",
     today.getMonth() + 1, "月",
     today.getDate(), "日   ",
     d[today.getDay() + 1],
     "");
}
function initArray() {
    this.length = initArray.arguments.length;
    for (var i = 0; i < this.length; i++)
        this[i + 1] = initArray.arguments[i]
} 
function bindTabLi() {
    var tablist = document.getElementById("tabTextBox").getElementsByTagName("li");
    for (var i = 0; i < tablist.length; i++) {
        if (window.addEventListener) {

            tablist[i].addEventListener('click', new Function("tabLi(" + i + ");"), false);
           
        }
        else if (window.attachEvent) {  //attachEvent   
         
            tablist[i].attachEvent('onclick', new Function("tabLi(" + i + ");"));
        }
    }

    bindFn("searchValue", "click", searchFocus);
    bindFn("searchButton", "click", GetSear);
    document.getElementById("weathiF").src = 'http://m.weather.com.cn/m/pn4/weather.htm';
}  
//菜单，搜索选项卡
function tabLi(obj) {
    var tablist = document.getElementById("tabTextBox").getElementsByTagName("li");
    for (var i = 0; i < tablist.length; i++) {
        tablist[i].className = "";
    }
    colid = obj+1;

    tablist[obj].className = "selTab";
}
function bindFn(obj,fnName, fn) {
   
    if (typeof (obj) != Object)
        obj = $G(obj);
    if (window.attachEvent)
        obj.attachEvent("on"+fnName, fn);
    if (window.addEventListener)
        obj.addEventListener(fnName, fn, false);
}

function tabToggle(tabNum, tabIndex)  //共几个tab切换,当前要显示第几个
{
    for (k = 1; k <= tabNum; k++) {
        GetId("tab" + k).style.display = 'none'; //隐藏所有的tab
        GetId("tabTitle" + k).className = 'tabTitle';
    }
    GetId("tab" + tabIndex).style.display = 'block'; //显示想要的tab
    GetId("tabTitle" + tabIndex).className = 'tabTitle seletedTab';
}
function tab_2(objShow, objNone) {
    $G(objShow).style.display = 'block';
    $G(objShow + "Tab").style.borderBottom = "0px";
    $G(objNone).style.display = 'none';
    $G(objNone + "Tab").style.borderBottom = "1px solid #E1E1E1";
}
function overSty(obj) {
    obj.className = "overBox";
}

 
if (typeof ($) != "undefined") {   //undefined
    $(function () {

        $("#temp1").Slide({    //推荐品牌滚动效果
            effect: "scroolY",
            speed: 500,
            timer: 3000
        });
        $("#temp2").Slide({
            effect: "scroolX",
            speed: "normal",
            timer: 3000
        });
        $(".proMore a[name!='more']").mouseover(    //推荐产品切换效果
               function () {
                   $(".proMore a").removeClass("on");
                   $(this).addClass("on");

                   $(".ProContent").css("display", "none");
                   var index = $(".proMore a").index($(this)); //当前元素是选择结果中的第一几个

                   $("#topPro" + index).css("display", "block");
               }
        //  function () { alert("out"); $(this).removeClass("on"); }

            )
    });
}
 
