﻿//系统级的JS操作
function S$(){

}

//发生错误函数
S$.E=function (message,source,stackTrace){

    var err=[message,source,stackTrace];
    err.message=message;
    err.source=source;
    err.stackTrace=stackTrace;
    
    var url=C$.AppPath+"Error.htm";
    window.showModalDialog(url, err,"dialogHeight:600px;dialogWidth:800px;");
}

S$.W=function (str){
    document.write(str);
}

S$.ID=function (id){
    return document.getElementById(id);
}

S$.Name=function (name){
    return document.getElementsByName(name);
}


S$.Exist=function (src){
    if(src && src!=undefined && src!="undefined"){
        return true;
    }
    else{
        return false;
    }
}

S$.RadioChecked=function (src,value){
    
}

S$.Show=function (url,width,height,canScroll,dialogArguments){
  
    
    
    var sFeatures="";
    
    if(width){
        sFeatures+="dialogWidth:"+width+"px; ";
    }else{
        sFeatures+="dialogWidth:"+400+"px; ";
    }
    
    if(height){
        sFeatures+="dialogHeight:"+height+"px; ";
    }else{
        sFeatures+="dialogHeight:"+250+"px; ";
    }
    
    if(canScroll){
        sFeatures+="scroll:"+canScroll+"; ";
    }else{
        sFeatures+="scroll:"+1+"; ";
    }
    
    if(!dialogArguments){
        dialogArguments=window;
    }
    
    sFeatures+="resizable: no; help: no; status: no;";
    
    
    return showModalDialog(url, dialogArguments, sFeatures);
}

S$.Open=function (url,width,height){

    var sFeatures="";
    
    var top=(screen.availHeight-height)/2;
    var left=(screen.availWidth-width)/2;
    
    sFeatures+="width="+width+", ";
    
    sFeatures+="height="+height+", ";
    
    window.open(url, "_blank", sFeatures+"scrollbars=yes,top="+top+",left="+left);
  
}


S$.OpenFull=function (url){

    var sFeatures="height="+(screen.availHeight-32)+",width="+screen.availWidth+",scrollbars=yes,top=0,left=0";

    try{
        window.fullwin.focus();}
    catch(e){
        window.fullwin=window.open(url, "_blank", sFeatures);
    }
    
}

S$.ShowFull=function (url){
   

    var sFeatures="";
    
    sFeatures+="dialogWidth:"+screen.availWidth+"px; ";
    
    
    sFeatures+="dialogHeight:"+screen.availHeight+"px; ";
    
    
    sFeatures+="resizable: no; help: no; status: no;scroll: yes;dialogHide:yes;";
    
    return showModalDialog(url, window, sFeatures);
}

S$.AllUrlProperty=function (url,key,value){

    url=url.toLowerCase();
    key=key.toLowerCase();
    value=value.toLowerCase();
    
}

S$.AttachEvent=function(type, target, handler, owner)
{
    var eventHandler = handler;
    if(owner)
    {
            // 在这里重新定义一个处理函数
            eventHander = function(e)
            {
                    handler.call(owner, e);
            }
    }
    if(window.document.all)
            target.attachEvent("on" + type, eventHander );
    else
            target.addEventListener(type, eventHander, false);
}

S$.SelectFile=function(src,onlyAllowExtendNames,rootPath,notAllowPath,notAllowExtendNames){
    if(!S$.Exist(onlyAllowExtendNames)){
        onlyAllowExtendNames=""
    }
    if(!S$.Exist(rootPath)){
        rootPath=""
    }
    if(!S$.Exist(notAllowPath)){
        notAllowPath=""
    }
    if(!S$.Exist(notAllowExtendNames)){
        notAllowExtendNames=""
    }
    var url=C$.AppPath+"/Controls/FileSelect/Default.aspx?rootPath="+rootPath
        + "&notAllowPath=" +notAllowPath
        + "&notAllowExtendNames=" +notAllowExtendNames
        + "&onlyAllowExtendNames=" +onlyAllowExtendNames;
    var returnV=S$.Show(url,800,600,1);
    if(S$.Exist(returnV) && returnV!=""){
        src.value=returnV;
    }
}

S$.SelectFolder=function(src){
    var url=C$.AppPath+"/Controls/FolderSelect/Default.aspx";
    var returnV=S$.Show(url,400,500,1);
    if(S$.Exist(returnV) && returnV!=""){
        src.value=returnV;
    }
}

S$.UploadImage=function(src,fileType,dirPath,isAllow,fileSize,flagNullRename){
    if(!S$.Exist(dirPath)){
        dirPath=""
    }
    if(!S$.Exist(fileType)){
        fileType=""
    }
    if(!S$.Exist(isAllow)){
        isAllow=""
    }
    if(!S$.Exist(fileSize)){
        fileSize=""
    }
    if(!S$.Exist(flagNullRename)){
        flagNullRename=""
    }
    var url=C$.AppPath+"/Controls/ImageUpload/Default.aspx?dirPath="+dirPath
        + "&fileType=" +fileType
        + "&isAllow=" +isAllow
        + "&fileSize=" +fileSize
        + "&flagNullRename=" +flagNullRename;
    var returnV=S$.Show(url,350,400,0);
    if(S$.Exist(returnV) && returnV!=""){
        src.value=returnV;
    }
}

S$.UploadImageList=function(src,fileType,dirPath,isAllow,fileSize,flagNullRename){
    if(!S$.Exist(dirPath)){
        dirPath=""
    }
    
    if(!S$.Exist(fileType)){
        fileType=""
    }
    
    if(!S$.Exist(isAllow)){
        isAllow=""
    }
    
    if(!S$.Exist(fileSize)){
        fileSize=""
    }
    
    if(!S$.Exist(flagNullRename)){
        flagNullRename=""
    }
    
    var url=C$.AppPath+"/Controls/ImageUpload/ListUpload.aspx?dirPath="+dirPath
        + "&NeedAll=true"
        + "&fileType=" +fileType
        + "&isAllow=" +isAllow
        + "&fileSize=" +fileSize
        + "&flagNullRename=" +flagNullRename;
        
    var returnV=S$.Show(url,750,600,0);

    try{
    if(S$.Exist(returnV) && returnV!=""){
        var tempArr=returnV.split("|");
        
        for(var i=0;i<tempArr.length;i++){
            var tempArrB=tempArr[i].split(",");
            var hasResultImg=false;
            
            if(tempArrB.length>1){
                hasResultImg=true;
            }
            
            var htmlStr;
            
            if(hasResultImg){
                htmlStr="<a href='"+tempArrB[0]+"' target='_blank'><img src='"+tempArrB[1]+"' border='0' /></a>";
            }else{
                htmlStr="<img src='"+tempArrB[0]+"' border='0' />";
            }
            
            var used=false;
            
            for(var j=1;j<=S$.ID('count').value;j++){
                try{if(FCKeditor.GetHTML("FCKeditor_"+j+"___Frame")==""){
                    FCKeditor.SetHTML("FCKeditor_"+j+"___Frame",htmlStr)
                    used=true;
                }
                }catch(e){}
                
            }
            
            if(!used){
                tabbox1.addafter(htmlStr);
            }
            
        }
        
    }
    }catch(e){
        alert(e.message);
    }
}

S$.UploadImageNeedBiger=function(srcOriginal,srcResult,fileType,dirPath,isAllow,fileSize,flagNullRename){
    if(!S$.Exist(dirPath)){
        dirPath=""
    }
    if(!S$.Exist(fileType)){
        fileType=""
    }
    if(!S$.Exist(isAllow)){
        isAllow=""
    }
    if(!S$.Exist(fileSize)){
        fileSize=""
    }
    if(!S$.Exist(flagNullRename)){
        flagNullRename=""
    }
    var url=C$.AppPath+"/Controls/ImageUpload/Default.aspx?dirPath="+dirPath
        + "&NeedAll=true"
        + "&fileType=" +fileType
        + "&isAllow=" +isAllow
        + "&fileSize=" +fileSize
        + "&flagNullRename=" +flagNullRename;
    var returnV=S$.Show(url,350,400,0);
    if(S$.Exist(returnV) && returnV!=""){
        var tempArr=returnV.split(",");
        srcOriginal.value=tempArr[0];
        
        if(tempArr.length>1){
            srcResult.value=tempArr[1];
        }else{
            srcResult.value=srcOriginal.value;
        }
        
    }
}

S$.UploadFile=function(src,fileType,dirPath,isAllow,fileSize,flagNullRename){
    if(!S$.Exist(dirPath)){
        dirPath=""
    }
    if(!S$.Exist(fileType)){
        fileType=""
    }
    if(!S$.Exist(isAllow)){
        isAllow=""
    }
    if(!S$.Exist(fileSize)){
        fileSize=""
    }
    if(!S$.Exist(flagNullRename)){
        flagNullRename=""
    }
    var url=C$.AppPath+"/Controls/FileUpload/Default.aspx?dirPath="+dirPath
        + "&fileType=" +fileType
        + "&isAllow=" +isAllow
        + "&fileSize=" +fileSize
        + "&flagNullRename=" +flagNullRename;
    var returnV=S$.Show(url,300,250,0);
    if(S$.Exist(returnV) && returnV!=""){
        src.value=returnV;
    }
}

S$.ViewImage=function(src){
    if(src.value!=""){
        S$.Show(src.value,800,600,1);
    }
    else
    {
        alert("没有值，不需要查看。");
    }
    
}

S$.EditImage=function(src){
    var url=C$.AppPath+"Controls/ImageEdit/Default.aspx?image="+src.value;
    
    if(src.value!=""){
        S$.Show(url,800,600,1);
    }
    else
    {
        alert("没有值，不能编辑。");
    }
    
}


S$.EditNameRule=function(src){
    var url=C$.AppPath+"Content/Channel/EditNameRule.htm";
    
    var returnV = S$.Show(url,500,300,1,src.value);
    
    if(S$.Exist(returnV) && returnV!=""){
        src.value=returnV;
    }
    
}

S$.LoadScript=function(url){
    S$.W('<script language="javascript" type="text/javascript" src="'+url+'"></script>');
}


try{
    S$.ID('WaitingInfo').style.display='none';
}catch(e){}


//系统的颜色配置
function Color$(){}
Color$.Gridview_Row_OnMouseOver = "#E9ECF3"; //鼠标移上的颜色
Color$.Gridview_Row_Normal = "#FFFFFF"; //鼠标移开的颜色
Color$.Gridview_Row_Checked= "#D5DBE6"; //选中后的颜色


function sAlert(str){
			var msgw,msgh,bordercolor;
			msgw=400;//提示窗口的宽度
			msgh=100;//提示窗口的高度
			titleheight=25 //提示窗口标题高度
			bordercolor="#336699";//提示窗口的边框颜色
			titlecolor="#99CCFF";//提示窗口的标题颜色
			
			var sWidth,sHeight;
			sWidth=document.body.offsetWidth;
			sHeight=document.body.offsetHeight;
			if (sHeight<screen.height)
			{
				sHeight=screen.height;
			}

			var bgObj=document.createElement("div");
			bgObj.setAttribute('id','bgDiv');
			bgObj.style.position="absolute";
			bgObj.style.top="0";
			bgObj.style.background="#777";
			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";
			bgObj.style.zIndex = "1000000";
			document.body.appendChild(bgObj);
			
			var msgObj=document.createElement("div")
			msgObj.setAttribute("id","msgDiv");
			msgObj.setAttribute("align","center");
			msgObj.style.background="white";
			msgObj.style.border="1px solid " + bordercolor;
	    	msgObj.style.position = "absolute";
            msgObj.style.left = "50%";
            msgObj.style.top = "50%";
            msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
            msgObj.style.marginLeft = "-225px" ;
            msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
            msgObj.style.width = msgw + "px";
            msgObj.style.height =msgh + "px";
            msgObj.style.textAlign = "center";
            msgObj.style.lineHeight = (msgh-titleheight) + "px";
            msgObj.style.zIndex = "1000001";
   
		   var title=document.createElement("h4");
		   title.setAttribute("id","msgTitle");
		   title.setAttribute("align","right");
		   title.style.margin="0";
		   title.style.padding="3px";
		   title.style.background=bordercolor;
		   title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
		   title.style.opacity="0.75";
		   title.style.border="1px solid " + bordercolor;
		   title.style.height="18px";
		   title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
		   title.style.color="white";
		   title.style.cursor="pointer";
		   title.innerHTML="";
		   title.onclick=function(){
		        return;
		        document.body.removeChild(bgObj);
                document.getElementById("msgDiv").removeChild(title);
                document.body.removeChild(msgObj);
                }
		   document.body.appendChild(msgObj);
		   document.getElementById("msgDiv").appendChild(title);
		   var txt=document.createElement("p");
		   txt.style.margin="1em 0"
		   txt.setAttribute("id","msgTxt");
		   txt.innerHTML="<table><tr><td>"+str+"</td>"+"<td><img src=/Images/VooShow/dwait.gif /></td></tr></table>";
           document.getElementById("msgDiv").appendChild(txt);
            }
            
            function checkType(mf,mimg,tbimg){
			  
			   var fileName=document.getElementById(mf).value;

			   
			   
			   var exName=fileName.substr(fileName.lastIndexOf(".")+1).toUpperCase();	
			   
			   var FileASrc=document.getElementById(mimg).src;
				var t1="";
				var t2="";
				var t3="";
				var t4="";
				var t5="";
				var t6="";
				today = new Date()
				t1=today.getFullYear();
				t2=today.getMonth()+1;
				t3=today.getDay()+1;
				t4=today.getHours();
				t5=today.getMinutes();
				t6=today.getSeconds();		
				document.getElementById(tbimg).value=t1+""+t2+""+t3+""+t4+""+t5+""+t6+"."+exName;
				
				
				
					if (fileName !=""){	
					
//                    var img=document.createElement("img");
//                    img.src=fileName;
//                    
//                    var fs=img.fileSize;
//                    
//                    if(parseInt(img.width)>600)
//                    {
//                       alert("大于600");
//                    }


//alert(img.width);

					            
	///////////////////////////////////////////////////////////////////////////////////				
					if(exName=="JPG" || exName=="GIF")
						{
						
								document.getElementById(mimg).src=fileName;
							
								//document.getElementById("BT_Submit").disabled=false;
							
						
						}
					else
						{
						
							//alert("只能上传JPG或Gif格式的图片！！！");
							//document.getElementById("BT_Submit").disabled=true;
							var aa="";
							//document.getElementById(mf).value=aa;
							document.getElementById(tbimg).value=aa;
							
						}
				}
				
			}
			function checkType2(mf){
			   //alert(mf);
			  
			   var fileName=document.getElementById(mf).value;
			   
			  // var exName=fileName.substr(fileName.lastIndexOf(".")+1).toUpperCase();	
			   
				
					if (fileName !=""){	
					if(exName!="JPG" || exName!="GIF")
						{
						alert("只能上传JPG或Gif格式的图片！！！");
						document.getElementById(mf).value="";
						}
					
				}
				
			}
			
			
			function checkType3(mf,tbimg)
			{
			  
			   var fileName=document.getElementById(mf).value;

			   
			   
			   var exName=fileName.substr(fileName.lastIndexOf(".")+1).toUpperCase();	
			   
			    //var FileASrc=document.getElementById(mimg).src;
				var t1="";
				var t2="";
				var t3="";
				var t4="";
				var t5="";
				var t6="";
				today = new Date()
				t1=today.getFullYear();
				t2=today.getMonth()+1;
				t3=today.getDay()+1;
				t4=today.getHours();
				t5=today.getMinutes();
				t6=today.getSeconds();		
				document.getElementById(tbimg).value=t1+""+t2+""+t3+""+t4+""+t5+""+t6+"."+exName;
				
			}
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			function qAlert(str){
			var msgw,msgh,bordercolor;
			msgw=400;//提示窗口的宽度
			msgh=100;//提示窗口的高度
			titleheight=25 //提示窗口标题高度
			bordercolor="#ff7303";//提示窗口的边框颜色
			titlecolor="#ff7303";//提示窗口的标题颜色
			
			var sWidth,sHeight;
			sWidth=document.body.offsetWidth;
			sHeight=document.body.offsetHeight;
			if (sHeight<screen.height)
			{
				sHeight=screen.height;
			}

			var bgObj=document.createElement("div");
			bgObj.setAttribute('id','bgDiv');
			bgObj.style.position="absolute";
			bgObj.style.top="0";
			bgObj.style.background="#777";
			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";
			bgObj.style.zIndex = "1000000";
			document.body.appendChild(bgObj);
			
			var msgObj=document.createElement("div")
			msgObj.setAttribute("id","msgDiv");
			msgObj.setAttribute("align","center");
			msgObj.style.background="white";
			msgObj.style.border="1px solid " + bordercolor;
	    	msgObj.style.position = "absolute";
            msgObj.style.left = "50%";
            msgObj.style.top = "50%";
            msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
            msgObj.style.marginLeft = "-225px" ;
            msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
            msgObj.style.width = msgw + "px";
            msgObj.style.height =msgh + "px";
            msgObj.style.textAlign = "center";
            msgObj.style.lineHeight = (msgh-titleheight) + "px";
            msgObj.style.zIndex = "1000001";
   
		   var title=document.createElement("h4");
		   title.setAttribute("id","msgTitle");
		   title.setAttribute("align","right");
		   title.style.margin="0";
		   title.style.padding="3px";
		   title.style.background=bordercolor;
		   title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
		   title.style.opacity="0.75";
		   title.style.border="1px solid " + bordercolor;
		   title.style.height="18px";
		   title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
		   title.style.color="white";
		   title.style.cursor="pointer";
		   title.innerHTML="";
		   title.onclick=function(){
		        return;
		        document.body.removeChild(bgObj);
                document.getElementById("msgDiv").removeChild(title);
                document.body.removeChild(msgObj);
                }
		   document.body.appendChild(msgObj);
		   document.getElementById("msgDiv").appendChild(title);
		   var txt=document.createElement("p");
		   txt.style.margin="1em 0"
		   txt.setAttribute("id","msgTxt");
		   txt.innerHTML="<table><tr><td>"+str+"</td>"+"<td><img src=/Images/VooShow/dwait.gif /></td></tr></table>";
           document.getElementById("msgDiv").appendChild(txt);
            }
            
            
            
            
            function qtAlert(str){
			var msgw,msgh,bordercolor;
			msgw=400;//提示窗口的宽度
			msgh=100;//提示窗口的高度
			titleheight=25 //提示窗口标题高度
			bordercolor="#b5e426";//提示窗口的边框颜色
			titlecolor="#b5e426";//提示窗口的标题颜色
			
			var sWidth,sHeight;
			sWidth=document.body.offsetWidth;
			sHeight=document.body.offsetHeight;
			if (sHeight<screen.height)
			{
				sHeight=screen.height;
			}

			var bgObj=document.createElement("div");
			bgObj.setAttribute('id','bgDiv');
			bgObj.style.position="absolute";
			bgObj.style.top="0";
			bgObj.style.background="#777";
			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";
			bgObj.style.zIndex = "1000000";
			document.body.appendChild(bgObj);
			
			var msgObj=document.createElement("div")
			msgObj.setAttribute("id","msgDiv");
			msgObj.setAttribute("align","center");
			msgObj.style.background="white";
			msgObj.style.border="1px solid " + bordercolor;
	    	msgObj.style.position = "absolute";
            msgObj.style.left = "50%";
            msgObj.style.top = "50%";
            msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
            msgObj.style.marginLeft = "-225px" ;
            msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
            msgObj.style.width = msgw + "px";
            msgObj.style.height =msgh + "px";
            msgObj.style.textAlign = "center";
            msgObj.style.lineHeight = (msgh-titleheight) + "px";
            msgObj.style.zIndex = "1000001";
   
		   var title=document.createElement("h4");
		   title.setAttribute("id","msgTitle");
		   title.setAttribute("align","right");
		   title.style.margin="0";
		   title.style.padding="3px";
		   title.style.background=bordercolor;
		   title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
		   title.style.opacity="0.75";
		   title.style.border="1px solid " + bordercolor;
		   title.style.height="18px";
		   title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
		   title.style.color="white";
		   title.style.cursor="pointer";
		   title.innerHTML="";
		   title.onclick=function(){
		        return;
		        document.body.removeChild(bgObj);
                document.getElementById("msgDiv").removeChild(title);
                document.body.removeChild(msgObj);
                }
		   document.body.appendChild(msgObj);
		   document.getElementById("msgDiv").appendChild(title);
		   var txt=document.createElement("p");
		   txt.style.margin="1em 0"
		   txt.setAttribute("id","msgTxt");
		   txt.innerHTML="<table><tr><td>"+str+"</td>"+"<td><img src=Images/VooShow/dwait.gif /></td></tr></table>";
           document.getElementById("msgDiv").appendChild(txt);
            }
            
