	$(document).ready(function(){

		//ocultamos el contenido
		$('#content').hide();

		//si se pone mouse sobre logo, abre el menu
		$('#logo').mouseover(function() {
			$('#accordion').slideDown();
		});
		$('#logo').click(function() {
			$('#accordion').slideUp(function(){
				$('#content').html('');
				window.location.hash = '#';
			});
		});

		//si la url viene con # cargamos la pagina correspondiente
		var hash = window.location.hash.substr(1);
		if (hash.length>0) {
			var toLoad = '?q='+hash+' #content';
			$('#content').load(toLoad, function() {
				$('#content').show('normal',function(){
					contentTransform();
				});
			});
		}

		//transformamos los links del menu
		$('#accordion li a').filter(function(i){
			var href = $(this).attr('href');
			var classes = this.className.split(' ');
			return (href!='#' && href.length>5 && href.substr(0,4)=='http' && $.inArray('nottransform',classes)==-1);
		}).click(function(){
			linkTransform(this);
			return false;
		});

		//iniciamos el menu
		initMenu();

		//cargamos lightbox en imagenes
		$('.photo a').lightBox();

		//Masked Inputs
		//$(".masked_date").mask("99/99/9999");
		//$(".masked_phone").mask("(999) 999-9999");
		//$.blockUI.defaults.css.cursor = 'default'; 
	});

	function initMenu() {
		$('#accordion ul').hide();
		$('#accordion li a').click(function() {
			/*$('#accordion ul').slideUp();*/
			$(this).next().slideToggle('normal');
		});
	}

	function linkTransform(a) {
		var href = $(a).attr('href');
		var toLoad = href+' #content';
		$('#accordion').slideUp(function(){
			$('#content').hide('fast',function(){
				$('#content').load(toLoad,'',function(){
					$('#content').show('normal',function(){
						$('#load').fadeOut('normal');
						contentTransform();
					});
				});
			});
			$('#accordion ul').hide();
		});
		$('#load').remove();
		$('#wrap').append('<span id="load">LOADING...</span>');
		$('#load').fadeIn('normal');
		//window.location.hash = href.substr(0,href.length-5);
		//window.location.hash = jQuery.url.param('q');
		window.location.hash = (href.split('?q='))[1];
	}

	//transformamos los links del contenido y cambiamos la barra
	function contentTransform() {
		$('#main_col2').jScrollPane({showArrows:true});
		$('#content a').filter(function(i){
			var href = $(this).attr('href');
			var classes = this.className.split(' ');
			return (href!='#' && href.length>5 && href.substr(0,4)=='http' && $.inArray('nottransform',classes)==-1);
		}).click(function(){
                        linkTransform(this);
			return false;
		});
		$('#content .photo a').lightBox();
		$('#content div.bigcycle').cycle({ 
			fx:     'fade', 
			speed:  'slow', 
			timeout: 5000, 
			pager:  '',
			next: '.next'	
		});
	}

function modal_sendtoafriend() {
	$.blockUI({
		message: $('#divSendtoafriend'),
		css: {
			border: '1px solid white',
			top: (jQuery(window).height() - 350) /2 + 'px', 
			left: (jQuery(window).width() - 500) /2 + 'px', 
			padding: '15px', 
			backgroundColor: '#999', 
			width: '500px', 
			height: '350px', 
			'-webkit-border-radius': '10px', 
			'-moz-border-radius': '10px', 
			color: '#fff'
		}
	});
}
function modal_visit() {
	$.blockUI({
		message: $('#divVisit'),
		css: {
			border: '1px solid white',
			left: (jQuery(window).width() - 500) /2 + 'px', 
			padding: '15px', 
			backgroundColor: '#999', 
			width: '500px', 
			height: '230px', 
			'-webkit-border-radius': '10px', 
			'-moz-border-radius': '10px', 
			color: '#fff'
		}
	});
}
function modal_montaje() {
	$.blockUI({
		message: $('#divMontaje'),
		css: {
			border: '1px solid white',
			left: (jQuery(window).width() - 500) /2 + 'px', 
			top: (jQuery(window).height() - 500) /2 + 'px', 
			padding: '15px', 
			backgroundColor: '#999', 
			width: '500px', 
			height: '500px', 
			'-webkit-border-radius': '10px', 
			'-moz-border-radius': '10px', 
			color: '#fff'
		}
	});
}
function modal_video() {
	$.blockUI({
		message: $('#divVideo'),
		css: {
			border: '1px solid white',
			left: (jQuery(window).width() - 600) /2 + 'px', 
			top: (jQuery(window).height() - 500) /2 + 'px', 
			padding: '15px', 
			backgroundColor: '#999', 
			width: '600px', 
			height: '500px', 
			'-webkit-border-radius': '10px', 
			'-moz-border-radius': '10px', 
			color: '#fff'
		}
	});
}
