String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
function $(val)
{
    return document.getElementById(val);
}
function WinOpen(url,n,w,h)
{
    var left = (screen.width-w)/2;
    var top = (screen.height-h)/2;
    var f = "width="+w+",height="+h+",top="+top+",left="+left;
    var c = window.open(url,n,f);
    return c;
}
function WinOpenDialog(url,w,h)
{
    var feature = "dialogWidth: "+w+"px; dialogHeight: "+h+"px; center: yes; status :no; help: no;";
    showModalDialog(url,window,feature);
}
function showlist(path,chId,fieldName,fieldValue,_target)
{
    var encodeValue = escape(fieldValue);
    if(_target.toLowerCase()=='blank')
    window.open(path+'/List.aspx?ChId='+chId+'&FieldName='+fieldName+'&KeyWord='+encodeValue);
    else
    location.href(path+'/List.aspx?ChId='+chId+'&FieldName='+fieldName+'&KeyWord='+encodeValue);
}
function ReviewPadding(appPath,modelType,id,pageSize,pageIndex)
{
    var data = XmlHttpGetMethodText(appPath + "/SysTemplate/MoreReviewList.aspx?ModelType=" + modelType + "&Id=" + id + "&PageSize=" + pageSize + "&P=" + pageIndex);
    document.getElementById('review_morelist_' + modelType + '_' + id).innerHTML=data
}
function SetSearchField(appPath,val)
{
    if(val.value!=0)
    {
        document.getElementById("src_field_list").src=appPath+"/Common/GetSearchForm.aspx?id="+val.value+"&flag=1"
    }
    else
    {
        document.getElementById("src_field_list").src=appPath+"/Common/GetSearchForm.aspx?id="+val.value+"&flag=0"
    }
}
function GoSearch(appPath)
{
    var chid = document.getElementById("search_channel_list").value;
    var fieldName =  document.getElementById("search_field_list").value;
    var keyword = document.getElementById("search_txt_keyword").value.trim();
    if(keyword.length==0)
    {
        alert('请输入搜索内容！');
        return;
    }
    if(chid!=0&&fieldName!=0)
    {
        window.open(appPath+"/List.aspx?ChId="+chid+"&FieldName="+fieldName+"&KeyWord="+escape(keyword)+"&Search=1");
    }
    else
    {
        alert("请选择频道或字段！");
    }
}
function CheckNumber(val)
{
    var patt=/^\d+$/;
    return patt.test(val) ;
}
function go(f_url,pc,colid)
{
    var pi = $("txtPageNav"+colid).value;
    if(!CheckNumber(pi))
    {
        alert('页索引必须为数字字符！');
        return;
    }
    if(pi<1||pi>pc)
    {
        alert("页索引超出搜索范围！") ;
        return;
    }
    if(pi==1)
    {
        location.href(f_url) ;
        return;
    }
    var charindex = f_url.lastIndexOf(".")
    var preStr = f_url.substr(0,charindex);
    var ext = f_url.substr(charindex,f_url.length - charindex);
    var patt = /.*(\..*?)\?.*/i
    if(f_url.replace(patt,"$1").toLowerCase() != ".aspx")
    {
        location.href(preStr + "_" + pi + ext);
    }
    else
    {
        location.href(f_url.setQuery("p",pi));
    }
}
String.prototype.setQuery = function(name, value)
{
    var reg = new RegExp("(^|&|\\?)(" + name + "=)([^&]*)(&|$)");
    var r = this.substr(this.indexOf("?") + 1).match(reg);
    if (r != null) return this.replace(reg, "$1$2" + value + "$4");
    else return this + (this.indexOf("?")>-1 ? "&" : "?") + name + "=" + value
}
function SetDig(appPath,modelid,id)
{
    if( $("dig_"+modelid+"_"+id)!=null&&$("click_dig_"+modelid+"_"+id)!=null)
    {
        var loadstr = '<img src="'+appPath+'/Images/dig_loading.gif">'
        $("click_dig_"+modelid+"_"+id).innerHTML = loadstr;
        var data = XmlHttpGetMethodText(appPath+"/Common/Dig.aspx?type=set&modelid="+modelid+"&id="+id);
        if(data!="-1")
        {
            $("dig_"+modelid+"_"+id).innerHTML=data;
        }
        $("click_dig_"+modelid+"_"+id).innerHTML="成功";
        $("click_dig_"+modelid+"_"+id).style.removeAttribute("cursor");
        $("click_dig_"+modelid+"_"+id).removeAttribute("onclick");
     }
    return false;
}
function SuperLabelPage(PagePath,CaseId)
{
    var data = XmlHttpGetMethodText(PagePath);
    document.getElementById(CaseId).innerHTML=data;
}
function GetAjaxLabel(url,paramStr,currId,type)
{
    var data = XmlHttpPostMethodText(url,"paramStr="+paramStr+"&currId="+currId+"&type="+type)
    document.write(data) ;
}
function GetHiddenContent(url,paramStr,infoId,pageIndex,pageCount,tableName)
{
    var data = XmlHttpPostMethodText(url,"paramstr="+paramStr+"&id="+infoId+"&pageindex="+pageIndex+"&pagecount="+pageCount+"&tablename="+tableName);
    document.write(data) ;
}
function GetAjaxPropertyList(url,paramStr,listTypeFlag,propertyId,objId,pageIndex)
{
    var data=XmlHttpPostMethodText(url,"paramstr="+paramStr+"&listtypeflag="+listTypeFlag+"&propertyId="+propertyId+"&pageIndex="+pageIndex+"&objId="+objId);
    return data;
}
function goAjaxPage(url,paramStr,listTypeFlag,propertyId,objId,pc)
{
    var pi = $("txtPageNav"+objId).value;
    if(!CheckNumber(pi))
    {
        alert('页索引必须为数字字符！');
        pi=1;
    }
    if(pi<1||pi>pc)
    {
        alert("页索引超出搜索范围！") ;
        pi=pc;
     }
    var data=XmlHttpPostMethodText(url,"paramstr="+paramStr+"&listtypeflag="+listTypeFlag+"&propertyId="+propertyId+"&pageIndex="+pi+"&objId="+objId);
    return data;
}
function goPropertyPage(url,pc,propertyId,typeId,sorceId)
{
    var pi=$("txtPageNav"+propertyId).value;
    if(!CheckNumber(pi))
    {
        alert('页索引必须为数字字符！');
        return;
    }
    if(pi<1||pi>pc)
    {
        alert("页索引超出搜索范围！") ;
        return;
    }
    if(pi==1)
    {
        location.href(url) ;
        return;
    }
    var charindex=url.lastIndexOf(".");
    var preStr=url.substr(0,charindex);
    var ext=url.substr(charindex,url.length-charindex);
    var patt=/.*(\..*?)\?.*/i
    if(url.replace(patt,"$1").toLowerCase()!=".aspx")
    {
        location.href(preStr+"_"+pi+ext);
    }
    else
    {
        location.href(url+"&pageIndex="+pi);
    }
}
function ViewVotes(ID)
{
    jQuery.dialog({
        id: 'txtViewVotes',
        lock: true,
        title: '查看投票结果',
        content: "url:/Common/ViewVote.aspx?vid=" + ID + "",
        width: 800,
        height: 'auto'
    });
}