function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr;
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document;
  if(d.images){
    if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
    for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){
      d.MM_p[j]=new Image;
      d.MM_p[j++].src=a[i];
    }
  }
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
document.observe('dom:loaded' , function() {
  //MM_preloadImages('categ_menu_over.png');
  //alert('fasdf')
});

// functie pentru vizualizarea imaginilor intr-o fereastra popup
function newWindow(img) {
  winWidth = 700
  winHeight = 500
  leftPos = screen.width/2 - winWidth/2
  topPos = (screen.height/2 - winHeight/2) - 30
  win = window.open(img, "wind", "width="+ winWidth +",height="+ winHeight +",scrollbars=yes,resizable=no,left="+ leftPos +",top="+ topPos +"")
  win.focus()
}

/*1=long, 0=short*/
function hideTab(tab, actiune)
{
  elem1 = document.getElementById('tabShort'+tab);
  elem2 = document.getElementById('tabLong'+tab);
  if(actiune==0){
    elem1.style.display = 'block';
    elem2.style.display = 'none';
  }else{
    elem1.style.display = 'none';
    elem2.style.display = 'block';
  }
}
//Afisare Submeniuri
/*1=Over, 0=Out*/
function showSubmenu(tab, actiune)
{
  $$('div.subMenuItem').each(function(s){s.style.display='none';});
  if(actiune) $('subMenuItem'+tab).style.display='block';
}
/*****  VALIDARE forma review *****
* frm = forma vare se verifica
* mesaje = string sub forma de url (&camp1=valoare1&camp2=caloare2&...) cu mesajele de eroare
*/
function validReviewForm(frm, mesaje)
{
  eml = /^\w+([\.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/

  var params = mesaje.toQueryParams();

  if (frm.username.value == ""){
    alert(params.username);
    frm.username.focus()
    return false
  }
  if (!eml.test(frm.email.value)){
    alert(params.email);
    frm.email.focus()
    return false;
  }
  if (frm.location.value == ""){
    alert(params.location);
    frm.location.focus()
    return false
  }
  if (frm.message.value == ""){
    alert(params.message);
    frm.message.focus()
    return false
  }
  alert(params.succes);
  return true;
}
/*###############  VALIDARE forma newsletter ###################
* frm = forma vare se verifica
* mesaje = string sub forma de url (&camp1=valoare1&camp2=caloare2&...) cu mesajele de eroare
*/
function validNewsletterForm(frm, mesaje)
{
  eml = /^\w+([\.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/
  
  var params = mesaje.toQueryParams();
  
  if (!eml.test(frm.email.value)){
    alert(params.email);
    frm.email.focus()
    return false;
  }
  return true;
}
//#####################################
Event.observe(window, 'load', function() {
  $$('img.parentNode').each(function(s) {
    Event.observe(s, 'click', handler.bindAsEventListener(this));
  });
});

function handler(e) {
  var node = Event.element(e);
  var a=node.id.split('_');
  a[0]='children';
  var childDiv=$(a.join('_'));
  childDiv.toggle();

  if (node.tagName=='IMG') {
    var v=Element.visible(childDiv);
    if (node.src.match(/node(p|m)(last)?\.gif$/))
    node.src=node.src.replace(/nodep|nodem/,'node'+(v ? 'm' : 'p'));
  }
}