﻿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 + "/sys_template/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,chid,colid)
{
	
	
   var keyword = document.getElementById(appPath).value.trim();
   
    if(keyword.length==0||keyword=="请输入关键字")
   {
        alert('关键字不能为空');
        return;
   }
   	//var backtext=XmlHttpGetMethodText("/other/updatesearch.aspx?keyword="+escape(keyword ));
	
    //if(backtext=="true"){
window.location.href="/list.aspx?chid="+chid+"&colid="+colid+"&fieldname=title&keyword="+escape(keyword );
//}
   
}
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="成&nbsp;&nbsp;功";
        $("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 ktsms(){
	var lxr=document.getElementById("LXR").value;
	var sjh=document.getElementById("SJH").value;
	var dq=document.getElementById("dyarea").value;
	var nr=document.getElementById("DYNR").value;
	if(lxr==""){
		alert("联系人不能为空");
		document.getElementById("LXR").focus();
		return;
	}
	if(sjh==""){
		alert("手机号不能为空");
		document.getElementById("SJH").focus();
		return;
	}
	if(checkmobile(sjh)){
	window.showModalDialog('/user/console/apps/sms/book.aspx?mobile='+sjh+'&lxr='+escape(lxr)+'&dq='+dq+'&nr='+nr ,'aaa',"Toolbar= no;menubar=yes;scroll=no;status=no;location=no;directories=no;dialogWidth=960px;dialogHeight=750px;help: No;dialogTop=30px;dialogLeft=100px;");
	}
}

function booksms(id){
		var regu =/^[1]([3][0-9]{1}|59|58|52|51|53|88|89|87)[0-9]{8}$/; //验证手机号
		if(document.getElementById(id).value==""||(!regu.test(document.getElementById(id).value)))
																							   {
																								   alert("请输入正确的手机号");
																								document.getElementById(id).focus();
																								   return;
																								   
																						}
		 if (checkmobile(document.getElementById(id).value)){
			
		
		window.open('/user/console/apps/sms/book.aspx?mobile='+document.getElementById(id).value ,'aaa');
		 }
	}

function checkmobile(mobile){
	var url="/user/console/apps/sms/checkmobile.aspx?mobile="+mobile;
	var res=XmlHttpGetMethodText(url);
	if(res=="false"){
		alert("本号码已开通过短信试用，请电话联系400-617-0021申请再次试用")
		return false;
		
	}
	return true;
}
function CopyURL(infoid){
var myHerf="http://feigang.com/"+infoid+".fg";
var title=document.title;
if(window.clipboardData){
var tempCurLink=title + " " + myHerf;
var ok=window.clipboardData.setData("Text",tempCurLink);
if(ok) alert("复制成功，按Ctrl + V 发给你的好友们吧 ！");
}else{alert("对不起，目前此功能只支持IE，请直接复制地址栏的地址！");
}
}

function setFontSize(obj,size){
document.getElementById("content-text").style.fontSize=size+"px";
}

