﻿// JScript 文件
//图片轮播
//<div id='imgADPlayer'></div>
//PImgPlayer.addItem( "test", "http://www.pomoho.com", "/skin/default/images/gywm.gif");
//PImgPlayer.addItem( "test2", "http://www.pomoho.com", "http://static.pomoho.com/static/samesong/images/logo4.jpg");
//PImgPlayer.addItem( "test", "http://www.pomoho.com", "/skin/default/images/gywm.gif");
//PImgPlayer.addItem( "test2", "http://www.pomoho.com", "http://static.pomoho.com/static/samesong/images/logo4.jpg");
//PImgPlayer.addItem( "test3", "http://www.pomoho.com", "http://static.pomoho.com/static/samesong/images/logo3.jpg");
//PImgPlayer.init( "imgADPlayer", 225, 210 );

var PImgPlayer = {
	_timer : null,
	_items : [],
	_container : null,
	_index : 0,
	_imgs : [],
	intervalTime : 5000,	//轮播间隔时间
	init : function( objID, w, h, time ){
		this.intervalTime = time || this.intervalTime;
		this._container = document.getElementById( objID );
		this._container.style.display = "block";
		this._container.style.width = w + "px";
		this._container.style.height = h + "px";
		this._container.style.position = "relative";
		this._container.style.overflow  = "hidden";
		//this._container.style.border = "1px solid #fff";
		var linkStyle = "display: block; TEXT-DECORATION: none;";
		if( document.all ){
			linkStyle += "FILTER:";
			linkStyle += "progid:DXImageTransform.Microsoft.Barn(duration=0.5, motion='out', orientation='vertical') ";
			linkStyle += "progid:DXImageTransform.Microsoft.Barn ( duration=0.5,motion='out',orientation='horizontal') ";
			linkStyle += "progid:DXImageTransform.Microsoft.Blinds ( duration=0.5,bands=10,Direction='down' )";
			linkStyle += "progid:DXImageTransform.Microsoft.CheckerBoard()";
			linkStyle += "progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=0)";
			linkStyle += "progid:DXImageTransform.Microsoft.GradientWipe ( duration=1,gradientSize=1.0,motion='reverse' )";
			linkStyle += "progid:DXImageTransform.Microsoft.Inset ()";
			linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=out )";
			linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=PLUS,motion=in )";
			linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=DIAMOND,motion=in )";
			linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=1,irisStyle=SQUARE,motion=in )";
			linkStyle += "progid:DXImageTransform.Microsoft.Iris ( duration=0.5,irisStyle=STAR,motion=in )";
			linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=CLOCK )";
			linkStyle += "progid:DXImageTransform.Microsoft.RadialWipe ( duration=0.5,wipeStyle=WEDGE )";
			linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=horizontal )";
			linkStyle += "progid:DXImageTransform.Microsoft.RandomBars ( duration=0.5,orientation=vertical )";
			linkStyle += "progid:DXImageTransform.Microsoft.RandomDissolve ()";
			linkStyle += "progid:DXImageTransform.Microsoft.Spiral ( duration=0.5,gridSizeX=16,gridSizeY=16 )";
			linkStyle += "progid:DXImageTransform.Microsoft.Stretch ( duration=0.5,stretchStyle=PUSH )";
			linkStyle += "progid:DXImageTransform.Microsoft.Strips ( duration=0.5,motion=rightdown )";
			linkStyle += "progid:DXImageTransform.Microsoft.Wheel ( duration=0.5,spokes=8 )";
			linkStyle += "progid:DXImageTransform.Microsoft.Zigzag ( duration=0.5,gridSizeX=4,gridSizeY=40 ); width: 100%; height: 100%";
		}
		//
		var ulStyle = "margin:0;width:"+w+"px;position:absolute;z-index:999;right:0px;FILTER:Alpha(Opacity=30,FinishOpacity=90, Style=1);overflow: hidden;bottom:-1px;height:16px; border-right:1px solid #fff;";
		//
		var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;";
		//
		var baseSpacStyle = "clear:both; display:block; width:23px;line-height:18px; font-size:12px; FONT-FAMILY:'宋体';opacity: 0.6;";
		baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;";
		baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; ";
		//
		var ulHTML = "";
		for(var i = this._items.length -1; i >= 0; i--){
			var spanStyle = "";
			if( i==this._index ){
				spanStyle = baseSpacStyle + "background:#ff0000;";
			} else {				
				spanStyle = baseSpacStyle + "background:#000;";
			}
			ulHTML += "<li style=\""+liStyle+"\">";
			ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\""+spanStyle+"\" onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i+1) + "</span>";
			ulHTML += "</li>";
		}
		//
		var html = "<a href=\""+this._items[this._index].link+"\" title=\""+this._items[this._index].title+"\" target=\"_blank\" style=\""+linkStyle+"\"></a><ul style=\""+ulStyle+"\">"+ulHTML+"</ul>";
		this._container.innerHTML = html;
		var link = this._container.getElementsByTagName("A")[0];	
		link.style.width =  w + "px";
		link.style.height = h + "px";
		link.style.background = 'url(' + this._items[0].img + ') no-repeat center center';
		document.getElementById("proName").innerHTML="<a href='"+this._items[this._index].link+"'><b>"+(this._items[this._index].title.length>20?this._items[this._index].title.substring(0,20)+"...":this._items[this._index].title)+"</b></a>"
		this._timer = setInterval( "PImgPlayer.play()", this.intervalTime );
	},
	addItem : function( _title, _link, _imgURL ){
		this._items.push ( {title:_title, link:_link, img:_imgURL } );
		var img = new Image();
		img.src = _imgURL;
		this._imgs.push( img );
	},
	play : function( index ){
		if( index!=null ){
			this._index = index;
			clearInterval( this._timer );
			this._timer = setInterval( "PImgPlayer.play()", this.intervalTime );
		} else {
			this._index = this._index<this._items.length-1 ? this._index+1 : 0;
		}
		var link = this._container.getElementsByTagName("A")[0];	
		if(link.filters){
			var ren = Math.floor(Math.random()*(link.filters.length));
			link.filters[ren].Apply();
			link.filters[ren].play();
		}
		
		link.href = this._items[this._index].link;
		link.title = this._items[this._index].title;
		link.style.background = 'url(' + this._items[this._index].img + ') no-repeat center center';
		document.getElementById("proName").innerHTML="<a href='"+this._items[this._index].link+"'><b>"+(this._items[this._index].title.length>20?this._items[this._index].title.substring(0,20)+"...":this._items[this._index].title)+"</b></a>"
		var liStyle = "margin:0;list-style-type: none; margin:0;padding:0; float:right;";
		var baseSpacStyle = "clear:both; display:block; width:23px;line-height:18px; font-size:12px; FONT-FAMILY:'宋体'; opacity: 0.6;";
		baseSpacStyle += "border:1px solid #fff;border-right:0;border-bottom:0;";
		baseSpacStyle += "color:#fff;text-align:center; cursor:pointer; ";
		var ulHTML = "";
		for(var i = this._items.length -1; i >= 0; i--){
			var spanStyle = "";
			if( i==this._index ){
				spanStyle = baseSpacStyle + "background:#ff0000;";
			} else {				
				spanStyle = baseSpacStyle + "background:#000;";
			}
			ulHTML += "<li style=\""+liStyle+"\">";
			ulHTML += "<span onmouseover=\"PImgPlayer.mouseOver(this);\" onmouseout=\"PImgPlayer.mouseOut(this);\" style=\""+spanStyle+"\" onclick=\"PImgPlayer.play("+i+");return false;\" herf=\"javascript:;\" title=\"" + this._items[i].title + "\">" + (i+1) + "</span>";
			ulHTML += "</li>";
		}
		this._container.getElementsByTagName("UL")[0].innerHTML = ulHTML;	
	},
	mouseOver : function(obj){
		var i = parseInt( obj.innerHTML );
		if( this._index!=i-1){
			obj.style.color = "#ff0000";
		}
	},
	mouseOut : function(obj){
		obj.style.color = "#fff";
	}
}


//加载xml文件
function loadxmldoc(dname) 
{
try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
    xmlDoc=document.implementation.createDocument("","",null);
    }
  catch(e) {alert(e.message)}
  }
try 
  {
  xmlDoc.async=false;
  xmlDoc.load(dname);
  return(xmlDoc);
  }
catch(e) {alert(e.message)}
return(null);
}
//轮播加参
var xmlDoc=null;
function BeginPlayer()
{
if(xmlDoc==null)
xmlDoc=loadxmldoc("/xml/newsRecommend.xml");
var count=0;
for(var i=0;i<xmlDoc.getElementsByTagName("web_news").length;i++)
{
  var name=xmlDoc.getElementsByTagName("title")[i].childNodes[0];
  var id=xmlDoc.getElementsByTagName("id")[i].childNodes[0];
  var pid=xmlDoc.getElementsByTagName("pId")[i].childNodes[0];
  var url=xmlDoc.getElementsByTagName("icoPath")[i].childNodes[0];
 
  if(url!=null && url.nodeValue!="" && pid.nodeValue==115 && count<10)
   {
  
     PImgPlayer.addItem( name==null?"":name.nodeValue, "/detail"+id.nodeValue+"_"+pid.nodeValue+".htm", "/upfiles/"+url.nodeValue);
     count++;
   }
   if(count>=10)
   {
     break;
   }
}
 PImgPlayer.init( "imgADPlayer", 285, 175,4000);
}

//各地区医院简介
function getExpertsInfo(_name,cursel,n,cs,id)
{
   setTab(_name,cursel,n,cs);
   if(xmlDoc==null)
    xmlDoc=loadxmldoc("/xml/newsRecommend.xml");
    for(var i=0;i<xmlDoc.getElementsByTagName("web_news").length;i++)
    {
       var name=xmlDoc.getElementsByTagName("title")[i].childNodes[0];
       var url=xmlDoc.getElementsByTagName("icoPath")[i].childNodes[0];
       var summary=xmlDoc.getElementsByTagName("summary")[i].childNodes[0];
       var author=xmlDoc.getElementsByTagName("author")[i].childNodes[0];
       var linkUrl=xmlDoc.getElementsByTagName("linkUrl")[i].childNodes[0];
       var _id=xmlDoc.getElementsByTagName("id")[i].childNodes[0];
       
       if(_id.nodeValue==id)
       {
           if(_name=="expMenu")
           {
               document.getElementById("expertsImg").src="/upfiles/"+(url==null?"":url.nodeValue);
               if(author==null || author.nodeValue=="")
                 document.getElementById("expertsName").innerHTML=name.nodeValue+"教授";
               else
                 document.getElementById("expertsName").innerHTML=author.nodeValue+"："+name.nodeValue+"教授";
                 
               document.getElementById("expertsInfo").innerHTML=(summary==null?"":(summary.nodeValue.length>390?summary.nodeValue.substring(0,390)+"……":summary.nodeValue));
               var temp="<a href='/expertDetail_all.htm' class='more04'>更多</a>";
               document.getElementById("expertsBaidu").innerHTML=(linkUrl==null?temp:temp+"<a href='"+(linkUrl==null?"":linkUrl.nodeValue)+"'><img target='_bland' src='/skin/default/images/index-04-950_58.jpg' width='59' height='25' /></a>");
               break;
           }
            if(_name=="expArea")
           {
               document.getElementById("expAreaDetail").innerHTML=(summary==null?"":(summary.nodeValue.length>260?summary.nodeValue.substring(0,260)+"……":summary.nodeValue));
               document.getElementById("areaId").href="/AreaDetail"+id+"_79.htm";
               break;
           }
       }
    }
}


//地图热点动作
function getHotAreaInfo(id,cont)
{
  var len=document.getElementsByName("expArea").length;
  for(var i=0;i<len;i++)
  {
    document.getElementsByName("expArea")[i].className="";
    var content=document.getElementsByName("expArea")[i].innerHTML;
    content=content.replace("&nbsp;","").replace(" ","");
    if(cont==content)
    {
      document.getElementsByName("expArea")[i].className='hospital-now';
    }
  }
   if(xmlDoc==null)
    xmlDoc=loadxmldoc("/xml/newsRecommend.xml");
    for(var i=0;i<xmlDoc.getElementsByTagName("web_news").length;i++)
    {
       var summary=xmlDoc.getElementsByTagName("summary")[i].childNodes[0];
       var _id=xmlDoc.getElementsByTagName("id")[i].childNodes[0];
       if(_id.nodeValue==id)
       {
           document.getElementById("expAreaDetail").innerHTML=(summary==null?"":(summary.nodeValue.length>260?summary.nodeValue.substring(0,260)+"……":summary.nodeValue));
           document.getElementById("areaId").href="/AreaDetail"+id+"_79.htm";
           break;
       }
    }
}

