
<!--
// The order of display : True - Random / False - Sequential
var randomOrder = false;
// Default Width of the image (if not set individually)
var defaultWidth = 750;
// Default Height of the image (if not set individually)
var defaultHeight = 203;
// An array of the images to be rotated (Image Path[, Width of the Image[, Height of the Image]])
// If the width and height is not specified, the Default value specified above will be used
var arImg = new Array();
arImg[0] = ['http://avisdirectory.com/wpdemo284/wp-content/themes/Benja/images/random_head1.jpg'];
arImg[1] = ['http://avisdirectory.com/wpdemo284/wp-content/themes/Benja/images/random_head2.jpg'];
arImg[2] = ['http://avisdirectory.com/wpdemo284/wp-content/themes/Benja/images/random_head3.jpg'];


function rotateImage(){
    if(randomOrder){
        index = Math.floor(Math.random() * arImg.length);
    }else{
        var index = getCookie('rotate_image');
        index = index ? index : 0;
        index = ++index % arImg.length;
    }
    (img = document.getElementById('image_id')).src = arImg[index][0];
    img.width = (arImg[index][1]) ? arImg[index][1] : defaultWidth;
    img.height = (arImg[index][2]) ? arImg[index][2] : defaultHeight;
    setCookie('rotate_image', index);
}
/*
Functions for storing and retrieving cookies from my previous example
Check http://www.weberdev.com/get_example-4570.html
*/

function getCookie(name) {
    var sPos = document.cookie.indexOf(name + '=');
    var len = sPos + name.length + 1;
    if((!sPos) && (name != document.cookie.substring(0, name.length))){
        return null;
    }
    if(sPos == -1){
        return null;
    }
    var ePos = document.cookie.indexOf(';', len);
    if(ePos == -1) ePos = document.cookie.length;
    return unescape(document.cookie.substring(len, ePos));
}

function setCookie(name, value, expires, path, domain, secure){
    var today = new Date();
    if(expires){
        expires = expires * 1000 * 3600 * 24;
    }
    document.cookie = name+'='+escape(value) +
        ((expires) ? ';expires=' + new Date(today.getTime() + expires).toGMTString() : '') +
        ((path) ? ';path=' + path : '') +
        ((domain) ? ';domain=' + domain : '') +
        ((secure) ? ';secure' : '');
}
//-->
 
