﻿// JScript 文件

function Switch(index,ctrlObj)
{
    if (ctrlObj.id)
    {
        var ctrlName = ctrlObj.id.substring(0, ctrlObj.id.indexOf("MessageIndex"));
        var objhfdIndex = document.getElementById(ctrlName + "hfdIndex");        
        var oldIndex = objhfdIndex.value;
        objhfdIndex.value = index;
        var d_image=document.getElementById(ctrlName + "d_image");
        var d_title=document.getElementById(ctrlName+"d_title");
        var d_content=document.getElementById(ctrlName+"d_content");
        var image=document.getElementById(ctrlName+"MessagePicPath"+index).innerHTML;
        var title=document.getElementById(ctrlName+"MessageTitle"+index).innerHTML;
        var content=document.getElementById(ctrlName+"MessageContent"+index).innerHTML;
        d_image.innerHTML=image;
        d_title.innerHTML=title;
        d_content.innerHTML=content;
        var objCount=document.getElementById(ctrlName+"hfdCount");
        for(i=1;i<parseInt(objCount.value)+1;i++)
        {   
            var d_a=document.getElementById(ctrlName+"d_Link"+i);
            if(index==i)
            {
                d_a.style.color="#ff6600";//标明当前的索引项
            }
            else
            {
               d_a.style.color="#000"; 
            }
        }
    }  
}

function SwitchEx(ctrlObj,count)
{ 
        
    if (ctrlObj.id)
    {
        var ctrlName = ctrlObj.id.substring(0, ctrlObj.id.indexOf("MessageIndex"));
        var objhfdIndex = document.getElementById(ctrlName + "hfdIndex");
        var Index = objhfdIndex.value;
        if(Index<count)
        {
            objhfdIndex.value=parseInt(Index)+1;
        }
        else
        {
            objhfdIndex.value=1;
        }
        var objhfdCount=document.getElementById(ctrlName+"hfdCount");
        objhfdCount.value=count;
        Switch(objhfdIndex.value,ctrlObj);

    }  
}
function InitExchange(ctrlObj,count,Speed)//所属控件标示，总的索引数
{
    if (ctrlObj.id)
    {
        var ctrlObjName=ctrlObj.id;
        var ctrlName = ctrlObj.id.substring(0, ctrlObj.id.indexOf("MessageIndex"));
        var objhfdIndex = document.getElementById(ctrlName + "hfdIndex");
        var Index = objhfdIndex.value;
        var d_image=document.getElementById(ctrlName + "d_image");
        var d_title=document.getElementById(ctrlName+"d_title");
        var d_content=document.getElementById(ctrlName+"d_content");      
        var timeID = setInterval('SwitchEx('+ctrlObjName+','+count+')', Speed );//设置循环与间隔
        for(i=0;i<count;i++)
        {
            var j=i+1;
            var d_a=document.getElementById(ctrlName+"d_Link"+j);
            d_a.onmouseover = function(){clearInterval( timeID);}//鼠标移动至div上时清除循环
	        d_a.onmouseout = function(){ timeID = setInterval('SwitchEx('+ctrlObjName+','+count+')', Speed );}
        }

        d_image.onmouseover = function(){ clearInterval( timeID); }//鼠标移动至div上时清除循环
	    d_image.onmouseout = function(){ timeID = setInterval('SwitchEx('+ctrlObjName+','+count+')', Speed ); }//鼠标移开后继续循环 
	    d_title.onmouseover = function(){ clearInterval( timeID); }//鼠标移动至div上时清除循环
	    d_title.onmouseout = function(){ timeID = setInterval('SwitchEx('+ctrlObjName+','+count+')', Speed ); }//鼠标移开后继续循环   
        d_content.onmouseover = function(){ clearInterval( timeID); }//鼠标移动至div上时清除循环
	    d_content.onmouseout = function(){ timeID = setInterval('SwitchEx('+ctrlObjName+','+count+')', Speed ); }//鼠标移开后继续循环   
    
    }  
}

