function G(id){   
    return document.getElementById(id);   
}   
  
var focus_photo_pic = G("focus_photo_pic");   
var focus_photo_title = G("focus_photo_title");   
var focus_photo_link = G("focus_photo_link");   
var focus_title_link = G("focus_title_link");   
var focus_photo_page = G("focus_photo_page");   
var theTimer = null;   
var curNum = 0;   
var isIE = navigator.userAgent.toUpperCase().indexOf("MSIE") > 0;   
var photoPic = new Array();   
var photoTitle = new Array();   
var photoLink = new Array();   
var opa;   
var opaTimer = null;   
  
photoPic[0]   = "http://www.sinotools.com/css/img1.jpg";   
photoTitle[0] = "";   
photoLink[0]  = "http://www.sinotools.com/";   
  
photoPic[1]   = "http://www.sinotools.com/css/img2.jpg";   
photoTitle[1] = "";   
photoLink[1]  = "http://www.sinotools.com/";   
  
photoPic[2]   = "http://www.sinotools.com/css/img3.jpg";   
photoTitle[2] = "";   
photoLink[2]  = "http://www.sinotools.com/";   
  
photoPic[3]   = "http://www.sinotools.com/css/img4.jpg";   
photoTitle[3] = "";   
photoLink[3]  = "http://www.sinotools.com/";   

photoPic[4]   = "http://www.sinotools.com/css/img5.jpg";   
photoTitle[4] = "";   
photoLink[4]  = "http://www.sinotools.com/";   

photoPic[5]   = "http://www.sinotools.com/css/img6.jpg";   
photoTitle[5] = "";   
photoLink[5]  = "http://www.sinotools.com/";  
  
function start(){   
    preLoadImages();   
    createPage();   
    play();   
}   
  
function preLoadImages(){   
    var images = new Array();    
    for(var i = 0; i < photoPic.length; i++){    
        images[i] = new Image();    
        images[i].src = photoPic[i];   
    }   
}   
  
function createPage(){   
    for(var i = photoPic.length-1; i >= 0 ; i--){   
        var a = document.createElement("A");   
        var txt = document.createTextNode(i+1);    
        var n = i;   
        a.id = "focus_photo_page_" + i;   
        a.href = "javascript:changePic(" + i + ")";   
        a.appendChild(txt);    
        focus_photo_page.appendChild(a);   
    }   
}   
           
function playEffect(){    
    if (isIE){    
        focus_photo_pic.filters[0].apply();    
        focus_photo_pic.filters[0].play();   
    } else {   
        opa = 0.3;   
        focus_photo_pic.style.opacity = opa;   
        clearInterval(opaTimer);   
        opaTimer = setInterval("changeOpacity()",60);   
    }   
}   
  
function changeOpacity(){   
    if(opa < 1){   
        opa += 0.1;   
    }   
    focus_photo_pic.style.opacity = opa;   
}   
  
function changePic(n){   
    clearTimeout(theTimer);   
    curNum = n - 1;   
    nextPic();   
}   
  
function nextPic(){    
    if(curNum < photoPic.length - 1){   
        curNum++;   
    } else {   
        curNum = 0;    
    }   
    playEffect();   
    play(curNum);   
}    
  
function play(n){    
    if(!n) n = 0;   
    focus_photo_pic.src = photoPic[n];   
    focus_photo_pic.alt = photoTitle[n];   
    focus_photo_link.href = photoLink[n];   
    focus_title_link.href = photoLink[n];   
    focus_title_link.innerHTML = photoTitle[n];   
    for(var i=0; i<photoPic.length; i++){   
        G("focus_photo_page_" + i).className = "";   
    }   
    G("focus_photo_page_" + n).className = "on";   
    theTimer = setTimeout("nextPic()",5000);   
}   
  
start();   

