﻿if (!Array.indexOf) {
    Array.prototype.indexOf = function(obj) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] == obj) {
                return i;
            }
        }
        return -1;
    }
}

function PreloadImages(imgArray) {
    if (document.images)
    {
        preload_image_object = new Image();
        var i = 0;
        for(i=0; i<window[imgArray].length; i++)
            preload_image_object.src = window[imgArray][i];
    }
}

function RotateImage(imageId, id) 
{
    $("#" + imageId).fadeTo(1300, 0.15, function() {

        if (window['imgIndex_' + id] == window['images_' + id].length)
            window['imgIndex_' + id] = 0;
        $(this).attr("src", window['images_' + id][window['imgIndex_' + id]]);
        if (window['imgWidth_' + id] != null)
            $(this).attr("width", window['imgWidth_' + id][window['imgIndex_' + id]]);
        if (window['imgHeight_' + id] != null)
            $(this).attr("height", window['imgHeight_' + id][window['imgIndex_' + id]]);
        if (window['imgAlt_' + id] != null) {
            $(this).attr("alt", window['imgAlt_' + id][window['imgIndex_' + id]]);
            $(this).attr("title", window['imgAlt_' + id][window['imgIndex_' + id]]);
        }
        if (window['imgLinks_' + id] != null && window['imgLinks_' + id][window['imgIndex_' + id]] != '#') {
            if (!$(this).parent().is('a')) {
                $(this).wrap('<a />');
            }
            $(this).parent().attr("href", window['imgLinks_' + id][window['imgIndex_' + id]]);

            if (window['imgLinkTargets_' + id] != null)
                $(this).parent().attr("target", window['imgLinkTargets_' + id][window['imgIndex_' + id]]);
        }
        else if($(this).parent().is('a')) {
            $(this).unwrap();
        }
        window['imgIndex_' + id]++;

        $(this).fadeTo(1300, 1);
    });
}

function PopUpWindow(obj) {
    window.open($(obj).attr('href'), 'popwindow', 'status=0,toolbar=0,menubar=0,width=750,resizable=1,scrollbars=1');
    return false;
}
