
var mobanmenu=new Array();
var mobanmenu_num=0;
/*
//id,titleMessage,url
	new Array("divid","编辑","jec_manage.php?action=club&operation=new");
*/
function setmobanmenu(_mobanmenu){
	mobanmenu=_mobanmenu;
}
function editinit(){
	/*
	for(var i=0;i<mobanmenu.length;i+=3){
		try{
			_$(mobanmenu[i]).setAttribute("iframesign", mobanmenu[i+1]);
			_$(mobanmenu[i]).setAttribute("iframeurl", mobanmenu[i+2]);
			_$(mobanmenu[i]).onmouseover=function(){showEditorDiv(this);}
		}catch(e){}
	}
	*/
}
var datadivobj=null;
function removeEvent(){
	try{
		CloseIframeDialog()
		datadivobj.onmouseover=function(){}
	}catch(e){alert("error");}
}
function removeAllEvent(){
	try{
		for(var i=0;i<mobanmenu.length;i+=3){
			_$(mobanmenu[i]).onmouseover=function(){}
		}
	}catch(e){}
	CloseIframeDialog();
}
/**
	鼠标滑入时显示编辑对话框
*/
function showEditorDiv(_datadivobj){
	try{
		datadivobj=_datadivobj;
		var divid=_datadivobj.id;
		for(var i=0;i<mobanmenu.length;i+=2){
			if(mobanmenu[i]==divid){
				datadivSign=mobanmenu[i+1];
				break;
			}
		}
		//alert(datadivobj.offsetWidth+"-----"+datadivobj.clientHeight);
		var editordiv=document.getElementById('editor_div');
		editordiv.style.top = getAbsTop(_datadivobj)-40 + "px";
		editordiv.style.left = getAbsLeft(_datadivobj)-5 + "px";
		editordiv.style.width = _datadivobj.offsetWidth+10 + "px";
		editordiv.style.height = _datadivobj.offsetHeight+40 + "px";
		document.getElementById("editor_caption").innerHTML=datadivobj.iframesign+" 编辑";
		editordiv.style.display='block';
	}catch(e){}
}
/**
	编辑模块内容
*/
function onEdit(){
	try{
		this.onIframeLoad = function(el, func) {
			var cb = function() {
				try {
					func.call(this);
				} catch (e) {}
			}
			if (el.contentDocument) {
				el.onload = function() {
					setTimeout(cb, 0);
					el.onload = null;
				}
			} else {
				el.onreadystatechange = function(){
					if (el.readyState == 'complete') {
						setTimeout(cb, 0);
						el.onreadystatechange = null;
					}
				}
			}
		}
		this.ReSizeiFrame=function(iframe)
		{
			onIframeLoad(iframe, function(){
				try {
					if(iframe && !window.opera)
					{
						iframe.style.display = "block";
						var h='';
						if(iframe.contentDocument)
						{
							h= iframe.contentDocument.documentElement.offsetHeight + 16;
						}
						else if (iframe.document)
						{
							h= iframe.document.body.scrollHeight;
						}
						if (h == '') {
							var func = arguments.callee;
							setTimeout(function(){ func(); }, 20);
							return;
						}
						iframe.style.height = h+'px';
					}
				} catch (e) {}
			});
		}
		//var _url="jec_manage.php?action=club&operation=new&ajaxframe=1";
		var mask=_$('mask_div');
		mask.style.top=0;
		mask.style.left=0;
		mask.style.width=document.body.clientWidth;
		mask.style.height=document.body.clientHeight;
		mask.style.display='';
		
		var dialog=_$('dialog_div');
		var _width=850;
		var _height=screen.height/2;
		//ReSizeiFrame(dialog); 
		var _left=(document.body.clientWidth-_width)/2;
		var _top=document.documentElement.scrollTop+50;
		dialog.style.left=_left;
		dialog.style.top=_top;
		dialog.style.width=_width;
		dialog.style.height=_height+100;
		dialog.document.getElementById('dialog_caption').innerHTML=datadivobj.iframesign+" 编辑";
		var iframehtml=null;
		if(datadivobj.iframeurl!=""){
			iframehtml='<iframe ID="manage_iframe" width="'+_width+'" height="'+_height+'" src="'+(datadivobj.iframeurl)+'" frameborder="0"></iframe>';
		}else{
			_$("editor_content1").value=datadivobj.innerHTML;
			iframehtml='<iframe ID="eWebEditor1" width="'+_width+'" height="'+_height+'" src="eWebEditor/ewebeditor.htm?id=content1&style=coolblue" frameborder="0"></iframe>';
			_$("save_bt").style.display="block";
		}
		//datadivobj.innerHTML;
		document.getElementById('dialog_iframe').innerHTML=iframehtml;
		dialog.style.display='block';
	}catch(e){}
}
/**
	关闭对话框
*/
function CloseIframeDialog(){
	document.getElementById('dialog_iframe').innerHTML='';
	document.getElementById('dialog_div').style.display='none';
	document.getElementById('mask_div').style.display='none';
	document.getElementById('editor_div').style.display='none';
	
	//parent.
}
/**
	刷新eWebEditor1的值
*/
function validateForm()
{ 
	//执行iframe页面中的AttachSubmit函数 
	window.frames["eWebEditor1"].AttachSubmit();
	if(_$("editor_content1").value != "")
	{ 
		return _$("editor_content1").value;
	}
	else
	{ 
		return ""; 
	}
}
/**
	确定
*/
function ok(){
	
}
/**
	保存
*/
function save(){
	datadivobj.innerHTML=validateForm();
	CloseIframeDialog();
}

//gloab function //// 
/////////////////////////////////

function _$(id){
	return document.getElementById(id);	
}
function getAbsLeft(e){
	var   l=e.offsetLeft;   
	while(e=e.offsetParent)   
		l   +=   e.offsetLeft;   
	return   l;
}   

function getAbsTop(e){
	var   t=e.offsetTop;     
	while(e=e.offsetParent)   
		t   +=   e.offsetTop;     
	return   t;
}
//drag drop function for IE 4+//// 
///////////////////////////////// 
var dragapproved=false 

function drag_dropie(){ 
	try{
		if (dragapproved==true){
			document.all.dialog_div.style.pixelLeft = tempx + event.clientX - iex
			document.all.dialog_div.style.pixelTop = tempy + event.clientY - iey 
		return false 
		} 
	}catch(E){}
} 

function initializedragie(){ 
	try{
		iex=event.clientX 
		iey=event.clientY
		tempx = dialog_div.style.pixelLeft
		tempy = dialog_div.style.pixelTop 
		dragapproved=true 
		document.onmousemove=drag_dropie 
	}catch(E){}
} 
if (document.all){ 
	document.onmouseup=new Function("dragapproved=false") 
}
