function showpic_generic(l,picid, w, h, path) {
  bigw = new Number(w) + 30;
  bigh = new Number(h) + 40;
  s = 'toolbar=no,menubar=no,location=no,personalbar=no,scrollbars=no,directories=no,status=no,resizable=no,' + 'width=' + bigw + ',height=' + bigh;
  NewWin=window.open('/'+l+'/'+path+'/'+picid,'',s);
  NewWin.focus();
  if(NewWin == 'undefined') {
    return true
  }
  return false;
}

function showpic(l,picid, w, h) {
    return showpic_generic(l,picid, w, h, "pic");
}

function showpicref(l,picid, w, h) {
    return showpic_generic(l,picid, w, h, "picref");
}

function adv_search_toggle(idform) { res = toggle_visible("adv_search_box"); frm = document.getElementById(idform); if(res)  { frm.action = 'advanced'; } else { frm.action = 'normal'; } } function toggle_visible(idel) { el = document.getElementById(idel); dpy = el.style.display; if(dpy != "block") { el.style.display = "block"; return true; } else { el.style.display = "none"; return false; } }

var ua = navigator.userAgent.toLowerCase();
var isOpera = ua.indexOf("opera")>-1;
var isIE = ua.indexOf("msie")>-1 && !isOpera;

function slideshow(lang) {
  popupHandle = __popupCenterWindow(900,600,"IMI - International","/" + lang + "/slideshow.html",null,null,false)
  if(popupHandle)
    return false;
  else
    return true;
}

var popupHandle = null;
function __popupCenterWindow(w,h,title,src,content,style,resizable) {
  var win = window.top;
  var xOffset = 0;
  var yOffset = 0;
  //alert(w+" "+screen.availWidth);
  if (w>screen.availWidth || h>screen.availHeight) {
    w = screen.availWidth-20;
    h = screen.availHeight-60;
    resizable = true;
  } else if (isIE) {
    xOffset = win.screenLeft + (win.document.documentElement.offsetWidth-w-10)/2;
    yOffset = win.screenTop + (win.document.documentElement.offsetHeight-h-104)/2;
    xOffset = Math.min(xOffset, screen.availWidth-w-10);
    yOffset = Math.min(yOffset, screen.availHeight-h-30);
  } else {
    xOffset = win.screenX + (win.outerWidth-w-6)/2;
    yOffset = win.screenY + (win.outerHeight-h-44)/2;
    xOffset = Math.min(xOffset, screen.availWidth-w-6);
    yOffset = Math.min(yOffset, screen.availHeight-h-44);
  }
  xOffset = Number( Math.max(xOffset, 0) );
  yOffset = Number( Math.max(yOffset, 0) );

  if (!isOpera && popup && !popup.closed)
    popup.close();

  var attr = 'toolbar=no,menubar=no,location=no,personalbar=no,directories=no';
  if (resizable) attr += ',status=yes,resizable=yes,scrollbars=yes';
  else attr += ',status=no,resizable=no,scrollbars=no';
  attr += ',width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',left='+xOffset+',top='+yOffset;

  if (src) {
    var popup = win.open(src,'popup',attr);
    } else if (content) {
    var s = '';
    s += '<style type="text/css">'
    s += 'body, tbody {font-size:11px;font-family:Verdana,Geneva,Arial,Helvetica,sans-serif}';
    s += 'body {margin:0px;padding:0px}';
    if (!resizable) s += 'body {overflow:hidden}';
    if (style) s += style;
    s += '</style>';

    var c = '';
    c += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
    c += '<html xmlns="http://www.w3.org/1999/xhtml"><head>';
    c += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
    c += '<meta http-equiv="imagetoolbar" content="no" />';
    c += '<title>'+title+'</title>'+s+'</head>';
    c += '<body onkeypress="if (event &amp;&amp; event.keyCode==27) self.close()">'+content+'</body>';
    c += '</html>';

    var popup = win.open('','popup',attr);
    popup.document.open();
    popup.document.write(c);
    popup.document.close();
    }
  if (popup && popup.focus) {
    popup.focus();
    popupHandle = popup;
    return true;
  }
  return false;

}

voted = function() {
    rsp = Json.evaluate(this.response.text);
    if(rsp.message) {
        _poll_msg = document.getElementById('poll_msg');
        $(_poll_msg).setHTML(rsp.message);
    }
    if(!rsp.results)
        return;
    for(i in rsp.results) {
        _id = "poll_option_" + i;
        _value = rsp.results[i];
        _a = $E('a', "poll_option_" + i);
        _text = _a.innerHTML;
        $E('span', _id).remove();
        _new_a = new Element("span");
        _new_a.setText(_text + " " + _value);
        _a.replaceWith(_new_a)

        _div = $E('.score', _id);
        _div.setStyle('width', _value+"%")

    }
}

function vote(poll,answer) {
    var voteXHR = new Ajax(baseurl + "vote/" + answer, {method: 'get', autoCancel:true, onSuccess:voted});
    voteXHR.send(baseurl + "vote/" + answer);
    sucess = true;
    if(sucess) {
        Cookie.set('poll_'+poll, 1, {duration:3650,path:"/"});
        return false;
    }
}

function fold_category(idcategory) {
    is_selected = $('p_gr_'+idcategory).hasClass('selected');
    if(is_selected) {
        $('p_gr_'+idcategory).removeClass("selected");
        $('p_pr_'+idcategory).setStyle('display', 'none');
        return false;
    }

//     group = document.getElementById(''+idcategory
    nv = document.getElementById('nav_catalog');
//     alert(nv);
//     grps = $('nv');
    grps = $$('#nav_catalog li.group');

//     alert(grps.length);
    l = grps.length;
    for(i=0;i<l;i++) {
        grps[i].removeClass("selected");
        pr_list = grps[i].getElement('ul');
    }

    products = $$('#nav_catalog li.nav_sub_proucts');
    l = products.length;
    expand_pr_list_id = "p_pr_" + idcategory;
    for(i=0;i<l;i++) {
        products_list_id = products[i].getProperty('id');
        if(products_list_id == expand_pr_list_id) {
            products[i].setStyle('display', 'block');
//                mySlider = new Fx.Slide(products[i], {duration: 500});
//                mySlider.slideIn("vertical");
        } else {
            products[i].setStyle('display', 'none');
        }
    }

    $('p_gr_' + idcategory).addClass("selected");
    return false;
}
function set_hover(el_id) { $(el_id).addClass("hover"); }
function remove_hover(el_id) { $(el_id).removeClass("hover"); }
function toggle_hidden_show_css(el_id) {
    if($(el_id).hasClass("hidden")) {
        $(el_id).removeClass("hidden");
        return true;
    } else {
        $(el_id).addClass("hidden");
        return false;
    }
}
function set_content(el,val,text_true,text_false) {
    if(val) { $(el).setHTML(text_false); } else { $(el).setHTML(text_true); }
//     'show','hidde'
}

function faq_collapse() {
    all_q = $$('#faq_questions dd');
    for(i=0;i<all_q.length;i++) {
        all_q[i].setStyle('display', 'none');
    }
}

function faq_expand(idquestion) {
    all_q = $$('#faq_questions dd');
    for(i=0;i<all_q.length;i++) {
        _id = all_q[i].id;
        if(_id == 'qa'+idquestion) {
            if(all_q[i].getStyle('display') == 'block') {
                all_q[i].setStyle('display', 'none');
            } else {
                all_q[i].setStyle('display', 'block');
            }
        } else
            all_q[i].setStyle('display', 'none');
    }
}























