/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Description: Image manipulation library
Note: In order to use this library use <script> tag as shown bellow:

<head>
<title>...</title>
....
<script language="JavaScript" src="image-manip.js"></script>
....
</head>
*/


var imgs; //array of image objects for the current page 
var gbgn; //first image number for the current page
var gend; //last image number for the current page
var supre = 0; //sufix - 1, prefix - 0
var image_path;
var archive_path;
var thumb;
var src_file_name;

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Description: function preloads page images and sets global variables for page.
Usage: <body onLoad="onLoad(...);">.
Arguments:
    img_dir - a name of a directory which contains images for current page;
    img_prefix - an image name prefix, e.g. in img1.jpg prefix is "img";
    bgn - first image number;
    end - last image number (must be greater than bgn number);
Example: <body onLoad="onLoad('images', 'img', 10, 21);"> 
*/

function onLoad(img_dir, img_prefix, bgn, end){
    gbgn = bgn;
    gend = end;
        
    var size = end - bgn + 1;
        
    imgs = new Array(size);
    
    for (var i = 0; i < size; i++){
        imgs[i] = new Image();
        imgs[i].src = img_dir + '/' + img_prefix + eval(bgn + i) + '.jpg';
    }

    return true;
}
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Description: function preloads page images and sets global variables for page.
Usage: <body onLoad="onLoad(...);">.
*/

function onLoad(){
    var size = 21;
    imgs = new Array(size);
    for (var i = 0; i < size; i++){
        imgs[i] = new Image();
    }
    imgs[0].src = 'images/ls.gif';
    imgs[1].src = 'images/header.gif';
    imgs[2].src = 'images/menu-header.gif';
    
    imgs[3].src = 'images/forum-o.gif';
    imgs[4].src = 'images/forum.gif';
    imgs[5].src = 'images/community-o.gif';
    imgs[6].src = 'images/community.gif';
    imgs[7].src = 'images/events-o.gif';
    imgs[8].src = 'images/events.gif';
    imgs[9].src = 'images/guestbook-o.gif';
    imgs[10].src = 'images/guestbook.gif';
    imgs[11].src = 'images/home-o.gif';
    imgs[12].src = 'images/home.gif';
    imgs[13].src = 'images/karaoke-o.gif';
    imgs[14].src = 'images/karaoke.gif';
    imgs[15].src = 'images/links-o.gif';
    imgs[16].src = 'images/links.gif';
    imgs[17].src = 'images/music-o.gif';
    imgs[18].src = 'images/music.gif';
    imgs[19].src = 'images/photos-o.gif';
    imgs[20].src = 'images/photos.gif';

    return true;
}
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Description: function displays a new image based on number passed through 
    attribute.
Usage: .
Arguments:
    img_num - a number of image to be displayed;
    disp_name - a name of image to be replaced with a new one;
Example:  <a name="4" href="#" onMouseOver="onFocus(this.name, 'disp')" 
                onFocus="onFocus(this.name, 'disp')">image 1</a>
      ...
     <img name="disp" src="images/an3.jpg">
    Broweser will display an4.jpg in the spot occupied by an3.jpg. 
*/

function onFocus(img_num, disp_name){
    if (document.images) {
        document[disp_name].src = imgs[img_num - gbgn].src;
    }
}
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*/

function onFocus(img_name){
    if (document.images) {
        document[img_name + '_im'].src = 'images/' + img_name + '-o.gif';
    }
}
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*/
function onBlur(img_name){
    if (document.images) {
        document[img_name + '_im'].src = 'images/' + img_name + '.gif';
    }
}
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*/
function add_active_thumb(img_name){
    if (document.images) {
        document.writeln('<a href="javascript:popup(\'' + image_path + '/'+ img_name + '\')"><img name="' + img_name + '" src="' + image_path + '/' + ((supre == 0) ? thumb : "") + img_name + ((supre == 1) ? thumb : "") +'.jpg" border="0"></a>');
    } else {
        document.writeln('N/A');
    }
}

function add_archive_photo_thumb(img_name){
    if (document.images) {
        document.writeln('<a href="javascript:popup(\'' + '/'+ img_name + '\')"><img name="' + img_name + '" src="' + '/' + ((supre == 0) ? thumb : "") + img_name + ((supre == 1) ? thumb : "") +'.jpg" border="0"></a>');
    } else {
        document.writeln('N/A');
    }
}

function add_active_archive_thumb(img_name){
    if (document.images) {
        document.writeln('<a href="\'' + archive_path + '/'+ img_name +'/'+ src_file_name + '\'"><img name="' + img_name + '" src="' + image_path + '/' + ((supre == 0) ? thumb : "") + img_name + ((supre == 1) ? thumb : "") +'.jpg" border="0"></a>');
    } else {
        document.writeln('N/A');
    }
}


function popup(img_name){
    if (document.images) {
        parent.document['main_img'].src =  img_name + ".jpg";
    }
}

function banner(param){
    if (param) {
        parent.content.rows="157, *, 70";
    } else {
        parent.content.rows="157, *, 0";
    }
}

/*function popup(img_name){
    if (document.images) {
        var w = window.open(img_name + ".jpg","HI","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=no, width=600,height=500")
        w.focus();
    }
}
*/

