var chosen_pic = 0;
var border_weight = 3;

function popUp(picture, title) {
    if (chosen_pic) picture = chosen_pic;
    uusaken=window.open("http://www.travermotox.ee/show_full_pic.php?pic="+picture+"&title="+title,"trauto","scrollbars=no, titlebar=no, resizable=yes");
    uusaken.document.close();
}

function JsInitStickyObject(obj,timeout) {
// Initsialiseeri stiki objekt (leier n�iteks) $obj refreshimise reidiga $timeout
// Objekti top v�etakse hetkel kehtivad v��rtused
// Praegult t��tab ainult �les-alla kerimise puhul ja �he objektiga korraga
// (objekti stickymise muutujad kirjutatakse globaalskoopi)
    var reg_exp = '';
    reg_exp = /([0-9]+)(\.[0-9]+)?px/; // stiil annab top-i v��rtuse kujul XXX.XXXpx, v�ibolla murdosata
    
    so_obj = obj; // sticky objekt kui objekt
    so_timeout = timeout; // kui tihti ta end uuendab
    so_top = JsGetObjStyle(so_obj,'top','top');
    so_top = Number(so_top.replace(reg_exp, "$1"));
    so_cur_top = so_top; // praegune koordinaat
    //so_left = JsGetObjStyle(menu,'left','left');
    //so_left = Number(so_left.replace(reg_exp, "$1"));
    
    //if (so_obj.style.getProperty('position') != 'absolute') { // kui tema positsioon ei ole absoluut,
        //so_obj.style.setProperty('position','absolute',''); // ...siis tee ta selleks
    //}

    //so_old_left = so_left;
    
    JsMoveStickyObject();
}

function JsMoveStickyObject() {
// Liigutab stickyt objekti
    var new_top = 0;
    
    // leia praeguse vaate �lemine koordinaat
    if (window.innerHeight) {
        new_top = window.pageYOffset
    } else if (document.documentElement && document.documentElement.scrollTop) {
        new_top = document.documentElement.scrollTop
    } else if (document.body) {
        new_top = document.body.scrollTop
    }
    
    //SetLayerText('abx','new_top: '+new_top+'<br>so_top: '+so_top);
    //new_top = new_top + so_top;
    
    new_top = new_top + so_top; // l�kka �lalt ��rest eemale
    if (new_top == so_cur_top) so_obj.style.top = new_top;
    so_cur_top = new_top;
    
    var temp = setTimeout('JsMoveStickyObject()',so_timeout);
}

function changeBorder(item, op) {
    var picture = document.getElementById('pic_'+item);
    var table = document.getElementById('t_'+item);
    var link = document.getElementById('a_'+item)
    
    if (null == picture || null == table || null == link) return false;
    
    if (border_weight > 5) border_weight = 5;
    if (op == 1) {
        border_pic = '1px solid black';
        padding_t = '5px';
        color_a = '#FFFFFF';
    } else if (op == 2) {
        border_pic = border_weight+'px solid red';
        padding_t = (6-border_weight)+'px';
        color_a = '#D6231C';
    }
    
    
    picture.style['border'] = border_pic;
    table.style['padding'] = padding_t;
    link.style['color'] = color_a;
}

function ChangeItemPicColor(picture, img_src) {
    chosen_pic = picture;
    document['item_large_pic'].src=img_src;
}

var blinkSpeed = 1500;
function blink(objId){
    var objStyle = document.getElementById(objId).style;
    if(objStyle.visibility == "hidden") {
        objStyle.visibility = "visible";
        blinkSpeed=1200;
    } else {
        objStyle.visibility = "hidden";
        blinkSpeed=400;
    }
    window.setTimeout('blink("'+objId+'")', blinkSpeed);
}
