document.write ("<script type='text/javascript' src='/design/js/common.js'><\/script>");

function setIframeHight(){
  if (self.location != top.location)
  {
     parent.document.all(self.name).height = document.body.scrollHeight;
  }
}


//flash编辑开始
function editFlash(){
	var oformid=window.document.pageForm;
	
	oformid.tfWidth.value=oformid.topFWidth.value;
	oformid.tfHeight.value=oformid.topFHeight.value;
	
	if(oformid.topFIsshow.value=="Y"){
		oformid.tfIsshow.checked="checked";
	
	}
	
	oformid.nfWidth.value=oformid.navFWidth.value;
	oformid.nfHeight.value=oformid.navFHeight.value;
	
	if(oformid.navFIsshow.value=="Y"){
		oformid.nfIsshow.checked="checked";
	
	}
	
	oformid.bfWidth.value=oformid.botFWidth.value;
	oformid.bfHeight.value=oformid.botFHeight.value;
	
	if(oformid.botFIsshow.value=="Y"){
		oformid.bfIsshow.checked="checked";
	
	}
	
	for(i=0;i<oformid.elements.length;i++)
	{		
		if(oformid.elements[i].type=="radio"&&oformid.elements[i].id=="tf_r"){
				if(oformid.elements[i].value==oformid.topFUrl.value){
						oformid.elements[i].checked=true;
					}
		}
		if(oformid.elements[i].type=="radio"&&oformid.elements[i].id=="nf_r"){
				if(oformid.elements[i].value==oformid.navFUrl.value){
						oformid.elements[i].checked=true;
					}
		}
		if(oformid.elements[i].type=="radio"&&oformid.elements[i].id=="bf_r"){
				if(oformid.elements[i].value==oformid.botFUrl.value){
						oformid.elements[i].checked=true;
					}
		}


	}
	
}

function viewFlash(){
	var oformid=window.document.pageForm;
	var topurl="";
	var navigateurl="";
	var bottomurl="";
	var width="";
	var height="";
	for(i=0;i<oformid.elements.length;i++)
	{		
		if(oformid.elements[i].type=="radio"&&oformid.elements[i].id=="tf_r"&&oformid.elements[i].checked){
			topurl=oformid.elements[i].value;
		}
		if(oformid.elements[i].type=="radio"&&oformid.elements[i].id=="nf_r"&&oformid.elements[i].checked){
			navigateurl=oformid.elements[i].value;
		}
		if(oformid.elements[i].type=="radio"&&oformid.elements[i].id=="bf_r"&&oformid.elements[i].checked){
			bottomurl=oformid.elements[i].value;
		}


	}
	
	if(oformid.tfIsshow.checked){
		width=oformid.tfWidth.value;
		height=oformid.tfHeight.value;
		var url="/design/out_flash.jsp?width="+width+"&height="+height+"&url="+topurl;
		var text=getContent(url);
		
		window.top.document.getElementById("flash_div_top").innerHTML=text;
	}
	else{
		window.top.document.getElementById("flash_div_top").innerHTML="";
	}
	
	if(oformid.nfIsshow.checked){
			width=oformid.nfWidth.value;
			height=oformid.nfHeight.value;
			var url="/design/out_flash.jsp?width="+width+"&height="+height+"&url="+navigateurl;
		var text=getContent(url);
		
		window.top.document.getElementById("flash_div_navigate").innerHTML=text;
	}
	else{
		window.top.document.getElementById("flash_div_navigate").innerHTML="";
	}
	if(oformid.bfIsshow.checked){
		width=oformid.bfWidth.value;
		height=oformid.bfHeight.value;
		
		var url="/design/out_flash.jsp?width="+width+"&height="+height+"&url="+bottomurl;
		var text=getContent(url);
		
		window.top.document.getElementById("flash_div_bottom").innerHTML=text;
	}
	else{
		window.top.document.getElementById("flash_div_bottom").innerHTML="";
	}
	
}
function setFlash(){
	
	try{
					var oformid=window.document.pageForm;
					
					oformid.topFWidth.value=oformid.tfWidth.value;
					oformid.topFHeight.value=oformid.tfHeight.value;
					
					if(oformid.tfIsshow.checked){
						oformid.topFIsshow.value="Y";
					
					}
					else{
						oformid.topFIsshow.value="N";
					}
					
					oformid.navFWidth.value=oformid.nfWidth.value;
					oformid.navFHeight.value=oformid.nfHeight.value;
					
					if(oformid.nfIsshow.checked){
						oformid.navFIsshow.value="Y";
					
					}
					else{
						oformid.navFIsshow.value="N";
					}
					
					oformid.botFWidth.value=oformid.bfWidth.value;
					oformid.botFHeight.value=oformid.bfHeight.value;
					
					if(oformid.bfIsshow.checked){
						oformid.botFIsshow.value="Y";
					}
					else{
						oformid.botFIsshow.value="N";
					}
					
					for(i=0;i<oformid.elements.length;i++)
					{		
						if(oformid.elements[i].type=="radio"&&oformid.elements[i].id=="tf_r"&&oformid.elements[i].checked){
							oformid.topFUrl.value=oformid.elements[i].value;
						}
						if(oformid.elements[i].type=="radio"&&oformid.elements[i].id=="nf_r"&&oformid.elements[i].checked){
								oformid.navFUrl.value=oformid.elements[i].value;
						}
						if(oformid.elements[i].type=="radio"&&oformid.elements[i].id=="bf_r"&&oformid.elements[i].checked){
							oformid.botFUrl.value=oformid.elements[i].value;
						}
				
				
					}
		}
	catch(e){
		
	}
	
	
}
//主框架编辑开始

function editMain(){
	try{
			window.document.pageForm.setMainHeight.value=window.document.pageForm.mainHeight.value;	
		
	}
	catch(e){
		
	}
	
}
function setMain(obj){
	var mh=obj.value;
	if(mh==""||mh<=0){
		alert("设置的值不合法！");	
		obj.value=window.document.pageForm.mainHeight.value;
	}
	else{
		window.document.pageForm.mainHeight.value=obj.value;	
		window.top.document.getElementById("div_main_height").style.minHeight="800px";
	}
	
}

/**
*套装编辑开始
*/
function initial_suite(){
	var url="/design/suite.do?method=suiteList"
	var text=getContent(url);
	var obj_div_css=window.document.getElementById("div_suite");
	obj_div_css.innerHTML=text;
	
}


function loadSuite(page,productId)
{	
	var ocssfilediv = document.getElementById("custom_style");
    ocssfilediv.innerHTML="正在加载数据....";
    var para="page="+page+"&productId="+productId;
	var url="/design/material.do?method=materialList&forward=Style&"+para;
	ocssfilediv.innerHTML=getContent(url);
   
}
var img_suite="";
function select_cssSuite (obj,url){
	 showTip('Doing')

			if(img_suite!=""){
				img_suite.className='style_bg1_custom';
			}
			img_suite=obj;
			obj.className='style_bg2_custom';
		
				var linknum=window.top.document.getElementsByTagName("link");	
				 for(var i=1;i<linknum.length;i++)
				 {	
				 	var css_href=linknum[i].href;
					
					if(css_href.indexOf("style")>0){
						 linknum[i].href=url; 
					}

				 }
				 window.document.pageForm.pagecss.value=url;

}

function del_material(id,materialId)
{	
	var oli = document.getElementById(id);
    var ok= confirm("该操作不能恢复！确定删除？");
	if(ok==true){
		var url="/design/material.do?method=materialDelete&materialId="+materialId;
		var text=getContent(url);
		text=text.replace(/(^\s*)|(\s*$)/g, "");
		if(text=="success"){
			alert("操作成功！");
			var oli_p=oli.parentNode;
			oli_p.removeChild(oli);
		}
		else{
			alert("操作失败！");
		}
	}
   
}



/**
初始化小框架

function initial_module_list(){

	var pagedivids=parent.document.getElementById("divids").value;
	var oformid=document.getElementById("coustomForm");
	if(pagedivids!=""){
		for(i=0;i<oformid.elements.length;i++)
		{		
			if(oformid.elements[i].type=="checkbox"){
					var navigateId=oformid.elements[i].id;
				
					if(pagedivids.indexOf(navigateId)>-1){
						oformid.elements[i].checked=true;
					}
			}
	
		}

	}


}
*/
function divHorS(obj){
	if(obj.checked){
		window.document.div_form.isshow.value="Y";
	}
	else{
		window.document.div_form.isshow.value="N";
	}
}



//导航开始
function editNavigate(){
	var showtype=window.document.pageForm.navShowtype.value;
	var nShowtype=window.document.getElementsByName("nShowtype");
		for(i=0;i<nShowtype.length;i++)
		{	
				if(nShowtype[i].value==showtype){
					//nShowtype[i].click();
				
				}
							
		}
	
}

function select_navigate_type(objid,productId){
	
	window.document.getElementById("div_menu_hidden").className="custom_title_f hidden";
	window.document.getElementById("div_menu_word_show").className="custom_title_f hidden";
	window.document.getElementById("div_menu_pic_show").className="custom_title_f hidden";
	window.document.getElementById(objid).className="custom_title_f";
	if(objid=="div_menu_pic_show"){
		
		   var ocssfilediv = document.getElementById("div_navigate_bg");
  	 	    ocssfilediv.innerHTML="正在加载数据....";
			var url="/design/material.do?method=materialList&&dpStructureId=3&format=1&type=BG&forward=NavigateBg&productId="+productId;
			ocssfilediv.innerHTML=getContent(url);
			
			
			initial_set_navigate_bg();
	}

}

var obj_ng_bg=""
function set_navigate_bg(obj,navigateId)
{
	
	if(obj_ng_bg!=""){
		obj_ng_bg.className="custom_pic_default";
	}
	obj.className="custom_pic_selected";
	obj_ng_bg=obj
	window.document.pageForm.set_nabg_value.value=navigateId;//当设置的是那栏目的背景
}
function sel_navigate_bg(imgurl){
	var nabg_value=window.document.pageForm.set_nabg_value.value;//当设置的是那栏目的背景
	if(nabg_value==""){
		
		alert("请先选择栏目");		
	}
	else{
		var obj_div_img=window.document.getElementById("div_ng_bg_show"+nabg_value);
			if(obj_div_img){
				obj_div_img.innerHTML="<img src="+imgurl+" width='100px'/>";
				window.document.getElementById("nimgs"+nabg_value).value=nabg_value+"="+imgurl;
			}
	}
}
function initial_set_navigate_bg(){
	var navbgs=window.document.pageForm.navImgs.value;
	if(navbgs!=""){
		
			var navbg=navbgs.split(";");
			for(i=0;i<navbg.length;i++){
				var na_bg=navbg[i];
				if(na_bg!=""){
					
						var na_bgs=na_bg.split("=");
						var nId=na_bgs[0];//栏目ID
						var imgurl=na_bgs[1];//栏目ID
						var obj_div_img=window.document.getElementById("div_ng_bg_show"+nId);
						var obj_input_img=window.document.getElementById("nimgs"+nId);
						if(obj_div_img&&obj_input_img){
							obj_input_img.value=na_bg;
							obj_div_img.innerHTML="<img src="+imgurl+" width='100px'/>";
						}
				}
				
			}
	}
	
}

function view_navigate(){
	//menu_word_show  menu_pic_show menu_hidden
	var navigate_type="W";
	var nShowtype=window.document.getElementsByName("nShowtype");
		for(i=0;i<nShowtype.length;i++)
		{	
				if(nShowtype[i].checked){
					navigate_type=nShowtype[i].value;	
				
				}
							
		}
	var obj_div_navigate=window.top.document.getElementById("div_navigate");
	if(navigate_type=="W"){
		obj_div_navigate.className="menu_word_show"
	}
	else if(navigate_type=="F"){
		obj_div_navigate.className="menu_hidden"
	}
	else if(navigate_type=="I"){
		obj_div_navigate.className="menu_pic_show"	
			var onimgs=window.document.getElementsByName("nimgs");
			for(i=0;i<onimgs.length;i++)
			{	
				
					var na_bg=onimgs[i].value;	
					if(na_bg!=""){
							var na_bgs=na_bg.split("=");
								var nId=na_bgs[0];//栏目ID
								var imgurl=na_bgs[1];//栏目ID
								var obj_span_img=window.top.document.getElementById("span_na_img"+nId);
								if(obj_span_img){
									obj_span_img.innerHTML="<img src="+imgurl+" />";
								}	
					}											
			}
		
	}
	
	
	
}

function set_navigate(){
	
	try{
			var na_bg_param="";
			var onimgs=window.document.getElementsByName("nimgs");
			var nShowtype=window.document.getElementsByName("nShowtype");
			if(onimgs&&nShowtype){
					
					for(i=0;i<onimgs.length;i++)
						{		
								var na_bg=onimgs[i].value;	
								if(na_bg!=""){
									na_bg_param+=na_bg+";";
								}
														
						}
						if(na_bg_param!=""){
							window.document.pageForm.navImgs.value=na_bg_param;
						}

					
				
					for(i=0;i<nShowtype.length;i++)
						{	
								if(nShowtype[i].checked){
								
									window.document.pageForm.navShowtype.value=nShowtype[i].value;
								}
											
						}
				
			}
			
			
	}
	catch(e){
		
	}
}



//自定义开始


function setCustom(num,productId){	

		var url="/design/html.do?method=getHtml&productId="+productId+"&oper=CP"
		var text=getContent(url);
		if(text=="success"){
				var obj_div_custom_iframe=window.top.document.getElementById("index_div_custom_iframe")
				obj_div_custom_iframe.height="302px";
			    var obj_div_inherit=window.document.getElementById("div_inherit");
				var obj_div_custom=window.document.getElementById("div_custom")
				if(num=="1"){
					obj_div_inherit.className="custom_topBar g_p_block";
					obj_div_custom.className="custom_body hidden";	
				}
				else if(num=="2")
				{
					window.top.setmove();//move.js; 可以移动
					
					window.top.document.getElementById("div_body").className="body_wrap  main_custom_edit user_rights_have";
					obj_div_inherit.className="custom_topBar hidden";
			
					obj_div_custom.className="custom_body g_p_block";
					
					//加载套装样式
					var css_url='/design/material.do?method=materialList&format=1&type=CS&dpStructureId=9&forward=Style&productId='+productId;
					custom_tool('custom_nav_style','custom_style',css_url);
				
				}
				window.document.getElementById("div_tool").className="custom_topBar hidden";
					
		}
		else{
			alert("数据出错！");	
		}
	
	
}

var obj_li_custom_nav="";
var mobj_div_custom="";
function custom_tool(obj_id,mobj,url){
	var obj=window.document.getElementById(obj_id);
	
	if(obj_li_custom_nav!=""){		
		obj_li_custom_nav.className=""
	}
	else{
		window.document.getElementById("custom_nav_style").className="";
	}
	obj_li_custom_nav=obj;
	obj.className="now";
	
	if(mobj_div_custom!=""){
		mobj_div_custom.className="hidden"		
	}
	else{
		window.document.getElementById("custom_style").className="hidden";	
	}
	
	mobj_div_custom=window.document.getElementById(mobj);
	mobj_div_custom.className="";
	mobj_div_custom.innerHTML=getContent(url);
	
	if(mobj=="custom_flash"){
		editFlash();
	}
	else if(mobj=="custom_main"){
		
		 editMain();
	}
	else if (mobj=="custom_navigate"){
		init_nShowtype(); 
		editNavigate();
	}
	
	
}

//add by huangcs 20100609
function init_nShowtype(){
	var obj_div_navigate=window.top.document.getElementById("div_navigate");
	var nShowtype1 = window.document.getElementById("nShowtype1");
	var nShowtype2 = window.document.getElementById("nShowtype2");
	var nShowtype3 = window.document.getElementById("nShowtype3");
	nShowtype1.checked=false;
	nShowtype2.checked=false;
	nShowtype3.checked=false;
	
	//内容
	window.document.getElementById("div_menu_hidden").className="custom_title_f hidden";
	window.document.getElementById("div_menu_word_show").className="custom_title_f hidden";
	window.document.getElementById("div_menu_pic_show").className="custom_title_f hidden";
		
	if(obj_div_navigate.className=="menu_hidden"){
		nShowtype3.checked=true;
		window.document.getElementById("div_menu_hidden").className="custom_title_f";
	}else if(obj_div_navigate.className=="menu_pic_show"){
		nShowtype2.checked=true;
		window.document.getElementById("div_menu_pic_show").className="custom_title_f";
		//显示相应的数据
		var productId = window.document.getElementById("productId").value;
		var ocssfilediv = document.getElementById("div_navigate_bg");
 	 	ocssfilediv.innerHTML="正在加载数据....";
		var url="/design/material.do?method=materialList&&dpStructureId=3&format=1&type=BG&forward=NavigateBg&productId="+productId;
		ocssfilediv.innerHTML=getContent(url);
		
		initial_set_navigate_bg();

	}else{
		nShowtype1.checked=true;
		window.document.getElementById("div_menu_word_show").className="custom_title_f";
	}
}

function set_page(obj){
	var navigateId=obj.value
	var productId=window.document.pageForm.productId.value;
	
	window.top.document.location.href="/production/specific_site/"+productId+"/"+navigateId+".htm";
	//var cp_navigateId='index';
	//window.top.document.location.href="/design/inherit.jsp?productId="+productId+"&navigateId="+navigateId+"&cp_navigateId="+cp_navigateId;
		
}
function save_inherit(){
	var ok= confirm("该操作不能恢复，确认该操作吗？");
	if(ok==true){
			showTip('Doing');
			var cp_navigateId=window.document.pageForm.inherit_navigateId.value;
			var navigateId=window.document.pageForm.navigateId.value;
			var productId=window.document.pageForm.productId.value;
			
			var url="/design/html.do?method=inherit&productId="+productId+"&navigateId="+navigateId+"&cp_navigateId="+cp_navigateId;
			var text=getContent(url);
			if(text=="success"){
					
					window.top.document.location.reload();
			}
			else{
					showTip('F');
			}
			
		
	}

}
/**
保存
*/
function saveCustom(productId){
	 showTip('Doing');

	var url="/design/clear_config.do?productId="+productId;
	var text=getContent(url);
		
	 setDivMove();
	 setFlash();
	 set_navigate();
	 	
	window.setTimeout("window.document.pageForm.submit()",2000);
	
			
			
}



function outCustom(){
	var ok= confirm("确认退出编辑？");
	if(ok==true){
		window.top.document.location.reload();	
	}

}

//只能输入整数的检测.
function checkInteger(obj){	
	if(!/^(-?[1-9][0-9]*|0)$/.test(obj.value)){ 
		alert("请输入整数!");  
		obj.value="";
	}
}

