Cufon.replace('.cufon',{ hover: true, hoverables: {li:false, a:false} });


/* Activity */
$(document).ready(function() {
	$('#activity li.child > p').click(function() {
		$(this).toggleClass('expanded');
		$(this).next('ul.main').slideToggle('normal');
        $(this).parent().siblings('li').children('ul.main:visible').slideUp('normal')
            .parent('li').find('p').removeClass('expanded');
		return false;
	});
});


/* Skins */
$(document).ready(function() {
	try {
		$(".select50").msDropDown({ mainCSS: 'dd50' });
		$(".select60").msDropDown({ mainCSS: 'dd60' });
		$(".select80").msDropDown({ mainCSS: 'dd80' });
		$(".select90").msDropDown({ mainCSS: 'dd90' });
		$(".select120").msDropDown({ mainCSS: 'dd120' });
		$(".select130").msDropDown({ mainCSS: 'dd130' });
		$(".select170").msDropDown({ mainCSS: 'dd170' });
	} catch (e) {
	}
})



$(window).load(function() {
	$('.copyright').show();
});


/* Aumentar/Diminuir Texto */
$(document).ready(function(){
	$(".zoom a").click(function(){
		try{
		var $speech = $('.txt');
		var currentSize = $speech.css('font-size');
		var num = parseFloat(currentSize,10);
		var unit = currentSize.slice(-2);
		if(this.id == 'plus' && num <= 16){ num *= 1.1; }
		else if(this.id == 'minus' && num >= 10) { num /= 1.1; }
		$speech.css('fontSize', num + unit);
		$speech.css('line-height', (num+6) + unit);
		}catch(e){}
	});
});


/* Alinhamentos Horizontais */
$(window).load(function() {
	function alignMenu($div,$ul){
		$list_width = 0;
		$divwidth = $($div).width();
		$($ul + ' li').each(function(){
			$list_width = $(this).width() + $list_width;
		});
		$totalspace = ($divwidth - $list_width);
		$leftmargin = ($totalspace / 2);
		$($ul).css({'margin-left' : $leftmargin});
	}

	try{
		alignMenu('.header .navigation','.header .navigation ul.nav');
	}catch(e){
	}
	try{
		alignMenu('.navigation_wrap .navigation','.navigation_wrap .navigation ul.nav');
	}catch(e){
	}
	alignMenu('.footer .second' , '.footer .second ul');

});


/* Menu Vertical */
$(document).ready(function(){
	$('.logo').bind('mouseenter',
            function(){
                $('.logo_trigger a').addClass('expanded');
                $('.logo_menu').show();
                return false;
            }
        );
    $('.logo').bind('mouseleave',
            function(){
                $('.logo_trigger a').removeClass('expanded');
                $('.logo_menu').hide();
                return false;
            }
        );
    $('.logo_trigger a').click(
        function(){
            $(this).toggleClass('expanded');
            $('.logo_menu').toggle();
            return false;
        }
    );
    $('.logo_menu li.parent').hover(
        function(){
            $(this).toggleClass('expanded');
            $x = $(this).width();
            $(this).children('ul').css('position','relative');
            $(this).children('ul').css('top','-28px');
            $(this).children('ul').css('left',$x);
            $(this).children('ul').toggle();
            return false;
        },
        function(){
            $(this).children('ul').hide();
        }
    );
    $('.logo_menu li.parent:last').addClass('last');
    $('.logo_menu ul.submenu').each(function(){
        $(this).find('li:last').addClass('last');
    });
});


/* Menu Horizontal */
$(document).ready(function(){
	$('.header_wrap .navigation ul li a').hover(
		function(){
			$(this).parent().find('ul:first').css('border-top','3px solid #715323')
		}
	);
	/* hover botoes */
	$('.navigation ul li').hover(
		function(){
			$thisclass = $(this).attr('class');
			$thiswidth = $(this).width();
			$(this).parent().find('ul.'+$thisclass + ' li a').hover(
				function(){
					$(this).addClass('hover');
				},
				function(){
					$(this).removeClass('hover');
				}
			);
			if($.browser.msie){
				//$(this).parent().find('ul.'+$thisclass).animate({width:'toggle', height: 'toggle', opacity: 'toggle'}, {duration: 300});
				$(this).parent().find('ul.'+$thisclass).toggle();
			}else{
				//$(this).parent().find('ul.'+$thisclass).animate({width:'auto',height: 'toggle', opacity: 'toggle'}, {duration: 300});
				$(this).parent().find('ul.'+$thisclass).toggle();
			}

			$('a.'+$thisclass).toggleClass('hover');
		}
	);
	$('.navigation ul li ul').each(function(){
		$(this).find('li:last').css('background-image','none');
		$(this).find('li a:last').hover(function(){
			$(this).css('background-image','none');
		});
	});
});


/* Dom Objects */
$(document).ready(function() {
	$('.gallery_wrap, .gallery_albuns').addClass('block');
})


/* Last */
$(document).ready(function(){
    function getChild($class,$pos,$add,$clear){
        $num_divs = $class.length;
        $i = 1;
        for($i; $i <= $num_divs; $i++){
            if($i % $pos == 0){
                $($class).eq($i-1).addClass($add);
				if($clear == 1){
					$('<div class="clear"></div>').insertAfter($($class).eq($i-1));
				}
            }
        }
    }
	getChild('.gallery_albuns ul',3,'nomarginright',1);
	getChild('.list_offers li:not(.separator)',2,'nopaddingright',1);
	getChild('.form_work ul.inputs li',3,'nomarginright',1);
	getChild('.resort_welcome ul li',2,'nomarginright',1);
	getChild('.gallery ul.thumbs li',5,'nomarginright',0);

	$('.vertical_banners li:last').addClass('nomarginright');
	$('.sliding_gallery li:last').addClass('nomarginright');
	$('.bingMapsControl a:last').addClass('noborderright');
	$('.mod_290 ul.new:last').addClass('nomarginbottom');
	$('.column_right .mod_other_hotels li:last').addClass('nomarginright');
	$('.column_right .weather cufon:last').css({'background':'url(/images/png/bullet_input_submit.png) right 5px no-repeat', 'padding-right':'20px'});
	$('.column_right .newsletter cufon:last').css({'background':'url(/images/png/bullet_input_submit.png) right 5px no-repeat', 'padding-right':'20px'});
	$('.column_right .bookings cufon:last').css({'background':'url(/images/png/bullet_input_submit.png) right 5px no-repeat', 'padding-right':'20px'});
    $('.column_right .prices cufon:last').css({'background':'url(/images/png/bullet_input_submit.png) right 5px no-repeat', 'padding-right':'20px'});
});


/* Sliding Gallery */
$(document).ready(function() {
	//$('.resort_welcome a,.sliding_gallery a').attr('href','javascript:void(0)');
	$('.resort_welcome a').click(function(){
		$('.main .resort_welcome').slideToggle();
		$('.main .gallery').slideToggle();
	});
})


/* Map  */
$(document).ready(function(){
	$(".bingMapsControl a").hover(
	  function () {
		$(this).click(function(){
			$(".bingMapsControl a").removeClass('active');
			$(this).addClass('active');
		});
	  }
	);
});


/* Imgs Align */
$(document).ready(function(){
	$('.txt img').each(function(){
		if(
			$(this).css('float') == 'left'){
			$(this).addClass('align_left');
		}
		if($(this).css('float') == 'right'){
			$(this).addClass('align_right');
		}
	});
});



/* Sitemap */
$(document).ready(function() {
	//$('li.child > ul').hide();
	/*$('#sitemap li.child > p').click(function() {
		$(this).toggleClass('status');
		$(this).next('ul').slideToggle();
		return false;
	});*/
});


/* FAQ */
$(document).ready(function() {
	$('#faq li.child > p').click(function() {
		$(this).toggleClass('expanded');
		$(this).next('ul').slideToggle();
        $(this).parent().siblings('li').children('ul:visible').slideUp('fast')
            .parent('li').find('p').removeClass('expanded');
		return false;
	});
});


/* Text Hight */
$(window).load(function(){
	$height = 0;
	$('.list_offers ul li h5').each(
		function(){

			if ($(this).height() > $height){
				$height = $(this).height();
			}
		}
	);
	$('.list_offers h5').css('min-height',$height);
});


/* Tabs */
$(document).ready(function() {
    $(".tab_content:first").fadeIn();
    $("ul.tabs li:first").addClass("active").show();
    $("ul.tabs li").click(function(e) {
		$("ul.tabs li").removeClass("active");
        $(this).addClass("active");
        $(".tab_content").hide();
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
    });
});

$(document).ready( function() {
	try{
		$('#mycarousel').jcarousel({
			vertical: false,
			scroll: 2
		});

	}catch(e){
	}
});

$(document).ready( function() {
	$('#accordion li.anteriores > ul:not("#mycarousel")').hide();
	$('#accordion .atitulo').click(function() {
		$(this).toggleClass('selected');
		$(this).next('ul').slideToggle('normal');
		$(this).parent().siblings('li').children('ul:visible').slideUp('normal')
		.parent('li').find('a').removeClass('selected');
		return false;
	});

});


/* Modified to support Opera */
function addbookmark(title,url){
url="http://www.vivendamiranda.pt/"
title="Vivenda Miranda"
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
}
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}



function getChild($class,$pos,$add,$clear){
	$num_divs = $class.length;
	$i = 1;
	for($i; $i <= $num_divs; $i++){
		if($i % $pos == 0){
			$($class).eq($i-1).addClass($add);
			if($clear == 1){
				$('<div class="clear"></div>').insertAfter($($class).eq($i-1));
			}
		}
	}
}

/* ACTIVITIES */
$(document).ready(function() {

	$('.activities').addClass('block');

	getChild('.activities ul li',2,'nomarginright',1);

	$('.activities a').each(function(){
		$(this).hover(function(){
			$(this).parent().find('span').animate({width:'toggle',height: 'toggle'}, 200);
		});
	});
})
