function downloadSubmit(form)
{
  $.fancybox({
    href:'/download.php?lang=' + lang,
    autoDimensions:false,
    width:430,
    height:160,
    scrolling:'no',
    ajax:{type:'POST',data:$(form).serialize()}
  });
}
function downloadValidatorSetup()
{
  $('form#download').validate(
  {
    submitHandler: downloadSubmit,
    rules: {
      title:
      {
        required: true
      },
      name: {
        required: true,
        minlength:3
      },
      place: {
        required: true,
        minlength:3
      },
      address: {
        required: true,
        minlength:3
      },
      country: {
        required: true
      },
      email: {
        required: true,
        email:true
      },
      phone: {
        required: true,
        minlength:7,
        digits:true
      },
      category: {
        required: true
      },
      privacy: {
        required: true
      }
    }
  }
  );
}

function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
  if (parseInt(navigator.appVersion) >= 4) {
    obj_window.window.focus();
  }
}
function openCompany() {
  // newWindow("/company.htm", 'popup', 315, 290,0, 0, 0, 0, 0, 0, 0);
  $.fancybox({
    href:'/company.htm'
  });

};
function openMap() {
  //newWindow("http://maps.google.it/maps?f=q&source=s_q&hl=it&geocode=&q=Via+Creare,+17,+37050+Villafontana,+Verona,+Veneto&sll=45.297491,11.076774&sspn=0.011517,0.027874&g=Via+Creare,+15,+37050+Villafontana,+Verona,+Veneto&ie=UTF8&hq=&hnear=Via+Creare,+17,+37050+Oppeano+Verona,+Veneto&ll=45.296958,11.073028&spn=0.002879,0.006968&t=h&z=18", 'popup', 960, 600, 1, 1, 0, 0, 0, 1, 0);
  $.fancybox({
    type:'iframe',
    href:'http://maps.google.it/maps?f=q&source=s_q&hl=it&geocode=&q=Via+Creare,+17,+37050+Villafontana,+Verona,+Veneto&sll=45.297491,11.076774&sspn=0.011517,0.027874&g=Via+Creare,+15,+37050+Villafontana,+Verona,+Veneto&ie=UTF8&hq=&hnear=Via+Creare,+17,+37050+Oppeano+Verona,+Veneto&ll=45.296958,11.073028&spn=0.002879,0.006968&t=h&z=18',
    autoDimensions: false,
    width: 960,
    height: 650
  });
};
function showpic(pic,h,w) {
  //newWindow("/showpic.htm?pic="+pic, 'popup', h, w, 0, 0, 0, 0, 0,0, 0);
  $.fancybox({
    href:pic
  });
};

function openDownload()
{
  $.fancybox({
    href:'/download.php?lang=' + lang,
    autoDimensions:true,
    width:430,
    height:600,
    scrolling:'no',
    onComplete: downloadValidatorSetup
  });
}

function openGallery()
{
  $.fancybox({
    href:'/flash/slideshow.swf?dataFile=/xml/gallery.xml&showVersionInfo=false&showLogo=false&faux=.swf',
    autoDimensions:false,
    width:700,
    height:550
  });
}
/*
$(document).ready(function() {
  $("a.fancybox").fancybox();

  $("a.gallery").fancybox({
    autoDimensions:false,
    width:700,
    height:550
  });
  $("a.download").fancybox({
    autoDimensions:false,
    width:430,
    height:510,
    scrolling:'no',
    onComplete: downloadValidatorSetup
  });
});
 */
