Saturday, November 13, 2010

Image Slider

<div id="myIMG" style="display: none;"></div>

<script>
$(function(){

    total_img = 3;

    img = Array();
    img[0] = 'http://ip.skyzone.mn/mb_images/header_computer.jpg';
        img[1] = 'http://ip.skyzone.mn/mb_images/header_mobile.jpg';
        img[2] = 'http://ip.skyzone.mn/mb_images/header_voip.jpg';

    lnk = Array();
    lnk[0] = 'link1';
        lnk[1] = 'link2';
        lnk[2] = 'link3';

    showIMG(0,'#myIMG');

});

    function showIMG(idx, target_div){
        if(idx == total_img){
            idx = 0;
        }
        $(target_div).css('display','none');
        $(target_div).html('<a href="'+lnk[idx]+'" target="_blank"><img src="'+img[idx]+'" border="0" /></a>');
        $(target_div).fadeIn(3000);
        idx++;
        //alert(idx);
        setTimeout("showIMG("+idx+",'"+target_div+"');",5000);
    }
</script>

No comments:

Post a Comment