var sys_arr_dialog=[];
function dialog_init(msgname,msgtit,msgwidth,msgheight){
	var strWidth=get_realW()-200;
	var strHeight=get_realH()-200;
	if(strHeight<300) strHeight=300;
	var regex =/^\d$/;
	if(msgwidth && !regex.test(msgwidth) && msgwidth>0){
		strWidth=msgwidth;
	}
	if(msgheight && !regex.test(msgheight) && msgheight>0){
		strHeight=msgheight;
	}
	var str_content="";
	str_content+='<div class="alpha" style="width:'+strWidth+'px;height:'+strHeight+'px"></div>';
	var strWidth2=strWidth-20;
	var strHeight2=strHeight-20;
	var strTop2=strHeight-10;
	var strLeft2=strWidth-10;
	var strHeight3=strHeight2-40;
	str_content+='<div class="body" style="width:'+strWidth2+'px;height:'+strHeight2+'px;top:-'+strTop2+'px;left:10px">';
	str_content+='<div class="title">';
	str_content+='<li><b>'+msgtit+'</b></li>';
	str_content+='<li class="x_close"><a href="javascript:div_hide_show(\'win'+msgname+'\');" title="关闭">&nbsp;</a></li>';
	str_content+='</div>';
	str_content+='<div class="val"><iframe name="frm'+msgname+'" id="frm'+msgname+'" src="" width="100%" height="'+strHeight3+'px" frameborder=0></iframe></div>';
	str_content+='</div>';

	var obj_div=document.createElement("div");
	obj_div.id='win'+msgname;
	obj_div.className="divDialog";
	obj_div.style.cssText="display:block;width:"+strWidth+"px;height:"+strHeight+"px";
	obj_div.innerHTML=str_content;
	document.body.appendChild(obj_div);
	sys_arr_dialog.push("win"+msgname);
	lng_len=sys_arr_dialog.length;
	for(var i=0;i<lng_len;i++){
		obj_win=document.getElementById(sys_arr_dialog[i]);
		divMove(obj_win);
	}
	//div_show('win'+msgname);
}
function dialog_init_content(msgname,msgcontent,msgtit,msgwidth,msgheight,notitle){
	strWidth=get_realW()-200;
	strHeight=get_realH()-200;
	var regex =/^\d+$/;
	if(msgwidth && msgwidth!=""){
		if(!regex.test(msgwidth)){
			msgwidth=msgwidth.replace("px","");
		}
		strWidth=msgwidth;
	}
	if(msgheight && msgheight!=""){
		if(!regex.test(msgheight)){
			msgheight=msgheight.replace("px","");
		}
		strHeight=msgheight;
	}
	var str_content="";
	str_content+='<div class="alpha" style="width:'+strWidth+'px;" id="id_alpha_'+msgname+'"></div>';
	var strWidth2=strWidth-20;
	str_content+='<div class="body" style="width:'+strWidth2+'px;left:10px;" id="id_body_'+msgname+'">';
	if(!notitle){
		str_content+='<div class="title">';
		str_content+='<li><b>'+msgtit+'</b></li>';
		str_content+='<li class="x_close"><a href="javascript:div_hide_show(\'win'+msgname+'\');" title="关闭">&nbsp;</a></li>';
		str_content+='</div>';
	}
	str_content+='<div class="val" onmousedown="event.cancelBubble=true;" onmouseup="event.cancelBubble=true;" onmousemove="event.cancelBubble=true;" style="cursor:default" id="id_val_'+msgname+'">'+msgcontent+'</div>';
	str_content+='</div>';

	var obj_div=document.createElement("div");
	obj_div.id='win'+msgname;
	obj_div.className="divDialog";
	obj_div.style.cssText="display:none;width:"+strWidth+"px;height:"+strHeight+"px";
	obj_div.innerHTML=str_content;
	document.body.appendChild(obj_div);


	sys_arr_dialog.push("win"+msgname);
	lng_len=sys_arr_dialog.length;
	for(var i=0;i<lng_len;i++){
		obj_win=document.getElementById(sys_arr_dialog[i]);
		divMove(obj_win);
	}

	//div_show('win'+msgname);
	var obj_val=document.getElementById("id_val_"+msgname);
	var obj_alpha=document.getElementById("id_alpha_"+msgname);
	var obj_body=document.getElementById("id_body_"+msgname);
	var lng_h=40;
	if(msgheight){
		lng_h+=parseInt(strHeight);
	}else{
		lng_h+=obj_val.clientHeight;
	}
	obj_body.style.height=lng_h+"px";
	obj_body.style.top="-"+(lng_h+10)+"px";
	obj_alpha.style.height=lng_h+20+"px";
	obj_win.style.height=lng_h+20+"px";
}
function dialog_init_ajax(msgname,msgtit,msghtml,msgwidth,msgheight){
	var strHeight="";
	//strHeight=document.documentElement.clientHeight-200;
	var lng_width=0;
	if(msgwidth&&msgwidth>0){
		lng_width=msgwidth;
	}else{
		lng_width=document.documentElement.clientWidth-200;
	}
	if(msgheight&&msgheight!=0) strHeight=";height:"+msgheight+"px";
	var str_content="";
	str_content+='<div class="alpha" style="width:'+lng_width+';" id="id_alpha_'+msgname+'"></div>';
	var strWidth2=lng_width-40;
	str_content+='<div class="body" style="width:'+strWidth2+'px;left:10px;padding:0px 10px 0px 10px" id="id_body_'+msgname+'">';
	str_content+='<div class="title" onmousedown="event.cancelBubble=true;" onmouseup="event.cancelBubble=true;" onmousemove="event.cancelBubble=true;" style="cursor:default">';
	str_content+='<li><b>'+msgtit+'</b></li>';
	str_content+='<li class="x_close"><a href="javascript:div_hide_show(\'win'+msgname+'\');" title="关闭">&nbsp;</a></li>';
	str_content+='</div>';
	str_content+='<div class="val" onmousedown="event.cancelBubble=true;" onmouseup="event.cancelBubble=true;" onmousemove="event.cancelBubble=true;" style="cursor:default" id="id_val_'+msgname+'">'+msghtml+'</div>';
	str_content+='</div>';

	var obj_div=document.createElement("div");
	obj_div.id='win'+msgname;
	obj_div.className="divDialog";
	obj_div.style.cssText="display:;width:"+lng_width+"px;"+strHeight;
	obj_div.innerHTML=str_content;
	document.body.appendChild(obj_div);

	obj_win=document.getElementById("win"+msgname);

	sys_arr_dialog.push("win"+msgname);
	lng_len=sys_arr_dialog.length;
	for(var i=0;i<lng_len;i++){
		obj_win=document.getElementById(sys_arr_dialog[i]);
		divMove(obj_win);
	}
	//div_show('win'+msgname);
	var obj_val=document.getElementById("id_val_"+msgname);
	var obj_alpha=document.getElementById("id_alpha_"+msgname);
	var obj_body=document.getElementById("id_body_"+msgname);
	var lng_h=obj_val.clientHeight+40;
	obj_body.style.height=lng_h+"px";
	obj_body.style.top="-"+(lng_h+10)+"px";
	obj_alpha.style.height=lng_h+20+"px";
	obj_win.style.height=lng_h+20+"px";
}

function dialog_winPic(msgname)
{
	obj=document.getElementById("winpic_"+msgname);
	if(!obj){
		dialog_init("pic_"+msgname,"选择图片");
		obj_frm=document.getElementById("frmpic_"+msgname);
		obj_frm.src=cfg_web_url+"/plus/dialog/upload.php?win_type=pic&win_objid="+msgname;
		//window.open(cfg_web_url+"/plus/dialog/upload.php?win_type=pic&win_objid="+msgname,"frmpic_"+msgname);
	}
	div_show("winpic_"+msgname);
}
function dialog_winStore(storeid,storetxt)
{
	obj=document.getElementById("winstore"+storeid);
	if(!obj){
		dialog_init("store"+storeid,"选择图片");
		window.open(cfg_web_url+"/plus/dialog/store.php?objstoreid="+storeid+"&objstoretxt="+storetxt,"frmstore"+storeid);
		div_show("winstore"+storeid);
	}else{
		div_show("winstore"+storeid);
	}
}
function dialog_winJobApply(jobid)
{
	var obj=document.getElementById("winJobApply");
	if(!obj){
		dialog_init("JobApply","职位申请");
		window.open(cfg_web_url+"/plus/dialog/job_apply.php?jobid="+jobid,"frmJobApply");
		div_show("winJobApply");
	}else{
		div_show("winJobApply");
	}
}
function dialog_show(msgid,msgtit,msgurl,msgrefresh,msgw,msgh){
	var obj=document.getElementById("win"+msgid);
	if(!obj){
		var strw=0;
		var strh=0;
		if(msgw) strw=msgw;
		if(msgh) strh=msgh;
		dialog_init(msgid,msgtit,strw,strh);
		window.open(msgurl,"frm"+msgid);
	}else{
		if(msgrefresh){
			window.open(msgurl,"frm"+msgid);
		}
	}
	div_show("win"+msgid);
}
function dialog_show_cont(msg_id,msgcont,msgtit,msgw,msgh,isshow){
	var obj=document.getElementById("win"+msg_id);
	if(!obj){
		dialog_init_content(msg_id,msgcont,msgtit,msgw,msgh);
	}
	if(!isshow){
		div_show("win"+msg_id);
	}

}
function dialog_winJobInvite(userid)
{
	var obj=document.getElementById("winJobInvite");
	if(!obj){
		dialog_init("JobInvite","职位申请","600","250");
		window.open(cfg_web_url+"/plus/dialog/job_invite.php?userid="+userid,"frmJobInvite");
		div_show("winJobInvite");
	}else{
		div_show("winJobInvite");
	}
}function dialog_winTemplates(msgname)
{
	obj=document.getElementById("wintemplates"+msgname);
	if(!obj){
		dialog_init("templates"+msgname,"选择模板");
		window.open(cfg_web_url+"/plus/dialog/wintemplates.php?obj="+msgname,"frmtemplates"+msgname);
		div_show("wintemplates"+msgname);
	}else{
		div_show("wintemplates"+msgname);
	}
}
function dialog_winTemplates_lib(msgname)
{
	obj=document.getElementById("wintemp");
	if(!obj){
		dialog_init("temp","注册用户");
		window.open(cfg_web_url+"/plus/dialog/wintemplates_lib.php?obj="+msgname,"frmtemplates_lib");
		div_show("wintemp");
	}else{
		div_show("wintemp");
	}
}
function dialog_winUser(userid,username,msg_parm)
{
	obj=document.getElementById("winuser"+userid);
	if(!obj){
		dialog_init("user"+userid,"注册用户");
		str_parm="";
		if(msg_parm) str_parm="&"+msg_parm;
		window.open(cfg_web_url+"/plus/dialog/user.php?objuserid="+userid+"&objusername="+username+str_parm,"frmuser"+userid);
		div_show("winuser"+userid);
	}else{
		div_show("winuser"+userid);
	}
}
function dialog_winCompany(userid,username)
{
	obj=document.getElementById("winuser"+userid);
	if(!obj){
		dialog_init("user"+userid,"企业用户");
		window.open(cfg_web_url+"/plus/dialog/company.php?objuserid="+userid+"&objusername="+username,"frmuser"+userid);
		div_show("winuser"+userid);
	}else{
		div_show("winuser"+userid);
	}
}
function get_area_select(objthis,msgname){
	objx=document.getElementById(msgname);
	obj=objx.getElementsByTagName("select");
	strx=objthis.value.split(",");
	msglay=strx[0];
	msgid=strx[1];
	lngx=obj.length-1;
	for(var i = lngx; i >= msglay; i--) {
		var e = obj[i];
		pobj=e.parentElement;
		pobj.removeChild(e);
	}
	strval="";
	for(var i = 0; i < msglay; i++) {
		var e = obj[i];
		if(e.selectedIndex>0)strval+=e.options[e.selectedIndex].innerHTML+" ";
	}
	objx=document.getElementById(msgname);
	obj=objx.getElementsByTagName("input");
	objarea=document.getElementById(obj[0].id);
	objarea.value=strval;
	if(msgid=="") return;
	yj_ajax_get(cfg_web_url+"/plus/ajax/index.php?act=get_area_select&id="+msgid,function(data,textStatus){
		on_area_addselect(data,msgname);
	});
}

function get_area_select_1(msgname,msgid,msglay){
	objx=document.getElementById(msgname);
	obj=objx.getElementsByTagName("select");
	lngx=obj.length-1;
	for(var i = lngx; i >= msglay; i--) {
		var e = obj[i];
		pobj=e.parentElement;
		pobj.removeChild(e);
	}
	strval="";
	for(var i = 0; i < msglay; i++) {
		var e = obj[i];
		if(e.selectedIndex>0)strval+=e.options[e.selectedIndex].innerHTML+" ";
	}
	objx=document.getElementById(msgname);
	obj=objx.getElementsByTagName("input");
	objarea=document.getElementById(obj[0].id);
	objarea.value=strval;
	if(msgid=="") return;
	yj_ajax_get(cfg_web_url+"/plus/ajax/index.php?act=get_area_select&id="+msgid,function(data,textStatus){
		on_area_addselect(data,msgname);
	});
}

function on_area_addselect(data,msgname)
{
	if(data=="") return;
	testDiv=document.getElementById(msgname);
	var select = document.createElement("select"); 
	str_option=data.split("|");
	for(i=0;i<str_option.length;i++){
		str_x=str_option[i].split("=");
		strx=str_x[0].split(",");
		msglay=strx[0];
		select.options[i+1] = new Option(str_x[1],str_x[0]);
	}
	select.options[0] = new Option("--请选择--", msglay+",");
	select.options[0].selected=true;
	select.onchange=function(){get_area_select(this,msgname);};
	var object = testDiv.appendChild(select);
}
function on_area_edit(msg_name)
{
	div_display(msg_name,"span","none");
	div_display(msg_name,"a","none");
	div_display(msg_name,"select","");
}
function get_folder_select(objthis,msgname){
	objx=document.getElementById(msgname);
	obj=objx.getElementsByTagName("select");
	strx=objthis.value.split(",");
	msglay=strx[0];
	msgid=strx[1];
	lngx=obj.length-1;
	for(var i = lngx; i >= msglay; i--) {
		var e = obj[i];
		pobj=e.parentElement;
		pobj.removeChild(e);
	}
	msglay--;
	if(obj[msglay]) strval=obj[msglay].options[obj[msglay].selectedIndex].value;
	objx=document.getElementById(msgname);
	obj=objx.getElementsByTagName("input");
	objfolder=document.getElementById(obj[0].id);
	objfolder.value=strval;
	if(msgid=="") return;
	yj_ajax_get(cfg_web_url+"/plus/ajax/index.php?act=get_folder_select&id="+msgid,function(data,textStatus){
		on_folder_addselect(data,msgname);
	});
}

function get_folder_select_1(msgname,msgid,msglay){
	objx=document.getElementById(msgname);
	obj=objx.getElementsByTagName("select");
	lngx=obj.length-1;
	for(var i = lngx; i >= msglay; i--) {
		var e = obj[i];
		pobj=e.parentElement;
		pobj.removeChild(e);
	}
	strval="";
	msglay--;
	if(obj[msglay]) strval=obj[msglay].options[obj[msglay].selectedIndex].value;
	objx=document.getElementById(msgname);
	obj=objx.getElementsByTagName("input");
	objfolder=document.getElementById(obj[0].id);
	objfolder.value=strval;
	if(msgid=="") return;
	yj_ajax_get(cfg_web_url+"/plus/ajax/index.php?act=get_folder_select&id="+msgid,function(data,textStatus){
		on_folder_addselect(data,msgname);
	});
}

function on_folder_addselect(data,msgname)
{
	if(data=="") return;
	testDiv=document.getElementById(msgname);
	var select = document.createElement("select"); 
	str_option=data.split("|");
	for(i=0;i<str_option.length;i++){
		str_x=str_option[i].split("=");
		strx=str_x[0].split(",");
		msglay=strx[0];
		select.options[i+1] = new Option(str_x[1],str_x[0]);
	}
	select.options[0] = new Option("--请选择--", msglay+",");
	select.options[0].selected=true;
	select.onchange=function(){get_folder_select(this,msgname);};
	var object = testDiv.appendChild(select);
}
