/*
 * Javascript general
 * [DBH]
 *
 * Date: 2011-11-10 11:54:16
 * Revision: 0
 */
$(function() {
            $("#location").each(function(){
            var h = 516;
            var w = 516;
            $(this).fancybox({
				'width'			: h,
				'height'		: w,
				'autoScale'		: false,
				'transitionIn'		: 'dinamic',
				'transitionOut'		: 'dinamic',
				'type'			: 'iframe'
			});
            });

            if($('#form-contacto').length>0){
                var val="";
                $('#enviar').click(function(){
                    var errores1 = [];
                    var er= 0;

                    //campos
                    if(document.contacto.nombre.value == ""){
                        errores1.push(nombre_val);
                    }
                    if(!/\w+@\w+[\.\w\w\w?}]+/.test(document.contacto.email.value)){
                        errores1.push(email_val);
                    }

                    if(errores1.length>0){
                        $('select').css('visibility','hidden');
                        $('#dialog').html(errores1.join('<br/>')).dialog({
                                                modal: true,

                                                close: function(event, ui){
                                                $('select').css('visibility','visible');
                                                },
                            buttons: [{
                                        text: btn_val,
                                        click: function() {$(this).dialog("close");}
                                      }]
                        });
                        return false;

                    } else {
                        $('#form-contacto').submit();
                    }


                });
                
            }
			
			$('.sw-submenu').click(function(){
				$('#submenu').show();return false;
			});
                        $('.sw-submenu').mouseout(function(){
                            $('#submenu').stop().fadeOut(250);
                        }).mouseenter(function(){
                                if($('#submenu').is(':visible')) {
                                  $('#submenu').stop().show();
                                }
                        });

                        var selectOpened = false;
                        $('#area-slc').click(function(e){
                            selectOpened = !selectOpened;
                            e.stopPropagation();
                        });
                        $('#submenu').live("mouseenter", function() {
                            var $this = $(this);
                            $this.stop().show();
                        }).live("mouseleave", function(e) {
                            if (!selectOpened) {
                                var $this = $(this);
                                $this.stop().fadeOut(250);   
                            }
                        });                        

});

