﻿var Browser = new Object();

Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument != 'undefined');
Browser.isIE = window.ActiveXObject ? true : false;
Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox") != - 1);
Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("safari") != - 1);
Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != - 1);
var global_pageOverflow = "";
var deNode="//DocumentElement/_x0033_65AD/";

//返回上一个页面
function HistoryBack()
{
	return window.history.back(window.history.length - 1);
}

//在url中读出指定的querystring
Request = {
	queryString : function(item){
		var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)","i"));
		return svalue ? svalue[1] : svalue;
	}
}

Response = { 
	redirect : function() {
		var url = Request.queryString("ReturnUrl");
		
		if (url)
			window.location.replace(unescape(url));
	}	
}

/*功能：格式化字符串
**使用方法：var s = "aaa{0}{1}";s = s.format(1,2);
*/
String.prototype.format=function() {
	var s = this;
	var args;	
	for(var i = 0,count = arguments.length;i < count;i ++)
	{
		args = arguments[i];
		if (args == null)
			args = "";					
		s = s.split("{" + (i).toString() + "}").join(args);
	}	
	return s;
}
 function checkAll(boolvalue){
        if(document.all.chk.length>1){
            for(var i=0;i<document.all.chk.length;i++){
                document.all.chk[i].checked = boolvalue;            
            }
        }
        else
            document.all.chk.checked = boolvalue;
    }
// 显示数据载入框
function showLoadingBox()
{
	global_pageOverflow = document.body.style.overflow;
	document.body.style.overflow = "hidden";
     var sWidth,sHeight;
            sWidth=document.body.offsetWidth;
            sHeight=screen.height;
            var bgObj=document.createElement("div");
            bgObj.setAttribute('id','bgDiv');
            bgObj.style.position="absolute";
            bgObj.style.top="0";
            bgObj.style.background="#ccc";
            bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
            bgObj.style.opacity="0.6";
            bgObj.style.left="0";
            bgObj.style.width=sWidth + "px";
            bgObj.style.height=sHeight + "px";
            document.body.appendChild(bgObj);
	var divBox = document.createElement("DIV");
	divBox.id = "divLoading";
	document.body.appendChild(divBox);
	
	// 计算显示位置
	var w=150;
	var h=divBox.offsetHeight;
	var bodyW=document.body.clientWidth;
	var bodyH=document.body.clientHeight;
	
	l=bodyW-150;
	t=40;
	

	divBox.innerHTML = '<div style="position:absolute;z-index:999;top:'+t+'px;left:'+l+'px;" class="loadingBox"><img src="/images/loading.gif" align="absmiddle" border="0" >' + " 数据载入中,请稍候..." + '</div>';
	
	setTimeout("hideLoadingBox()",1000);
}

// 隐藏数据载入框
function hideLoadingBox()
{
	document.body.style.overflow = global_pageOverflow;	
	document.body.removeChild($("bgDiv"));
	var obj = $("divLoading");
	
	if(obj)
	{
		obj.style.display = "none";
		document.body.removeChild(obj);
	}
}


//去掉首尾空格
String.prototype.trim=function() {
  return this.replace(/(^\s*)|(\s*$)/g,"");
}


function $(){
	var elements=new Array();
	for (var i=0; i < arguments.length; i++)
	{
		var element=arguments[i];
		if (typeof element=='string')
			element=document.getElementById(element);
			
		if (arguments.length==1)
			return element;
			
		elements.push(element);
	}
	return elements;
}
//获取单选值
function $R(rName)
{
        var _value="";
		for(i=0 ;i<document.getElementsByName(rName).length;i++){
	        if(document.getElementsByName(rName)[i].checked == true){
	          _value = document.getElementsByName(rName)[i].value;
	        }
	}
	return _value;
}


function OpenWindow(FileName,WW,WH){
 var WL=(screen.width-WW)/2;
 var WT=(screen.height-WH)/2;
 window.showModelessDialog(FileName,'', 'scroll:1; status:0; help:0; resizable:1; dialogWidth:' + WW + 'px; dialogHeight:' + WH + 'px');
}
 
function GetPictureCode(path,url){
    return "<a href=\""+url+"\"><img src=\"/uploads/"+path+"\" border=0></a>";
}
function GetFlashCode(path,w,h){
    return "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+w+"\" height=\""+h+"\"  codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\">"+
  "<param name=\"movie\" value=\"/uploads/"+path+"\">"+
  "<param name=\"quality\" value=\"high\">"+
  "<embed src=\"/uploads/"+path+"\" quality=\"high\" width=\""+w+"\" height=\""+h+"\"  pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed>"+
"</object>";
}
function exist(id){
    var s=document.getElementById(id);
    if(s){return true}
    else{return false}
}

function showTab(obj){
    var id=obj.id.substring(0,3);
    switch(id)
    {
        case "001":
	        var arr = [id+"0",id+"1",id+"2",id+"3"];
            break;
         case "002":
	        var arr = [id+"0",id+"1"];
            break;
        case "003":
	        var arr = [id+"0",id+"1"];
            break;
        default:
	        var marr = [id+"0",id+"1",id+"2",id+"3"];
            break;
   }
		for(var i=0;i<arr.length;i++){
		if(obj.id==arr[i]){
			document.getElementById(arr[i]).className="queryon";
			document.getElementById(arr[i]+i).style.display="block";
		}
		else{
			document.getElementById(arr[i]).className="queryoff";
			document.getElementById(arr[i]+i).style.display="none";

		}
    }
}
//二级频道窗口切换效果，适用于2个tag情况 id 为q_1,u_1,1_2,u_2
function showMiddleTab(obj){

       if(obj==1){
	        	document.getElementById("q_1").className="queryon";
			document.getElementById("u_1").style.display="block";
	       		document.getElementById("q_2").className="queryoff";
			document.getElementById("u_2").style.display="none";
	}else{
			document.getElementById("q_2").className="queryon";
			document.getElementById("u_2").style.display="block";
	       		document.getElementById("q_1").className="queryoff";
			document.getElementById("u_1").style.display="none";
	
	}
}
//产品最终页面tag切换效果
function SetProductTags(obj){
    for(var i=1;i<=3;i++){
        if(i!=obj){
        document.getElementById("a_"+i).className="taboff";
        document.getElementById("d_"+i).style.display="none";
        
        }else{
        document.getElementById("a_"+i).className="tabon";
        document.getElementById("d_"+i).style.display="";
        
        }
    }
}

 function chkVote(){
        var chk=false;
        if(document.all.votechk.length>1){
            for(var i=0;i<document.all.votechk.length;i++){
                if(document.all.votechk[i].checked){
                    chk=true;
                    break;
                }  
            }
        }
        if(chk==false){
            alert("请选择调查项！！！");
            return false;
        }
    }
function ViewVote(){
         window.open("/vote/result.aspx","365","left=400,top=200,height=290,width=475,toolbar=no,menubar=no,status=no,scrollbars=no");
}
function chkRadio(){
    var is=false;
	for(i=0 ;i<document.getElementsByName("voterad").length;i++){
        if(document.getElementsByName("voterad")[i].checked == true){
          is = true;
          break;
        }
    }
    if(!is){
        alert("请选择调查项！！！");
        return false;
    }

}
function submitComment()
{
    var _name=document.title;
    if($("CommentContent").value==""){
        alert("提示：\n\n请填写评论内容！！！");
        $("CommentContent").focus();
        return false;
    }
    var oHttpReq = new ActiveXObject("MSXML2.XMLHTTP");    
    var oDoc = new ActiveXObject("MSXML2.DOMDocument");
    oHttpReq.open("post","/Ajax.aspx?type=subCom&name="+encodeURI(_name)+"&content="+encodeURI($("CommentContent").value)+"", false);
    oHttpReq.send("");
    $("CommentContent").value=""; 
   loadComment(_name);
}
var result;
function loadComment(){
    var oHttpReq = new ActiveXObject("MSXML2.XMLHTTP");    
    oHttpReq.open("post","/Ajax.aspx?type=getCom&name="+encodeURI(document.title), false);
    oHttpReq.send("");
    result = oHttpReq.responseText;
    showPageData(1);
}
function showPageData(page){
   var str="";
   var pager=4;//每页显示评论条数
   var oDoc = new ActiveXObject("MSXML2.DOMDocument");
   oDoc.loadXML(result);
   var items = oDoc.selectNodes(deNode+"CommentContent");
   var itemsLength=items.length;
   var tPage=itemsLength%pager==0?itemsLength/pager:itemsLength/pager+1;
   tPage=parseInt(tPage);
   var et=parseInt(page*pager)-1;
   var st=et-pager+1;
   if(et>itemsLength-1)
   et=itemsLength-1;
    for(var i=st;i<=et;i++){
	    str+="<table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"24\"  bgcolor=\"#999999\" style=\"padding:5px 5px 5px 10px;border-right:1px solid #666666;border-bottom:1px solid #666666\">"+items[i].text+"</td><td width=\"25%\" align=\"right\" bgcolor=\"#999999\" style=\"padding-right:20px;border-bottom:1px solid #666666\">发布时间："+oDoc.selectNodes(deNode+"addDate")[i].text+"</td></tr>";
	        if(oDoc.selectNodes(deNode+"Reply")[i]!=null)
                str+="<tr><td colspan=2 bgcolor=\"#CCCCCC\"  style=\"padding:5 5 5 10;border-bottom:1px dashed #666666\"><font color=red>回复："+oDoc.selectNodes(deNode+"Reply")[i].text+"</font></td></tr>";
			else
                str+="<tr><td colspan=2 bgcolor=\"#CCCCCC\"  style=\"padding:5 5 5 10;border-bottom:1px dashed #666666\"><font color=red>暂未回复</font></td></tr>";
        str+="</table>";
    }
    if(itemsLength>pager){
    for(var j=1;j<=tPage;j++){
    
        str+="<span onclick='showPageData("+j+");' style='cursor:hand;";
        if(page==j) {str+="color:red;"}else{str+="color:white"};
        str+="'>&nbsp;"+j+"&nbsp;</span>&nbsp;";
    }
    }
    $("divComment").innerHTML= str;
}
function chgTab(id){
    for(var i=1;i<3;i++){
        if(i!=id){
        $("Tab"+i).className="";
        $("Con"+i).style.display="none";
        
        }else{
        $("Tab"+i).className="tab3on";
        $("Con"+i).style.display="";
        
        }
    }
}
