//搜索栏使用
function clearField(field,value){
	if (field.value==value)
		field.value="";
}
function setField(field,value){
	if (field.value=="")
		field.value=value;
}
function checkSearch(){
	clearField(searchForm.keyword,'关键字');
	clearField(searchForm.brand,'品牌');
	return true;
}

//显示或隐藏
function showOrHide(id) {//单个层控制
  if(document.getElementById(id).style.display == "none"){
	  document.getElementById(id).style.display = "" ;
  }else{
	  document.getElementById(id).style.display = "none" ;
  }
}

//切换效果
function showDiv(showName,showId){
   document.getElementById(tempSearchId).style.display="none";
   document.getElementById(showName+'_'+showId).style.display="block";
   tempSearchId = showName+'_'+showId;
}

//点击标题，图片切换
function genShowBigPic(picUrl,Link,text,idx,type) {//idx参数是栏目ID
  document.getElementById("bigPic_"+idx).src = picUrl ;
  document.getElementById("bigPic_"+idx).alt = text ;
  document.getElementById("bigPicLink_"+idx).href = Link ;
  if(type==1) {//显示标题
	document.getElementById("hrefLink_"+idx).href = Link ;
  	document.getElementById("hrefLink_"+idx).innerText = text ;
  }  
}

//单个层控制 0隐藏 1显示
function isShowDiv(id,isShow) {
  if(isShow==0){
	  document.getElementById(id).style.display = "none" ;
  }else{
	  document.getElementById(id).style.display = "" ;
  }
}

//flash调用代码
function showFlash(src,w,h){
	var str = '';
	str += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+w+'" height="'+h+'">';
	str += '<param name="movie" value="'+src+'">';
	str += '<param name="quality" value="high">';
	//str += '<param name=wmode value="transparent">'; //这个是使flash透明的参数
	str += '<embed src="'+src+'" quality=high width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	str += '</object>';
	document.write(str);
}

//播放视频
function showMV(swf_width,swf_height,texts,files)
{
	var config='0:自动播放|1:连续播放|100:默认音量|0:控制栏位置|2:控制栏显示|0x000033:主体颜色|60:主体透明度|0x66ff00:光晕颜色|0xffffff:图标颜色|0xffffff:文字颜色|:logo文字|:logo地址|:结束swf地址';
	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">');
	document.write('<param name="movie" value="SunbalaFlv.swf"><param name="quality" value="high">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="allowFullScreen" value="true" />');
	document.write('<param name="FlashVars" value="vcastr_file='+files+'&vcastr_title='+texts+'&vcastr_config='+config+'">');
	document.write('<embed src="SunbalaFlv.swf" allowFullScreen="true" FlashVars="vcastr_file='+files+'&vcastr_title='+texts+'&vcastr_config='+config+'" menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); 
	document.write('</object>'); 
}

//循环滚动   idName为名称,speed为滚动速度,red为滚动方向
function showMoving(idName, speed, red){
  var showMovingId,showMovingId1,showMovingId2
  showMovingId = document.getElementById(idName);
  showMovingId1 = document.getElementById(idName+"1");
  showMovingId2 = document.getElementById(idName+"2");
  showMovingId2.innerHTML = showMovingId1.innerHTML
  function Marquee(){     //offsetWidth对象的可见宽度
    if(red=='left') {   //向左滚动
    	if(showMovingId2.offsetWidth-showMovingId.scrollLeft<=0){
       		showMovingId.scrollLeft-=showMovingId1.offsetWidth;
    	}else{     //offsetWidth返回和设置当前横向滚动务的坐标值 
       		showMovingId.scrollLeft+=2
    	}
  	}else if(red=='right'){   //向右滚动
        if(showMovingId.scrollLeft<=0){
           showMovingId.scrollLeft+=showMovingId2.offsetWidth
		}else{
           showMovingId.scrollLeft--
		}
	}
  }
  var MyMar=setInterval(Marquee,speed)
  showMovingId.onmouseover=function() {clearInterval(MyMar)}
  showMovingId.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}

//通用图层显示 cmyChen Add 
function genShowSubMenu(lan,sid,lan_shu,showDivImgNot,showDivImg,showCssNot,showCss)
{
  //lan大栏目号(字符型),sid小栏目号(数值型,1开始),lan_shu小栏目总数(数值型)
  //showDivImgNot不显示图层时背景图(字符型),showDivImg显示图层时背景图(字符型)
  //showCssNot不显示图层时Css类(字符型),showCss显示图层时Css类(字符型)
  var whichEl,whichEl_td
  for (var i=1;i<lan_shu+1;i++){
       whichEl = document.getElementById("gen_" + lan + "_" + i);
	   whichEl_td = document.getElementById("gen_" + lan + "_" + i + "_td");
	   //是否更改状态
	   if(i==sid){
	      whichEl.style.display = 'block';
		  whichEl_td.className = showCss;
		  whichEl_td.style.backgroundImage = 'url("'+showDivImg+'")';	
	   }else{
		  whichEl.style.display = 'none';
		  whichEl_td.className = showCssNot;
		  whichEl_td.style.backgroundImage = 'url("'+showDivImgNot+'")';	
	   }
  }
}

//图片变换效果
function showPhotoChange(pics, links, texts, focus_width, focus_height, text_height)
{
	var swf_height   =  focus_height + text_height
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+swf_height+'">');
	document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="http://www.sunbala.cn/Ehome/inc/pic/pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value="#ffffff">');
	document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
	document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
	document.write('<embed src="http://www.sunbala.cn/Ehome/inc/pic/pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}


function doZoom(size){
	document.getElementById('zoom').style.fontSize=size+'px'
	//setTailPosition()
}
function doPrint(){
	var str="<html>\n<meta http-equiv='content-type' content='text/html; charset=gb2312'>";
	var article;
	var css;
	var strAdBegin="<!--NEWSZW_HZH_BEGIN-->";
	var strAdEnd="<!--NEWSZW_HZH_END-->";
	var strdoPrint="doPrint()";
	var strTmp;

	css="<style>"
	+"body{font-family:宋体}"
	+"td,.f12{font-size:12px}"
	+".f24 {font-size:24px;}"
	+".f14 {font-size:14px;}"
	+".title14 {font-size:14px;line-height:130%}"
	+".l17 {line-height:170%;}"
	+".x14 {font-size:14px;line-height:130%}"
	+"</style>";

	str +=	css;
	str +=	'<meta http-equiv="content-type" content="text/html; charset=gb2312">';
	str +=	"<body bgcolor=#ffffff topmargin=5 leftmargin=5 marginheight=5 marginwidth=5 onLoad='window.print()'>";
	str +=	"<center><table width=600 border=0 cellspacing=0 cellpadding=0><tr><td height=34 width=150><a href=http://www.cbiq.com/Ehome><img src=http://sunbala.cn/ehome/inc/images/LOGOSUN3.jpg width=70 height=29 border=0></a></td><td valign=bottom><font color=#0000ff>"
	str +=	"</font></td><td align=right valign=bottom><font color=#ca90ef>|</font> <a href='javascript:history.back()'>返回</a>　<a href='javascript:window.print()'>打印</a></td></tr></table>";
	str +=	"<table width=600 border=0 cellpadding=0 cellspacing=20 bgcolor=#EFEFEF><tr><td>";
	
	article=document.getElementById('article').innerHTML;
	if(article!=null && article!="" )
	{article=article+"";
		if(article.indexOf(strAdBegin)!=-1){
			str +=article.substr(0,article.indexOf(strAdBegin));
			strTmp=article.substr(article.indexOf(strAdEnd)+strAdEnd.length, article.length);
		}
		else{
			strTmp=article;
		}
	}
	str +=strTmp;
	str += window.location.href;
	str +=	"</td></tr></table></center>";
	str +=	"</body></html>";
	document.write(str);
	document.close();
}

//首页星座切换
function showXZ(toId){
  var inDiv = "xinZuo_" + toId + "|||";
  if(toId!=xinZuo_temId && strNotIn.indexOf(inDiv) ==-1){
     document.getElementById("xinZuo_"+xinZuo_temId).style.display = "none" ;
	 document.getElementById("xinZuo_"+toId).style.display = "" ;
	 xinZuo_temId = toId;
  }
}

function OpenReg(Num){
	if (Num==4)  //个人用户注册
		window.open("http://www.sunbala.cn/user/persons/RegPersons.asp");
	else if (Num==1){  //企业用户注册
		window.open("http://blog.sunbala.cn/register.aspx");
	}
	else if (Num==2){  //设计师会员注册地址
		window.open("http://design.sunbala.cn/club/register.htm");
	}
	else if (Num==3){  //论坛地址
		window.open("http://bbs.sunbala.cn/");
	}
	else if (Num==5){  //博客地址
		window.open("http://blog.sunbala.cn/");
	}
}



