﻿


/***************************************************************************/
/********************* Select Category *************************************/


// Container for Selecting Category
// template1 means the template for category level1
// template2 means the template for category level2
// template3 means the template for category level3
function SelectCategoryByAjax(txtCategoryID, txtID, typeID, allowP, template1, template2, template3)
{
    var sUrl = "/Services.aspx";
    var objDiv=getObject("divPopupForSelectCategory");
    if(typeof(allowP)=="undefined")
        allowParent=false;
    else   
        allowParent=allowP;
        
    var dialogsBox = new campton.dialogs(objDiv, "dialogs", "CloseCategoryList()");
    
    dialogsBox.setTitle(__selectCategoryTitle);
    dialogsBox.setContent(__containerBodyContent);
    dialogsBox.setFooter(__containerFooterContent);
//    dialogsBox.render(objDiv);
	showMask();
	objDiv.style.top=document.body.scrollTop+10;
	
//	YAHOO.example.container.panel2.show();
	
    var SuccessToGetCategory = function(o){ 
        if(o.responseText !== undefined){ 
            var strContent = o.responseText;  
            
            if (strContent.length > 0)
            {
	            dialogsBox.setContent("<div class='bodyContent'>" + strContent + "</div>");
	            dialogsBox.render(objDiv);
	            YAHOO.example.initTreeView("treeView332541147887");
            }
            else
            {
	            dialogsBox.setContent("<div class='bodyContent'>" + __NoCategoryContent + "</div>");
	            dialogsBox.render(objDiv);
            }
        }
    }

    var FailToGetCategory = function(o){        
            //alert(o.statusText+'\r\n'+o.responseText);
    }

    var CallbackForSelectCategory =
    {
         success: SuccessToGetCategory,
         failure: FailToGetCategory
    };
    if(SelectCategoryByAjax.arguments.length<5){
        template1="";
        template2="";
        template3="";
    }
   
    var strQueryString = "action=GetCategoriesByTypeID&txtCategoryID="+txtCategoryID+"&txtID="+txtID+"&typeID="+typeID+"&templateforlevel1="+template1+"&templateforlevel2="+template2+"&templateforlevel3="+template3;

    YAHOO.util.Connect.asyncRequest("POST", sUrl, CallbackForSelectCategory, strQueryString);

}

function ChooseCategory(idControl, id, nameControl, name)
{
    objID=getObject(idControl);
    objName=getObject(nameControl); 
    if(!allowParent){
        var objLi=event.target || event.srcElement; 
        objLi=getParent("LI",objLi) 
        //var li=getObject(liId);
        var li=objLi;
        if(li != null)
        {
            var child=li.getElementsByTagName("LI");
            if(child.length>1)
                return;
        }
    }
    objID.value=id;
    objName.value=name;
    
    var objDiv=getObject("divPopupForSelectCategory");
    objDiv.innerHTML = "";
    closeMask();
    
}

function CloseCategoryList()
{
    var objDiv=getObject("divPopupForSelectCategory");
    objDiv.innerHTML = "";
    closeMask();
}

/*********************** Select Category **************************************/
/***************************************************************************/

/***************************************************************************/
/***************************************************************************/
/*********************** Select Skins **************************************/

function showTemplates(skinTempContent){
    
     showMask();
    
     _activeTemplate=0;
     _viewItems = [{index:0, id:"MNWVDetails", cssClass:"MNWVDetailsS", template:"MNWVDetails"}];
     __title = __selectSkins;
     __key = "";//no use
    
     var menuItems = __tabTemplatetitle; // var menuItems='Aaa,Bbb';
     var tabTitle = __tabTemplatetitle.replace(/\"/g,"").replace(/\'/g,"");
     var tabTitleArray=tabTitle.split(',');
     
     var leftcontent="";
     for(var i=0;i<tabTitleArray.length;i++)
     {
        leftcontent += '<A class=\"Normal\" onclick=\"return false;\" href=\"#' + tabTitleArray[i] + '\" title=\"' + tabTitleArray[i] + '\" >' + tabTitleArray[i] + '</A>';
     }
     
     var skinTemp1 = "";
     var skinTemp2 = "";
     var arySkinTemp = skinTempContent.split("##########");
     if (arySkinTemp && arySkinTemp.length == 2)
     {
        skinTemp1 = arySkinTemp[0];
        skinTemp2 = arySkinTemp[1];
        if (skinTemp2 == "")
            skinTemp2 = __noUserSkins;
     }   
     
     var menuContents=[skinTemp1, skinTemp2];
     var cache = campton.createCache(menuItems.split(','), menuContents, leftcontent);
     campton.seleter({title:__title, className:"tablist", close: closeMask, disableClose:false, closeTagClassName:"closeMe", subNavActive:"subNavActive", command:{left:"cache", content: "cache"}, action:[] }, cache);
}

// type likes "host" or "portal"
function GetSkinTemplate(skintype)
{
    var sUrl = "/Services.aspx";
    var SuccessToGetSkinTempate = function(o){
        if(o.responseText !== undefined){ 
            var strContent = o.responseText;  
            
            if (strContent.length > 0)
            {
                showTemplates(strContent);
            }
            else
            {
	            return __NoCategoryContent;
            }
        }
        else
            return "fail to get.";
    }

    var FailToGetSkinTempate = function(o){
            alert("fail.");
    }

    var CallbackForGetSkinTempate =
    {
         success: SuccessToGetSkinTempate,
         failure: FailToGetSkinTempate
    };
    
    var skinFormatTemplate="Templates.System.TemplateForSkins.template";
    
    var strQueryString = "action=GetSkinTemplate&templateforlevel1="+skinFormatTemplate;

    YAHOO.util.Connect.asyncRequest("POST", sUrl, CallbackForGetSkinTempate, strQueryString);

}

/*********************** Select Skins **************************************/
/***************************************************************************/
/***************************************************************************/

/***************************************************************************/
/*************************** Select Layout *********************************/
var Template=function(obj){  

    this.container=typeof(obj)=="string"?getObject(obj):obj;	
    
}

Template.prototype={
      checked:"checked",
	  style:"A",
      getValue:function()
      {
	     var checked=this.checked;
		 var getImg=this.getImg;
         var  container=this.container;
     	 var aryImg=container.getElementsByTagName("IMG");
	     var temp="";		     
	     for(var i=0;i<aryImg.length;i++)
	     {
	        if(aryImg[i].title==checked){
			    temp+=getImg(aryImg[i].parentNode).title+",";
		 }
		 
	  }

		
      return temp.substring(0,temp.length-1);
		
 },
  getImg: function(li){
	      var checked="checked";
	      var imgs=li.getElementsByTagName("IMG");
		  for(var i=0;i<imgs.length;i++){
		
		  	  if(imgs[i].title!="" && imgs[i].title!=checked)return imgs[i];
		  }
		  
		  return null;
	 },
  init:function(mutiselect,initValue,style,clickcallback,othercall){
  
     clickcallother=othercall;
     var checked=this.checked;
	 var getImg=this.getImg;
	 var sty=this.style;
	 if(style!=undefined)sty=style;
	
     var  container=this.container;
     var onmouseover=function(evt,obj){
	     
	       //obj.className="over";
	 }
	 var onmouseout=function(evt,obj){
	       //obj.className="out";
	 }
	
	 var clickFun=function(evt,obj){
	        var callback; 
	       
			if(isCheckedNode(obj.image))
			{	
			    removeImg(obj.image.parentNode);		
			    if(clickcallback!=undefined)
			    {
//			      callback=clickcallback+"('')"; // In order to add multiModules successfully, it needs to return the image title the user selected.
			      callback=clickcallback+"('"+obj.image.title+"')";	
			      eval(callback);				
			    }   
			   
				return;
			}
		
			var selectedNode=CheckedNode();
			if(!mutiselect&&selectedNode!=null)
			{			     
       			  removeImg(selectedNode.parentNode);
			}
			
			addImg(obj.image,sty);
			
			if(clickcallback!=undefined){
			     callback=clickcallback+"('"+obj.image.title+"')";
			    
			     eval(callback);
			 }   
	 };
	 var addImg=function(obj,sty){
	        var img=document.createElement("img");
			img.title=checked;
            img.style.position="absolute";
          
            if(sty=="b")
            {
            img.style.marginLeft=122+"px";
            img.style.marginTop=5+"px";
            }
            if(sty.toLowerCase()=="c")
            {
            img.style.marginLeft=400+"px";
            img.style.marginTop=5+"px";
            }
            obj.parentNode.insertBefore(img,obj);
            img.src="/images/icons/"+sty+"_selected.gif"; 
            if(clickcallother!=null)
            {
              imgobj=obj; 
              var moth=clickcallother+"(true)";
              eval(moth);
            }
	 }
	 var removeImg=function(obj){
	      for(var i=0;i<obj.childNodes.length;i++){
		  	   if(obj.childNodes[i].title==checked){
			      obj.removeChild(obj.childNodes[i]);
			      if(clickcallother!=null)
			      {
			        imgobj=obj; 
                    var moth=clickcallother+"(false)";
                    eval(moth);
			      }
			    }
		  }
	 }
	 var isLeaf=function(li){
	       var aryLI=li.getElementsByTagName("LI");
	       return aryLI.length==0;
	 }	 
	 var init=function(){	
	   
	      var aryLI=container.getElementsByTagName("LI");	
		 for(var i=0;i<aryLI.length;i++){
		       
		        if(!isLeaf(aryLI[i]))continue;
		        var img=getImg(aryLI[i]);	
				YAHOO.util.Event.addListener(aryLI[i],'mouseover',onmouseover,aryLI[i]);
				YAHOO.util.Event.addListener(aryLI[i],'mouseout',onmouseout,aryLI[i]);
				YAHOO.util.Event.addListener(aryLI[i],'click',clickFun,{image:img,action:true});
				
				if(typeof(initValue)==undefined||initValue==""||initValue==null)continue;
				if(img==null)continue; 
				if(initValue!=null&&initValue.toLowerCase()==img.title.toLowerCase()){
				      clickFun(null,{image:img,action:false});					 
				};  
		 }		
		
	 }
	
	 var isCheckedNode=function(obj){
	       for(var i=0;i<obj.parentNode.childNodes.length;i++){		      
		  	   if(obj.parentNode.childNodes[i].title==checked)return true;			       
		  }
		  return false;
	 }
	 var CheckedNode=function(){
	 	var aryImg=container.getElementsByTagName("IMG");
	    for(var i=0;i<aryImg.length;i++){
	        if(aryImg[i].title==checked)return aryImg[i];
	    } 
		return null;
	 }
	 
     init();

 }
 }
 
 
 //****************
 
 
if(typeof(campton) == "undefined"){
	var campton = {};
	campton.debug = true;
}

/*
-======= info 对象说明 =======-
info.className 样式类名
info.title 标题 string
info.action 操作 对象数组[{id:"MNWVDetails", cssClass:"MNWVDetailsS"}, {id:"MNWVThumb", cssClass:"MNWVThumbN"}, {id:"MNWVList", cssClass:"MNWVListN"}]
info.tools 附加工具 [{label:"",link:"", callback:""}]
info.subNavActive 当前tab的样式名称
info.baseTabUrl 请求的基本地址
info.baseParam 请求的基本参数
info.command {left:"ListView",content:"ContentView"}
info.close 附加一个函数到关闭事件上
info.closeTagClassName 启动关闭的标签类名,不写就按默认处理
info.refreshTagClassName 刷新 MNWPanel 的内容
*/
campton.seleter = function(info, cache,closeme) {
  
	var debug = campton.debug;
 
	if(typeof(info) != "object") return;
	var selecter = $("CamptonBox");
	var action = (typeof(info.action) == "object" ? info.action:[{id:"MNWVDetails", cssClass:"MNWVDetailsS"}]);
	var closeTag = info.closeTag;

	var currentView;
	var currentTab;
	var currentTabPage = new campton.cache();
	var pageSize = 24;
	if(typeof(cache) == "undefined")
	{
		cache = new campton.cache();
	}
	
    var first=true;
	var baseUrl = "/ajax.aspx?";
	if (info.url != null)
	    baseUrl = info.url + "&";
	var wt_level2='';
	var subNavVisible = false;
	var hoverSubNav = -1;
	var activeSubNav = 0;
	var l2timer;
	var l2op=0;
	var l2al=0;
	var mnwPanel = getObject('MNWPanel');
	var mnwFooter = getObject('MNWFooter');
	var isAnimating=false;
	var wt_level1='';
	var msWinPath=''
	var tabsContainer = getObject("MNWTabsC");
	var leftTab = info.currentTitle;
 
	var init = function(){
	
        _isStart =true;
        
		var mnwClose = getObject("MNWClose");
	
		YAHOO.util.Dom.setStyle(selecter, "display", "block");
		
		YAHOO.util.Event.removeListener(mnwClose, "click");
	
		YAHOO.util.Event.removeListener(mnwPanel, "click");
		
		YAHOO.util.Event.addListener(mnwClose, "click", close, selecter);
	
		YAHOO.util.Event.addListener(mnwPanel, "click", onClick, info);
		
		if(typeof(info.className) == "string"){
			selecter.className = info.className;
		}
		var width = YAHOO.util.Dom.getStyle(selecter, "width");
		var height = YAHOO.util.Dom.getStyle(selecter, "height");
		
//	    var x=getFixXY(width,height).x.replace("px","");
//		var y=getFixXY(width,height).y.replace("px","");
//		if(x > 0 && y > 0){ 
//			YAHOO.util.Dom.setX(selecter, x);
//			YAHOO.util.Dom.setY(selecter, y);
//		}
	    setFixXY(selecter,width.replace("px",""),height.replace("px",""));
		if(typeof(info.command) == "undefined" || 
				  typeof(info.command.left) == "undefined" || 
				  typeof(info.command.content) == "undefined"){
			if(debug) alert("Error Command of info object!!");
			return;
		};
		if(typeof(info.subNavActive) == "undefined") info.subNavActive = "subNavActive";
		display(info.title, "MNWHeader");
		
		createActionView();
		createToolsView();
		
		createTabsView(); // left 
		
	};
	var clearActionView = function(){
		var target = getObject("MNWView");
		var end = target.childNodes.length - 2;
		for(var i=0; i<end; i++){
			target.removeChild(target.lastChild);
		}
	}
	var close = function(evt, o){
	 
	    clearActionView();
	    
		updateContentView("");
	
		if(cache!=null)cache.clear();
		
		delete info;
		
	    YAHOO.util.Dom.setStyle(o, "display", "none");
	   
	    if(typeof(info.close) == "function") info.close();
	   
	};
		
	var onClick = function(evt, info)
	{
		if(info.disableClose == true) return;
		if(evt==null) evt = window.event;
		var _target = (evt.srcElement ? evt.srcElement : evt.target);
		
		if (closeTag!=null)
		{
		    if(_target.className.toLowerCase().indexOf(closeTag)<0)
		    {
		        if (_target.parentNode == null || _target.parentNode.className.toLowerCase().indexOf(closeTag.toLowerCase())<0)
		            return;
		    }
		}
		
		if(_target == mnwPanel) return;
		
		if ((typeof(info.refreshTagClassName) != "undefined") && (info.refreshTagClassName.toLowerCase().indexOf(_target.className.toLowerCase())>-1 && _target.className!=null &&_target.className !=""))
		{
		    var key = cacheKey();
		    refreshCache(key);
		}
		
        if (typeof(info.closeTagClassName) != "undefined" &&  ((info.closeTagClassName.toLowerCase().indexOf(_target.className.toLowerCase())>-1 && _target.className!=null &&_target.className !="") || (_target.parentNode != null && info.closeTagClassName.toLowerCase().indexOf(_target.parentNode.className.toLowerCase())>-1 && _target.parentNode.className!=null && _target.parentNode.className!="")))
		{		    
		    close(evt, selecter);
		}
	};
	var createActionView = function(){
	   
		var target = getObject("MNWView");
		currentView = (action.length > 0 ? action[0].id : "default");
		
		if(action.length<=1)return;
		for(var i=0; i<action.length; i++){
			var o = action[i];
			var v = document.createElement("DIV");
			v.id = o.id;
			v.className = o.cssClass;
			YAHOO.util.Event.removeListener(v, "mouseover");
			YAHOO.util.Event.removeListener(v, "mouseout");
			YAHOO.util.Event.removeListener(v, "mousedown");
			YAHOO.util.Event.removeListener(v, "mouseup");
			YAHOO.util.Event.removeListener(v, "click");
			YAHOO.util.Event.addListener(v, "mouseover", viewStyle, {obj:v, style:'H'});
			YAHOO.util.Event.addListener(v, "mouseout", viewStyle, {obj:v, style:'N'});
			YAHOO.util.Event.addListener(v, "mousedown", viewStyle, {obj:v, style:'D'});
			YAHOO.util.Event.addListener(v, "mouseup", viewStyle, {obj:v, style:'H'});
			YAHOO.util.Event.addListener(v, "click", changeView, v.id);
			target.appendChild(v);
		}
	};
	
	var viewStyle = function(evt, p){
		if(typeof(p)=="undefined" || p == null) return;
		if(p.style == "D"){
			for(var i=0; i<action.length; i++){
				if(p.obj.id == action[i].id){
					action[i].cssClass = action[i].id + "S";
					p.obj.className = action[i].id + "D";
				}else{
					action[i].cssClass = action[i].id + "N";
					var t = getObject(action[i].id);
					t.className = action[i].cssClass;
				}
			}
		}else if(p.style == "N"){
			for(var i=0; i<action.length; i++){
				var t = getObject(action[i].id);
				t.className = action[i].cssClass;
			}
		}else{
			p.obj.className = p.obj.id + p.style;
		}
	}
	var changeView = function(evt, id){
		currentView = id;
		var key = cacheKey();
		
		if(cache.contains(key)){
		   
			updateContentView(cache.get(key));
		}else{
		   
			mnwPanel.innerHTML = "";
			YAHOO.util.Dom.addClass(mnwPanel, "loading");
			updateCache(key);
		}
	}
	var createToolsView = function(currentFolder){
		if(typeof(info.tools) == "undefined" || info.tools == null || info.tools == "") {display("", "UPLOADLINK"); return;}
		var tools = info.tools;
		var oStr = "";
		for(var i=0; i<tools.length; i++){
		    if(typeof(tools[i].callback) != "undefined"){
			    oStr += "<a href=\"" + tools[i].link + "\"  onclick=\"" + tools[i].callback + "('"+currentFolder+"')\" >" + tools[i].label + "</a>";
			 
			}else{
			    oStr += "<a href=\"" + tools[i].link + "\" target=\"_blank\" >" + tools[i].label + "</a>";
			}
		}
		display(oStr, "UPLOADLINK");
		var tool = document.getElementById("UPLOADLINK");
		var links = tool.getElementsByTagName("A");
		
		for(var i=0; i<links.length; i++){
		    YAHOO.util.Event.removeListener(links[i], "click");
		    YAHOO.util.Event.addListener(links[i], "click", close, selecter);
		}
	}
	var createTabsView = function(){
		if(info.command.left != "cache"){
			var url = baseUrl + "randid="+Math.random()+"&command=" + info.command.left;
		
			campton.update(url, "", "MNWTabsC", addListener2tabs);
			
		}else{
			addListener2tabs("", {responseText:cache.get("$cache23235456464775454")}, getObject("MNWTabsC"));
		}
	}
		
	    var addListener2tabs = function(p, o, target){
		target.innerHTML = o.responseText;
		var tabs = tabsContainer.getElementsByTagName("A");
		currentTab = (tabs.length > 0 ? tabs[0]: null);
		for(var i=0; i<tabs.length; i++){
		    YAHOO.util.Event.removeListener(tabs[i], "mouseover");
		    YAHOO.util.Event.removeListener(tabs[i], "mouseout");
		    YAHOO.util.Event.removeListener(tabs[i], "click");
			YAHOO.util.Event.addListener(tabs[i], "mouseover", subNavOver, i);
			YAHOO.util.Event.addListener(tabs[i], "mouseout", subNavOut, i);
			YAHOO.util.Event.addListener(tabs[i], "click", subNavClick, {index:i, target:tabs[i]});
			YAHOO.util.Event.addListener(tabs[i], "click", function(){return false;});  
			leftTab = info.currentTitle;
			if(leftTab != null){
			     if(tabs[i].title == leftTab){
	                activeSubNav = i;
	                currentTab = tabs[i];  
	             }
	        }
		}
		var content = getContent();
		currentTab.className = info.subNavActive;
		if(content != null && content != "") {
			
			updateContentView(content);
		}
		if(info.command.left == "treeview"){
			//YAHOO.example.initTreeView("treeView5564565465");
		}
		
	}
	var refreshCache = function(key)
	{
	    if (cache != null)
	        cache.clear();
	        
	    mnwPanel.innerHTML = "";
		YAHOO.util.Dom.addClass(mnwPanel, "loading");
		updateCache(key);
	}
	
	var updateCache = function(key){
		var p = key.split('|');
		if(p.length != 3) return;
		
		var url = baseUrl + "command=" + info.command.content + "&folder=" + urlEncode(currentTab.title) + "&template=" + currentView + "&pageindex="+getCurrentTabPage() + "&pagesize=" + pageSize;
	    if(first)
	    {
	       url+="&first=1";
	       first=false;
	    }
	    
		campton.update(url, info.postData, "", addContent2Cache, key);
	}
	var addContent2Cache = function(key, o, target){
		var content = o.responseText;
		cache.add(key, content);
		updateContentView(content);
	}
	var updateContentView = function(value){
	  
		var splitIndex = value.indexOf("<!-- pager -->");
		
		if(splitIndex >= 0){
			//mnwPanel.innerHTML = value.substring(0, splitIndex);
			
			setInnerHTML(mnwPanel,value.substring(0, splitIndex));
			updatePagerView(value.substring(splitIndex));
		}else{
			//mnwPanel.innerHTML = value;
		
			setInnerHTML(mnwPanel,value);
			updatePagerView();
		}
	
		YAHOO.util.Dom.removeClass(mnwPanel, "loading");
        _isCompletion=true;//beer 2008 0426	
        _isStart=false;	
	};
	
	var display = function(txt, target){
		if(typeof(target) == "undefined" || target == null) return;
		var t = (typeof(target) == "string" ? getObject(target):target);
		if(typeof(t.innerHTML) == "string") {setInnerHTML(t,txt);}
		else if(typeof(t.innerText) == "string") {setInnerHTML(t,txt);}
		else if(typeof(t.value) == "string") {t.value = txt; }
	}
	var subNavOver = function(evt, index){
		if(index != activeSubNav && index != hoverSubNav) {
			var tabs = tabsContainer.getElementsByTagName("A");
		 	var newTab = tabs[index];
		 	hoverSubNav = index;
		} 
	}
	var subNavOut = function(evt, index) {
		if(index == hoverSubNav && index != activeSubNav) {
			var tabs = tabsContainer.getElementsByTagName("A");
			var hoverTab = tabs[hoverSubNav];
			hoverSubNav = -1;
		} 
	}
	var subNavClick = function(evt, p) {
	 
		if(isAnimating){
			return false;
		}
		var index = p.index;
		var target = p.target;
		currentTab = target;
		if(index != activeSubNav) {
			var tabs = tabsContainer.getElementsByTagName("A");
			var newTab = tabs[index];
			var oldTab = tabs[activeSubNav];
	
			if(newTab && oldTab) {
				newTab.className = info.subNavActive;
				oldTab.className = '';
				activeSubNav = index;
			}		
			if(mnwPanel!=null) {
				wt_level2 = target.childNodes[0].nodeValue;
				var value = getContent(newTab.childNodes[0].nodeValue);
				
				if(value != null && value != "")
				{
					fContent = value;
					isFading = true;
					isAnimating = true;
					l2al=100;
					l2op=1;
					l2timer = setInterval(subNavClickInterval, 1);
				}
			}
		}
		
		createToolsView(wt_level2);
		return false;
	}
	var subNavClickInterval = function() {
		if(isFading){
			if(l2al<=0){
				isFading=false;
			    
			    setInnerHTML(mnwPanel,"");
				setInnerHTML(mnwPanel,fContent);
				
			} else{
				l2al=l2al-15;
				if(l2al<0)
					l2al=0;
				l2op=l2op-0.15;
				if(l2op<0)
					l2op=0;
			}
		} else{
			l2al=l2al+15;
			l2op=l2op+0.15;
		}
		mnwPanel.style.MozOpacity = ''+l2op;
		mnwPanel.style.filter = 'alpha(Opacity='+l2al+')';
		if(l2al>=100 && !isFading) {
			mnwPanel.style.MozOpacity = '';
			mnwPanel.style.filter = '';
			clearInterval(l2timer);
			isAnimating = false;
			l2timer = null;
		}
	}
	var getContent = function(tab){
		var key = cacheKey();
		if(cache.contains(key)){
			var value = cache.get(key);
			var splitIndex = value.indexOf("<!-- pager -->");
			if(splitIndex >= 0){
				var content = value.substring(0, splitIndex);
				updatePagerView(value.substring(splitIndex));
			}else{
				var content = value;
				updatePagerView();
			}
			YAHOO.util.Dom.removeClass(mnwPanel, "loading");
			return content;
		}else{
			mnwPanel.innerHTML = "";
			YAHOO.util.Dom.addClass(mnwPanel, "loading");
			updateCache(key);
			return "";
		}
	}
	var updatePagerView = function(value){
		if(typeof(value) == "undefined"){
			mnwFooter.innerHTML = "";
			return;
		}
		mnwFooter.innerHTML = value;
		var list = mnwFooter.getElementsByTagName('A');
		for(var i=0; i<list.length; i++){
		    YAHOO.util.Event.removeListener(list[i], "click");
			YAHOO.util.Event.addListener(list[i], "click", changePage, list[i]);
		}
	}
	
	var changePage = function(evt, o){
		currentTabPage.add(currentTab.title, o.innerHTML);
		var key = cacheKey();
	
		if(cache.contains(key)){

			updateContentView(cache.get(key));
		}else{
		  
			mnwPanel.innerHTML = "";
			YAHOO.util.Dom.addClass(mnwPanel, "loading");
			updateCache(key);
		}
	}
	
	var cacheKey = function(){return currentView.replace('|','') + "|" + currentTab.title.replace('|','') + "|" + getCurrentTabPage();}
	
	var getCurrentTabPage = function() {return (currentTabPage.contains(currentTab.title) ? currentTabPage.get(currentTab.title):1);}
	if(campton.seleter.arguments.length==3){
	   
	    close(null,selecter);
	    
	    return;
	    
	 }
	init();
}

function DeleteImagesInSelecter(imgPath)
{
    if (confirm(__confirmToDeleteImages))
    {
        var url = "/ajax.aspx?command=deleteimagesinselecter&imgpath=" + imgPath;    
        YAHOO.util.Connect.asyncRequest("GET", url, null);
    }
    
}

campton.update = function(url, postData, target, callback, param,evalscript){
	var debug = campton.debug;
	if(typeof(url) == "undefined" || url == null || url == "") return;
	if(typeof(target) == "undefined" || target == null) return;
	var obj = (typeof(target) == "string" ? getObject(target) : target);
	if((typeof(obj) == "undefined" || obj == null) && (typeof(callback) != "function")) return;
	var init = function(){
		if(typeof(obj)=="object") YAHOO.util.Dom.addClass(obj, "loading");
		var request = YAHOO.util.Connect.asyncRequest('GET', url, Callback, postData);
	}
	var Success = function(o){
		if(typeof(obj)=="object") YAHOO.util.Dom.removeClass(obj, "loading");
		if(typeof(callback) == "function"){
			callback(param, o, obj);
		}else{
			setInnerHTML(obj, o.responseText);
		}	
	}
	var Failure = function(o){
		if(debug) alert(o.responseText);
		YAHOO.util.Dom.removeClass(obj, "loading");
	}
	var Callback = {success:Success, failure:Failure}
	init();
}
campton.cache = function(){this.cache = new Object();}
campton.cache.prototype ={
	contains:function(key){return typeof(this.cache[key]) != "undefined";},
	get:function(key){
		if(typeof(this.cache[key]) != "undefined"){
			return this.cache[key];
		}
		return null;
	},
	add:function(key, value){this.cache[key] = value;},
	remove:function(key){delete this.cache[key];},
	clear:function(){for(var key in this.cache){delete this.cache[key];}},
	getKeys:function(){
		var keys = [];
		for(var key in this.cache){
			keys.push(key)
		}
		return keys;
	}
}
campton.createCache = function(items, contents, leftContent){
	if(items.length != contents.length) return;
	var cache = new campton.cache();
	for(var i=0; i<items.length; i++){
		var key = "default|" + items[i].replace(/^\"|\"$/g,'') + "|1";
		cache.add(key, contents[i]);
	}
	cache.add("$cache23235456464775454", leftContent);
	return cache;
}

function urlEncode(str)
{
	if(str==null||str=="")
		return "";
	var newstr="";
	function toCase(str){
		return str.toString(16).toUpperCase();
	}
	for(var i=0,icode,len=str.length;i<len;i++){
		icode=str.charCodeAt(i);
		if( icode<0x10)
			newstr+="%0"+icode.toString(16).toUpperCase();
		else if(icode<0x80){
			if(icode==0x20)
				newstr+="+";
			else if((icode>=0x30&&icode<=0x39)||(icode>=0x41&&icode<=0x5A)||(icode>=0x61&&icode<=0x7A))
				newstr+=str.charAt(i);
			else
				newstr+="%"+toCase(icode);
		}
		else if(icode<0x800){
			newstr+="%"+toCase(0xC0+(icode>>6));
			newstr+="%"+toCase(0x80+icode%0x40);
		}
		else{
			newstr+="%"+toCase(0xE0+(icode>>12));
			newstr+="%"+toCase(0x80+(icode>>6)%0x40);
			newstr+="%"+toCase(0x80+icode%0x40);
		}
	}
	return newstr;
}
var setInnerHTML = function (el, htmlCode) {
    var ua = navigator.userAgent.toLowerCase(); 
    htmlCode=htmlCode.replace("JavaScript","javascript");  
    if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0) {      
        htmlCode = '<div style="display:none">for IE</div>' + htmlCode;
        htmlCode = htmlCode.replace(/<script([^>]*)>/gi,
                                    '<script$1 defer="true">');
          
                              
      
        el.innerHTML = htmlCode;  
                                
        el.removeChild(el.firstChild);
        
    }
    else {
        var el_next = el.nextSibling;
        var el_parent = el.parentNode;
        if(el_parent==null||el==null)return;
        el_parent.removeChild(el);
        el.innerHTML = htmlCode;
      
        if (el_next) {
            el_parent.insertBefore(el, el_next)
        } else {
            el_parent.appendChild(el);
        }
    }
}



document.AjaxWrite = function() {
    var body = document.getElementsByTagName('body')[0];
    for (var i = 0; i < arguments.length; i++) {
        argument = arguments[i];
        if (typeof argument == 'string') {
            var el = body.appendChild(document.createElement('div'));
            setInnerHTML(el, argument)
        }
    }
}

 
/*************************** Select Layout *********************************/
/***************************************************************************/

/***************************************************************************/
function formatUrl(sUrl)
{
    var index = sUrl.indexOf("#");
    var url = sUrl;
    
    if (index > -1 && index == url.length-1)
        url = url.substring(0, url.length-1); // remove the #
    
    index = sUrl.lastIndexOf("/");
    if (index > -1 && index == url.length-1)
        url = url + "default.aspx"; // if sUrl likes http://www.aa.com/, it should be added default.aspx to the end.
    
    index = url.indexOf("?");
    if (index > -1 && index == url.length-1) // http://www.123.com/default.aspx?
        url = url.substring(0, url.length-1);
    
    if (url.indexOf("?") > -1) // http://www.123.com/?
        url = url + "&"; // url has already had querystring
    else
        url = url + "?"; // 
    
    return url;
    
}

// Reset the value of the key in querystring
function SetQueryStringValue(url, key, value)
{
    var result = "";
    var index = url.indexOf(key + "=");
    if (index < 0)
    {
        result = formatUrl(url);
        result += key + "=" + value;
    }
    else
    {
        // key exists in url    
        var keyLength = key.length + 1;
        var indexOfStartReplace = index + keyLength;
        var valueContent = url.substring(indexOfStartReplace, url.length);
        var indexOfAnd = valueContent.indexOf("&");
        var indexOfEndReplace;
        if (indexOfAnd < 0)
            indexOfEndReplace = url.length;
        else
            indexOfEndReplace = indexOfStartReplace + indexOfAnd;
            
        var strReplace = url.substring(indexOfStartReplace, indexOfEndReplace);        
        result = url.replace(strReplace, value)
    }
    
    return result;    
}

// Remove the key in querystring
function RemoveQueryString(url, key)
{
    var result = "";
    var index = url.indexOf(key + "=");
    if (index < 0)
	    return url;
    else
    {
        // key exists in url    
        var keyLength = key.length + 1;
        var indexOfStartReplace = index; // from key 
        var valueContent = url.substring(indexOfStartReplace, url.length);
        var indexOfAnd = valueContent.indexOf("&");
        var indexOfEndReplace;
        if (indexOfAnd < 0)
        {
            indexOfStartReplace = index - 1;
            indexOfEndReplace = url.length;
        }
        else
        {
            indexOfEndReplace = indexOfStartReplace + indexOfAnd + 1;
        }
            
        var strReplace = url.substring(indexOfStartReplace, indexOfEndReplace);        
        result = url.replace(strReplace, "")
    }
    
    return result;    
}

/***************************************************************************/




function callItBack(value,width,height){
    _tempValue=value;
    _width=width;
    _height=height;
    if(_mothod!=null)
    {
       _isCompletion=false;
       eval(_mothod);
       callItBackTimer();
    }
    else{
    callItBackTimer();}
}

function callItBackTimer()
{ 
    if(!_isCompletion){window.setTimeout("callItBackTimer()",100);return;}
    _tempValue=_tempValue.substring(1);
    _tempValue=_tempValue.substring(_tempValue.indexOf('/')+1);
    _tempValue=_tempValue.substring(_tempValue.indexOf('/')+1);
    var control=$(_uploadFiletext);
    control.value = _tempValue;
    var websitelogoheight=$('websitelogoheight');
    var websitelogowidth=$('websitelogowidth');
//    if(websitelogowidth!=null&&websitelogoheight!=null)
//    {
////       if((_tempValue.toLowerCase()).indexOf(".swf")>0)
////       {
////          websitelogowidth.childNodes[1].value="";
////          websitelogoheight.childNodes[1].value="";
////       }
////       else{

//            if(_width!=null&&_width>0)
//            {
//              websitelogowidth.childNodes[1].value=_width;
//            }
//            else{
//            websitelogowidth.childNodes[1].value="";
//            }
//       
//            if(_height!=null&&_width>0)
//            {
//              websitelogowidth.childNodes[1].value=_height;
//            }
//            else{
//            websitelogoheight.childNodes[1].value="";
//            }
//       
////       }
//    }
}


var _formContainer = "formContainer823938293272932";
var _fileContainer = "fileContainer28932823873";
var _uploadSuccessFiles = [];
var _uploadFailFiles = [];
var _startInfo = {};
var _clearCache = false;

function showUploadControl(callback, targetFolder){

    __uploadsucessCallback=callback;
   // showMask();
	var width = 380;
   // var height = 400;
	//var x=getFixXY(width,height).x;
	//var y=getFixXY(height,height).y;
	
	var o = document.createElement("div");
	o.id = _formContainer;
	o.className =_formContainer;
	
	YAHOO.util.Dom.setStyle(o, "width", width + "px");
	//YAHOO.util.Dom.setStyle(o, "height", height + "px");//
	var closebar = document.createElement("div");
	closebar.className = "closeUploadBox";
	o.appendChild(closebar);
	YAHOO.util.Event.addListener(closebar, "click", doCloseFiles);
	var infoBar = document.createElement("div");
	infoBar.className = "infoBar";
	var infoText = document.createElement("div");
	infoText.id = "infoText2993289744";
	infoBar.appendChild(infoText);
	o.appendChild(infoBar);
	o.appendChild(buidUploadForm());
//	___hide();
	var btn = document.createElement("input");
	btn.type = "button";
	btn.id = "doUpload23832923";
	btn.value = __uploadLinkText;
	
	
//    var tabsContainer = getObject("MNWTabsC");
//    var tabs = tabsContainer.getElementsByTagName("A");
//	currentTab = (tabs.length > 0 ? tabs[0]: null);
//	
//    var defaultCurrentTitle = currentTab.innerHTML;
//    var index = defaultCurrentTitle.indexOf("#");
//    defaultCurrentTitle = defaultCurrentTitle.substring(index+1,defaultCurrentTitle.length-index);
	
//	YAHOO.util.Event.addListener(btn, "click", doUploadFiles, {target:(targetFolder==undefined)?defaultCurrentTitle:targetFolder});
    YAHOO.util.Event.addListener(btn, "click", doUploadFiles, {target:targetFolder});

	var btnContainer = document.createElement("div");
	btnContainer.className = "btnContainer";
	btnContainer.appendChild(btn);

	o.appendChild(btnContainer);
	document.body.appendChild(o);
    
//	YAHOO.util.Dom.setX(o, x);
//	YAHOO.util.Dom.setY(o, y);
    o.style.position = 'absolute';
    setFixXY(o,width,400);
   // o.style.top=y;
   // o.style.left=x;
    o.style.zIndex=1600;	
    o.style.height="";
    var strUploadHellpText="<span class='uploadHelpTextStyle'>"+__uploadHelpText+"</span>";
    
	displayInfo(strUploadHellpText, "WarningMsg");


};

// Upload File Event
function doUploadFiles(evt, obj){
	_uploadSuccessFiles = [];
	_uploadFailFiles = [];
    var formObject = $(_fileContainer);
    
    YAHOO.util.Connect.setForm(formObject, true);
    
    var url = "/UploadFilesHandler.aspx?id=" + __portalId + "&key=file" ;
    url += "&targetFolder=" + obj.target;
    
    YAHOO.util.Connect.asyncRequest('POST', url, uploadCallback);
  
	resetFormContainer("upLoading", "display", "none");
	
};

var uploadCallback = {
    upload:uploadCallback
};

function uploadCallback(o){
	var s = o.responseText;
	if(s.indexOf('|')>0){
	    var p = s.split("|");
	    for(var i = 0; i < p.length; i++){
	       eval(p[i] + "\(" + p[++i] + "\)");
	    }
	}	
};

function uploadSuccessFile(s){
	_uploadSuccessFiles.push(s);
};

function uploadFailFile(s){   
	_uploadFailFiles.push(s);	
};

function uploadComplete(s){
	_clearCache = true;
	if (_uploadFailFiles.length == 0)
	{	  
		doCloseFiles();		
	}
	else
	{
		var target = getObject(_fileContainer);
		var list = getFileItems();
	
		for(var i=0; i < list.length; i++){
			var isFail = false;
			for(var j=0; j< _uploadFailFiles.length; j++){
				if(isNull(_uploadFailFiles[j])) continue;
				if(list[i].value.indexOf(_uploadFailFiles[j]) >= 0){
					isFail = true;
					break;
				}
			}
			if(!isFail) target.removeChild(list[i].parentNode);

		}
		
		resetFormContainer(_formContainer, "display", "");
		
		returnValue = __uploadReturnText.replace("{1}", _uploadFailFiles);
		returnValue = returnValue.replace("{2}", s);
		
		displayInfo(returnValue, "ErrorMsg");
		
	}
};

function displayInfo(text, cssClass){
	text = text.replace(/[\r|\n]+/, "<br />");
	var info = getObject("infoText2993289744");
	info.className = cssClass;
	info.innerHTML = text;
};

function resetFormContainer(s, k, v){
	var obj = $("itemTemplate892283732");
	obj.className = s;
	var list = obj.childNodes;
	YAHOO.util.Dom.setStyle($("doUpload23832923"), k, v);
	for(var i=0; i<list.length; i++)
	{
		YAHOO.util.Dom.setStyle(list[i], k, v);
	}
};

function doCloseFiles(){
    var o = getObject(_formContainer);
    document.body.removeChild(o);
    eval(__uploadsucessCallback);
	
};

function getFileItems(){
    var target = getObject(_fileContainer);
    return YAHOO.util.Dom.getElementsByClassName("cssClassInputItem", "input", target);
};

function resetStatus(index){
    try{
        var btn = getObject("doUpload23832923");
       
        btn.style.display = "";
        var old = getObject("file_" + index);
        var list = getFileItems();
        var o = true;
        for(var i=0; i<list.length; i++){
            YAHOO.util.Dom.setStyle(list[i].parentNode, "backgroundColor", "");
            if(list[i] != old && list[i].value == old.value){

                YAHOO.util.Dom.setStyle(list[i].parentNode, "backgroundColor", "#00FF00");
                YAHOO.util.Dom.setStyle(old.parentNode, "backgroundColor", "#FF0000");
                btn.style.display = "none";
                return false;
            }
        }
    }catch(e){}
   
    return true;
};
function isNull(value){
    try{
        if(typeof value == "undefined" || value == null){
            return true;
       }
    }catch(e){
        return true;
   } 
    return false;
}
function addNextFile(index, noreset){
   
    if(noreset != true && !resetStatus(index)) return;
    var list = getFileItems();
   
    if(list.length > 7) return;
    index++;
    var obj = getObject("file_" + index);
   
    if(isNull(obj)){
        var target = getObject(_fileContainer);
        var newObj = formItem(index);
        target.appendChild(newObj);
    }
};

function removeFormItem(index){
    var obj = getObject("file_" + index);
    var list = getFileItems();
    var btn = getObject("doUpload23832923");
    if(!isNull(obj) && obj.value.length > 0){
        var bg = YAHOO.util.Dom.getStyle(obj.parentNode, "backgroundColor");
        if(bg.length > 0){
            for(var i=0; i<list.length; i++){
                if(list[i] != obj && list[i].value == obj.value){
                    YAHOO.util.Dom.setStyle(list[i].parentNode, "backgroundColor", "");
                    YAHOO.util.Dom.setStyle(obj.parentNode, "backgroundColor", "");
                    btn.style.display = "";
                }
            }
        }
        var target = getObject(_fileContainer);
        target.removeChild(obj.parentNode);
    }
    var o = true;
    for(var i=0; i<list.length; i++){
        if(list[i].value == ""){
            o = false;
        }
    }
    if(o){
        addNextFile(index+8, true);
    }
};

function buidUploadForm(){
    var o=document.createElement("div");
	o.id="itemTemplate892283732";
    var form = document.createElement("form");
    form.id = _fileContainer;
	form.name = _fileContainer;
    var target = formItem(1);
    form.appendChild(target);
    o.appendChild(form);
    return o;
};

function formItem(index){
    var o = document.createElement("div");
    YAHOO.util.Event.addListener(o, "mouseover", function(){YAHOO.util.Dom.setStyle(this, 'border', '1px solid #404040');});
    YAHOO.util.Event.addListener(o, "mouseout", function(){YAHOO.util.Dom.setStyle(this, 'border', '1px solid #D4D0C8');});
    o.className = "formItem";
    o.innerHTML = "<label class='uploadFileTextStyle'>" + __uploadFileText + "</label><input class=\"cssClassInputItem\" type=\"file\" id=\"file_" + index + "\" name=\"file_" + index + "\" onchange=\"addNextFile(" + index + ");\" /> <a href=\"javascript:void(0);\" onclick=\"removeFormItem(" + index + ");\"> <img src=\"/Tools/images/close_window.jpg\" width=\"11\" height=\"11\" border=\"0\" /></a>";
    return o;
};


function Addflashimage(i, trim)  
{
if (typeof(i) == "object")
    _uploadFiletext = i;
else
    if(!trim||isIE()){_uploadFiletext=$('file'+i);}
    else{
     _uploadFiletext=$('ImageFiles').childNodes[1].childNodes[i+2].childNodes[0].childNodes[0];;}
    if(trim!=null)_mothod=trim;
    else _mothod=null;
    showSelector();
   
}



function Add(controls, trim)  
{ 
    _uploadFiletext=controls;
    if(trim!=null)_mothod=trim;
    else _mothod=null;
    showSelector();
   
}
function showSelector(folder)
{
    showImageSelector(_uploadFiletext, null, "javascript:void(0);", "openUpload", folder);
}
function showImageSelector(target, callback,url,uploadCallback, targetFolder)
{
    __title = "File Tools";
    showMask();
    var __link = url;
    campton.seleter({title:__title, className:"treelist", currentTitle:(targetFolder==undefined)?"/":targetFolder+"/" ,closeTagClassName:"entry,detailpic,title,desc",refreshTagClassName:"deleteimg", close: (callback)?callback:closeMask, disableClose: false, subNavActive:"subNavActive", tools:[{label:__uploadLinkText, link:__link, callback:uploadCallback}], command:{left:"treeview", content: "contentview"} });
}
function openUpload(targetFolder)
{
    var tabsContainer = getObject("MNWTabsC");
    var tabs = tabsContainer.getElementsByTagName("A");
    currentTab = (tabs.length > 0 ? tabs[0]: null);
    
    if (targetFolder == undefined || targetFolder == null || targetFolder == "undefined")
    {
        if (currentTab == null)
            targetFolder = "/";
        else
            targetFolder = currentTab.innerHTML;
    }
    
    showUploadControl("showSelector('"+targetFolder+"')", targetFolder)
    window.setTimeout("showMask()",200);
}

function DeleteOneRecordUpdatePenl(lastRecoud,pageSize,pageIndex)
{  
  var chkboxtemp=document.getElementsByName("chk_select");
  if(pageIndex==null)pageIndex=document.getElementById("ddlPage").value;
  if(pageSize==null)
  pageSize=document.getElementById("txtPageSize").value;
  var length=chkboxtemp.length;//当前页面记录数

  if(length==1||lastRecoud)
    {
     pageIndex=pageIndex-1;
    }
  GetPageContent(pageIndex,pageSize);
}

function DeleteRecordsUpdatePenl(length,j)
{
    var pageIndex=(document.getElementById("ddlPage"));
    var pageSize=(document.getElementById("txtPageSize")); 
    var index=pageIndex.value; 
    if(j==length)
       {
         if(index!=1)index=index-1;
         
       }
    GetPageContent(index,pageSize.value);
 }
 
 function AddOrEditRecordsUpdatePenl()
 {
    var pageIndex=(document.getElementById("ddlPage"));
    var pageSize=(document.getElementById("txtPageSize"));
    if(pageIndex==null||pageSize==null)
    {
      GetPageContent(1,15);
    }
    else{
    GetPageContent(pageIndex.value,pageSize.value);
    }
 }
 
/**********************************可编辑的list下拉菜单******************************************/
 
 //增加列表的值
function addlistvalue()
{
   var text=document.getElementById("categoryname");
   var list1 = $("editselect");
   var opNode = document.createElement("option");
   var value=text.value.replace(/(^\s*)|(\s*$)/g,"");
   if(value=="")
     {
      alert(__isnull);
      return;
     }
   if(!IsExistValue(value,-1))//检查是否存在相同的Text
     {
         alert(__existevlue);
         return;
     }      
   opNode.text =value;
   opNode.value ="0";
   list1.options.add(opNode);
   text.value="";
   getmodelist();
   list1.selectedIndex=-1;
  
   
}
//得到列表的string值
function getmodelist()
{
  var hiddelist=document.getElementById("hiddelist");
  var string="[";
  var list1 = $("editselect");
  var length=list1.options.length;
  for(var i=0;i<length;i++)
  {
   if(i>0)string+=",";
   string+="{\"ID\":\""+list1.options[i].value+"\", \"Name\":\""+list1.options[i].text+"\"}";
   
  }
  string+="]";
  hiddelist.value=string;
  
}
//编辑列表
function editlistvalue()
{
   var objTable =$("editselect");
   var editcontrol=document.getElementById("edit");
   var text=document.getElementById("categoryname");
   var index=objTable.selectedIndex;
   var value=text.value.replace(/(^\s*)|(\s*$)/g,"");
    if(value=="")
       {
         alert(__isnull);
         return;
        }
     if(!IsExistValue(value,index))//检查是否存在相同的Text
     {
         alert(__existevlue);
         return;
     }    
     objTable[index].text=value;
     text.value="";
     objTable.selectedIndex=-1;
     getmodelist();
     Cancle();
     
    
} 
//删除列表中的值
function deletevalue()
{
  var editcontrol=document.getElementById("edit");
  var objTable =$("editselect");
  var index=objTable.selectedIndex;
  if(index<0)
     {
      alert(__noSelect);
      return;
     }
  var isdelete=confirm(__isDelete);
  if(isdelete)
   {
     objTable.remove(index);
     objTable.selectedIndex=-1;
     getmodelist();
     Cancle();
   }
}
//操作列表的取消
function Cancle()
{
  var addcontrol=document.getElementById("Add");
  var editcontrol=document.getElementById("edit");
  var delecontrol=document.getElementById("deleteid");
  var canccontrol=document.getElementById("cancleid");
  addcontrol.disabled="";
  delecontrol.disabled="disabled";
  canccontrol.disabled="disabled";
  editcontrol.disabled="disabled";
  var text=document.getElementById("categoryname");
  text.value="";
  var objTable =$("editselect");
  objTable.selectedIndex=-1;
 
}

function IsExistValue(value,index)
{
  var list1 = $("editselect");
  var length=list1.options.length;
  for(var i=0;i<length;i++)
  {
   if(index!=i&&list1.options[i].text==value) return false;
   
  }
  return true;
}

function onchanged()
{
  var addcontrol=document.getElementById("Add");
  var editcontrol=document.getElementById("edit");
  var delecontrol=document.getElementById("deleteid");
  var canccontrol=document.getElementById("cancleid");
  addcontrol.disabled="disabled";
  delecontrol.disabled="";
  canccontrol.disabled="";
  editcontrol.disabled="";
  var text=document.getElementById("categoryname");
  var objTable =$("editselect");
  var index=objTable.selectedIndex;
  text.value=objTable[index].text;
}
/*********************************************************************************************/

function getScroll()  {     var t, l, w, h;          if (document.documentElement && document.documentElement.scrollTop) {         t = document.documentElement.scrollTop;         l = document.documentElement.scrollLeft;         w = document.documentElement.scrollWidth;         h = document.documentElement.scrollHeight;     } else if (document.body) {         t = document.body.scrollTop;         l = document.body.scrollLeft;         w = document.body.scrollWidth;         h = document.body.scrollHeight;     }     return { top: t, left: l, width: w, height: h }; } 

function getFixXY(width,height){
      var scoll=getScroll();
      var scrollHeight=document.body.scrollTop;
      var availHeight=window.screen.availHeight;
      
	  var x = parseInt((document.body.clientWidth - (""+width).replace("px", ""))/2)+scoll.left;
	  var y = parseInt((document.body.clientHeight - (""+height).replace("px", ""))/2)+scoll.top;
	  
      if(parent.document!=null&&parent.document.getElementById('main')!=null)
      {
       var main=parent.document.getElementById('main');
        var topheight=main.offsetTop;
        parentScrollTop=parent.document.documentElement.scrollTop-topheight;
        y+=parentScrollTop;
        if(y<0)y=0;            
      }
      x+="px";
      y+="px";
	  return {x:x,y:y};	
}
function setFixXY(obj,width,height)
{
   var t=getScroll();
   obj.style.width=width+"px";
   if(height!=null)
   obj.style.height=height+"px";
   else obj.style.height="auto";
   obj.style.top="50%";
   obj.style.left="50%";
   obj.style.marginTop=-height/2+t.top+"px";
   obj.style.marginLeft=-width/2+t.left+"px";
   obj.style.display="block";
   if(parent.document!=null&&parent.document.getElementById('main')!=null)
    {                             
        var temp=0;                 
        if(!BrowserIsIE()){ 
          temp=-height/2+t.top-1000-236+parent.scrollY;
        }
        else 
        {                 
             temp=-height/2+t.top-1000-236+parent.parent.document.documentElement.scrollTop;
        } 
        if(temp<-1500)temp=-1500;         
        obj.style.marginTop=temp+"px";
    }
}

// Paging: Get content and put it into entity grid by ajax
function GetGrid(command, key, DataParam, getGridCallback)
{
    var url='/ajax.aspx';
    var data;
    
    data = 'command='+command+'&key='+key;
    data += '&'+DataParam; 
    YAHOO.util.Connect.asyncRequest("POST", url, getGridCallback, data);
}

function GetPageContent(PageIndex, PageSize)
{
    var strParam ='where='+_where+'&pageindex='+PageIndex+'&pagesize='+PageSize;
    GetGrid(_command, _key, strParam, getGridCallback);
}

function numbersonly(){return true;}

function changeEType(node,exitPorduct,exitNews,url,onclickStr,type){
  
    var typeStr_1;
    var typeStr_2;
    var typeStr_A;
    var typeStr_B;
    var t1=node.options[node.selectedIndex].text;
    if(node.options[node.selectedIndex].value==1)
    {
      typeStr_1="ty=1";
      typeStr_A="ty/1";
      typeStr_2="ty=4";
      typeStr_B="ty/4";
    }
    else
    {
      typeStr_2="ty=1";
      typeStr_1="ty=4";
      typeStr_A="ty/4";
      typeStr_B="ty/1";
    } 

    var t2=node.options[node.selectedIndex==0 ? 1 :0].text;
  
    var div=node.parentNode.parentNode;
    
    var ele=div.getElementsByTagName("A");
   
    for(var i=0;i<ele.length;i++){
   
       if(ele[i].innerHTML.toLowerCase().indexOf("option")>=0)continue; 
       ele[i].innerHTML=ele[i].innerHTML.replace(t2,t1).replace(t2,t1);
       if(ele[i].href!=null)
       ele[i].href=ele[i].href.replace(typeStr_2,typeStr_1).replace(typeStr_B,typeStr_A);
       if(ele[i].id=="category")
       {     
          if(node.options[node.selectedIndex].value==1)//product
          {
             if(exitPorduct)
             {
                  ele[i].innerHTML=__SelectPorductCategory;
                  ele[i].target="_self";
                  ele[i].href="javascript:"+onclickStr.replace("[TYPE]","1");                  
                  onchangeOnclick(ele[i],onclickStr.replace("[TYPE]","1"));
             }
             else
             {
                  ele[i].innerHTML=__AddPorductCategory;
                  ele[i].href=url;
                  ele[i].removeAttribute("onclick");
             }
          }
          else//news
          {
             if(exitNews)
             {
                  ele[i].innerHTML=__SelectNewsCategory;
                  ele[i].target="_self";
                  ele[i].href="javascript:"+onclickStr.replace("[TYPE]","4");
                  onchangeOnclick(ele[i],onclickStr.replace("[TYPE]","1"));
                  
                  
             }
             else
             {
                  ele[i].innerHTML=__AddNewsCategory;
                  ele[i].href=url;
                  ele[i].removeAttribute("onclick");
             }
           
          }
       }
       if(ele[i].id=="generlist")
       {
         if(node.options[node.selectedIndex].value==1)//product
          {
             if(exitPorduct)
             {
                  ele[i].innerHTML=__SelectPorduct;
                  ele[i].href="javascript:"+onclickStr.replace("[TYPE]","1");
                  ele[i].target="_self";                  
                  onchangeOnclick(ele[i],onclickStr.replace("[TYPE]","1"));
             }
             else
             {
                  ele[i].innerHTML=__AddPorduct;
                  ele[i].href=url;
                  ele[i].removeAttribute("onclick");
             }
          }
          else//news
          {
             if(exitNews)
             {
                  ele[i].innerHTML=__SelectNews;
                  ele[i].target="_self";
                  ele[i].href="javascript:"+onclickStr.replace("[TYPE]","4");
                  onchangeOnclick(ele[i],onclickStr.replace("[TYPE]","4"));
                  
                  
             }
             else
             {
                  ele[i].innerHTML=__AddNews;
                  ele[i].href=url;
                  ele[i].removeAttribute("onclick");
             }
           
          }
       }
       
    }
    
    //changeEType(this,false,false,'http://www.flashcjy.uk/Default.aspx?TabId=27077&s=BizCategoryManagement&ty=1','gselcategory(37701,this);return false;','categorylist')
    
}
function onchangeOnclick(obj,onclickStr)
{
  if(BrowserIsIE()){
     obj.setAttribute("onclick",new Function(onclickStr));
  }
  else
  {
    obj.setAttribute("onclick",onclickStr);
  }   
}

function gadd(url1,url2,mid,node){
    var url;
    var typeid=getTypeId(node);
    if(typeid==1)url=url1;
    else url=url2;
    window.open(url + "?listid="+mid);
}
function gsel(mid,node,typeID)
{ 
    var __title =__choseProduct;
    var __link="";
    showMask();
    var callback="";
    var typeid;
    if(typeID!=null){typeid=typeID;}
    else{typeid=getTypeId(node);}
    templateID=mid;
    pids=dnn.getVar("PID_"+mid);
    var pmd=dnn.getVar("PMD_"+mid);
    campton.seleter({url:"/ajax.aspx?typeid="+typeid+"&templateid="+templateID+"&pids="+pids+"&pmd="+pmd ,currentTitle:pmd,title:__title, className:"tablist",closeTag:__closeTag, close: (callback)?callback:closeMask, disableClose: false, subNavActive:"subNavActive", tools:[{label:"", link:__link}], command:{left:"porducetreeview", content: "porducetview"} });
}
function writeEnlable(value,temp,chkbox)
{
  var input=$('numperpagespan').childNodes[0];
  if(chkbox.checked)
  {
    input.readOnly=false;
    input.style.border="1px #CDCDCD solid";
    chkbox.value="1";
  }
  else
  {
   input.readOnly=true;
   input.style.border="0px";
   input.value=10;
   chkbox.value="";
  }
  
}
function getTypeId(node){

    var container=node.parentNode.parentNode;
  
  
    var select=container.getElementsByTagName("SELECT")[0];
  
    bizcategorytypeID=select.value;
    return bizcategorytypeID;
    

}
function gselcategory(mid,node,type)
{
    var objDivGCA = $("divGridControllerArea");
    showMask();
    categoryTemplate=mid;
    var typeid;
    if(type!=null){typeid=type;}
    else{typeid=getTypeId(node);}
    setFixXY(objDivGCA,620,300);
    var dialogsBox = new campton.dialogs(objDivGCA, "dialogs_editbrands", "CloseGridControllerArea()");
    dialogsBox.setTitle(__selectCategory);
    dialogsBox.setContent(__containerBodyContent);
    dialogsBox.setFooter(__containerFooterContent);
	var url = "/ajax.aspx?command=setviewcategory&typeid="+typeid+"&templateid="+categoryTemplate+"&rid="+Math.random();
	campton.update(url, "", dialogsBox.body);
}
function gcategorystyle(mid,tabmoduleid,node)
{
    var __title =__selectCategoryStyle;
    var __link="";
    showMask();
    var callback="";
    var typeid=getTypeId(node);
    templateID=mid;
    var psty=dnn.getVar("PST_"+mid);
    campton.seleter({url:"/ajax.aspx?typeid="+typeid+"&templateid="+templateID+"&tabmoduleid="+tabmoduleid ,currentTitle:psty,title:__title, className:"tablist",closeTag:__closeTag, close: (callback)?callback:closeMask, disableClose: false, subNavActive:"subNavActive", tools:[{label:"", link:__link}], command:{left:"categorystyletreeview", content: "categorystyleview"} });
}

function showSelectCategoryInAdvSelect(value, formId)
{
    var tdAdvSelect_selectcategory = $("trAdvSelect_selectcategory");
    
    if (value == 2)
        tdAdvSelect_selectcategory.style.display = "block";
    else
        tdAdvSelect_selectcategory.style.display = "none";
}


function Selectproductfromcategory(pageIndex,issendTask)
{
   var select=$("selectproductclass");
   var index=select.selectedIndex;
   var bizCategory=select[index].value;
   var keyWord=$("keyword");
   var keyWordStr=urlEncode(keyWord.value.replace(/(^\s*)|(\s*$)/g,""));
   var url = "/ajax.aspx?command=porducetview&bizcategoryid="+bizCategory+"&keyword="+keyWordStr+"&templateid="+templateID+"&currenttypeid="+bizcategorytypeID+"&template=1&rid="+Math.random();
   if(pageIndex>0)
   {
    var url =url+"&pageindex="+pageIndex;	
   }
   if(issendTask=1)
   {
     var url =url+"&select="+issendTask;	
   }
   var SuccessToSelect = function(o)
     { 
        
        getObject("divProductsGrid").innerHTML = o.responseText;          
    }
    var FailToSelect = function(o){        
      getObject("divProductsGrid").innerHTML ="Fail to get content..."; 
    }
    var CallbackForSelect =
    {
         success: SuccessToSelect,
         failure: FailToSelect
    };
	YAHOO.util.Connect.asyncRequest('GET', url, CallbackForSelect, "");
}

var SuccessToAdvanceSelect=function(o)
{
    $h(divLoading);
    
    if (o.responseText != "success")
        alert(o.responseText);
    
    window.location.reload(true);
}

var FailToAdvanceSelect=function(o)
{
    alert(__timeout);
   window.location.reload(true);
}

var selectProductCallBack =
{
  success: SuccessToAdvanceSelect,
  failure: FailToAdvanceSelect
};

function updatetemplatecontent()
{
  var idToStr="";
  var chkbox=document.getElementsByName("productchkbox");
  var count=chkbox.length;
  for(var i=0; i<count;i++)
  {
    if(chkbox[i].checked)
     {
      if(idToStr!="")idToStr+=",";
      idToStr+=chkbox[i].id;
     }
  }
  idToStr+=",";
 if(idToStr.length>0)
   {  
//      var url = "/ajax.aspx?command=selectproducttoxml&templateid="+templateID+"&currenttypeid="+bizcategorytypeID+"&entityids="+idToStr+"&select="+select;
      var url = "/ajax.aspx?command=selectproducttoxml&templateid="+templateID+"&currenttypeid="+bizcategorytypeID+"&entityids="+idToStr;
      var SuccessToSave = function(o)
        { 
           if(o.responseText!="success")
             {
               alert(__submitfail);
             }
             else
             {
               window.location.reload(true);
             } 
           
        }
      var FailToSave = function(o)
       {  
         alert(__timeout);
         
       }
     var CallbackForSaveXML =
      {
         success: SuccessToSave,
         failure: FailToSave
      };
    
    YAHOO.util.Connect.asyncRequest('GET', url, CallbackForSaveXML, "");
  }
}

function registration()
{
    var objDivGCA = $("divGridControllerArea");
    showMask();
    setFixXY(objDivGCA,620,300)
    var dialogsBox = new campton.dialogs(objDivGCA, "dialogs_editbrands", "CloseGridControllerArea()");
    dialogsBox.setTitle(__selectCategory);
    dialogsBox.setContent(__containerBodyContent);
    dialogsBox.setFooter(__containerFooterContent);
	var url = "/ajax.aspx?command=registration&rid="+Math.random();
	campton.update(url, "", dialogsBox.body);
}



 
	

function gstyle(mid,node)
{
    var __title =__entityStyle;
    var __link="";
    showMask();
    var callback="";
  
    var typeid=getTypeId(node);
    templateID=mid;
    var psty=dnn.getVar("PST_"+mid);
    if(psty==null)psty="List";
    campton.seleter({url:"/ajax.aspx?typeid="+typeid+"&templateid="+templateID ,currentTitle:psty,title:__title, className:"tablist",closeTag:__closeTag, close: (callback)?callback:closeMask, disableClose: false, subNavActive:"subNavActive", tools:[{label:"", link:__link}], command:{left:"eintitystyletreeview", content: "eintitystyleview"} });
}

function CanelEnter()
{
    if (event.keyCode == 13)
    {
         Selectproductfromcategory();
         return false;
    }
    return true;
}


if(typeof(campton) == "undefined")
	var campton = {};
campton.dialogs = function(o, className, closeEvent){
    if(typeof(closeEvent) == "undefined") closeEvent = "void(0);";
	this.dialogsStr = "<div class=\"" + className + "\"> <div class=\"hd\">  <div class=\"title\"><img src='/images/divico.png' style='margin-right:6px;' />{$title}</div>  <div class=\"close\"><img src=\"/images/closediv.gif\" alt=\"\" bode=\"0\" onclick=\""+closeEvent+"\" /></div> </div> <div id=\"divBodyForDeleteCategory\" class=\"bd\">{$content}</div><div class=\"ft\">{$footer}</div></div>";
	this.outStr = this.dialogsStr;
	this.title = "";
	this.content = "";
	this.footer = "";
	this.container=null;
	this.render(o);
	this.body = $("divBodyForDeleteCategory");
}
campton.dialogs.prototype = {
	setTitle:function(strTitle){
		this.title = strTitle;
        this.replaceTag();
	},
	setContent:function(strContent){
		this.content = strContent;
        this.replaceTag();
	},
	setFooter:function(strFooter){
		this.footer = strFooter;
        this.replaceTag();
	},
	replaceTag:function()
	{
	    var strResult = this.dialogsStr.replace("{$title}", this.title).replace("{$content}", this.content).replace("{$footer}", this.footer);
        if(this.container!=null){
	    this.container.innerHTML = strResult;
	    }
	    this.body = $("divBodyForDeleteCategory");
	},
	render:function(o){
		if(typeof(o) == "string"){o = getObject(o);}
		if(o==null||typeof(o) != "object" || o.innerHTML == null) return;
		
		this.container=o;
		o.innerHTML = this.outStr;
		this.replaceTag()
	}
}
/*iframe自动调节高度*/
function getiframeHeight(temp)
{
  var iframe="";
  if(temp!=null)
  {
    if(parent.document==null)return;
    parentboby=parent.document.getElementById('main');
    if(parentboby==null)return;
    parentboby.height=document.body.scrollHeight; 
    return;
  }
  iframe=$('main');
  if(iframe==null)return;
  iframe.height=0;
  var fdh=(iframe.Document?iframe.Document.body.scrollHeight:iframe.contentDocument.body.offsetHeight);
  iframe.height=(fdh>4?fdh:4);
}

function modifytabtitle(id,key)
{
    var objDivGCA = $("divGridControllerArea");
	setFixXY(objDivGCA,500,220);
    var dialogsBox = new campton.dialogs(objDivGCA, "dialogs_deletecategory", "CloseGridControllerArea()");
    
    dialogsBox.setTitle(__modifytabtitle);
    dialogsBox.setContent(__containerBodyContent);
    dialogsBox.setFooter(__containerFooterContent);
    showMask();
	var url = "/ajax.aspx?command=modifymenutitle&id="+id+"&key="+key;
	campton.update(url, "", dialogsBox.body);
}

function CloseGridControllerArea()
{
   var objDivGCA = $("divGridControllerArea");
   objDivGCA.style.display="none";
   objDivGCA.innerHTML = "";
   closeMask();
}

var getGridSuccess=function(o)
{
   $h(divLoading);
   if(o.responseText=="success") window.location.reload(true);
}

var getGridFailure=function(o)
{
    $h(divLoading);
    closeMask();
    alert(__timeout);
}

var operationModifyTitleNameCallBack =
{
     success: getGridSuccess,
     failure: getGridFailure
}; 

function updatetaborder(tabid,level,order)
{
    showMask();
    var url = "/ajax.aspx?command=updatetaborder&tabids="+tabid+"&levels="+level+"&orders="+order+"&rid="+Math.random();
    var SuccessToUpdateTabOrder = function(o)
    { 
      if(o.responseText=="success")
      {
         window.location.reload(true);
      }
      else{
        alert(__submitfail);
        closeMask();
      }
    }
    var FailToUpdateTabOrder = function(o){        
	   alert(__timeout);
	   closeMask();
    }
    var CallbackForUpdateTabOrder =
    {
         success: SuccessToUpdateTabOrder,
         failure: FailToUpdateTabOrder
    };
	YAHOO.util.Connect.asyncRequest('GET', url, CallbackForUpdateTabOrder, "");
}

function changecss(theClass,element,value) {    
    var cssRules;    
    if (document.all) {    
        cssRules = 'rules';    
    }    
    else if (document.getElementById) {    
        cssRules = 'cssRules';    
    }    
    for (var S = 0; S < document.styleSheets.length; S++){    
        for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {  
            if (document.styleSheets[S][cssRules][R].selectorText.toLowerCase()== theClass.toLowerCase()) {    
                document.styleSheets[S][cssRules][R].style[element] = value;    
            }    
        }    
    }     
}

function getFileFullNameByImageName(name,suffixName)
{
  var fullName="/portals/_default/";
  var file = name.split('.');
  for(var i=0;i<file.length-1;i++)
  {
    fullName+=file[i]+"/";
  }
  return fullName+=name+suffixName;  
}

function changpic(isshow)
{
   var img=YAHOO.util.Dom.getElementsByClassName("imgs","IMG",imgobj.parentNode.parentNode,true)[0];
   if(img==null)return;
   if(isshow){img.src=img.src.replace("ok","cancel");}
   else{img.src=img.src.replace("cancel","ok");}
}

function ggrouping(mid,node)
{
    var __title =__entityStyle;
    var __link="";
    showMask();
    var callback="";
  
    var typeid=getTypeId(node);
    templateID=mid;
    var psty=dnn.getVar("PGR_"+mid);
    if(psty==null)psty="CategoryListStyle.StyleLevel2";
    campton.seleter({url:"/ajax.aspx?moduleid="+mid ,currentTitle:psty,title:__title, className:"tablist",closeTag:__closeTag, close: (callback)?callback:closeMask, disableClose: false, subNavActive:"subNavActive", tools:[{label:"", link:__link}], command:{left:"eintitystylegroupingtreeview", content: "eintitystylegroupingview"} });
}

function cancelgroup(moduleid)
{
   showloading();
   var SuccessToCancelGorup = function(o)
    { 
      hiddenloading();
      if(o.responseText=="success")
      {
         window.location.reload(true);
      }
      else{
        alert(__submitfail);
        closeMask();
      }
    }
    var FailToCancelGorup = function(o){    
       hiddenloading();    
	   alert(__timeout);
	   closeMask();
    }
    var CallbackForCancelGorup =
    {
         success: SuccessToCancelGorup,
         failure: FailToCancelGorup
    };
    
    var url = "/ajax.aspx?command=cancelgorup&moduleid="+moduleid;
	YAHOO.util.Connect.asyncRequest('GET', url, CallbackForCancelGorup, "");
}

function showloading()
{
   var divLoading =$("loading");
   divLoading.innerHTML = __form_loading;
   divLoading.style.display="block";
}
function hiddenloading()
{
   var divLoading =$("loading");
   divLoading.style.display="none";
}

function UpdeteCity(temp,node,mothod_2,trueStr,valueIsText,textvalue)
{
    var id=temp.value;
    var url="";
    if(valueIsText!=null&&valueIsText)
    {
       url= "/ajax.aspx?command=selectcity&valueistext=1&id="+id+"&rid="+Math.random();
    }
    else{
      url= "/ajax.aspx?command=selectcity&id="+id+"&rid="+Math.random();
     }
    var SuccessToSelect = function(o)
     { 
       var ReturnString=o.responseText; 
	   var list=document.getElementById(node);
	   for(var i=0;i<list.options.length;)list.remove(i);
	   var cityArray=ReturnString.split(',');
	   if(cityArray.length<2)return;
       
       var selectIndex=0; 
	   for(var i=0,j=0;i<cityArray.length;j++){
	   var opNode = document.createElement("option");
	      opNode.value =cityArray[i++];
		  opNode.text =cityArray[i++];		  
		  if(textvalue!=null&&opNode.text==textvalue)selectIndex=j;
          list.options.add(opNode);
	   }
	   list.selectedIndex=selectIndex;
       if(trueStr)
       { 
         var mothod=mothod_2+"(null,'"+node+"')"
         eval(mothod );
       }
    }
     var FailToSelect = function(o){        
       var list=$(node);
	   for(var i=0;i<list.options.length;i++)list.remove(i);
	   alert(__timeout);
    }
    var CallbackForSelect =
    {
         success: SuccessToSelect,
         failure: FailToSelect
    };
	YAHOO.util.Connect.asyncRequest('GET', url, CallbackForSelect, "");
  
}

function closediv()
{
   var divPopupForEditCustomizeForm=$('divPopupForEditCustomizeForm');
   if(divPopupForEditCustomizeForm!=null) divPopupForEditCustomizeForm.style.display="none";   
   
}




var setPaneStyle=function(pid){
        if (document.location.href.indexOf("layout") > -1 || document.location.href.indexOf("skinsrc") > -1)
        {
            alert(__notAllowToEdit);
            return;
        }   
        
		var url="/tabid/"+__styleTabid+"/actiontabid/"+__tabId+"/paneid/"+pid+"/controlpanel/true/default.aspx";
	    document.location.href=url;
	}
var setPaneLayout=function(pid){
        if (document.location.href.indexOf("layout") > -1 || document.location.href.indexOf("skinsrc") > -1)
        {
            alert(__notAllowToEdit);
            return;
        }   
        
		 var url="/tabid/"+__layoutTabId+"/actiontabid/"+__tabId+"/paneid/"+pid+"/controlpanel/true/default.aspx";
		 document.location.href=url;
}


var divGhost=document.createElement("div");
divGhost.id="divGhost";
divGhost.style.border="2px dashed #999999 ";
var columnsObj={};
var index=0;
var colnum=0;
var __panes=[];
var col=null;
var _oldModuleIndex=0;
var _start_top=0;
var _start_y=80;
barClass="panebar";


 var ttt; 

var Drag={
   "obj":null,
   "init":function(a,aRoot){
        
			a.onmousedown=Drag.start;
			a.root=aRoot;
			if(isNaN(parseInt(a.root.style.left)))
			   a.root.style.left="0px";
			if(isNaN(parseInt(a.root.style.top)))a.root.style.top="0px";
			a.root.onDragStart=new Function();
			a.root.onDragEnd=new Function();
			a.root.onDrag=new Function();
		},
		
		"start":function(a){
		
		     var b=Drag.obj=this;
			
			 a=Drag.fixE(a);
			
			 var c=parseInt(b.root.style.top);
			 var d=parseInt(b.root.style.left);
			
			 b.root.onDragStart(d,c,a.clientX,a.clientY);
			
			 b.lastMouseX=a.clientX;
			 b.lastMouseY=a.clientY;
			
			 elem=b;
			 b.movescroll=window.setInterval("movescrollbar()",10);
			 document.onmousemove=Drag.drag;
			 document.onmouseup=Drag.end;
			
			 curwinId=Drag.obj.parentNode.id;
			
			 oldColNum=Drag.obj.parentNode.parentNode.colNum;
			
			 return false;
			},
			
			"drag":function(a){
			
			         a=Drag.fixE(a);
					 var b=Drag.obj;
					 var c=a.clientY;
					 var d=a.clientX;
					 var e=parseInt(b.root.style.top);
					 var f=parseInt(b.root.style.left);
					 var h,g;h=f+d-b.lastMouseX;
					 g=e+c-b.lastMouseY;
					 b.root.style.left=h+"px";
					 b.root.style.top=g+"px";
					 b.lastMouseX=d;
					 b.lastMouseY=c;
					 b.root.onDrag(h,g,a.clientX,a.clientY);	
					 return false;
					 },
					 
		   "end":function(){
		  
					  document.onmousemove=mouseMove;
					  document.onmouseup=mouseUp;
					  iMouseDown = false;
					  window.clearInterval(Drag.obj.movescroll);
					  Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style.left),parseInt(Drag.obj.root.style.top));
					 
					 curColNum=Drag.obj.parentNode.parentNode.colNum;
					 curNextWinNode=Drag.obj.parentNode.nextSibling;
					
					 
					  if(curNextWinNode){
					  		curNextWinId=curNextWinNode.id;
					  }
					  else{
					       curNextWinId="NULL";
					 }
				
					
					var tmp_obj=null; 
				
						Drag.obj=null;
						
						},
			"fixE":function(a){
				if(typeof a=="undefined")a=window.event;
				if(typeof a.layerX=="undefined")
					a.layerX=a.offsetX;
				if(typeof a.layerY=="undefined")
					a.layerY=a.offsetY;return a;
			 }
		    }
		    function findPosX(obj){
				var curleft=0;
				if(obj.offsetParent){
				       while(obj.offsetParent){
					         curleft+=obj.offsetLeft;
							 obj=obj.offsetParent;
						}
				}
				else if(obj.x)curleft+=obj.x;
				return curleft;
			}
			function findPosY(obj){
				var curtop=0;if(obj.offsetParent){
					while(obj.offsetParent){
						curtop+=obj.offsetTop;
						obj=obj.offsetParent;
					}
				}
				else if(obj.y)curtop+=obj.y;return curtop;
			}
	
	
	function getclientHeight(){
	      if(window.innerHeight<document.body.clientHeight){
		      return window.innerHeight
		  }
		  return document.body.clientHeight
	};
	
	function getscrollHeight(){
	      if(document.body.scrollHeight>document.documentElement.clientHeight){
		        return document.body.scrollHeight
		   }else{
		         return document.documentElement.clientHeight
		   }
	};
	function movescrollbar(){
	
	   var xbody=getScroll();
		  	
	      var body_clientHeight=getclientHeight();
		  var body_scrollHeight=getscrollHeight();
		  var body_scrollTop=xbody.top;
		  var body_scrollvalue=body_scrollTop;
		  var winvalue=elem.root.offsetTop;
		  var screenH=window.screen.availHeight;
		  var step=10;
		  var winTop=60;
		  var winDown=screenH-winTop-300;
		  if(elem.lastMouseY<=winTop){
		      
		  		winvalue=Math.max(0,elem.root.offsetTop-step);
				body_scrollvalue=Math.max(0,body_scrollTop-step);
		  }
		  else if(elem.lastMouseY>=winDown){
		       
		 		winvalue=elem.root.offsetTop+step;
				body_scrollvalue=body_scrollTop+step;
	   	}
	
		var ig_l=body_scrollvalue-body_scrollTop;
		if(ig_l!=0){
		   if((body_scrollHeight-winvalue)<elem.root.offsetHeight)winvalue=body_scrollHeight-elem.root.offsetHeight;
		    elem.root.style.top=winvalue+"px";
		
		    window.scrollTo(0,body_scrollvalue);
		
		}
		
	}
	
function iniPanes(){
	    var str=  dnn.getVar('__dnn_Panes');
	
	    getPanes(str);
	    var modules= YAHOO.util.Dom.getElementsByClassName("window");
	 
	    if(modules.length==0)return;
	    
	   
	    for(var i=0;i<modules.length;i++){
	        var header=YAHOO.util.Dom.getElementsByClassName("window_title","*",modules[i]);
	      
	        if(header==null||header.length==0)continue;
	        initModuleDragEnable(header[0],modules[i]);
	    }
	}
	
function initModuleDragEnable(headerstr,containerstr){

  var header=(typeof(headerstr)==String)?document.getElementById(header):headerstr;
  var divModuleFrame=(typeof(containerstr)==String)?document.getElementById(container):containerstr;

  Drag.init(header,divModuleFrame);
  //Drag.init(divModuleHeader,divModuleFrame);
 
  divModuleFrame.onDragStart=function(x,y,mousex,mousey){
          var left=findPosX(this);
		  var top=findPosY(this);
		  var w=this.offsetWidth;
		  this.style.width=(w)+"px";
		  this.style.left=(left-15)+"px";
		  this.isDragging=true;
		  _start_top=top;
	      this.parentNode.insertBefore(divGhost,this);
		  divGhost.style.height=this.offsetHeight+"px";
		  if(Browser.isGecko){
		     divGhost.style.height-=parseInt(divGhost.style.borderTopWidth)*2;
		  }
          this.style.position="absolute";
    	  this.style.top=(top)+"px";
		   divGhost.col=this.parentNode;
		   	var module=getWin(Drag.obj.root);
	var oPane=getCPane(module);
	
	getOldModuleIndex(module,oPane);
		 }		      
divModuleFrame.onDragEnd=function(x,y,el){
    var col=divGhost.col;
	this.isDragging=false;
		
	col.replaceChild(this,divGhost);
	
	this.style.position="static";
	this.style.width="auto";
	
	var module=getWin(Drag.obj.root);
	var oPane=getCPane(module);
	

	__dnn_dragCompleteBySimon(module,oPane);
}
function getWin(obj){
  
    return getParentByClass("window",obj)
}
function getOldModuleIndex(win,oPane){
    _oldModuleIndex =getIndexOfPane(win,oPane);
 
}




divModuleFrame.onDrag=function(x,y,mousex,mousey){

			for(var i=0;i<__panes.length;i++){
			  
				if( (x>=findPosX(__panes[i])) && (y>=findPosY(__panes[i])) && (x<=findPosX(__panes[i])+__panes[i].offsetWidth) && (y<=findPosY(__panes[i])+__panes[i].offsetHeight) ){
					col=__panes[i];
					break;
				}
			}
		
			if(col==null){
				col=this.parentNode;
			}
			
			if(divGhost.col!=col){
				divGhost.removeNode();
				divGhost.col=col;
				col.appendChild(divGhost);
			}
			
			var elems=getModuleArr(col);
			
			
			var myPos=getGhostPos(elems,y);
			
		
			
			var up=_start_top-y>=_start_y;
			
			if((myPos!=0 && up) || (myPos!=0&&y<=findPosY(elems[myPos-1]))){
			 
				divGhost.removeNode();
				col.insertBefore(divGhost,elems[myPos-1]);
				return;
			}
			
			var down=y-_start_top>=_start_y
			
			if(myPos!=(elems.length-1)&& ( y>=findPosY(elems[myPos+1]) || down)){
			
				if(elems[myPos+2]){
					col.insertBefore(divGhost,elems[myPos+2]);
				}else{
					col.appendChild(divGhost);
				}
			}
			
		}
		
   }
   
   
 function getModuleArr(column){
 	var arr=[];
	var ln=column.childNodes.length;
	for(var z=0;z<ln;z++){
	    if(column.childNodes[z]==null)continue;
	    if(column.childNodes[z].className==barClass)continue;
		if(column.childNodes[z].tagName!=null&&!column.childNodes[z].isDragging){
			arr.push(column.childNodes[z]);
		}
	}
	
	return arr;
	
}

function getGhostPos(arr,y){
	var ln=arr.length;
	for(var z=0;z<ln;z++){
 		
		if(arr[z]==divGhost)return z;
	}
}
  
 function getPanes(str){
  
    var strPanes=str.split(";");
 
    for(var i=0;i<strPanes.length;i++){
        __panes[i]=$(strPanes[i]);
    }
 
    
 }
 
modules_loaded=true;

function __dnn_dragCompleteBySimon(win,oPane)
{

    var sModuleID = getCtrlID(win);
  
	if (oPane != null)
	{
	
		iIndex = getIndexOfPane(win, oPane);
		
		if(iIndex>_oldModuleIndex)iIndex=(iIndex+1)*2;
		else iIndex=iIndex*2;
	
		var paras="XmlAction=MoveToPane&tabid="+__tabId+"&moduleid=" + sModuleID+"&pane="+oPane.paneName+"&order="+iIndex  ;

		XmlGet(paras,null,null,"/default.aspx");
	
		
	}
}
function getCPane(win){
   var oCtl = win;
	var oPane;
	var oPanes = __dnn_Panes();
	
	for (var i=0; i<oPanes.length; i++)
	{
	   
		if (oPanes[i].id == win.parentNode.id){
			
			 oPane = oPanes[i];
		}
	}
	
	return oPane;
}


function getIndexOfPane(win,oPane){
    var i=0;
    var index=0;
    var wins=getChildren($(oPane.id));
    for(i=0;i<wins.length;i++){
        if(wins[i].className=="window"){
            if(wins[i]==win)return index;
            index++;
        }
    }
    return 0;
}

function getChildren(o){
   
 
    return o.childNodes;
}
   function getChildContent(outerhtml,tag){
        outerhtml=removePart(outerhtml,"<"+tag,">")
        outerhtml=outerhtml.substring(0,outerhtml.length-tag.length-3);
        return outerhtml;
   }

//Simon
function getCtrl(ele){
    var i=0;
    var tags=ele.getElementsByTagName("SPAN");
    for(i=0;i<tags.length;i++){
        if(tags[i].id==null||tags[i].id=="")continue;
        if(tags[i].id.indexOf("_dnnTITLE_lblTitle")>0)return tags[i];
    }
    return null;
}
function getCtrlDiv(ele){
    var i=0;
    var tags=ele.getElementsByTagName("DIV");
 
    return tags[0];
}
function getCtrlID(ele){
    var sid=ele.id;
  
    if(sid==null||sid=="")return "";
    sid=sid.replace("ctr","");
    sid=sid.replace("_DD","");
    return sid;
}

 function getPart(content,startWord,endWord){
			    var strContent=content;
			    var intIndex=strContent.indexOf(startWord);
			    if(intIndex<0)return null;
			    var intEndIndex = strContent.indexOf(endWord, intIndex);
			    if(intEndIndex<0)return null;
			    intEndIndex += endWord.length;
			    return strContent.substring(intIndex, intEndIndex);
}
function removePart(content,startWord,endWord){
	 var parts=getPart(content,startWord,endWord);
	 return content.replace(content,parts,"");
}
//simon			  
			  
function CreateXmlhttp(){
		var xmlhttp = null;
		try{
			xmlhttp = new ActiveXObject('MSXML2.XMLHTTP'); 
			return xmlhttp;
		}
		catch(e){}
		try{
			xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');		
			return xmlhttp;
		}
		catch(e){} 
		  
	
		try{
			xmlhttp = new XMLHttpRequest();
			return xmlhttp;
		}
		catch(e){}
          return null;
		
}
		
function XmlGet(paras,objResponseFunction,objResponse,surl){
    var url=document.location.href;
    if(XmlGet.arguments.length==4)url=surl;
  
    url=url.replace("#","");
    if(url.indexOf("?")>0)url+="&"+paras;
    else url+="?"+paras;
    var xml=CreateXmlhttp();
    url=url+"&Randomitem=" + Math.random();

	try{ 
       
	    xml.open("Get",url,true); 
      
	    xml.onreadystatechange=function(){
	  
	        if(objResponseFunction==null)return;

	     	if(xml.readyState == 4){ 
	              
  					if(xml.status == 200)
					{ 
					    objResponse=xml.responseText;
					    window.setTimeout(objResponseFunction,100);
					}
	        }
	    }
	    xml.send(null); 
	}
	catch(e){
	
	}       
}


///////////////////////////////////////

if (typeof(Campton) == "undefined") {
    var Campton = {};
}

Campton.namespace = function() {
    var a=arguments, o=null, i, j, d;
    for (i=0; i<a.length; i=i+1) {
        d=a[i].split(".");
        o=Campton;

        // Campton is implied, so it is ignored if it is included
        for (j=(d[0] == "Campton") ? 1 : 0; j<d.length; j=j+1) {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }

    return o;
};

//
Campton.init = function() {
    this.namespace("Form","example");
};
Campton.init();
///////////////////////////////////////
function isIE() {
	if(document.all) return true;
	return false;
};
function BrowserIsIE() {
	if(document.all) return true;
	return false;
};
String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}





//
validator = function(){

	this._source = new Array();
	this.objId 		= 0; 
	this.infoId		= 1;
	this.action		= 2;
	this.aryMsg		= 3;
	this.actionObj	= 4;
	this.minLength	= 5;
	this.maxLength	= 6;
	this.bRange		= 7;
	this.eRange		= 8;
	this.para		= 9;

	this._isrequest	= 0x1;
	this._isEmail	= 0x2;
	this._isNum		= 0x4;
	this._isDate	= 0x8;
	this._sameas	= 0x10;
	this._limLength	= 0x20;
	this._range		= 0x40;
	this._regExp	= 0x80;
	
	
	
	this.callAction=0;
	this.POSTBACK_template="";
	
	//default classes for infobox
	this.infoboxOkClass			= "OkMsg";
	this.infoboxWarningClass	= "WarningMsg";
	this.infoboxErrorClass		= "ErrorMsg";
	this.infoboxHintClass		= "HintMsg";
	//default classes for input field
	this.inputWarningClass		= "Warning";
	this.inputErrorClass		= "Error";
	this.inputOkClass			= "Ok";
	this.inputNormalClass		= "Normal";
	this.submitButttonIds=[];
	this.postUrl="";
	this.infoboxId="";
	this.infoMode=true;//behind
	this.submitButtonId = "";
	this.containerId="";
	this.hiddenId="";
	this.callback=null;
	this.items={};
};

validator.prototype = {
	
	register:function(objId,infoId,action,aryMsg,actionObj,minLength,maxLength,bRange,eRange,para){
	 
	 
		this._source[this._source.length] = new Array(objId,infoId,action,aryMsg,actionObj,minLength,maxLength,bRange,eRange,para);
		this.attachEvent(objId);
		
	},
	setHiddenValue:function(v){
           var txtHidden=$(this.hiddenId);
            if(txtHidden==null)return;
            txtHidden.value=v;
    },
	getIndex:function(obj){
		for(var i = 0; i < this._source.length; i++){
			if(this._source[i][this.objId] == obj.id)
			{
				return i;
			}
		}
		return -1;
	},
    showInBox:function(){
        return this.infoboxId!="";
    },
	getInfobox:function(obj){
	 
	    if(!this.infoMode){
	        return $(this.infoboxId);
	    }
	 
		var index = this.getIndex(obj);
		var desc= $(this._source[index][this.infoId]);
		
		if(desc!=null)return desc;
		
		return $(this.infoboxId);
		
	},
	
	getFocus:function(evnt){
		var obj;
		if (BrowserIsIE()) {
			obj = event.srcElement;
		}else {
			obj = evnt.target;
		}
		this.showInfo(obj,0);
	},

	lostFocus:function(evnt) {
		var obj;
		if (BrowserIsIE()) {
			obj = event.srcElement;
		}else {
			obj = evnt.target;
		}
		
		this.checkInfo(obj, this.inputNormalClass);
		
	},

	showMyStatus:function(evnt){
	   
		var obj,errorCode;
		if (BrowserIsIE()) {
			obj = event.srcElement;
		}else {
			obj = evnt.target;
		}
		
		this.checkInfo(obj, this.infoboxOkClass);
		
	},
	
	checkInfo:function(obj, infoCss){
		var errorCode = this.validateValue(obj);

		if(errorCode == 0){		  
			this.showStatus(obj,"Ok");			
			//var index = this.getIndex(obj);		   
			//var infobox = $(this._source[index][this.infoId]);			
			var infobox = this.getInfobox(obj);			
		    if (infobox == null)
		        return 0;
		 
			//if(this.infoMode)  //beer 20080505 
			    infobox.className = infoCss;
			    		
			infobox.innerHTML = __inputInofValid;

			
		}

		if(errorCode >= 1){
			this.showStatus(obj,"Error");
			this.showInfo(obj, errorCode);
		}
		
		return errorCode;
	},
	
	
	showStatus:function(obj,stat){
		//Show the status of user currently inputting field
		//3 Statuses: Warning|Error|Ok
		switch(stat){
			case "Warning":
				obj.className = this.inputWarningClass;
				break;
			case "Error":
				obj.className = this.inputErrorClass;
				break;
			case "Ok":
				obj.className = this.inputOkClass;
				break;
			default:
				obj.className = this.inputNormalClass;
				break;
		}
		
		
	},
	
	showInfo:function(obj,errorCode,forcible){
		var index = this.getIndex(obj);
		//var infobox =this.getInfobox(this._source[index][this.infoId]);
	    var infobox =this.getInfobox(obj);
		if(infobox){
			if(infobox.className != this.infoboxErrorClass || forcible){
				if(errorCode == 0){
					infobox.className	= this.infoboxWarningClass;
					if(this.getErrorMsg(index,errorCode)!=null&&this.getErrorMsg(index,errorCode).length>0)infobox.innerHTML=this.getErrorMsg(index,errorCode);
				}
				if(errorCode >0){
				    infobox.className	= this.infoboxErrorClass;
					infobox.innerHTML	= this.getErrorMsg(index,errorCode);
				}
				if(errorCode <0){
					infobox.className	= this.infoboxHintClass;
				}
			}
		}	
		
	},
	
	getErrorMsg:function(index,errorCode){
		var strInfo = new Array();
	
		strInfo = this._source[index][this.aryMsg];
		
		if(strInfo != null){
			return strInfo[errorCode];
		}
		else{
			return "";
		}
	},
	
	quanjiao2Banjiao:function(str) {
		var i;
		var result = '';
		for (i = 0; i < str.length; i++) {
			code = str.charCodeAt(i);
			if (code >= 65281 && code < 65373) {
				result += String.fromCharCode(str.charCodeAt(i) - 65248);
			}
			else {
				result += str.charAt(i);
			}
		}
		return result;
	},
	
	createDelegate: function(oThis, pFunc){
        return function() {return pFunc.apply(oThis, arguments);};
    },

	//
	attachEvent:function(objId){
		var obj = document.getElementById(objId);
		if(obj){
			obj.onfocus	= this.createDelegate(this,this.getFocus);
			obj.onblur	= this.createDelegate(this,this.lostFocus);
			obj.onkeyup	= this.createDelegate(this,this.showMyStatus);
		}
	},

	//
	detachEvent:function(){
		if(window.removeEventListener){
			//FireFox
		}
		else if(window.detachEvent){
		
		}
	},

    getItems:function(){
        var items=[];
		for(var i = 0; i < this._source.length; i++){
		    items[i]=this._source[i][0];
		}
		return items;
    },
   
	onSubmit:function(){
		var status = true;
//		var submitButton = document.getElementById(this.submitButtonId);
//		submitButton.disabled = true;
      
		for(var i = 0; i < this._source.length; i++){
		   
		    var obj = $(this._source[i][this.objId]);
			
			if(obj != null)
			{
			    var result=this.checkInfo(obj, this.inputNormalClass);
			   
				if(result != 0){
					status = false ;
					break;}
					
			}
			else{
				//status = false ;
			}
		}

//		submitButton.disabled = false;
        if(status){
            if(this.postUrl!=""){
              
                var manager=new Campton.Form.Manager(); 
                manager.items=this.getItems();
                manager.url=this.postUrl;                
           
                manager.post(this.containerId,this.callAction,this.POSTBACK_template, this.callback);
              
                this.wait(this.callback==null);
               
                
            }
        }
        
        
		return status;
	},
	
	init:function(){
	    
	    if(__formContent!=null&&__formContent!="")
	    __formContent=$(this.containerId).innerHTML;
	   
		if(this.submitButtonId.length > 0){
		    this.submitButttonIds=this.submitButtonId.split(";");
		    var i=0;
		   
		    for(i=0;i<this.submitButttonIds.length;i++){
		        if(this.submitButttonIds[i]==""||this.submitButttonIds[i]==undefined)continue;
		        var submitButton = document.getElementById(this.submitButttonIds[i]);
		       
			    if(typeof(submitButton) == "undefined" || submitButton == null) return;
			    
			    submitButton.onclick = this.createDelegate(this, this.onSubmit);
			    
		    }
			
		}
	
		for(var i = 0; i < this._source.length; i++){
			var obj = document.getElementById(this._source[i][this.objId]);
			var info = document.getElementById(this._source[i][this.infoId]);
			if(obj != null && info != null)
			{
				if(this.isRequired(this._source[i][this.action]))
					obj.className = this.inputWarningClass;
					
				info.className = "Normal";
				info.innerHTML	= this.getErrorMsg(i,0);
			}
		}
	},
	
	/////////////////////////////////////////
	//
	num2Bin:function(num){
		if(!isNaN(num) && num > 1){
			var str = "";
			do{
				if(num % 2 == 1){
					str = "1" + str;
				}
				else{
					str = "0" + str;
				}
			}while((num = parseInt(num/2)) > 1)
			return "1" + str;
		}
		else if(!isNaN(num) && num == 1){
			return "1";
		}
		else {
			return "0";
		}
	},
	
	getMsgIndex:function(sum, x){

		if(sum == x) return 1;
		
		var strSum = this.num2Bin(sum);
		var lnS = strSum.length;
		var lnX = this.num2Bin(x).length;
		
		var arraySum = strSum.split("");
		var num = 0;
		for(var i = lnS - lnX; i < arraySum.length; i++){
			if(arraySum[i] == "1")
				num++;
		}
		
		return num;
	},
	/////////////////////////////////////////
	//
	validateValue:function(obj){
		//trim
		var patn = /^\s/;
		if(patn.test(obj.value))	obj.value = obj.value.trim();
		
		//switcher
		var errorCode = 0;
		var index = this.getIndex(obj);
		var action = this._source[index][this.action];
		
		if(this.isRequired(action)){

			errorCode = this.validateRequired(obj, action);

		}
		else{
			if(obj.value.length == 0) return 0;
		}
		
		if(this.isEmail(action) && errorCode ==0){
			errorCode = this.validateEmail(obj, action);
		}
		
		if(this.isNum(action) && errorCode ==0){
			errorCode = this.validateNum(obj, action);
		}
		
		if(this.isDate(action) && errorCode ==0){
			errorCode = this.validateDate(obj, action);
		}
		

		if(this.isSameas(action) && errorCode ==0){
			errorCode = this.validateSameas(index, action);
		}
		
		if(this.isLimLength(action) && errorCode ==0){

			errorCode = this.validateLimLength(index, action);

		}
		
		if(this.isRange(action) && errorCode ==0){
			errorCode = this.validateRange(index, action);
		}
		
		if(this.isRegexp(action) && errorCode ==0){
			errorCode = this.validateRegexp(index, action);
		}

		return errorCode;
	},
	
	//
	isRequired:function(action){
		if((this._isrequest & action) > 0)
			return true;
		else
			return false;
	},
	
	validateRequired:function(obj, action){
		if(obj.value.length > 0){
			return 0;
		}
		else{
			return this.getMsgIndex(action, this._isrequest);
		}
	},
	
	isEmail:function(action){
		if((this._isEmail & action) > 0)
			return true;
		else
			return false;
	},
	
	validateEmail:function(obj, action){
		var str = obj.value;
		var patn = /^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]*)*@[a-zA-Z0-9\-]+([\.][a-zA-Z0-9\-]+)+$/;
		if(patn.test(str)){
			return 0;
		}else{
			return this.getMsgIndex(action, this._isEmail);
		}
	},
	
	isNum:function(action){
		if((this._isNum & action) > 0)
			return true;
		else
			return false;
	},
	
	validateNum:function(obj, action){
	   
	    var str = obj.value;
	    
		if(!isNaN(str))
			return 0;
		else
			return this.getMsgIndex(action, this._isNum);
	},
	
	isDate:function(action){
		if((this._isDate & action) > 0)
			return true;
		else
			return false;
	},
	
	validateDate:function(obj, action){
		var str = obj.value;
		var patn = /^(\d{4}-\d{1,2}-\d{1,2})(\s\d{1,2}:\d{1,2}:\d{1,2})?$/;
		if(patn.test(str))
			return 0;
		else
			return this.getMsgIndex(action, this._isDate);
	},
	
	isSameas:function(action){

		if((this._sameas & action) > 0)
			return true;
		else
			return false;
	},
	
	validateSameas:function(index, action){

		var obj = document.getElementById(this._source[index][this.objId]);
		var obj2 = document.getElementById(this._source[index][this.actionObj]);
		if(obj != null && obj2 != null && obj.value == obj2.value){
			return 0;
		}
		else{
			return this.getMsgIndex(action, this._sameas);
		}
	},
	
	isLimLength:function(action){
		if((this._limLength & action) > 0)
			return true;
		else
			return false;
	},
	
	validateLimLength:function(index, action){
		var obj = document.getElementById(this._source[index][this.objId]);
		var minLength = this._source[index][this.minLength];
		var maxLength = this._source[index][this.maxLength];
		if(obj != null){
			if((maxLength == "undefined" || maxLength == null || maxLength < 0) && obj.value.length >= minLength){
				return 0;
			}
			
			if((minLength == "undefined" || minLength == null || minLength == "") && obj.value.length <= maxLength){
				return 0;
			}
			
			if(obj.value.length >= minLength && obj.value.length <= maxLength){
				return 0;
			}
		}
		
		return this.getMsgIndex(action, this._limLength);
	},
	
	isRange:function(action){
		if((this._range & action) > 0)
			return true;
		else
			return false;
	},
	
	validateRange:function(index, action){
		var obj = document.getElementById(this._source[index][this.objId]);
		var bRange = this._source[index][this.bRange];
		var eRange = this._source[index][this.eRange];
		if(obj != null){
			if((eRange == "undefined" || eRange == null || eRange == "") && obj.value >= bRange){
				return 0;
			}
			
			if((bRange == "undefined" || bRange == null || bRange == "") && obj.value <= eRange){
				return 0;
			}
			
			if(obj.value >= bRange && obj.value <= eRange){
				return 0;
			}
		}
		
		return this.getMsgIndex(action, this._range);
	},
	
	isRegexp:function(action){
		if((this._regExp & action) > 0)
			return true;
		else
			return false;
	},
	
	validateRegexp:function(index, action){

		var obj = document.getElementById(this._source[index][this.objId]);	
		//beer 2008 06 16 换用正则表达式判断
		//var obj = document.getElementById(this._source[index][this.objId]);
		//var patn = this._source[index][this.para];
		if(obj.value.replace(/(^\s*)|(\s*$)/g,"")=="")
		{
		  return this.getMsgIndex(action, this._regExp);
		}		
		var patns=new RegExp(this._source[index][this.para]);
		var rtn=obj.value.match(patns);

		if(rtn!=null){
			return 0;
		}
		else{
		
			return this.getMsgIndex(action, this._regExp);
	   }
	},
	wait:function(flag){

        var cc=$(this.containerId);
        var loading=new Campton.Form.Loading(cc);
        if (flag)
           cc.innerHTML="";

        loading.show();
     
        
    } 
}

var __formCId;
var __postback_action=0;
var __postback_template="";
var __formContent="";
formPostSuccess=function(o){

    this._POSTBACK_default=0;
	this._POSTBACK_response=1;
	this._POSTBACK_addBorder=2;
	this._POSTBACK_template=4;
	this._POSTBACK_nextTemplate=8;
	this.POSTBACK_responseText=16;
	
	$h(divLoading);
	var text=o.responseText;
	
	var container= $(__formCId);
	if(container==null){return;}
	var callback_default=function(){
	    setInnerHTML(container,"<div style=\"text-align:center;padding:20px;\"><div class=\"OkMsg_lite\" style='width:80%;height:150px;padding:12px;text-align: center;'>"+__form_postback_msg+"</div>"+__form_return+"</div>");
	};
	var callback_response=function(){
	    setInnerHTML(container,"<div style=\"text-align:center;padding:20px;\"><div class=\"OkMsg_lite\" style='width:80%;height:150px;padding:12px;text-align: center;'>"+text+"</div>"+__form_return+"</div>");
	    
//	    text+__form_return);
	};
	var callback_addborder=function(){
	    setInnerHTML(container,"<div style=\"text-align:center;padding:20px;\"><div class=\"OkMsg_lite\" style='width:80%;height:150px;padding:12px;text-align: center;'>"+text+"</div>"+__form_return+"</div>");
	};
	var callback_template=function(){
	     __postback_template=__postback_template.replace("{0}",text);
	    setInnerHTML(container,"<div style=\"text-align:center;padding:20px;\"><div class=\"OkMsg_lite\" style='width:80%;height:150px;padding:12px;text-align: center;'>"+__postback_template+"</div>"+__form_return+"</div>");
	};
	var callback_responsetext=function(){	     
	    setInnerHTML(container,text);
	};
	
	switch(parseInt(__postback_action)){
	    case this._POSTBACK_response:
	        callback_response();
	        break;
	    case this._POSTBACK_addBorder:
	        callback_addborder();
	        break;
	    case this._POSTBACK_template:
	        callback_template();
	        break;
	    case this.POSTBACK_responseText:
	        callback_responsetext();
	        break;
	    //case this._POSTBACK_nextTemplate:
	    default:
	       callback_default();
	       break;
	    
	};
	
    
   
     
};
var gobacktopre=function(){
     var container= $(__formCId);
	 if(container==null){return;}
     container.innerHTML=__formContent;
};
var formPostFailure=function(o){
     $h(divLoading);
     alert("formPostFailure");
};

var formPostCallback =
{
         success: formPostSuccess,
         failure: formPostFailure
};

var showWait=function(obj){
    
};    

Campton.Form.Manager=function(){
   
    this.items=[];
    this.url="";
  
   
}

Campton.Form.Manager.prototype={
     getValues:function(){
        var temp="";
        var first=true;
        var mutiFirst=true;
     
     
     
        for(var i = 0; i < this.items.length; i++){
            var strValue="";            
            var item=document.forms[0][this.items[i]];
            if(item==null){
                 if(mutiFirst){          
                     strValue=this.getMutiValue(this.items[i]);
                     temp+=first?"":"&";
                     first=false;
                     mutiFirst=false;
                     temp+=strValue;
                 }                
            }
            else{
                 if (item.value == null)
                 {
                     if(!item.length)continue;
                     var strValue="";
                     if(item.length==0)continue;
                  
                     for(var j=0;j<item.length;j++)
                     {                        
                         if (item[j].type==null)
                            continue;                         
                         if (item[j].type.toLowerCase() != "radio" && item[j].type.toLowerCase()!="checkbox")
                            continue;                            
                         if (!item[j].checked)
                            continue;                            
                         if (strValue!="")
                            strValue+=";";
                         strValue+=item[j].value;
                     }
                     temp+=first?"":"&";
                     first=false;
                     temp+=item[0].title+"=" +replaces(strValue,"&","$**$");
                     continue;
                 }
                 
                 if(!item.value)continue;
                 if(item.value==""||item.value==null)continue;
                 temp+=first?"":"&";
                 first=false;
		         temp+=item.title+"=" +replaces(item.value,"&","$**$") ;
            }
		}
		return temp;
    },
    getMutiValue:function(itemId){
        var temp="";
        var container= $(__formCId);
      
        var inputs=container.getElementsByTagName("INPUT");
        for(var i=0;i<inputs.length;i++){
            temp+=inputs[i].name+"="+urlEncode(replaces(inputs[i].value,"&","$**$"));
            if(i<inputs.length)temp+="&";
        }
        return temp;
    },
    
    post:function(id,action,template,callback){
        __formCId=id;
         var data=this.getValues();
               
//url, sArg, pSuccessFunc, sContext, pFailureFunc, pStatusFunc, bAsync        
        //dnn.xmlhttp.postBack (this.url, data, null,formPostFailure,formPostSuccess,true);      

         __postback_action=action;
         __postback_template=template;
              
         var vCallback=(callback==null||callback=="")?formPostCallback:callback;
         YAHOO.util.Connect.asyncRequest("POST", this.url+"&rnd="+Math.random(), vCallback, data);       
      
    }
}

var divLoading;


Campton.Form.Loading=function(obj){
     divLoading =$("loading");
//     alert("divLoading = " + divLoading);
     this.node=obj;
     
}
Campton.Form.Loading.prototype={
    show:function(){
       
        //this.node.insertBefore(divLoading);
        var pos=this.getPosition();
        
        divLoading.innerHTML = __form_loading;
        
//        alert("divLoading.innerHTML = " + divLoading.innerHTML);  
         
        YAHOO.util.Dom.setStyle(divLoading,"display","block");
        YAHOO.util.Dom.setStyle(divLoading,"left",pos[0]);
        YAHOO.util.Dom.setStyle(divLoading,"top",pos[1]+30);
        
        $s(divLoading);
      
    },
   
    getPosition:function(){
        var myPos = YAHOO.util.Dom.getXY(this.node);
        var w=this.node.offsetWidth;
        var h=this.node.offsetHeight;
       
        myPos[0]=myPos[0]+w/2-divLoading.style.width/2-50;
        myPos[1]=myPos[1]+h/2;
        return myPos;
    }
}

function deleteModule(moduleId,actionId)
{
  var url= window.location.href;
  var index=url.indexOf("?");
  var indextag=url.indexOf("#");
  var indextag1=url.indexOf("/#");
  if(indextag>0)
  {
      if(indextag1>0)
      {
        url=url.substring(0,indextag1);
        
      }
      else{
       url=url.substring(0,indextag);
     }
  }
  if(index==-1)
  {
    url+="?";
  }
  else
  {
   url=url.substring(0,index+1);
  }
  if(index==-1&&indextag==-1&&indextag1==-1)
  {
   window.location= url+"moduleid="+moduleId+"&actionId="+actionId;

   return;
  }
  window.location= url+"moduleid="+moduleId+"&actionId="+actionId;

}
//--Dialogs begin

function getMtoolD(obj){
    var w=getMtoolW(obj);
    if(w>=200)return "";
    return "none"
}
function getMtoolW(obj){
   if(obj==null)return -1;
   if(obj.parentNode.parentNode==null)return -2;
  
   if(obj.parentNode.parentNode.parentNode==null)return -3;
   var w=obj.parentNode.parentNode.parentNode.width;
   if(w!=null && w!="" && !isNaN(w))return w;
   w=obj.parentNode.parentNode.parentNode.style.width;
   if(w!=null && w!="" && !isNaN(w))return w;
   return 1000;
   
}
function AddMask()
{
  YAHOO.util.Event.addListener(window, "load", AddMasks);
}
function AddMasks(){   
     var maskDiv=document.createElement("DIV");
     if(!BrowserIsIE())
     {
      maskDiv.style.cssText="position:absolute;top:0px;z-index:500;background-color:#000;opacity:.0;";
      }
      else
      {
      maskDiv.style.cssText="position:absolute;top:0px;z-index:500;background-color:#000;filter:alpha(opacity=0);";
      }
      maskDiv.style.height=document.documentElement.scrollHeight+"px";
      maskDiv.style.width=document.documentElement.scrollWidth+"px";       
      document.body.appendChild(maskDiv);
      
      var image=document.createElement("img");
      image.style.cssText="position:absolute;top:0px;z-index:600;right:0px; width:150px;height:37px;cursor:pointer;"; 
      image.src="/images/closePreview"+language+".gif";
      document.body.appendChild(image);
      YAHOO.util.Event.addListener(image, "click", closepreview);
             
 }
 function closepreview()
 {
    window.close();
 }

function replaces(str,oldstr,newstr)
{
   str=str.replace(oldstr,newstr);
   if(str.indexOf(oldstr)!=-1)return replaces(str,oldstr,newstr);
   else{
   return str;}
}

//ViewCustomizeForm
var SuccessToSettingFormType = function(o)
{
    var result = o.responseText;    
    if (result != "success")
        alert(__errorOccurred);
    
    window.location.reload();
}
var FailToSettingFormType = function(o)
{
    alert(__errorOccurred);
    window.location.reload();
}
var closeCustomizeFormSetting = {success: SuccessToSettingFormType, failure: FailToSettingFormType}
function CustomizeFormSetting(tabmoduleid,moduleid,tabid)
{  
    var objDivIM = $("divFormSetting");
    showMask();
    setFixXY(objDivIM,600,300)
    var dialogsBox = new campton.dialogs(objDivIM, "dialogs_FormSetting", "CloseDivFormSetting()");
    dialogsBox.setTitle(__formsettingtitle);
    dialogsBox.setContent(__containerBodyContent);
    dialogsBox.setFooter(__containerFooterContent);
	var url = "/ajax.aspx?command=formsettingpanel&tabid="+tabid+"&tabmoduleid="+tabmoduleid+"&moduleid="+moduleid;
	campton.update(url, "", dialogsBox.body);
}
function CloseDivFormSetting()
{
    var objDivGCA = $("divFormSetting");
    objDivGCA.innerHTML = "";
    closeMask();
} 

function ManageContent(url)
{   
    window.location.href =url;
}
function GotoFormManagement(url)
{
    window.location.href = url;
}
function GotoFormAdvanceSetting(url)
{
    window.location.href = url;
}
