﻿// JScript 文件
function SetParam()
{
    var data = XmlHttpPostMethodText("GetColumn.aspx","ColId="+$('ddlColId').value);
    if(data== "")
    {
        return; 
    }  
    else
    {
        var param = data.split('$');
        if(param.length==7)
        {  
            $('rdBtnPageType_'+(param[0]-1)).checked=true; 
            $('txtTemplatePath').value = param[1];
            $('rdBtnChargeType'+param[2]).checked=true;
            $('txtChargeHourCount').value=param[3];
            $('txtChargeViewCount').value=param[4];
            $('txtPointCount').value=param[5]; 
            if(param[6]=="True")
            {
                $('chkBoxIsAllowComment').checked=true;
            }
       } 
    }   
}

function SetParamuser()
{
    var data = XmlHttpPostMethodText("../../system/info/GetColumn.aspx","ColId="+$('ddlColId').value);
    if(data== "")
    {
        return; 
    }  
    else
    {
        var param = data.split('$');
        $('rdBtnPageType_'+(param[0]-1)).checked=true; 
        $('txtTemplatePath').value = param[1];
        $('rdBtnChargeType'+param[2]).checked=true;
        $('txtChargeHourCount').value=param[3];
        $('txtChargeViewCount').value=param[4];
    }   
}

//获取颜色
function GetColor(img_val,input_val)
{
	var PaletteLeft,PaletteTop
	var obj = $("colorPalette");
	ColorImg = img_val;
	ColorValue = $(input_val);
	if (obj){
		PaletteLeft = getOffsetLeft(ColorImg)
		PaletteTop = (getOffsetTop(ColorImg) + ColorImg.offsetHeight)
		if (PaletteLeft+150 > parseInt(document.body.clientWidth)) PaletteLeft = parseInt(event.clientX)-260;
		if (PaletteTop > parseInt(document.body.clientHeight)) PaletteTop = parseInt(document.body.clientHeight)-165;
		obj.style.left = PaletteLeft + "px";
		obj.style.top = PaletteTop + "px";
		if (obj.style.visibility=="hidden")
		{
			obj.style.visibility="visible";
		}else {
			obj.style.visibility="hidden";
		}
	}
}

function getOffsetTop(elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}
function getOffsetLeft(elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}

function setColor(color)
{
	if(ColorImg.id=='FontColorShow' && color=="#") color='#000000';
	if(ColorImg.id=='FontBgColorShow' && color=="#") color='#FFFFFF';
	if (ColorValue){ColorValue.value = color.substr(1);}
	if (ColorImg && color.length>1){
		ColorImg.src='../../Images/Rect.gif';
		ColorImg.style.backgroundColor = color;
	}else if(color=='#'){ ColorImg.src='../../Images/rectNoColor.gif';}
	$("colorPalette").style.visibility="hidden";
}

//检测的短标题
function CheckTitle(TableName)
{
    var title = $("txtTitle").value.trim();
    if(title.length==0) 
    {
          alert('检测的标题必须填写');
          $("txtTitle").focus();
          return;
    } 
     var flag = CheckHas("../common/CheckHas.aspx",title,"Title",TableName)
     if(!flag)
     {
          alert("该标题不存在！"); 
          $("txtTitle").focus();
     }  
     else
     {
         alert("该标题已经存在！"); 
         $("txtTitle").focus();
     }
}

//标题类型
function SetTitleType(obj){
    var temp=obj;
    if(temp==1){
        $('rbComm').checked=true;
        ShowImgUrl.style.display="none";
        $('chkBoxIsSideShow').disabled=true;
    }
    else if(temp==2){
        $('rbImg').checked=true; 
        ShowImgUrl.style.display=""; 
         $('chkBoxIsSideShow').disabled=false; 
    }
}

//获取文章类型
function GetTitleType()
{
    if($("rbComm").checked){
        ShowDefault.style.display="";
        ShowImgUrl.style.display="none";
         $('chkBoxIsSideShow').disabled=true;
    }
   else  if($("rbImg").checked){
         ShowImgUrl.style.display="";
          ShowDefault.style.display="";
          $('chkBoxIsSideShow').disabled=false; 
    }
}

///文章类型是否外部链接
function SetIsOuter()
{
    if($('rbOuter').checked)
    {
       ShowOurterUrl.style.display=""; 
       ShowDefault.style.display="none";
       Tabs1.style.display="none";
       Tabs2.style.display="none";
       Tabs3.style.display="none";
    }
    else
    {
       ShowOurterUrl.style.display="none"; 
       ShowDefault.style.display="";
       Tabs0.style.display="";
       ShowTabs(0);
     }
}

//分隔关键字
function SepTagName()
{
    $("txtTagNameStr").focus();
   if(document.selection)
   {
     var range=document.selection.createRange();
     range.text="|";
   } 
}

function btnSetToppicStr(val)
{
   var lst1=$("lBoxTopicIdStr");
   var length=lst1.options.length;
   var tt="";
   if(val=="ChooseAll")
   {
       for(var i=0;i<length;i++)
       {
            lst1.options[i].selected = true;
       }
   }
   else 
   {
       for(var i=0;i<length;i++)
       {
            lst1.options[i].selected = false;
       }
   }
}
    
function GetLinkage(ParName,SelName,TypeId)
{
    var ParentId=$(ParName).value;
    var ParentText=$(ParName).options[$(ParName).selectedIndex].text;
    
    $(ParName.replace("select","txt")+"_Id").value=ParentId;
    $(ParName.replace("select","txt")).value=ParentText;
    if(ParentId=="0")
    {
        $(SelName).length=1;
        $(SelName).options[0].text = "请选择";
        $(SelName).options[0].value = "0";
        $(SelName.replace("select","txt")).value=0;
    }
    else
    {
        if(TypeId=="0")
        {
            common_Linkage.GetLinkageDs(ParentId,SelName,Call_Back_Linkage);
        }
        else
        {
            common_Linkage.GetLinkageDs(ParentId,SelName,Call_Back_Linkage_Update);
        }
    }
}
    
function Call_Back_Linkage(res)
{
    var SelName=res.value.Tables[1].Rows[0]["SelName"];
    $(SelName).length=0;
    
    if(res.value.Tables[0].Rows.length>0)
    {
        for(var i=0;i<res.value.Tables[0].Rows.length;i++)
        {
           $(SelName).length++;
           $(SelName).options[i].text = res.value.Tables[0].Rows[i]["DicName"];
           $(SelName).options[i].value = res.value.Tables[0].Rows[i]["ID"];
        }
        
        $(SelName.replace("select","txt")).value=res.value.Tables[0].Rows[0]["DicName"];
        $(SelName.replace("select","txt")+"_Id").value=res.value.Tables[0].Rows[0]["ID"];
    }
    else
    {
        $(SelName).length=1;
        $(SelName).options[0].text = "无相关小类";
        $(SelName).options[0].value = "0";
        $(SelName.replace("select","txt")).value="无";
        $(SelName.replace("select","txt")+"_Id").value=0;
    }
}

function GetSmallLinkage(SelName)
{
    var SelId=$(SelName).value;
    var SelIdText=$(SelName).options[$(SelName).selectedIndex].text;
    $(SelName.replace("select","txt")).value=SelIdText;
    $(SelName.replace("select","txt")+"_Id").value=SelId;
}

function Call_Back_Linkage_Update(res)
{
    var SelName=res.value.Tables[1].Rows[0]["SelName"];
    $(SelName).length=0;
    
    if(res.value.Tables[0].Rows.length>0)
    {
        for(var i=0;i<res.value.Tables[0].Rows.length;i++)
        {
           $(SelName).length++;
           $(SelName).options[i].text = res.value.Tables[0].Rows[i]["DicName"];
           $(SelName).options[i].value = res.value.Tables[0].Rows[i]["ID"];
           
           if(res.value.Tables[0].Rows[i]["ID"]==$(SelName.replace("select","txt")+"_Id").value)
           {
                $(SelName).options[i].selected=true;
           }
        }       
    }
    else
    {
        $(SelName).length=1;
        $(SelName).options[0].text = "无相关小类";
        $(SelName).options[0].value = "0";
        $(SelName.replace("select","txt")).value="无";
        $(SelName.replace("select","txt")+"_Id").value=0;
    }
}

function GetGipsIndexNum()
{
    $("txtIndexNum").value=$("IndexNum").value;
}
function SelProperty(kyweb,seltype,name,id,protype)
{
    WinOpenDialog(''+kyweb+'/common/SelectPropertyOpen.aspx?SelType='+seltype+'&Control='+name+'&Id='+id+'&ProType='+protype+'','600','400');
}

function SetListBoxInput(Name,Name1)
{
    if($(Name1).checked==true)
    {
        $(Name).value=$(Name).value+","+$(Name1+"_span").innerText;
    }
    else
    {
        $(Name).value=$(Name).value.replace(","+$(Name1+"_span").innerText,"");
    }
}

function SetListBoxMultiple(Name)
{
    $(Name).value="";
    var Name1=Name+"_Id";
    for(var i=0;i<$(Name1).options.length;i++)
    {
      if($(Name1).options[i].selected)
        {
           var e = $(Name1).options[i];
           $(Name).value=$(Name).value+","+e.text;
       }
   }
}
