﻿$(document).ready(function() {
    $("img").error(function() {
        $(this).attr("src", "/images/dftPro.jpg");
   });
    if (window.location.toString().indexOf("http://search.") > -1) {
        $("#search").attr("target", "_self");
    }
    var action;
    $("#searchnav>li").each(function(i) {     
  
           if ($("#selected").val() == "{menu_selected}")
             return false;
           if ($("#selected").val() == i)
          {                       
            $(this).addClass("searchnav_on");
            var keyword= document.getElementsByTagName("input")[0].value;
             switch (i) {
                    case 0:
                        action = "http://search.u69cn.com/supply/s.shtml?keyword="+encodeURI(keyword) ;
                        break;
                    case 1:
                       action = "http://search.u69cn.com/company/s.shtml?keyword="+encodeURI(keyword) ;        
                        break;
                    case 2:
                        action = "http://search.u69cn.com/sell/s.shtml?keyword="+encodeURI(keyword) ;   
                        break;
                    case 3:
                        action = "http://search.u69cn.com/aspx/search1.aspx";
                        break;
                        }
                     $("#search").attr("action", action);
           }
        else
              $(this).addClass("searchnav_off");       
        });
        
        
        
    $("#nav-bar>ul>li").each(function(i) {
        if ($("#selectbaner").val() == "{menu1_selected}")
            return false;
        if ($("#selectbaner").val() == i)
            $(this).addClass("cick");
        else
            $(this).removeClass("");
    });
    });
    
    function formsubmit(id)
    {   
     var keyword= id.getElementsByTagName("input")[0].value;
      if(keyword!="请输入关键词"&&keyword!="")
      {
        return true;
      }
      else
      {
        id.getElementsByTagName("input")[0].focus();
        return false;
       }
    }






















//    switch ($("#selected").val()) {
//              case 0:  
//                  action = "http://search.u69cn.com/supply/s.shtml";  
//              break;  
//               case 2:  
//                 action = "http://search.u69cn.com/sell/s.shtml";  
//                break;  
//            case 1:  
//                 action = "http://search.u69cn.com/demand/s.shtml";  
//                  break;  
//             case 3:  
//                   action = "http://search.u69cn.com/aspx/search1.aspx";  
//                  break;  
//    }
//  $("#search").attr("action", action);



//    $("div.nav-bottom>ul>li").each(function() {
//        if ($(this).attr("class") != "selected")
//            $(this).hover(function() { $(this).addClass("selected") }, function() { $(this).removeClass("selected") });
//    });
//    try {
//        $.post(
//            "/Tools/Ajax.aspx",
//            "t=checkloginstate",
//            function(xml, success) {
//                if ($(xml).find("result").attr("value") == "1")
//                    $("#login").html($(xml).find("result").attr("text") + "：您好，欢迎来到中华商机网！").css("line-height", "20px");
//            },
//            "xml"
//        );
//    }
//    catch (e) {
//    }
//    $("#top-img").slideToggle("flow", function() {
//        var iThis = this;
//        $(iThis).append("<div class=\"close-ico\"></div>").find("img").css("position", "relative");
//        $("div.close-ico").css({ top: "0px", left: $(iThis).find("img").width() + 10 + "px" }).click(function() {
//            $(iThis).slideToggle("flow");
//        });
//        window.setTimeout("close()", 10000);
//    });
//    navMenu("HomeNav", "_head_index_content", 0);
//    navMenu("ProductNav", "_head_product_content", 0);
//    navMenu("navMenu", "_menuNav", -270);


//    navMenu("ProductNav1", "_head_product_content1", 0);
//    navMenu("ProductNav11", "_head_product_content11", 0);
//    navMenu("ProductNav111", "_head_product_content111", 0);
//});

//function close() { 
//    if ($("#top-img").css("display") == "block")
//        $("#top-img").slideToggle("flow");
//}

//function navMenu(menuid, boxid, left) {
//    var iThis = $("#" + menuid + "");
//    iThis.mouseover(function() {
//        $(this).css("position", "relative");
//        $("#" + boxid + "").css({ display: "block", left: iThis.offset().left + left, top: iThis.offset().top + 12 + "px" }).mousemove(function() {
//            $(this).css({ display: "block", left: iThis.offset().left + left, top: iThis.offset().top + 12 + "px" });
//        }).mouseout(function() {
//            $(this).css("display", "none");
//        });
//    }).mouseout(function() {
//        $("#" + boxid + "").css("display", "none");
//    }).mousemove(function() {
//        $("#" + boxid + "").css({ display: "block", left: iThis.offset().left + left, top: iThis.offset().top + 12 + "px" }).mouseout(function() {
//            $(this).css("display", "none");
//        });
//    });
//}
