/* -------------------------------------------------- *
 * Project scripts
 * -------------------------------------------------- *
 * Author: Morozov Igor
 * URL: http://www.morozoff.info/
 * Copyright: 2010 Morozov Igor
** -------------------------------------------------- */

$(document).ready(function() {
	
	$("ul#hoteltab").tabs("div.b-item-info > div.pane");
	
	$(".fancy").fancybox({
		overlayOpacity:'0.5',
		overlayColor:'#000'
	});
	$(".fancy-iframe, .fancy-inline").fancybox({
		overlayOpacity:'0.5',
		overlayColor:'#000',
		frameWidth:330,
		frameHeight:427
	});
	
	
	if($('#slidervis').length) {
		$('#slidervis').nivoSlider({
			effect:'sliceDownLeft', //Specify sets like: 'fold,fade,sliceDown'
			slices:10,
			animSpeed:1000,
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:false, //Next & Prev
			controlNav:true, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
	      	controlNavThumbsFromRel:false, //Use image rel for thumbs
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:true, //Stop animation while hovering
			manualAdvance:false //Force manual transitions
		});
		
	}
	if($('.pp-search').length) {
		var $ppsearch = $('.pp-search');
		if(!$ppsearch.hasClass('active-pp-search')) {
			$ppsearch.addClass('active-pp-search');
			$('.m-uniform').jqTransform();
			$ppsearch.removeClass('active-pp-search');
		}	
		
		$('.label-search a',$ppsearch).click(function(){
			$ppsearch.toggleClass('active-pp-search');
			return false;
		})
	}
	if($('.simresults').length) {
		$('.simresults .sim-item').hover(function() {
			$(this).addClass('sim-item-hover')
		},function() {
			$(this).removeClass('sim-item-hover')
		}).click(function(){
			//alert($(this).find('a:first').attr('href'))
			window.location = $(this).find('a:first').attr('href')
		})
	}
	
	if ($('.subm').length) {
		$('.subm').each(function(){
			$(this)[0].onchange = function(){pricesFormSubmit();}
		});
		pricesFormSubmit();
	}
	
	if($('.m-uniform').length) {
		$('.m-uniform').jqTransform();
	}
	
	$('.eside-col').not('.files').each(function(){
		$(this).html('<p class="ebig">' + $(this).html() + '</p>');
	});
	
});


function showregion(regName) {
	var $regiontbl = $('#table-regions');
	$('.pane',$regiontbl).hide();
	$('#'+regName+'-tbl').show();
}

function pricesFormSubmit() {
	$('.table-cost table').fadeOut(400);
	$.post('./prices/', $('.subm').serialize(),function(data){
		$('.table-cost').html(data);
		$('.table-cost table').fadeIn(400);
	});
}

function getEmail(x,y){
	document.write('<a href="mailto:', y, '@', x, '">', y, '@', x, '</a>');
}
