$(document).ready( function() {
  $("img.parentNode").click( function() {
    var a = this.id.split('_');
    a[0] = 'children';
    var childDiv = a.join('_');
    $("#" + childDiv).toggle();
    if(this.tagName == 'IMG') {
      var v = $("#" + childDiv + ":visible");
      if(this.src.match(/node(p|m)(last)?\.gif$/)) {
        this.src = this.src.replace(/nodep|nodem/, 'node' + (v.length == 0 ? 'p' : 'm'));
      }
    }
  });

  /* Fix for png's in Internet Explorer */
  $("#main_menu a, #icon_menu a img, #change_language a img").pngfix();
  $(".categMenuItem, .categMenuItemHover").pngfix();
});
// 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()	
}
function open_window(img,w,h) {
	winWidth = w
	winHeight = h
	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()
}
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
function validComentariiForm(){

  eml    = /^\w+([\.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/
  if($F('titlucomment') == '') {
    alert('Va rugam introduceti titlul comentariului!');
    $('titlucomment').focus()
    return false;
  }
  if($F('nume') == '') {
    alert('Va rugam introduceti numele dvs.!');
    $('nume').focus()
    return false;
  }   
  if (!eml.test($F('email'))) {
    alert('Adresa de email incorecta!');
    $('email').focus()
    return false
  } 
  
  if($F('mesaj') == '') {
    alert('Va rugam introduceti continutul comentariului!');
    $('mesaj').focus()
    return false;
  }   
  
  return true;
}

$(function() {
	$('#gallery a').lightBox({fixedNavigation:true});
});
