//layerpopups
jQuery("document").ready(function() {
	

	
	jQuery("a.contentlayer").fancybox({
		'onStart'	: function() {
			jQuery('#fancybox-wrap').css('opacity','0');
		},
		'padding'			: 0,
		'autoScale'			: false,
		'autoDimensions'	: false,
		'scrolling'			: 'auto',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'modal'				: 'true',
		'overlayOpacity'	: 0.5,
		'overlayColor'		: '#000000',
		'onComplete' 		: function(){
			jQuery('#fancybox-wrap').css('opacity','0');
		},
		
		'type'				: 'iframe'
	});
	
	
	jQuery("a.reviewlayer").fancybox({
		'onStart'	: function() {
			jQuery('#fancybox-wrap').css('opacity','0');
			jQuery('div#fancybox-wrap').css('margin-top','-100px');
		},
		'padding'			: 0,
		'autoScale'			: false,
		'autoDimensions'	: false,
		'scrolling'			: 'auto',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'modal'				: 'true',
		'overlayOpacity'	: 0.5,
		'overlayColor'		: '#000000',
		'onComplete' 		: function(){
			jQuery('#fancybox-wrap').css('opacity','0');
			jQuery('div#fancybox-wrap').css('margin-top','-100px');
			overlayHeight();
		},
		
		'type'				: 'iframe'
	});
	
	
	
	$("#videoplayerinlayer").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'modal'				: 'true',
		'overlayOpacity'	: 0.5,
		'overlayColor'		: '#000000',
		'padding'			: 0
	});	
	
	$(".videoplayerinlayer").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'modal'				: 'true',
		'overlayOpacity'	: 0.5,
		'overlayColor'		: '#000000',
		'padding'			: 0
	});		
	
	
	
	$("a.infotourswf").fancybox({
		'overlayOpacity'	: 0.5,
		'overlayColor'		: '#000000',
		'width'				: 560,
		'height'			: 480,
		'hideOnContentClick': true
	});		

});


function resizeFancyBox(IWIDTH,IHEIGHT)
{
	
    	//var IHEIGHT = document.getElementById('fancybox-frame').contentWindow.document.body.scrollHeight;
    	//var IWIDTH = document.getElementById('fancybox-frame').contentWindow.document.body.scrollWidth; // id of iframe	
	
        jQuery.fx.off = true;
        jQuery('#fancybox-wrap').css('opacity','0');
        var outer = jQuery('#fancybox-wrap');
        var inner = jQuery('#fancybox-content');
        var paddingTotal = 0;
        var extra = 0; // some extra space to avoid Scrollbars

        if(IWIDTH > 0 && IHEIGHT > 0){
                jQuery('#fancybox-wrap').css({
                        height: IHEIGHT + paddingTotal + extra,
                        width: IWIDTH + paddingTotal + extra
                });
                jQuery('#fancybox-content').css({
                        height: IHEIGHT + extra,
                        width: IWIDTH + extra
                });
                
                jQuery.fancybox.center();
        }
    	parent.jQuery('#fancybox-wrap').css('opacity','100');
        
        jQuery.fx.off = false;
        
}

function closeFancyboxAndRedirectToUrl(url){
    jQuery.fancybox.close();
    window.location.href = url;
}


//Adjust Fancybox Overlay Height to Large Fancyboxes
function overlayHeight() {
  fancyBoxHeight = jQuery('#fancybox-wrap').height(); 
  bodyHeight = jQuery(document).height();
  finalheight = fancyBoxHeight + bodyHeight;
  jQuery('#fancybox-overlay').css('height', finalheight);
}

