jQuery.noConflict();

jQuery(document).ready(function(){


	
	
    jQuery("a.zoomTrigger").fancybox({
        'speedIn': 500,
        'speedOut': 300,
        'padding': 2,
        'titlePosition': 'over',
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'elastic',
        /*'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack',*/

        'onStart': function(par){
			
			
            var elem = jQuery(par);
			
            var siblings = elem.siblings();
			
            target = jQuery('img.thumb', siblings);
            this.orig = target;
        }
    });
	
	
    Photogallery.init();
	
    jQuery("a.top").click(function(){
        var h=jQuery("body").height();
        jQuery("body,html").animate({
            scrollTop:0
        },1000);
        return false;
    })

    jQuery("a.local-scroll").bind('click', function(){
        var target = jQuery(this).attr('href');
        jQuery.scrollTo(target, 1000);
        return false;
    });
	
});


var Photogallery = {
	
    openTrigger : "a#gallery_open",
    closeTrigger : "div#masthead-gallery a.close",
    toggleTrigger : "a.togglePhotogallery",
    infoContainer : null,
    galleryContainer : null,
    contentContainer : null,
    lang:null,
    category_id:null,
    isOpen: false,
    duration: 500,
    bookNow:false,
    autopen:false,
	
    init: function(){
        Photogallery.infoContainer = jQuery("div#masthead-hotel");
        Photogallery.galleryContainer = jQuery("div#masthead-gallery");
        Photogallery.contentContainer = jQuery("div#content-inner");
        jQuery(Photogallery.openTrigger).bind('click' , Photogallery.openGallery);
        jQuery(Photogallery.closeTrigger).bind('click' , Photogallery.closeGallery);
        jQuery(Photogallery.toggleTrigger).bind('click' , Photogallery.toggleGallery);
        Photogallery.lang = ASAP.LANG;
        Photogallery.category_id = Photogallery.galleryContainer.attr('category_id');
        Photogallery.bookNow = jQuery("a.book-now");

        Photogallery.autopen = Photogallery.galleryContainer.attr('auto') == 'true';


        var other_book_btn = jQuery("a.book-now-small");
        if(other_book_btn.size() > 0){
            other_book_btn.attr('href',Photogallery.bookNow.attr('href'));
            other_book_btn.attr('title',Photogallery.bookNow.attr('title'));
        }

        if(Photogallery.autopen)Photogallery.openGallery();

    },
	
    toggleGallery: function(event){
        if(event){
            event.stopPropagation();
            event.preventDefault();
        }
        if(Photogallery.isOpen){
            Photogallery.closeGallery(event);  
        }else{
            Photogallery.openGallery(event);   
        }
    },
	
    openGallery: function(event){
        if(event){
            event.stopPropagation();
            event.preventDefault();
        }

        jQuery(Photogallery.toggleTrigger).html("Close Photogallery");
		
        Photogallery.infoContainer.fadeOut( Photogallery.duration, function(){
					
            Photogallery.galleryContainer.fadeIn(500 , function(){
                Photogallery.contentContainer.animate({
                    paddingTop:"265px"
                });
                jQuery(this).animate({
                    height:"560px"
                }, 500, function(){
                    jQuery(".gallery-inner" , 	Photogallery.galleryContainer ).fadeIn(500) ;
							
		    var xml = ASAP.LIVESITE.URL + "/xmlfile.php?category_id="+Photogallery.category_id+"%26lang="+Photogallery.lang;
			
			
			var flashvars = {paramXMLPath: ASAP.TEMPLATE.URL+"/swf/param.php?category_id="+Photogallery.category_id+"%26lang="+Photogallery.lang, xmlfile:xml};
			var params = { allowFullScreen:true, quality: "best", base: ".", wmode:"transparent"};
			var attributes = {};
			 
			swfobject.embedSWF(ASAP.TEMPLATE.URL+"/swf/loader.swf", "slideshow", "706", "487", "9.0.0","/expressInstall.swf", flashvars, params, attributes);
			
               
                   /* var so = new swfobject(ASAP.TEMPLATE.URL+"/swf/loader.swf", "loader", "706", "487", "9", "#000");
                    so.addParam("allowFullScreen","true");
                    so.addParam("quality", "best");
                    so.addParam("base",".");
                    so.addParam("wmode","transparent");
                    so.addVariable("paramXMLPath", ASAP.TEMPLATE.URL+"/swf/param.php?category_id="+Photogallery.category_id+"%26lang="+Photogallery.lang);
                    so.addVariable("xmlfile",xml);
                    so.write("slideshow");*/
							
							
							
                } );
            });
																			
        });

        Photogallery.isOpen = true;
		
    },
	
	
    closeGallery: function(event){
        if(event){
            event.stopPropagation();
            event.preventDefault();
        }

        jQuery(Photogallery.toggleTrigger).html("Photogallery");
		
        jQuery(".gallery-inner" , 	Photogallery.galleryContainer ).fadeOut(500, function(){
            Photogallery.contentContainer.animate({
                paddingTop:"25px"
            });
            Photogallery.galleryContainer.animate({
                height:"320px"
            }, 500, function(){
                jQuery(this).fadeOut(300, function(){
                    Photogallery.infoContainer.fadeIn(500 , function(){
                        jQuery("#slideshow").html("");
                    });
                });
							
            } );				
        });

        Photogallery.isOpen = false;
				
    }
	
}
