// JavaScript Document
// The order of display : True - Random / False - Sequential 
var randomOrder = true; 
// Default Width of the image (if not set individually) 
var defaultWidth = 820; 
// Default Height of the image (if not set individually) 
var defaultHeight = 464; 
// 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] = ['images_bk/fotolia_26952024.jpg', 820, 464];
arImg[1] = ['images_bk/fotolia_11526982.jpg', 820, 464];
arImg[2] = ['images_bk/fotolia_16337129.jpg', 820, 464];
arImg[3] = ['images_bk/fotolia_19792734.jpg', 820, 464];
arImg[4] = ['images_bk/indImag_00000005.jpg', 820, 464];
arImg[5] = ['images_bk/indImag_00000006.jpg', 820, 464];
arImg[6] = ['images_bk/indImag_00000007.jpg', 820, 464];
arImg[7] = ['images_bk/indImag_00000008.jpg', 820, 464];
/*arImg[8] = ['images_bk/fotolia_19792734.jpg', 464, 341];
arImg[9] = ['images_bk/fotolia_19007223.jpg', 386, 512];
arImg[10] = ['images_bk/fotolia_19466131.jpg', 340, 512];
arImg[11] = ['images_bk/fotolia_25932384.jpg', 512, 341];
arImg[12] = ['images_bk/fotolia_26952024.jpg', 512, 464];
*/
function newPics(){ 
    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('switchimg')).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(nmlHome, swap, expires, path, domain, secure){ 
function setCookie(name, value, expires, domain){ 
    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' : ''); 
} 

