﻿/** @file basics.js
 *  Basic functions
 *  @author Julien Zorko
 *  @date 29.09.2003
 *  @version $Id: basics.js 2 2003-12-02 08:25:15Z julien $
 */

function test(){
    var body = document.getElementsByTagName('body')[0];
    var html = document.getElementsByTagName('html')[0];
    alert('Node '+body.nodeName+' scroll x='+body.scrollLeft+' scroll y='+body.scrollTop+'\n'
         +'Node '+html.nodeName+' scroll x='+html.scrollLeft+' scroll y='+html.scrollTop);
}

/// read a cookie
function jzjs_getcookie( name ){
    var my_cookie = document.cookie ;
    deb = my_cookie.indexOf( name );            // recherche rubrique
    if (deb == -1) return " ";                  // le cookie n'existe pas
    pv = my_cookie.indexOf("; ", deb)           // rech. Fin rubrique
    if (pv == -1) pv = my_cookie.length;        // c'est la dernière valeur.
    return my_cookie.substring( deb + name.length + 1, pv )
}

/// scroll window to saved scroll position.
function jzjs_setscroll(){
    var x = jzjs_getcookie('scroll');
    var y = x%10000;
    x = (x-y)/10000;
    var html = document.getElementsByTagName('HTML')[0];
    html.scrollLeft = x;
    html.scrollTop  = y;
}

/// set a cookie.
function jzjs_setcookie( name, value, expires ){
    document.cookie = name + " = " + escape(value) + " ; expires= " + expires.toGMTString() ;
}

/// save a value in a cookie with a default time out of 1 month.
function jzjs_save( name, value) {
    var date = new Date() ;
    date.setTime( date.getTime() + 1000*60*60*24*31 ) ;
    jzjs_setcookie( name, value, date ) ;
}

/// save scroll postion.
function jzjs_savescroll(){
    var html = document.getElementsByTagName('html')[0];
    var xy = html.scrollLeft * 10000 + html.scrollTop;
    jzjs_save('scroll',xy);
}

/// behaviour when a miniphoto is clicked.
/// @todo replace with jz_click()
function jzjs_img_click(ref){
    document.PHOTO_FORM.photo_selection.value = ref;
    document.PHOTO_FORM.submit();
}

/// behaviour main when selector is clicked.
/// @todo replace with jz_click()
function jzjs_selector_click(ref){
    document.SELECTOR.select_form.value = ref;
    document.SELECTOR.submit();
}

/// behaviour main when selector is clicked.
/// @todo replace with jz_click()
function jzjs_art_click(ref){
    document.ART_FORM.art_selection.value = ref;
    document.ART_FORM.submit();
}

/** set value of the k element in form f and submit form.
 *  k must be a unique hidden input or the value will not be sent.
 */
function jz_click(f,k,v){
    if( v != null )
    {
        document.forms[f].elements[k].value = v;
        document.forms[f].submit();
    }
}

//Hide status bar msg II script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use

function hidestatus(){
    window.status='';
    return true;
}

if (document.layers)
    document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);

document.onmouseover=hidestatus;
document.onmouseout=hidestatus;

