﻿// JScript 文件
$(document).ready(function(){  
    setTimeout("GetXML(1000)",3000);
   GetData();
   BtnSearch();
   style_bar(1);
   
    $("#_ctl0_ContentPlaceHolder1_newsbar1").css("display","none");
    $("#_ctl0_ContentPlaceHolder1_newsbar2").css("display","block");
    $("#_ctl0_ContentPlaceHolder1_newsbar3").css("display","none");
    $("#_ctl0_ContentPlaceHolder1_newsbar4").css("display","none");
    $("#module1").attr("src","ptgt/images/tzgg2.gif");
    $("#module2").attr("src","ptgt/images/zpgxxgg.gif");
    $("#module3").attr("src","ptgt/images/tddjgg2.gif");
    $("#module4").attr("src","ptgt/images/zdsxgg2.gif");
});

var countGetXML = 0;
var limitGetXML = 10;

var GetXML = function(t){  	
	$.ajax({
		url: 'PTGT/XMLFiles/vote.xml',
		type: 'GET',
		dataType: 'xml',
		timeout: t,
		error: function(){
		    countGetXML++;
		    if (countGetXML != limitGetXML)
		    {
		        setTimeout("GetXML(" + (parseInt(t) + 1000) + ")",2000);
		    }
		    else
		    {
			    alert('网络超时,读取数据失败!');
			}
		},
		success: function(xml){
			LoadVote(xml);			
		}
	});
}
	
IsChecked = function(elementID){
    var sChecked = "";
    $('#' + elementID + ' input').each(function(){
	    var el = $(this);
	    if ((el.attr('type').toLowerCase() == 'checkbox'))
		    if(this.checked)
		        sChecked = sChecked + "," + el.val();			
	});
	if(sChecked != "")
	    sChecked = sChecked.substring(1);
	window.open("ptgt/VoteOnline.aspx?CheckedIndexes=" + escape(sChecked));
}   

//添加问卷调查内容
var LoadVote = function(xml) {
	var item_VoteOption = $('ul#VoteOption');
	item_VoteOption.html("");
	item_VoteOption.hide();
	var item_title = $(xml).find('theme').attr('title');
	$('<li class="title"></li>')
			.html(item_title)
			.appendTo(item_VoteOption);
	$(xml).find('theme').find('option').each(function(){
		var item_text = $(this).text();
		var item_value = $(this).attr("value");
		$('<li></li>')
			.html("<input type=\"checkbox\" class=\"checkbox\" name=\"votecheck\" value='" + item_value + "' />" + item_text)
			.appendTo(item_VoteOption);
	});
	
	$('<li class="foot"></li>')
			.html("<input type=\"button\" class=\"button\" id=\"butSave\" name=\"butSave\" value=\"提交\" onclick=\"IsChecked('votebar');\" /><input type=\"button\" class=\"button\" id=\"butSelect\" name=\"butSelect\" value=\"查看\" onclick=\"javascript:window.open('ptgt/VoteOnline.aspx');\" />")
			.appendTo(item_VoteOption);
	item_VoteOption.fadeIn('slow');
}

//填充数据
var GetData = function(){
    $("<option value='1'>按标题</option>").appendTo("#sType");
    $("<option value='2'>按内容</option>").appendTo("#sType");
    var path="ptgt/Controls/GetSearchDataXML.aspx?type=0";
    $.ajax({
        url:path,
        type:'Post',
        dataType:'xml',
        success:function(xml)
        {
           for(var i=0;i<$(xml).find("classid").length;i++)
           {
		       $("<option value='"+$(xml).find('classid').eq(i).text()+"'>"+$(xml).find("classname").eq(i).text()+"</option>").appendTo("#sTitle");
		   }
        }
    });
}
//点击搜索触发的事件
var BtnSearch = function(){
    $("#btnSearch").click(function(){
        var sType=$("select[@name='sel_type'] option[@selected]").val();
        var sInfo=$("#keywords").val();
        if(sInfo=="请输入关键字" || sInfo=="")
        {
            alert("请输入关键字！");
            $("#keywords").focus();
            return;
        }
        window.open("ptgt/ShowSearchResult.aspx?TypeID="+sType+"&Info="+sInfo);
    });
}

function style_mode(a){
	if (a=="1"){
		link_table1.style.display = "block";
		link_table1_1.style.display = "none";
		link_table2.style.display = "none";
		link_table3.style.display = "none";
		link_table4.style.display = "none";
		document.getElementById("style_1").className = "font17";
		document.getElementById("style_1_1").className = "font18";
		document.getElementById("style_2").className = "font18";
		document.getElementById("style_3").className = "font18";
		document.getElementById("style_4").className = "font18";
	}
	if (a=="5"){
		link_table1.style.display = "none";
		link_table1_1.style.display = "block";
		link_table2.style.display = "none";
		link_table3.style.display = "none";
		link_table4.style.display = "none";
		document.getElementById("style_1").className = "font18";
		document.getElementById("style_1_1").className = "font17";
		document.getElementById("style_2").className = "font18";
		document.getElementById("style_3").className = "font18";
		document.getElementById("style_4").className = "font18";
	}
	if(a=="2"){
		link_table1.style.display = "none";
		link_table1_1.style.display = "none";
		link_table2.style.display = "block";
		link_table3.style.display = "none";
		link_table4.style.display = "none";
		document.getElementById("style_1").className = "font18";
		document.getElementById("style_1_1").className = "font18";
		document.getElementById("style_2").className = "font17";
		document.getElementById("style_3").className = "font18";
		document.getElementById("style_4").className = "font18";
	}
	if(a=="3"){
		link_table1.style.display = "none";
		link_table1_1.style.display = "none";
		link_table2.style.display = "none";
		link_table3.style.display = "block";
		link_table4.style.display = "none";
		document.getElementById("style_1").className = "font18";
		document.getElementById("style_1_1").className = "font18";
		document.getElementById("style_2").className = "font18";
		document.getElementById("style_3").className = "font17";
		document.getElementById("style_4").className = "font18";
	}
	if(a=="4"){
		link_table1.style.display = "none";
		link_table1_1.style.display = "none";
		link_table2.style.display = "none";
		link_table3.style.display = "none";
		link_table4.style.display = "block";
		document.getElementById("style_1").className = "font18";
		document.getElementById("style_1_1").className = "font18";
		document.getElementById("style_2").className = "font18";
		document.getElementById("style_3").className = "font18";
		document.getElementById("style_4").className = "font17";
	}
}	
function style_bar(a){
    if (a=="1"){
        $("#_ctl0_ContentPlaceHolder1_News1").css({display:"block"});
        $("#_ctl0_ContentPlaceHolder1_News2").css({display:"none"});
        $("#pic1").attr("src","ptgt/images/bar1.gif");
        $("#pic2").attr("src","ptgt/images/bar2.gif");
	}
	if(a=="2"){
        $("#_ctl0_ContentPlaceHolder1_News1").css("display","none");
        $("#_ctl0_ContentPlaceHolder1_News2").css("display","block");
		$("#pic1").attr("src","ptgt/images/bar11.gif");
        $("#pic2").attr("src","ptgt/images/bar22.gif");
	}
}
function GetBarInfo(classid){
    //通知公告
    if(classid=="1")
    {
        $("#_ctl0_ContentPlaceHolder1_newsbar1").css("display","block");
        $("#_ctl0_ContentPlaceHolder1_newsbar2").css("display","none");
        $("#_ctl0_ContentPlaceHolder1_newsbar3").css("display","none");
        $("#_ctl0_ContentPlaceHolder1_newsbar4").css("display","none");
        $("#module1").attr("src","ptgt/images/tzgg.gif");
        $("#module2").attr("src","ptgt/images/zpgxxgg2.gif");
        $("#module3").attr("src","ptgt/images/tddjgg2.gif");
        $("#module4").attr("src","ptgt/images/zdsxgg2.gif");
    }
    if(classid=="2")
    {
        $("#_ctl0_ContentPlaceHolder1_newsbar1").css("display","none");
        $("#_ctl0_ContentPlaceHolder1_newsbar2").css("display","block");
        $("#_ctl0_ContentPlaceHolder1_newsbar3").css("display","none");
        $("#_ctl0_ContentPlaceHolder1_newsbar4").css("display","none");
        $("#module1").attr("src","ptgt/images/tzgg2.gif");
        $("#module2").attr("src","ptgt/images/zpgxxgg.gif");
        $("#module3").attr("src","ptgt/images/tddjgg2.gif");
        $("#module4").attr("src","ptgt/images/zdsxgg2.gif");
    }   
    if(classid=="3")
    {
        $("#_ctl0_ContentPlaceHolder1_newsbar1").css("display","none");
        $("#_ctl0_ContentPlaceHolder1_newsbar2").css("display","none");
        $("#_ctl0_ContentPlaceHolder1_newsbar3").css("display","block");
        $("#_ctl0_ContentPlaceHolder1_newsbar4").css("display","none");
        $("#module1").attr("src","ptgt/images/tzgg2.gif");
        $("#module2").attr("src","ptgt/images/zpgxxgg2.gif");
        $("#module3").attr("src","ptgt/images/tddjgg.gif");
        $("#module4").attr("src","ptgt/images/zdsxgg2.gif");
    }  
    if(classid=="4")
    {
        $("#_ctl0_ContentPlaceHolder1_newsbar1").css("display","none");
        $("#_ctl0_ContentPlaceHolder1_newsbar2").css("display","none");
        $("#_ctl0_ContentPlaceHolder1_newsbar3").css("display","none");
        $("#_ctl0_ContentPlaceHolder1_newsbar4").css("display","block");
        $("#module1").attr("src","ptgt/images/tzgg2.gif");
        $("#module2").attr("src","ptgt/images/zpgxxgg2.gif");
        $("#module3").attr("src","ptgt/images/tddjgg2.gif");
        $("#module4").attr("src","ptgt/images/zdsxgg.gif");
    }  
}