﻿function getNewCart(_cartpart, _this, _selectClass, _cartconpart, _connum) {
    $("#" + _cartpart + " li a").removeClass(_selectClass);
    $(_this).addClass(_selectClass);
    $("#" + _cartconpart+" ul").hide();
    $("#" + _cartconpart + " ul:eq(" + _connum + ")").show();
}
function getNewCart1(_cartpart, _this, _selectClass, _cartconpart, _connum) {
    $("#" + _cartpart + " li a").removeClass(_selectClass);
    $(_this).addClass(_selectClass);
    $("#" + _cartconpart + _connum).nextAll().hide();
    $("#" + _cartconpart + _connum).prevAll().hide();
    $("#" + _cartconpart + _connum).show();
}
function getNewCart2(oi, url) {
    $(".announce .ac").removeAttr("class");
    $(".announce ul").hide();
    $(".announce dd").eq(oi).attr("class", "ac");
    $(".announce ul").eq(oi).show();
    $(".announce .more").attr("href", url);
}
String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); } 
function TrimMoreToOnly(str) {
    str = str.Trim();
	var reg = /\s{1,}/g;
	var arr = str.split(reg);
	var strturn = "";
	for (var i = 0; i < arr.length; i++) {
	    if (arr[i] != "") {
	        strturn += encodeURIComponent(arr[i]) + "+";
	    }
	}
	strturn = strturn.substring(0, strturn.length - 1);
	return strturn;

}
function Request(strName) {
    var strHref = window.document.location.href;
    var intPos = strHref.indexOf("?");
    var strRight = strHref.substr(intPos + 1);
    var arrTmp = strRight.split("&");
    for (var i = 0; i < arrTmp.length; i++) {
        var arrTemp = arrTmp[i].split("=");
        if (arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
    }
    return "";
}

function searchxxxgk(txtid, selecttypeid, selectcatid) {
    var key = TrimMoreToOnly(document.getElementById(txtid).value);
    var param = "?op=search&key=" + key + "&type=" + document.getElementById(selecttypeid).value + "&scatid=" + document.getElementById(selectcatid).value + "&catid=" + Request("catid");
    location.href = param;
}
//全站搜索
function AllSearch() {
    if (document.getElementById("TxtSearch").value == "") {
        alert("请输入搜索内容");
        document.getElementById("TxtSearch").focus();
        return
    }
    var key = escape(TrimMoreToOnly(document.getElementById("TxtSearch").value));
    var param = "/News/Search.html?key=" + key;
    location.href = param;
}

function AllAdvSearch() {
    window.open("/News/AdvSearch.html", "_blank");
}

function getWeather() {
    var url = "http://www.weather.com.cn/html/weather/101211101.shtml";
    var city = "舟山";
    $.ajax({
        type: "POST",
        url: "/WebServer/GetWeather.ashx",
        data: "url=" + url + "&city=" + city,
        dataType: "html",
        success: function(retv) {
     
            $(".travelinfo").html("<div id='divweather' style='font-family: 宋体;text-indent:2em;'>"+retv+"</div>");
        }
    });
}
$(function() {
    if (location.pathname.toLowerCase() == "/" || location.pathname.toLowerCase() == "/default.aspx" || location.pathname.toLowerCase() == "/index.html") {
        getWeather();
    }
})
