var EditorBasePath='plug/fckeditor/';
var EditorJS='<script type="text/javascript" src="'+EditorBasePath+'fckeditor.js"></script>';
function isIE(){ //ie?
   if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1)
    return true;
   else
    return false;
}

if(!isIE()){ //firefox innerText define
   HTMLElement.prototype.__defineGetter__(     "innerText",
    function(){
     var anyString = "";
     var childS = this.childNodes;
     for(var i=0; i<childS.length; i++) {
      if(childS[i].nodeType==1)
       anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
      else if(childS[i].nodeType==3)
       anyString += childS[i].nodeValue;
     }
     return anyString;
    }
   );
   HTMLElement.prototype.__defineSetter__(     "innerText",
    function(sText){
     this.textContent=sText;
    }
   );
}
document.write(EditorJS);

var nil=false;
function $(o){
    return document.getElementById(o);
}
function GetEditor(){

    var _field=arguments[0];
    var _value=arguments[1];
    var _toolbarSet=arguments[2] || 'CGC';
    var _height=arguments[3] || 'nil'; 
    var _width=arguments[4] || 'nil';
    var _toolbar=arguments[5] || 'nil';
   
    
    var oFCKeditor = new FCKeditor( _field ) ;
    oFCKeditor.BasePath	= EditorBasePath ;
    oFCKeditor.ToolbarSet=_toolbarSet;
    if(_width!='nil') oFCKeditor.Width=_width;
    if(_height!='nil') oFCKeditor.Height = _height ;
    if(_toolbar!='nil') oFCKeditor.Config[ 'ToolbarLocation' ] = 'Out:' + _toolbar ;
    oFCKeditor.Value = _value ;
    oFCKeditor.Create() ;
}

function H2H(h1,h2){
    var menu=document.getElementById(h1);
	var page=document.getElementById(h2);
	if(page.scrollHeight>menu.scrollHeight)
		menu.style.height=page.scrollHeight+60;
}

function displayLayer(){
    $(arguments[0]).style.display='block';
    for(i=1;i<arguments.length;i++){
        $(arguments[i]).style.display="none";
    }
    
}
function fnOnPageChanged(page) {
	document.location.href = url+page;
}
function displayContent(id,o){
	if($('content_' + id).style.display=='none' || !$('content_' + id).style.display){
		$('content_' + id).style.display='block';
		//o.innterText="关闭内容";
	}else{
		$('content_' + id).style.display='none';
		//o.innterText="显示内容";
	}
}
function getElementsByClassName(className, parentElement){
var elems = ($(parentElement)||document.body).getElementsByTagName("*");
var result=[];
for (i=0; j=elems[i]; i++){
   if ((" "+j.className+" ").indexOf(" "+className+" ")!=-1){
result.push(j);
   }
}
return result;
}
function displayAll(){
	var layers=getElementsByClassName('contents','');
	for(i=0;i<layers.length;i++){
		layers[i].style.display='block';
	}
}
function hideAll(){
	var layers=getElementsByClassName('contents','page');
	for(i=0;i<layers.length;i++){
		layers[i].style.display='none';
	}
}
function reply(id){
    var rep=$('reply_'+id).innerText;
    $('reply-form').style.display='block';
   // window.alert(rep);
    $('reply').value=rep;
    $('feed_id').value=id;
   // window.alert(id);
}

function roll(){
   var rollLinks=getElementsByClassName('roll','t1');
   var rlen=rollLinks.length;
   
    for(i=0;i<rlen;i++){
      
      addListener(rollLinks[i],'mouseover',rollover);
      addListener(rollLinks[i],'mouseout',rollout);
      addListener(rollLinks[i],'click',lblur);
   }
  
}
function addListener(el,ev,func){
   if(el.addEventListener){
      el.addEventListener(ev,func,false);
   }else{
      el.attachEvent("on"+ev,func);
   }
}
function lblur(e){
    var el=e.strElement||e.target;
    el.blur();
}
function rollover(e,which){
   var el=e.srcElement||e.target;
   var src=el.src;
   if(src.substring(src.lastIndexOf('-')+1,src.lastIndexOf('.'))!='on')
           el.src=src.substring(0,src.lastIndexOf('.'))+"-on.gif";
   
}

function rollout(e){
   var el=e.srcElement||e.target;
   var src=el.src;
   if(src.substring(src.lastIndexOf('-')+1,src.lastIndexOf('.'))=='on')
   el.src=src.substring(0,src.lastIndexOf('-'))+".gif";
}
function cn2en(){
    var tabs=getElementsByClassName('roll');
    if(language=='english-utf8'){
        for(i=0;i<tabs.length;i++){
            var src=tabs[i].src.substring(0,tabs[i].src.lastIndexOf('.'))+"-en.gif";
            //alert(src);
            tabs[i].setAttribute('src',src);
        }
    }
}
window.onload=function(){
   // cn2en();
    roll();
    }
function flash(src,width,height){
    var media='<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="'+width+'" height="'+height+'">\
          <param name="movie" value="'+src+'" />\
          <param name="quality" value="high" />\
          <embed src="'+src+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>\
        </object>';
    document.write(media);
}
//var currentPhoto=0;
//var totalPhotos;
var purl="img/f/slide_prev_";
var nurl="img/f/slide_next_";
function _$(id){
	return eval("photos_"+id);	
}
function showPhotos(fotos){
	fotos.current=0;
	fotos.count=fotos.length-1;
	//alert(photos.currentPhoto);
    if(fotos!='undefined'&&fotos.length>0){
       var code='<div style="text-align:left"><span id=currentp_'+fotos.id+'>1</span>/<span id="total">'+eval(fotos.count+1)+'</span></div>\
       <div class="p-0" id="slide" style="margin:20px auto;margin-top:5px;border:1px solid #e1e1e1;padding:10px;text-align:center">\
       	<table cellpadding="0" cellspacing="0" width=96% class="s-0 slide" >\
		<tr>\
		<td width="18" valign=top>\
				<a href="javascript:prev(\''+fotos.id+'\')"><img id="prev_'+fotos.id+'" src="img/f/slide_prev_'+pn('prev',fotos.id)+'.gif" alt=""/></a>\
		</td>\
		<td width="" style="over-flow:hidden;text-align:center" ><img width=200 id=cphoto_'+fotos.id+' src="upld/'+fotos[0]['photo_filename']+'" /></td>\
		<td width="18" valign=top>\
				<a href="javascript:next(\''+fotos.id+'\');"><img id="next_'+fotos.id+'" src="img/f/slide_next_'+pn("next",fotos.id)+'.gif" alt=""/></a>\
				</td>\
		</tr>\
		</table>\
	</div> ';
	//alert(code);
    document.write(code);
    }
}
function pn(obj,f){
	f=_$(f);
	if(obj=="prev"){
		if(f.current>0) return "enable";
		else return "disable";
	}else if(obj=="next"){
		if(f.current<f.count) return "enable";
		else return "disable";
	}
}
function prev(f){
	f=_$(f);
	//alert(f.count);
   if(f.current>0){
    f.current--;
    $('cphoto_'+f.id).src='upld/'+f[f.current]['photo_filename'];
	//alert($('cphoto_'+f.id).src);
    $('currentp_'+f.id).innerText=eval(f.current+1);
	$('prev_'+f.id).src=purl+pn("prev",f.id)+'.gif';
	$('next_'+f.id).src=nurl+pn("next",f.id)+'.gif';
   }
}
function next(f){
	f=_$(f);
   if(f.current<f.count){
    f.current++;
    $('cphoto_'+f.id).src='upld/'+f[f.current]['photo_filename'];
    $('currentp_'+f.id).innerText=eval(f.current+1);
	$('prev_'+f.id).src=purl+pn("prev",f.id)+'.gif';
	$('next_'+f.id).src=nurl+pn("next",f.id)+'.gif';
   }
}
var imgShow="zhengshu";
function changeImg(id){
	$(imgShow).style.display='none';
	imgShow=id;
	$(imgShow).style.display='block';
	$('fo').focus();
}
var thisObj=null;
var thisPro=null;
function insertProduct(){
	var out="";
	if(productId.length>1){
	   out="<div id='type'>";
	for(i=0;i<productId.length;i++){
		out+="<a id=a_"+productId[i];
		if(i==0) out+=" class='on' ";
		out+=" href=\"javascript:showPro('"+productId[i]+"');\">"+productName[i]+"</a><br/>";
	}
	
	out+="</div>";
	}
	thisObj='a_'+productId[0];
	out+="<div id='product'></div>";
	//alert(out);
	$('out').innerHTML=out;
	thisPro=productId[0];
	showPro(productId[0]);
	
}
function showPro(id){
	//alert(obj.id);
	$('product_'+thisPro).style.display="none";	
	thisPro=id;
	$('product_'+thisPro).style.display="block";	
	$(thisObj).className='';
	$('a_'+id).className='on';
	thisObj='a_'+id;
}







