$(document).ready(function(){

   $.isJSON = function (json) {
        json = json.replace(/\\["\\\/bfnrtu]/g, '@');
        json = json.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']');
        json = json.replace(/(?:^|:|,)(?:\s*\[)+/g, '');
        return (/^[\],:{}\s]*$/.test(json));
    };

    $.fn.isJSON = function () {
        var json = this;
        if (jQuery(json).is(":input")) {
            json = jQuery(json).val();
            json = new String(json);
            return jQuery.isJSON(json);
        } else {
            throw new SyntaxError("$(object).isJSON only accepts fields!");
        }
    };
    String.prototype.isJSON = function () {
        var y = this;
        return jQuery.isJSON(y);
	    };
	
	setInterval( alternarLogos , 3000);
	
	function alternarLogos(){
		var active = 1;
		var noActive = 2;		
		if( $('#logo #logo1').is(':visible') ) {
			active = 1;
			inactive = 2;
		} else {
			active = 2;
			inactive = 1;
		}
		
		$('#logo #logo'+inactive).show();
		
		$('#logo #logo'+active).stop(true,true).fadeOut(1000,function(){
			$('#logo #logo'+inactive).css('z-index',3);
			$('#logo #logo'+active).css('z-index',1);			
		});
	}

	$('#menu #opciones .opcion').mouseenter(function(){
		if ($(this).attr('id')!='equipamiento') {
			$('#menu #equipamientos').stop(true,true).fadeOut();
		}else{
			$('#menu #equipamientos').stop(true,true).fadeIn();
		}
	});
	
	$('#menu #equipamientos').mouseleave(function(){
		$(this).fadeOut();
	});
	
	/*var columnSize = new Array();
	/*columnSize[1] = 135;
	columnSize[2] = 170;
	columnSize[3] = 170;	
	columnSize[4] = 115;*/
	/*
	columnSize[1] = 140;
	columnSize[2] = 175;
	columnSize[3] = 175;	
	columnSize[4] = 120;
	
	var columnCurrent = 0;
	$('#menu #equipamientos .equipamiento').each(function(){
		columnCurrent++;
		$(this).wrap("<span class='equipamientoWrapper' style='width:"+columnSize[columnCurrent]+"px'></span>");
		if(columnCurrent==4){
			columnCurrent=0;
		}
	
	});*/
	
});
