$(document).ready(function(){

	$('#navigationMenu li .normalMenu').each(function(){

		$(this).before($(this).clone().removeClass().addClass('hoverMenu'));

	});
	
	$('#navigationMenu li').hover(function(){
	
		$(this).find('.hoverMenu').stop().animate({marginTop:'0px'},200);

	},
	
	function(){
	
		$(this).find('.hoverMenu').stop().animate({marginTop:'-40px'},200);

	});

});

/* Nota: Basta 1 selecção numa ou outra checkbox list para o pedido ser valido.
         Vamos então verificar logo as 2.*/
function cb_verify(source, args) {
    var parentID = source.id.substring(0, source.id.lastIndexOf("_"));
    var produtosCKListID = parentID + "_CKProdutos";
    var condComerciaisCKListID = parentID + "_CKCondComerciais";

    var val = document.getElementById(produtosCKListID);
    var col = val.getElementsByTagName("*");
    if ( col != null ) {
        for (i = 0; i < col.length; i++) {
            if (col.item(i).tagName == "INPUT") {
                if (col.item(i).checked) {
                    args.IsValid = true;
                    return;
                }
            }
        }
    }

    val = document.getElementById(condComerciaisCKListID);
    col = val.getElementsByTagName("*");
    if (col != null) {
        for (i = 0; i < col.length; i++) {
            if (col.item(i).tagName == "INPUT") {
                if (col.item(i).checked) {
                    args.IsValid = true;
                    return;
                }
            }
        }
    }

    args.IsValid = false;
  }

  //Begin OCC code for Apoio Omnilog department
  (function () {
    var occ = document.createElement('script'); occ.type = 'text/javascript'; occ.async = true;
    occ.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'www.onlinechatcenters.com/code-18861-33512-1.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(occ, s);
  })();
  //End OCC code

  (function ($) {
    $.fn.extend({
      popUp: function (settings) {
        var defaults = {
          href: null
        };

        var settings = $.extend(defaults, settings);
        return this.each(function () {

          var s = settings;
          var load = 'popup/PopupNatal.htm';

          $('body').append('<div id="overlay" />');
          $('#overlay').fadeIn(300, function () {
            $('body').append('<div id="popupModalOuter"><div id="popupModal"></div></div>');
            var outer = $('#popupModalOuter');
            var modal = $('#popupModal');
            var defWidth = outer.outerWidth();
            var defHeight = outer.outerHeight();
            modal.load(load + ' #popup', function () {

              var alertBoxContent = $('#popup');

              $('.imgNatal').attr("src", s.href);

              var alertWidth = alertBoxContent.outerWidth();
              var alertHeight = alertBoxContent.outerHeight();

              var widthCombine = -((defWidth + alertWidth) / 2);
              var heightCombine = -((defHeight + alertHeight) / 2);

              modal.animate({ width: alertWidth, height: alertHeight }, 200);
              outer.animate({ marginLeft: widthCombine, marginTop: heightCombine }, 200, function () {
                alertBoxContent.fadeIn(200, function () {
                  var cancelBtn = $('#fechar');
                  if (cancelBtn.length > 0) {
                    cancelBtn.click(function (e) {
                      e.preventDefault();
                      $('#overlay, #popupModalOuter').fadeOut(400, function () {
                        $(this).remove();
                      });
                    });
                  }
                });
              });
            });
          });
        });
      }
    });
  })(jQuery);
