/* 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) {
		//alert("Error: " + e.message);
	}
})

/* Cufon */
$(document).ready(function(){
	$('.cufon').addClass('block');
	Cufon.replace('.mod_links_top, .mod_projects_top, .mod_agenda_top, .mod_infra_top, .mod_featured_top, .mod_radio_top, .mod_boletim_top, .mod_tourism_top h2, .mod_highlights_top h2, li.header_phone, ul.header_contacts_bottom, ul.menu li h2, .teaser_top, .news_top h2, .mod_videos_top h2, .cufon, .mod_bannerlinks_top h2, .mod_poll_top h2, .bot_enviar_amigo', { hover: false, hoverables: { li: false, a: false } });
    $('.copyright').show();
});


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


/* Teaser */
jQuery(function() {
//$(window).load(function() {
//$(document).ready(function(){
    $('#slider').nivoSlider({
        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:1, //15
        animSpeed:500, //Slide transition speed
        pauseTime:5200,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:false, //Next & Prev
        directionNavHide:false, //Only show on hover
        controlNav:true, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:false, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
});


/* Aumentar/Diminuir Texto */
$(document).ready(function(){
	$(".zoom a").click(function(){
		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.2; }
		else if(this.id == 'minus' && num >= 10) { num /= 1.2; }
		$speech.css('fontSize', num + unit);
		$speech.css('line-height', (num+6) + unit);
	 });
});


/* Menu Vertical */
$(document).ready(function(){
	/*
	$('.logo_trigger a').click(function(){
		$(this).toggleClass('expanded');
		$('.logo_menu').toggle();
	});
	$('.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();
	});
	$('.logo_menu li.parent:last').addClass('last');
	$('.logo_menu ul.submenu').each(function(){
		$(this).find('li:last').addClass('last');
	});
	*/
	$('.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'); // saber a classe que escolhemos
			$thiswidth = $(this).width(); 		// largura do li
			$(this).parent().find('ul.'+$thisclass + ' li a').hover(
				function(){
					// $('.navigation ul li').parent().find('ul.'+$thisclass + ' li:first').css('border-top','3px solid #715323');
					$(this).addClass('hover');
				},
				function(){
					$(this).removeClass('hover');
				}
			);
			$(this).parent().find('ul.'+$thisclass).toggle();


			$('a.'+$thisclass).toggleClass('hover');
		}
	);
	/* remover separadores */
	$('.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');
		});
	});
	$('.mod_290 ul.new:last').addClass('nomarginbottom');
	$('.column_right .mod_other_hotels li:last').addClass('nomarginright');
});


/* Dom Objects */
//$(document).ready(function() {
$(window).load(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('.gallery .navigation ul.thumbs li',5,'nomarginright',0);
	getChild('.list_offers li:not(.separator)',2,'nopaddingright',1);
	getChild('.form_work ul.inputs li',3,'nomarginright',1);
	$('.vertical_banners li:last').addClass('nomarginright');
	$('.sliding_gallery li:last').addClass('nomarginright');
	$('.bingMapsControl a:last').addClass('noborderright');
});


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


/* Map  */
$(document).ready(function() {
/*	$('.bingMapsControl a').hover(function(){
		$(this).toggleClass('active');
	});	*/
})
$(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() {
		if($(this).children('a').attr('href') == "#"){
			$(this).toggleClass('status');
			$(this).next('ul').slideToggle();
			return false;
		}
	});
});


/* FAQ */
$(document).ready(function() {
	//$('li.child > ul').hide();
	$('#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() {
    $("ul.tabs li:first").addClass("active").show();
    $(".tab_content:first").fadeIn();
    $("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active");
        $(this).addClass("active");
        $(".tab_content").hide();
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
    });
});


/* Modified to support Opera */
function addbookmark(title,url){
url="http://www.cascade-resort.com/"
title="Cascade Resort"
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);
}
