// JavaScript Document
 function upload(iname) 
{SK_windowlable('edigg','自定义字段 SKCMS','url:'+skpath+''+skadmin+'/Label/SK_Custom_folder.asp?ModeID='+document.myform.ModeID.value+'',300,330,false,false,false,false); }

 /*打开窗口 ID，标题，网址，宽，高，最大按钮，最小按钮，锁屏，是否拉大*/
function SK_windowlable( id,title,url,k,g,ma,mi,sp,tj) 
{ $.dialog({id:id,title:title,content:url,width:k,height:g,max:ma,min:mi,lock:sp,parent:api,resize:tj,cache:false,fixed:true,zIndex:999999});  

 } 
 

function SetDiyContent(strText,oTextarea)
{$(oTextarea).insertContent(strText);}
 (function($){
	$.fn.extend({
		insertContent: function(myValue,t){
			var $t=$(this)[0];

			if (document.selection) {//ie
				this.focus();
				var sel = document.selection.createRange();
				sel.text = myValue;
				this.focus();
                sel.moveStart ('character', -l);
		        var wee = sel.text.length;
                if(arguments.length == 2){
                    var l = $t.value.length;
                    sel.moveEnd("character", wee+t );
                    t<=0?sel.moveStart("character",wee-2*t-myValue.length):sel.moveStart("character",wee-t-myValue.length);

                    sel.select();
                }
			} else if ($t.selectionStart || $t.selectionStart == '0') {
                var startPos = $t.selectionStart;
                var endPos = $t.selectionEnd;
                var scrollTop = $t.scrollTop;
                $t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length);
                this.focus();
                $t.selectionStart = startPos + myValue.length;
                $t.selectionEnd = startPos + myValue.length;
                $t.scrollTop = scrollTop;
                if(arguments.length == 2){
                    $t.setSelectionRange(startPos-t,$t.selectionEnd+t);
                    this.focus();
                }
            }
            else {
                this.value += myValue;
                this.focus();
            }
		}
	})
})(jQuery);


 

function SelectClass()
{
 if(document.myform.select1.value==0)	
	{
	document.all.ClassID.value=0
	document.myform.SubClass.disabled=false;
	document.getElementById('gccg1').style.display='none';
	}
if(document.myform.select1.value==1 )	
	{
	document.all.ClassID.value=1
	document.myform.SubClass.disabled=false;
	document.getElementById('gccg1').style.display='none';
	}
 if(document.myform.select1.value==2 )	
	{
	var cid=document.myform.ModeID.value
		document.getElementById('gccg1').style.display='';
	if (cid==0)
	{ 
	document.all.ClassID.value=0;
	alert('模型公用,不能指定栏目!');
	return false;
	}
	var result = Selector(2, document.all.ClassID.value,cid);
	if(!result) return false;
	var val = "";
	for(var i=0; i<result.length; i++)
	for(var i=0; i<result.length; i++)
	{
		if(val == "")
		{
			val += result[i].id;
		}else{
			val += "," + result[i].id;
		}
	}
	document.all.ClassID.value = val;
		var str=val;
		var i = str.indexOf(",");
		if (i==-1)
		{
 		document.myform.SubClass.disabled=false;
		}
		else{document.myform.SubClass.disabled=true;}
	}}	

function Selector(type,val,ModeID,all)
{
	val = val.replace(/['"]/g,"");
	ModeID = ModeID?ModeID:'';
	all = all?all:'';
	 SKCLASS_windowback('stylesbssort','选择栏目','url:'+skpath+'SKCMS/Selectorlist.asp?Type=' + type + '&ModeID=' + ModeID + '&ShowAll=all&IdList=' + $("#ClassID").val() + ',124545',360,480,true,false,true,true,'ClassID',9999999); 
}	
	
 function SKCLASS_windowback(id,title,url,k,g,ma,mi,sp,tj,idname,z) 
{ $.dialog({id:id,title:title,content:url,width:k,height:g,max:ma,min:mi,lock:sp,resize:tj,cache:false,fixed:true,parent:api,zIndex:z});} 



function SelectClassnav()
{
	var cid=document.myform.ModeID.value
		document.getElementById('gccg1').style.display='';
	if (cid!=0)
	{ 
	alert('请将模型设置成选择栏目!');
	return false;
	}
	var result = Selector(2, document.all.ClassID.value,cid);
	}	  