<%@ Control Language="c#" CodeBehind="scrollPicNews.ascx.cs" AutoEventWireup="false" Inherits="TourOnline.TemplateDefault.Guide.scrollPicNews" %>
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>
<%
	string strSql = "select top 4 nId,nTitleImg,nName from tbWebTourNews where NState = 1 and sId = 'BH000019' and nIsScrollPic = 1 order by NTime desc";
			DataBase db = new  DataBase();
			DataSet ds = new DataSet();
			ds = db.GetDataSet(strSql,ds);
			int iScrollPic = ds.Tables[0].Rows.Count;
			Response.Write("<script language='javascript'>");
			Response.Write("var cpAD=new Array();var cpADlink=new Array();var cpADmsg=new Array();var adNum=" + (iScrollPic-1).ToString() + ";var coll=0;");
			int i = 0;
			DescCrypto dct = new DescCrypto();
			foreach(DataRow row in ds.Tables[0].Rows)
			{
				Response.Write("cpAD[" + i.ToString() + "]='" + row[1].ToString() + "';cpADlink[" + i.ToString() + "]='../News/News" + row[0].ToString().Trim() + ".html';cpADmsg[" + i.ToString() + "]='';");
				i++;
			}
			Response.Write("</script>");
			ds = null;
			db = null;
			dct = null;
%>
<script LANGUAGE="javascript">
<!--
var preloadedimages=new Array(); 
for (i=1;i<cpAD.length;i++){ 
preloadedimages[i]=new Image(); 
preloadedimages[i].src=cpAD[i]; 
} 

//跳转的URL地址
function jump2url()
{ 
jumpUrl=cpADlink[adNum]; 
jumpTarget='_blank'; 
if (jumpUrl != '')
{ 
 if (jumpTarget != '')
  window.open(jumpUrl,jumpTarget); 
 else location.href=jumpUrl; 
 } 
}

//图片变化的函数
function changeimg(n)
{
 adNum=n;
 switch(adNum)
 {
 case 0:
 {
  document.getElementById("img1").src="../images/tb_11_12.gif";
   document.getElementById("img2").src="../images/tb_12w_12.gif";
  document.getElementById("img3").src="../images/tb_13w_12.gif";
  document.getElementById("img4").src="../images/tb_14w_12.gif";
  break;
 }
 case 1:
 {
  document.getElementById("img1").src="../images/tb_1w_12.gif";
   document.getElementById("img2").src="../images/tb_12x_12.gif";
  document.getElementById("img3").src="../images/tb_13w_12.gif";
  document.getElementById("img4").src="../images/tb_14w.gif";
  break;
 }
 case 2:
 {
  document.getElementById("img1").src="../images/tb_1w_12.gif";
   document.getElementById("img2").src="../images/tb_12w_12.gif";
  document.getElementById("img3").src="images/tb_13x_12.gif";
  document.getElementById("img4").src="images/tb_14w_12.gif";
  break;
 }
  case 3:
 {
  document.getElementById("img1").src="../images/tb_1w_12.gif";
   document.getElementById("img2").src="../images/tb_12w_12.gif";
  document.getElementById("img3").src="../images/tb_13w_12.gif";
  document.getElementById("img4").src="../images/tb_14x_12.gif";
  break;
 }
 }
 window.clearInterval(theTimer);
 adNum=adNum-1;
 nextAd();
}
//当点击时直接跳转
function nextAd(){ 
coll++;
if(coll>1)
{
switch(adNum+1)
{
 case 4:
 {
  document.getElementById("img1").src="../images/tb_11_12.gif";
   document.getElementById("img2").src="../images/tb_12w_12.gif";
  document.getElementById("img3").src="../images/tb_13w_12.gif";
  document.getElementById("img4").src="../images/tb_14w_12.gif";
  break;
 }
 case 1:
 {
 document.getElementById("img1").src="../images/tb_1w_12.gif";
   document.getElementById("img2").src="../images/tb_12x_12.gif";
  document.getElementById("img3").src="../images/tb_13w_12.gif";
  document.getElementById("img4").src="../images/tb_14w_12.gif";
  break;
 }
 case 2:
 {
 document.getElementById("img1").src="../images/tb_1w_12.gif";
   document.getElementById("img2").src="../images/tb_12w_12.gif";
  document.getElementById("img3").src="../images/tb_13x_12.gif";
  document.getElementById("img4").src="../images/tb_14w_12.gif";
  break;
 }
 case 3:
 {
  document.getElementById("img1").src="../images/tb_1w_12.gif";
  document.getElementById("img2").src="../images/tb_12w_12.gif";
  document.getElementById("img3").src="../images/tb_13w_12.gif";
 document.getElementById("img4").src="../images/tb_14x_12.gif";
  break;
 }
}
}
if(adNum<cpAD.length-1)adNum++ ; 
else adNum=0; 
setTransition(); 
document.images.cpADrush.src=cpAD[adNum]; 
playTransition(); 
displayStatusMsg();
//定义了轮换时间 5s
theTimer=setTimeout("nextAd()", 7000); 
} 

function setTransition(){ 
if (document.all){ 
document.getElementById("cpADrush").filters.revealTrans.Transition=23; 
document.getElementById("cpADrush").filters.revealTrans.apply(); 
} 

} 
function playTransition(){ 
if (document.all) 
document.getElementById("cpADrush").filters.revealTrans.play() 
} 
function displayStatusMsg() { 
document.returnValue = true; 
} 
//结束
// -->
</script>
<table height="138" cellspacing="0" cellpadding="0" border=0>
   <tr> 
  <td> <a href="javascript:jump2url()"> <img  style="FILTER: revealTrans(duration=2,transition=23)" height="138"  width="505" border="0" name="cpADrush"></a></td>
  <script language="JavaScript">nextAd()</script>
   </tr>
   <tr> 
  <td align=right> 
    <table width="84" id="T1" border="0" cellspacing="0" cellpadding="0">
   <tr> 
     <td width="21"><a href="javascript:jump2url();" onMouseOver="changeimg(0)"><img name="Image2"  id="img1" border="0" src="../images/tb_1w_12.gif" width="19" height="14" onClick="changeimg(0)"></a></td>
     <td width="21"><a href="javascript:jump2url();" onMouseOver="changeimg(1)"><img name="Image3" id="img2" border="0" src="../images/tb_12w_12.gif" width="19" height="14" onClick="changeimg(1)"></a></td>
     <td width="21"><a href="javascript:jump2url();" onMouseOver="changeimg(2)"><img name="Image4" id="img3" border="0" src="../images/tb_13w_12.gif" width="19" height="14" onClick="changeimg(2)"></a></td>
     <td width="21"><a href="javascript:jump2url();" onMouseOver="changeimg(3)"><img name="Image5" id="img4" border="0" src="../images/tb_14w_12.gif" width="19" height="14" onClick="changeimg(3)"></a></td>
   </tr>
    </table>
  </td>
   </tr>
</table>

