﻿//Javascript init
var nextImageText = "";
var nextImageIndex = 1;
var jsSize = 1;
var backgroundImageTimer = null;
var imageMenuTopElement = 1;
switch(websiteSize)
{
    case 0:
        jsSize = 0.64;
    break;
    case 1:
        jsSize = 0.8;
    break;
    case 2:
        jsSize = 1;
    break;
}//switch

//When dom is ready.
$(document).ready(function() {
    
    InitElements();
});

function InitElements(){

    //Init top menu elements
    $(".activeImage").removeClass('Hidden');
    $(".divTopMenuImageLink").mouseenter(function(){
        
        if(jQuery.support.opacity){
        
            $(".activeImage", this).stop().animate({opacity: 1.0}, 250);
        }//if
        else{
        
            $(".activeImage", this).stop().css({"display" : "block"});
        }//else
    });
    $(".divTopMenuImageLink").mouseleave(function(){
        
        if(jQuery.support.opacity){
        
            $(".activeImage", this).stop().animate({opacity: 0.0}, 500);
        }//if
        else{
        
            $(".activeImage", this).stop().css({"display" : "none"});
        }//else
    });
    
    if(!jQuery.support.opacity){
        
        $(".divTopMenuImageLink .activeImage").css({"display" : "none"});
    }//if
    else{
        
        $(".divTopMenuImageLink .activeImage").css({"opacity" : 0.0});
    }
    
    //Check pagetype
    switch(pagetype)
    {
        case 1:
            $(".toggleContainer").mouseenter(function(){
                $(".toggleBackgroundOffRight", this).addClass("toggleBackgroundOnRight");
                $(".toggleBackgroundOffRight", this).removeClass("toggleBackgroundOffRight");
                
                $(".toggleBackgroundOffCenter", this).addClass("toggleBackgroundOnCenter");
                $(".toggleBackgroundOffCenter", this).removeClass("toggleBackgroundOffCenter");
                
                $(".toggleContainer").addClass("toggleContainerOn").removeClass("toggleContainerOff");
            });
            
            $(".toggleContainer").mouseleave(function(){
                $(".toggleBackgroundOnRight", this).addClass("toggleBackgroundOffRight");
                $(".toggleBackgroundOnRight", this).removeClass("toggleBackgroundOnRight");
                
                $(".toggleBackgroundOnCenter", this).addClass("toggleBackgroundOffCenter");
                $(".toggleBackgroundOnCenter", this).removeClass("toggleBackgroundOnCenter");
                
                $(".toggleContainer").addClass("toggleContainerOff").removeClass("toggleContainerOn");
            });
            
            $(".toggleTextHide").click(function(){
                  
                  $(".contentTextFieldRoot").animate({left: calcValue(23) + "px", width: calcValue(400)+"px"},1000, '', textFieldHidden);
                  
                  //Update text field hidden
                  ScriptService.SetHideTextField(true, onVoidComplete, OnTimeOut, OnError);
            }); 
            
            $(".toggleTextShow").click(function(){
                
                $(".toggleContainerShow").addClass("Hidden");
                $(".contentTextFieldRoot").animate({left: calcValue(449) + "px", width: calcValue(507)+"px"},1000);
                
                //Update text field hidden
                ScriptService.SetHideTextField(false, onVoidComplete, OnTimeOut, OnError);
            });
            
            //Load large background flash
            LoadLargeBackgroundFlash();
            
            //Execute the slideShow
            if(animatedBackground){
	            startSlideShow();
	        }//if
	        else{
	            LoadSmallBackgroundFlash();
	            startSmallSlideShow();
	            
	            $(".divBackgroundImagePrev").click(function(){
        
                    //Show previous background image
                    prevGallery();
                });
                
                $(".divBackgroundImageNext").click(function(){
        
                    //Show next background image
                    gallery();
                });
	        }//else
    	    
    	    $(".tblPhoto").mouseenter(function(){
                $(".tdPhotoLeftOff", this).addClass("tdPhotoLeftOn");
                $(".tdPhotoCenterOff", this).addClass("tdPhotoCenterOn");
                $(".tdPhotoRightOff", this).addClass("tdPhotoRightOn");
            });
            
            $(".tblPhoto").mouseleave(function(){
                $(".tdPhotoLeftOff", this).removeClass("tdPhotoLeftOn");
                $(".tdPhotoCenterOff", this).removeClass("tdPhotoCenterOn");
                $(".tdPhotoRightOff", this).removeClass("tdPhotoRightOn");
            });
            
            $(".tblPhoto").click(function(){
            
                $(".tdPhotoLeftOn", this).removeClass("tdPhotoLeftOff");
                $(".tdPhotoCenterOn", this).removeClass("tdPhotoCenterOff");
                $(".tdPhotoRightOn", this).removeClass("tdPhotoRightOff");
            
                changeLargeFlashToImage();
            });
            
            $(".tbl360Photo").mouseenter(function(){
                $(".tdPhotoLeftOff", this).addClass("tdPhotoLeftOn");
                $(".tdPhotoCenterOff", this).addClass("tdPhotoCenterOn");
                $(".tdPhotoRightOff", this).addClass("tdPhotoRightOn");
            });
            
            $(".tbl360Photo").mouseleave(function(){
                $(".tdPhotoLeftOff", this).removeClass("tdPhotoLeftOn");
                $(".tdPhotoCenterOff", this).removeClass("tdPhotoCenterOn");
                $(".tdPhotoRightOff", this).removeClass("tdPhotoRightOn");
            });
            
            $(".tbl360Photo").click(function(){
            
                $(".tdPhotoLeftOn", this).removeClass("tdPhotoLeftOff");
                $(".tdPhotoCenterOn", this).removeClass("tdPhotoCenterOff");
                $(".tdPhotoRightOn", this).removeClass("tdPhotoRightOff");
                
                changeLargeFlashTo360();
            });
    	    
	        //Show text field with effect
	        textFieldStartEffect();
    	    
	        //Init scrollbar
	        InitScrollBar('textFieldCenter','divTextContainer', 'divTextDocument','divScrollbarContainer', true);
            break;
        case 2:
            InitScrollBar('divCalenderContentRoot','divCalenderContentContainer', 'divCalenderContentDocument','divCalenderContentScrollbarContainer', false);
            
            $(".trCalendarWeek").mouseenter(function(){
                $(".tdCalenderDayCell", this).addClass("tdCalenderDayCellOn");
            });
            
            $(".trCalendarWeek").mouseleave(function(){
                $(".tdCalenderDayCell", this).removeClass("tdCalenderDayCellOn");
            });
            
            $(".divCalendarEventContainer").mouseenter(function(){
                $(".tdCalendarEventTopOff", this).addClass("tdCalendarEventTopOn");
                $(".tdCalendarEventTopOff", this).removeClass("tdCalendarEventTopOff");
                
                $(".tdCalendarEventCenterOff", this).addClass("tdCalendarEventCenterOn");
                $(".tdCalendarEventCenterOff", this).removeClass("tdCalendarEventCenterOff");
                
                $(".tdCalendarEventBottomOff", this).addClass("tdCalendarEventBottomOn");
                $(".tdCalendarEventBottomOff", this).removeClass("tdCalendarEventBottomOff");
                
                $(".divCalendarInfoOff", this).addClass("divCalendarInfoOn");
                $(".divCalendarInfoOff", this).removeClass("divCalendarInfoOff");
            });
            
            $(".divCalendarEventContainer").mouseleave(function(){
                $(".tdCalendarEventTopOn", this).addClass("tdCalendarEventTopOff");
                $(".tdCalendarEventTopOn", this).removeClass("tdCalendarEventTopOn");
                
                $(".tdCalendarEventCenterOn", this).addClass("tdCalendarEventCenterOff");
                $(".tdCalendarEventCenterOn", this).removeClass("tdCalendarEventCenterOn");
                
                $(".tdCalendarEventBottomOn", this).addClass("tdCalendarEventBottomOff");
                $(".tdCalendarEventBottomOn", this).removeClass("tdCalendarEventBottomOn");
                
                $(".divCalendarInfoOn", this).addClass("divCalendarInfoOff");
                $(".divCalendarInfoOn", this).removeClass("divCalendarInfoOn");
            });
            
            $(".divCalendarEventContainer").click(function(){
            
                //Get event id
                var eventId = this.id.split("_")[1];
            
                //Update hash
                window.location.hash = "" + eventId;
            
                //Update print link
                $(".aCalenderPrint").attr("href", "print.aspx?type=event&id=" + eventId);
            
                //Load event data {date, time, text and image}
                ScriptService.GetEventData(eventId, onGetEventDataComplete, OnTimeOut, OnError);
            });
            
            //Check for start hash
            if(window.location.hash.length > 1){
            
                //Load selected event
                ScriptService.GetEventData(parseInt(window.location.hash.substring(1)), onGetEventDataComplete, OnTimeOut, OnError);
            }//if
            
            $(".divCalenderEventDetailsHideContainer").click(function(){
                
                //Hide outer container with slide effect
                $(".divCalenderEventDetailsOuterContainer").animate({top: calcValue(658) + "px"}, 500, "", function(){$(".divCalenderEventDetailsRoot").css({"display":"none"});});
            });
            
            
            $(".divCalenderEventDetailsHideContainer").mouseenter(function(){
                $(".toggleBackgroundOffRight", this).addClass("toggleBackgroundOnRight");
                $(".toggleBackgroundOffRight", this).removeClass("toggleBackgroundOffRight");
                
                $(".toggleBackgroundOffCenter", this).addClass("toggleBackgroundOnCenter");
                $(".toggleBackgroundOffCenter", this).removeClass("toggleBackgroundOffCenter");
                
                $(".toggleContainer").addClass("toggleContainerOn").removeClass("toggleContainerOff");
            });
            
            $(".divCalenderEventDetailsHideContainer").mouseleave(function(){
                $(".toggleBackgroundOnRight", this).addClass("toggleBackgroundOffRight");
                $(".toggleBackgroundOnRight", this).removeClass("toggleBackgroundOnRight");
                
                $(".toggleBackgroundOnCenter", this).addClass("toggleBackgroundOffCenter");
                $(".toggleBackgroundOnCenter", this).removeClass("toggleBackgroundOnCenter");
                
                $(".toggleContainer").addClass("toggleContainerOff").removeClass("toggleContainerOn");
            });
            break;
        case 3:
            break;
        case 4:
            //Always show textbox
            boolHideTextField = false;
        
            $(".toggleContainer").mouseenter(function(){
                $(".toggleBackgroundOffRight", this).addClass("toggleBackgroundOnRight");
                $(".toggleBackgroundOffRight", this).removeClass("toggleBackgroundOffRight");
                
                $(".toggleBackgroundOffCenter", this).addClass("toggleBackgroundOnCenter");
                $(".toggleBackgroundOffCenter", this).removeClass("toggleBackgroundOffCenter");
                
                $(".toggleContainer").addClass("toggleContainerOn").removeClass("toggleContainerOff");
            });
            
            $(".toggleContainer").mouseleave(function(){
                $(".toggleBackgroundOnRight", this).addClass("toggleBackgroundOffRight");
                $(".toggleBackgroundOnRight", this).removeClass("toggleBackgroundOnRight");
                
                $(".toggleBackgroundOnCenter", this).addClass("toggleBackgroundOffCenter");
                $(".toggleBackgroundOnCenter", this).removeClass("toggleBackgroundOnCenter");
                
                $(".toggleContainer").addClass("toggleContainerOff").removeClass("toggleContainerOn");
            });
            
            $(".toggleTextHide").click(function(){
                  
                  $(".contentTextFieldRoot").animate({left: calcValue(23) + "px", width: calcValue(400)+"px"},1000, '', textFieldHidden);
                  $(".contentRightTextFieldRoot").animate({width: 0 + "px"},1000);
            }); 
            
            $(".toggleTextShow").click(function(){
                
                $(".toggleContainerShow").addClass("Hidden");
                $(".contentTextFieldRoot").animate({left: calcValue(449) + "px", width: calcValue(507)+"px"},1000);
                $(".contentRightTextFieldRoot").animate({width: calcValue(507) + "px"},1000);
            });
            
            $(".newsListElement").click(function(){
            
                //Remove old selected
                $(".selectedNewsListElement").removeClass("selectedNewsListElement");
            
                //Set new as selected
                $(this).addClass("selectedNewsListElement");
            
                //Hide right text field
                $(".contentRightTextFieldRoot").stop().animate({width: 0 + "px"}, 1000, "", function(){
                
                    //Get selected id
                    var selectedNewsId = $(".selectedNewsListElement").attr("id").split("_")[1];
        
                    //load selected news data
                    ScriptService.GetNewsData(selectedNewsId, onGetNewsDataComplete, OnTimeOut, OnError);
                    
                    //Update url hash
                    window.location.hash = "" + selectedNewsId;
                });
            })//
        
            //Load large background flash
            LoadLargeBackgroundFlash();
            
            //Execute the slideShow
            if(animatedBackground){
	            startSlideShow();
	        }//if
	        else{
	            LoadSmallBackgroundFlash();
	            startSmallSlideShow();
	            
	            $(".divBackgroundImagePrev").click(function(){
        
                    //Show previous background image
                    prevGallery();
                });
                
                $(".divBackgroundImageNext").click(function(){
        
                    //Show next background image
                    gallery();
                });
	        }//else
    	    
    	    //Check for url hash
            if(window.location.hash.length > 1){
                
                var selectedNewsItemId = window.location.hash.substring(1);
                
                //Remove old selected
                $(".selectedNewsListElement").removeClass("selectedNewsListElement");
            
                //Set new as selected
                $("#news_" + selectedNewsItemId).addClass("selectedNewsListElement");
                
                //Show list field
                textFieldStartEffect();
                
                //Init scrollbar (list field)
	            InitScrollBar('textFieldCenter','divTextContainer', 'divTextDocument','divScrollbarContainer', false);
    	        
	            //Set start scroll position
	            if($(".selectedNewsListElement").position().top > $(".divTextContainer").height()){
    	        
	                InitScrollPosition('divTextContainer', 'divTextDocument', $(".selectedNewsListElement").position().top * -1 + $(".divTextContainer").height() - $(".selectedNewsListElement").height() - calcValue(20) );
                }//if
                
                //Hide news field
                $(".contentRightTextFieldRoot").css({width: "" + calcValue(0)+"px"});
                $(".contentRightTextFieldRoot").removeClass("opacityO");
                
                //load selected news data
                ScriptService.GetNewsData(selectedNewsItemId, onGetNewsDataComplete, OnTimeOut, OnError);
            }//if
            else{
            
	            //Show text field with effect
	            textFieldStartEffect();
    	        rightTextFieldStartEffect();
        	    
	            //Init scrollbar (list field)
	            InitScrollBar('textFieldCenter','divTextContainer', 'divTextDocument','divScrollbarContainer', false);
    	        
	            //Init scrollbar (news field)
	            InitScrollBar('rightTextFieldCenter','divRightTextContainer', 'divRightTextDocument','divRightScrollbarContainer', false);
	        }
            break;
        case 5:
            LoadFrontPageFlash();
            break;
        case 6:
            $(".divImageMenuItem").mouseenter(function(){
            
                if(jQuery.support.opacity){
                    
                    $(".imgImageMenuItemOn", this).stop().animate({opacity: 1.0},500);
                }//if
                else{
                
                    $(".imgImageMenuItemOn", this).stop().css({"display" : "block"});
                }//else
            });
            
            $(".divImageMenuItem").mouseleave(function(){
            
                if(!$(this).hasClass("selectedDivImageMenuItem")){
                    
                    if(jQuery.support.opacity){
                    
                        $(".imgImageMenuItemOn", this).stop().animate({opacity: 0.0},500);
                    }//if
                    else{
                    
                        $(".imgImageMenuItemOn", this).stop().css({"display" : "none"});
                    }//else
                }//if
            });
            
            $(".divImageMenuUpArrowContainer").mouseenter(function(){
            
                if(jQuery.support.opacity){
                
                    $(".imgImageMenuUpArrowOn", this).stop().animate({opacity: 1.0},500);
                }//if
                else{
                
                    $(".imgImageMenuUpArrowOn", this).stop().css({"display" : "block"});
                }//else
            });
            
            $(".divImageMenuUpArrowContainer").mouseleave(function(){
            
                if(jQuery.support.opacity){
                
                    $(".imgImageMenuUpArrowOn", this).stop().animate({opacity: 0.0},500);
                }//if
                else{
                    
                    $(".imgImageMenuUpArrowOn", this).stop().css({"display" : "none"});
                }//else
            });
            
            $(".divImageMenuDownArrowContainer").mouseenter(function(){
            
                if(jQuery.support.opacity){
                
                    $(".imgImageMenuDownArrowOn", this).stop().animate({opacity: 1.0},500);
                }//if
                else{
                
                    $(".imgImageMenuDownArrowOn", this).stop().css({"display" : "block"});
                }//else
            });
            
            $(".divImageMenuDownArrowContainer").mouseleave(function(){
            
                if(jQuery.support.opacity){
                
                    $(".imgImageMenuDownArrowOn", this).stop().animate({opacity: 0.0},500);
                }//if
                else{
                
                    $(".imgImageMenuDownArrowOn", this).stop().css({"display" : "none"});
                }//else
            });
            
            if(!jQuery.support.opacity){
            
                $(".imgImageMenuUpArrowOn").stop().css({"opacity" : 1.0});
                $(".imgImageMenuDownArrowOn").stop().css({"opacity" : 1.0});
                $(".imgImageMenuUpArrowOn").stop().css({"display" : "none"});
                $(".imgImageMenuDownArrowOn").stop().css({"display" : "none"});
                
                $(".divImageMenuItem .imgImageMenuItemOn").css({"opacity" : 1.0});
                $(".divImageMenuItem .imgImageMenuItemOn").css({"display" : "none"});
            }//if
            
            
            $(".divImageMenuUpArrowContainer").click(function(){
                
                //Get number of items
                var numberOfItems = $(".divImageMenuItem").length;
                
                //Check menu position
                if(imageMenuTopElement > 1)
                {
                    imageMenuTopElement--;
                    var target = calcValue(110) * (imageMenuTopElement - 1);
                    $(".divImageMenuDocument").stop(true, true).animate({top: -target + calcValue(50) + "px"},500).animate({top: -target - calcValue(25) + "px"},300).animate({top: -target + "px"},200);
                }//if
            });
            
            $(".divImageMenuDownArrowContainer").click(function(){
                
                //Get number of items
                var numberOfItems = $(".divImageMenuItem").length;
   
                //Check menu position
                if(imageMenuTopElement < (numberOfItems - 4))
                {
                    imageMenuTopElement++;
                    var target = calcValue(110) * (imageMenuTopElement - 1);
                    $(".divImageMenuDocument").stop(true, true).animate({top: -target - calcValue(50) + "px"},500).animate({top: -target + calcValue(25) + "px"},300).animate({top: -target + "px"},200);
                }//if
            });
            
            $(".divImageMenuItem").click(function(){
                
                //Check if new element
                if($(this).attr("id") != $(".selectedDivImageMenuItem").attr("id")){
                
                    //Remove old selected
                    if(jQuery.support.opacity){ 
                
                        $(".selectedDivImageMenuItem .imgImageMenuItemOn").stop().animate({opacity: 0.0},700);
                    }//if
                    else{
                        
                        $(".selectedDivImageMenuItem .imgImageMenuItemOn").stop().css({"display" : "none"});
                    }//else
                    
                    $(".selectedDivImageMenuItem").removeClass("selectedDivImageMenuItem");
                
                    //Set new selected
                    $(this).addClass("selectedDivImageMenuItem");
                    
                    //Get selected id
                    var selectedItemId = $(this).attr("id").split("_")[1];
                    
                    //hide textfield
                    $(".contentTextFieldRoot").animate({left: calcValue(23) + "px", width: calcValue(400)+"px"},1000, '', function(){
                        
                        //Get selected id
                        var selectedItemId = $(".selectedDivImageMenuItem").attr("id").split("_")[1];
            
                        //load selected news data
                        ScriptService.GetPackageDealData(selectedItemId, onGetPackageDealDataComplete, OnTimeOut, OnError);
                        
                        //Update url hash
                        window.location.hash = "" + selectedItemId;
                    });
                }//if
                
                //Update print link
	            $("#aPrintPage").attr("href", "print.aspx?type=packagedeal&id=" + selectedItemId);
            });
            
            $(".toggleContainer").mouseenter(function(){
                $(".toggleBackgroundOffRight", this).addClass("toggleBackgroundOnRight");
                $(".toggleBackgroundOffRight", this).removeClass("toggleBackgroundOffRight");
                
                $(".toggleBackgroundOffCenter", this).addClass("toggleBackgroundOnCenter");
                $(".toggleBackgroundOffCenter", this).removeClass("toggleBackgroundOffCenter");
                
                $(".toggleContainer").addClass("toggleContainerOn").removeClass("toggleContainerOff");
            });
            
            $(".toggleContainer").mouseleave(function(){
                $(".toggleBackgroundOnRight", this).addClass("toggleBackgroundOffRight");
                $(".toggleBackgroundOnRight", this).removeClass("toggleBackgroundOnRight");
                
                $(".toggleBackgroundOnCenter", this).addClass("toggleBackgroundOffCenter");
                $(".toggleBackgroundOnCenter", this).removeClass("toggleBackgroundOnCenter");
                
                $(".toggleContainer").addClass("toggleContainerOff").removeClass("toggleContainerOn");
            });
            
            $(".toggleTextHide").click(function(){
                  
                  $(".contentTextFieldRoot").animate({left: calcValue(23) + "px", width: calcValue(400)+"px"},1000, '', textFieldHidden);
            }); 
            
            $(".toggleTextShow").click(function(){
                
                $(".toggleContainerShow").addClass("Hidden");
                $(".contentTextFieldRoot").animate({left: calcValue(449) + "px", width: calcValue(507)+"px"},1000);
            });
    	    
    	    //Check for url hash
            if(window.location.hash.length > 1){
                
                //Init text field
                $(".contentTextFieldRoot").css({left: "" + calcValue(23) + "px", width: "" + calcValue(400)+"px"});
                $(".contentTextFieldRoot").removeClass("opacityO");
    
                //get selected
                var selectedItemId = window.location.hash.substring(1);
                
                //Update selected
                $(".selectedDivImageMenuItem .imgImageMenuItemOn").stop().animate({opacity: 0.0},700);
                $(".selectedDivImageMenuItem").removeClass("selectedDivImageMenuItem");
                
                //Set new selected
                $("#imageMenuItem_"+selectedItemId).addClass("selectedDivImageMenuItem");
                
                //Update image menu top position
                for(var i = 1; i <= $(".divImageMenuItem").length; i++){
                    
                    if(i > 1 && parseInt( $($(".divImageMenuItem")[i-1]).attr("id").split("_")[1]) == parseInt(selectedItemId)){
                    
                        //Update 
                        if( i > $(".divImageMenuItem").length -4)
                            i = $(".divImageMenuItem").length -4;
                            
                        imageMenuTopElement = i;
                        var target = calcValue(110) * (imageMenuTopElement - 1);
                        $(".divImageMenuDocument").stop(true, true).animate({top: -target - calcValue(50) + "px"},500).animate({top: -target + calcValue(25) + "px"},300).animate({top: -target + "px"},200);
                        
                        break;
                    }//if
                }//for 
                
                //Highlight selected
                if(jQuery.support.opacity){ 
                
                    $("#imageMenuItem_"+selectedItemId+" .imgImageMenuItemOn").stop().animate({opacity: 1.0},1000);
                }//if
                else{
                    
                    $("#imageMenuItem_"+selectedItemId+" .imgImageMenuItemOn").stop().css({"display" : "block"});
                }//else
                
                //load selected data
                ScriptService.GetPackageDealData(selectedItemId, onGetPackageDealDataComplete, OnTimeOut, OnError);
            }//if
            else{
            
                //Load large background flash
                LoadLargeBackgroundFlash();
                
                //Execute the slideShow
                if(animatedBackground){
	                startSlideShow();
	            }//if
	            else{
	                LoadSmallBackgroundFlash();
	                startSmallSlideShow();
    	            
	                $(".divBackgroundImagePrev").click(function(){
            
                        //Show previous background image
                        prevGallery();
                    });
                    
                    $(".divBackgroundImageNext").click(function(){
            
                        //Show next background image
                        gallery();
                    });
	            }//else
            
	            //Show text field with effect
	            textFieldStartEffect();
        	    
	            //Init scrollbar
	            InitScrollBar('textFieldCenter','divTextContainer', 'divTextDocument','divScrollbarContainer', false);
	            
	            //Highlight selected 
                if(jQuery.support.opacity){ 
                
                    $(".selectedDivImageMenuItem .imgImageMenuItemOn").stop().animate({opacity: 1.0},1000);
                }//if
                else{
                    
                    $(".selectedDivImageMenuItem .imgImageMenuItemOn").stop().css({"display" : "block"});
                }//else
	        }//
	        
	        //Update print link
	        $("#aPrintPage").attr("href", "print.aspx?type=packagedeal&id=" + $(".selectedDivImageMenuItem").attr("id").split('_')[1]);
            break;
        case 7:
            //Photo
            /*
            $(".divGalleryLeftZone").mouseenter(function(){
                
                continueLeftRoll = true;
                setTimeout("galleryListRollLeft(\""+$(this).parent().attr("id")+"\")", 1000);
            });
            
            $(".divGalleryLeftZone").mouseleave(function(){

                stopGalleryListRollLeft();
            });
            
            $(".divGalleryRightZone").mouseenter(function(){
                
                continueRightRoll = true;
                setTimeout("galleryListRollRight(\""+$(this).parent().attr("id")+"\")", 1000);
            });
            
            $(".divGalleryRightZone").mouseleave(function(){

                stopGalleryListRollRight();
            });
            */
        
            $(".divGalleryContainer").click(function(){
            
                //Position flash div
                var lightbox = document.getElementById('divGalleryFlashFrame');
                var w = calcValue(1072);
                var h = calcValue(681); 

                var top = parseInt(document.documentElement.scrollTop ? 
                document.documentElement.scrollTop :
                document.body.scrollTop);

                // the important part
                lightbox.style.top = getViewportHeight()/2 - (h/2) + top + 'px';
                lightbox.style.left = getViewportWidth()/2 - (w/2) + 'px';

                //Show background div
                $("#divGalleryBox").css({"display" : "block", width: getViewportWidth() + "px", height: getViewportHeight() + "px", opacity : 0.0}).animate({opacity: 0.8},500);
                $("#divGalleryFlashFrame").css({"display" : "block", opacity : 0.0}).animate({opacity: 1.0},500);
                
                //Get selected gallery id
                var selectedItemId = $(this).attr("id").split("_")[1];
                
                //Load gallery images
                ScriptService.GetGalleryImageData(selectedItemId, onGetGalleryImagesDataComplete, OnTimeOut, OnError);
            });
            
            $(".divGalleryFlashFrame").mouseenter(function(){
                
                //Show close box
                $(".divCloseGallery").css({"display":"block"});
                $(".divGalleryControlBoard").css({"display":"block"});
            });
            
            $(".divGalleryFlashFrame").mouseleave(function(){

                //Hide close box
                $(".divCloseGallery").css({"display":"none"});
                $(".divGalleryControlBoard").css({"display":"none"});
            });

            $(".divCloseGallery").click(function(){
            
                //Stop and close flash gallery
                closeFlashGallery();
            });
            
            $(".tdGalleryBack").click(function(){
            
                //Gallery back
                flashGalleryBack();
            });
            
            $(".tdGalleryPlay").click(function(){
            
                //Gallery next
                flashGalleryPlay();
                
                //toggle play/pause
                $(".tdGalleryPlay").removeClass("show");
                $(".tdGalleryPause").addClass("show");
            });
            
            $(".tdGalleryPause").click(function(){
            
                //Gallery next
                flashGalleryPause();
                
                //toggle play/pause
                $(".tdGalleryPlay").addClass("show");
                $(".tdGalleryPause").removeClass("show");
            });
            
            $(".tdGalleryNext").click(function(){
            
                //Gallery next
                flashGalleryNext();
            });

            $(".divGlleriesListBack").click(function(){
            
                $(".tblGalleriesList").stop(true,true);
                
                //Check if more galleries back
                if( parseInt($(".tblGalleriesList").css("top")) < 0 ){
                    
                    $(".tblGalleriesList").animate({"top":parseInt($(".tblGalleriesList").css("top")) + $(".divGalleryContainer").height() + $(".divGalleryTitle").height() + calcValue(109) +"px"},1000);
                }//if
            });
            
            $(".divGlleriesListNext").click(function(){
            
                $(".tblGalleriesList").stop(true,true);
                
                //Check if more galleries next
                if( parseInt($(".tblGalleriesList").css("top")) >  -1 * ($(".tblGalleriesList").height() - $(".divGalleriesListRoot").height()) ){
                
                    $(".tblGalleriesList").animate({"top": parseInt($(".tblGalleriesList").css("top")) - $(".divGalleryContainer").height() - $(".divGalleryTitle").height() - calcValue(109)  + "px"},1000);
                }//if
            });

            break;
        case 8:
            //Init scrollbar
	        InitScrollBar('contentFullTextFieldRoot','divFullTextContainer', 'divFullTextDocument','divFullTextContainerScroll', false);
            break;
        case 9:
            //Load large background flash
            LoadLargeBackgroundFlash();
            break;
        case 10:
            //Init scrollbar
	        InitScrollBar('contentFullTextFieldRoot','divFullTextContainer', 'divFullTextDocument','divFullTextContainerScroll', false);
            break;
    }//switch
    
    $(".divBooking").click(function(){
                
        //Change booking link text
        if($(".divBookingLinkGoToText").hasClass("Hidden")){
        
            $(".divBookingLinkGoToText").removeClass("Hidden");
            $(".divBookingLinkGoBackText").addClass("Hidden");
            
            //Hide booking iframe
            $(".divBookingIframe").addClass("Hidden");
            document.getElementById("iframeBooking").src = "";
        }else{
            
            $(".divBookingLinkGoToText").addClass("Hidden");
            $(".divBookingLinkGoBackText").removeClass("Hidden");
            
            //Show booking iframe
            $(".divBookingIframe").removeClass("Hidden");
            document.getElementById("iframeBooking").src = bookingLinkURL;
        }//else
    });
    
    $(".divBookingLinkContainer").mouseenter(function(){
            
        if(jQuery.support.opacity){
            
            $(".imgBookingLinkOn", this).stop().animate({opacity: 1.0}, 200);
        }//if
        else{
        
            $(".imgBookingLinkOn", this).stop().css({"display" : "block"});
        }//else
    });
    
    $(".divBookingLinkContainer").mouseleave(function(){
        
        if(jQuery.support.opacity){
            
            $(".imgBookingLinkOn", this).stop().animate({opacity: 0.0}, 200);
        }//if
        else{
        
            $(".imgBookingLinkOn", this).stop().css({"display" : "none"});
        }//else
    });

    if(!jQuery.support.opacity){
    
        $(".divBookingLinkContainer .imgBookingLinkOn").stop().css({"display" : "none"});
    }//if
    else{
        $(".divBookingLinkContainer .imgBookingLinkOn").stop().css({"opacity" : 0.0});
    }//else
    
    //Check if page has a gallery preview
    if(boolUsePreviewGallery){

        setTimeout("startGalleryPreviewFlash()",100);
    }//if
    
    //Load addthis
    setTimeout("loadAddThis()",200);
}//InitElements

function loadAddThis(){
    
    //Detect browser
    var ieVer = getInternetExplorerVersion();
    if(ieVer > 0 && ieVer < 7)
    {
        //No add this
    }//if
    else
    {
        $(".addthis_button").html('<a href="http://addthis.com/bookmark.php?v=250&amp;username=xa-4b5430a151478041"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4b5430a151478041"></script>');
    }//else
    
}//loadAddThis

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function calcValue(intValue){
    return parseInt(intValue * jsSize);
}

function resValue(int1, int2, int3){
    
    switch(websiteSize)
{
    case 0:
        return int1;
    break;
    case 1:
        return int2;
    break;
    case 2:
        return int3;
    break;
}//switch
}

function textFieldStartEffect(){

    $(".contentTextFieldRoot").css({left: "" + calcValue(23) + "px", width: "" + calcValue(400)+"px"});
    $(".contentTextFieldRoot").removeClass("opacityO");

    if(!boolHideTextField){
    
        $(".toggleContainerShow").addClass("Hidden");
        $(".contentTextFieldRoot").animate({left: "" + calcValue(23) + "px"},500).animate({left: "" + calcValue(449) + "px", width: "" + calcValue(507)+"px"},1000);
    }//if
    else{
        textFieldHidden();
    }
}//textFieldStartEffect

function rightTextFieldStartEffect(){
    
    $(".contentRightTextFieldRoot").css({width: "" + calcValue(0)+"px"});
    $(".contentRightTextFieldRoot").removeClass("opacityO");
    $(".contentRightTextFieldRoot").animate({width: 0 + "px"},500).animate({width: calcValue(507) + "px"},1000);
}

function textFieldHidden(){
    
    $(".toggleContainerShow").css({opacity : 0.0});
    $(".toggleContainerShow").removeClass("Hidden");
    $(".toggleContainerShow").animate({opacity : 1.0},500);
}

function startSlideShow() {

    if($("#backgroundGallery").children().length > 1){
	    //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	    backgroundImageTimer = setInterval('gallery()',6000);
	}//if
}//startSlideShow

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#backgroundGallery a.show')?  $('#backgroundGallery a.show') : $('#backgroundGallery a:first'));

    //Update image index
    if(current.next().length > 0)
        nextImageIndex++;
    else
        nextImageIndex = 1;

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#backgroundGallery a:first') :current.next()) : $('#backgroundGallery a:first'));	
	
	//Get next image caption
	nextImageText = next.find('span').attr('rel');
	var nextImageSrc = next.find('span').attr('src');
	
	//Update background flash image
	thisMovie("slide_js").displayImage(nextImageSrc);
	//alert(nextImageSrc);
	//Update next pointer
	next.addClass('show');
	current.removeClass('show');
}//gallery

function prevGallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#backgroundGallery a.show')?  $('#backgroundGallery a.show') : $('#backgroundGallery a:first'));

    //Update image index
    if(current.prev().length > 0)
        nextImageIndex--;
    else
        nextImageIndex = $('#backgroundGallery').children().length;//TODO..Change to max....

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var previous = ((current.prev().length) ? ((current.prev().hasClass('caption'))? $('#backgroundGallery a:last') :current.prev()) : $('#backgroundGallery a:last'));	
	
	//Get next image caption
	nextImageText = previous.find('span').attr('rel');	
	var nextImageSrc = previous.find('span').attr('src');
	
	//Update background flash image
	thisMovie("slide_js").displayImage(nextImageSrc);
	
	//Update next pointer
	previous.addClass('show');
	current.removeClass('show');
}//gallery

var firstFlashImage = true;
function flashRespons(n,id){
	
	if(id == "largeFlash")
	{
	    if(firstFlashImage)
	        firstFlashImage = false;
	    else{
	    
	        if(jQuery.support.opacity){
                    
                $("#divContentBackgroundImageText").animate({opacity : 0.0},1000,'',updateBackgroundImageText);
                $("#spanCurrentImageIndex").animate({opacity : 0.0},1000,'',updateBackgroundImageCounter);
            }//if
            else{
                $("#divContentBackgroundImageText").css({"display" : "none"}).animate({"z-index":"1000"},1000,'',updateBackgroundImageText);
                $("#spanCurrentImageIndex").css({"display" : "none"}).animate({"z-index":"1000"},1000,'',updateBackgroundImageCounter);
            }//else
	    }//else
	}//if
}//flashRespons

function updateBackgroundImageText(){
    
    if(jQuery.support.opacity){
    
        $("#divContentBackgroundImageText").html(nextImageText).animate({opacity : 1.0},1000); 
    }//if
    else{
        
        $("#divContentBackgroundImageText").html(nextImageText).css({"display" : "inline-block"}); 
    }
}//updateBackgroundImageText

function updateBackgroundImageCounter(){

    if(jQuery.support.opacity){
        
        $("#spanCurrentImageIndex").html(nextImageIndex).animate({opacity : 1.0},1000);
    }//if
    else{
    
        $("#spanCurrentImageIndex").html(nextImageIndex).css({"display" : "inline-block"}); 
    }
}//updateBackgroundImageCounter

function thisMovie(movieName) {
    return document[movieName];
}//thisMovie

function startSmallSlideShow() {

	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	if($("#divSmallFlashImageContainer").children().length > 0)
	    setInterval('smallGallery()',6000);
}//startSlideShow

function smallGallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#divSmallFlashImageContainer a.show')?  $('#divSmallFlashImageContainer a.show') : $('#divSmallFlashImageContainer a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#divSmallFlashImageContainer a:first') :current.next()) : $('#divSmallFlashImageContainer a:first'));	
	
	//Get next image caption
	var nextImageSrc = next.find('span').attr('src');
	
	//Update background flash image
	thisMovie("slide_js_2").displayImage(nextImageSrc);
	
	//Update next pointer
	next.addClass('show');
	current.removeClass('show');
}//gallery

function startGalleryPreviewFlash(){

    //Build flash
    LoadGalleryPreviewFlash();
    
    //Start timer
    setInterval('previewGallery()',4000);
}//startGalleryPreviewFlash

function previewGallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#divGalleryPreviewFlashImages a.show')?  $('#divGalleryPreviewFlashImages a.show') : $('#divGalleryPreviewFlashImages a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#divGalleryPreviewFlashImages a:first') :current.next()) : $('#divGalleryPreviewFlashImages a:first'));	
	
	//Get next image caption
	var nextImageSrc = next.find('span').attr('src');
	
	//Update background flash image
	thisMovie("slide_gallery_preview").displayImage(nextImageSrc);
	
	//Update next pointer
	next.addClass('show');
	current.removeClass('show');
}//gallery

function LoadGalleryPreviewFlash(){

/*
'width',resValue((523*0.64),(523*0.8),523) + 'px',
'height', resValue((330*0.64),(330*0.8),330) + 'px',
*/

    document.getElementById("divGalleryPreviewFlash").innerHTML = AC_FL_RunContent(
			    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0',
			    'width',resValue((523*0.64),(523*0.8),523) + 'px',
                'height', resValue((330*0.64),(330*0.8),330) + 'px',
			    'src', 'slide_js',
			    'quality', 'high',
			    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			    'align', 'top',
			    'play', 'true',
			    'loop', 'true',
			    'scale', 'exactfit',
			    'wmode', 'transparent',
			    'devicefont', 'false',
			    'id', 'slide_gallery_preview',
			    'bgcolor', '#cccccc',
			    'name', 'slide_gallery_preview',
			    'menu', 'true',
			    'allowScriptAccess','sameDomain',
			    'allowFullScreen','false',
			    'movie', 'slide_js',
			    'FlashVars', "test=false&intern=false&id=smallFlash&lib=img_gallery/&imgs="+ firstPreviewGalleryImage + "&display_sec=4&fade_sec=2&stage_width=100%&stage_height=100%",
			    'salign', 'lt'
			    ); //end AC code
//alert(document.getElementById("divGalleryPreviewFlash").innerHTML);
}//LoadGalleryPreviewFlash

function LoadSmallBackgroundFlash(){
  
     document.getElementById("divSmallFlash").innerHTML = AC_FL_RunContent(
			    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0',
			    'width', '100%',
			    'height', '100%',
			    'src', 'slide_js',
			    'quality', 'high',
			    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			    'align', 'top',
			    'play', 'true',
			    'loop', 'true',
			    'scale', 'noscale',
			    'wmode', 'transparent',
			    'devicefont', 'false',
			    'id', 'slide_js_2',
			    'bgcolor', '#cccccc',
			    'name', 'slide_js_2',
			    'menu', 'true',
			    'allowScriptAccess','sameDomain',
			    'allowFullScreen','false',
			    'movie', 'slide_js',
			    'FlashVars', "test=false&intern=false&id=smallFlash&lib="+backgroundImageFolder+"/&imgs="+ firstSmallBackgroundImage + "&display_sec=4&fade_sec=2&stage_width=100%&stage_height=100%",
			    'salign', 'lt'
			    ); //end AC code           
}//LoadSmallBackgroundFlash

function LoadLargeBackgroundFlash(){
  
     document.getElementById("divContentBackgroundImage").innerHTML = AC_FL_RunContent(
			    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0',
			    'width', '100%',
			    'height', '100%',
			    'src', 'slide_js',
			    'quality', 'high',
			    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			    'align', 'top',
			    'play', 'true',
			    'loop', 'true',
			    'scale', 'noscale',
			    'wmode', 'transparent',
			    'devicefont', 'false',
			    'id', 'slide_js',
			    'bgcolor', '#cccccc',
			    'name', 'slide_js',
			    'menu', 'true',
			    'allowScriptAccess','sameDomain',
			    'allowFullScreen','false',
			    'movie', 'slide_js',
			    'FlashVars', "test=true&intern=false&id=largeFlash&lib="+backgroundImageFolder+"/&imgs="+ firstBackgroundImage + "&display_sec=4&fade_sec=2&stage_width=100%&stage_height=100%",
			    'salign', 'lt'
			    ); //end AC code           
}//LoadLargeBackgroundFlash

function changeLargeFlashToImage(){

    //Change active tab
    $(".tblPhoto .tdPhotoLeftOff").addClass("tdPhotoLeftOn").removeClass("tdPhotoLeftOff");
    $(".tblPhoto .tdPhotoCenterOff").addClass("tdPhotoCenterOn").removeClass("tdPhotoCenterOff");
    $(".tblPhoto .tdPhotoRightOff").addClass("tdPhotoRightOn").removeClass("tdPhotoRightOff");
    
    $(".tbl360Photo .tdPhotoLeftOn").addClass("tdPhotoLeftOff").removeClass("tdPhotoLeftOn");
    $(".tbl360Photo .tdPhotoCenterOn").addClass("tdPhotoCenterOff").removeClass("tdPhotoCenterOn");
    $(".tbl360Photo .tdPhotoRightOn").addClass("tdPhotoRightOff").removeClass("tdPhotoRightOn");

    //show prev/next image
    $(".divBackgroundImagePrev").css({"display": "block"});
    $(".divBackgroundImageNext").css({"display": "block"});
    
    //show text field
    textFieldStartEffect()
    
    //Rebuild background image flash
    document.getElementById("divContentBackgroundImage").innerHTML = AC_FL_RunContent(
		    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0',
		    'width', '100%',
		    'height', '100%',
		    'src', 'slide_js',
		    'quality', 'high',
		    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		    'align', 'top',
		    'play', 'true',
		    'loop', 'true',
		    'scale', 'noscale',
		    'wmode', 'transparent',
		    'devicefont', 'false',
		    'id', 'slide_js',
		    'bgcolor', '#cccccc',
		    'name', 'slide_js',
		    'menu', 'true',
		    'allowScriptAccess','sameDomain',
		    'allowFullScreen','false',
		    'movie', 'slide_js',
		    'FlashVars', "test=false&intern=false&id=largeFlash&lib="+backgroundImageFolder+"/&imgs="+ firstBackgroundImage + "&display_sec=4&fade_sec=2&stage_width=100%&stage_height=100%",
		    'salign', 'lt'
		    ); //end AC code 

    //Check if automatic background change
	if(animatedBackground){
        startSlideShow();
    }//if
}//changeLargeFlashToImage

function changeLargeFlashTo360(){
    
    //Stop background image flash
    clearInterval(backgroundImageTimer);
    
    //Hide text field
    $(".contentTextFieldRoot").addClass("opacityO");
    
    //Hide prev/next image
    $(".divBackgroundImagePrev").css({"display": "none"});
    $(".divBackgroundImageNext").css({"display": "none"});
    
    //Change active tab
    $(".tbl360Photo .tdPhotoLeftOff").addClass("tdPhotoLeftOn").removeClass("tdPhotoLeftOff");
    $(".tbl360Photo .tdPhotoCenterOff").addClass("tdPhotoCenterOn").removeClass("tdPhotoCenterOff");
    $(".tbl360Photo .tdPhotoRightOff").addClass("tdPhotoRightOn").removeClass("tdPhotoRightOff");
    
    $(".tblPhoto .tdPhotoLeftOn").addClass("tdPhotoLeftOff").removeClass("tdPhotoLeftOn");
    $(".tblPhoto .tdPhotoCenterOn").addClass("tdPhotoCenterOff").removeClass("tdPhotoCenterOn");
    $(".tblPhoto .tdPhotoRightOn").addClass("tdPhotoRightOff").removeClass("tdPhotoRightOn");
    
    //change flash to 360
    document.getElementById("divContentBackgroundImage").innerHTML = AC_FL_RunContent(
			    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0',
			    'width', '100%',
			    'height', '100%',
			    'src', 'slide_js',
			    'quality', 'high',
			    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			    'align', 'top',
			    'play', 'true',
			    'loop', 'true',
			    'scale', 'noscale',
			    'wmode', 'transparent',
			    'devicefont', 'false',
			    'id', 'slide_js',
			    'bgcolor', '#cccccc',
			    'name', 'slide_js',
			    'menu', 'true',
			    'allowScriptAccess','sameDomain',
			    'allowFullScreen','false',
			    'movie', flash360Filename,
			    'salign', 'lt'
			    ); //end AC code 
 
}//changeLargeFlashTo360

function LoadFrontPageFlash(){

    //Load flash movie
    document.getElementById("divFrontpageFlashContainer").innerHTML = AC_FL_RunContent(
		    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0',
		    'width', calcValue(1538),
		    'height', calcValue(800),
		    'src', 'front',
		    'quality', 'high',
		    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		    'align', 'top',
		    'play', 'true',
		    'loop', 'true',
		    'scale', 'showall',
		    'wmode', 'transparent',
		    'devicefont', 'false',
		    'id', 'slide_js',
		    'bgcolor', '#cccccc',
		    'name', 'slide_js',
		    'menu', 'true',
		    'allowScriptAccess','sameDomain',
		    'allowFullScreen','false',
		    'movie', 'front',
		    'FlashVars', "test=false&intern=false&lib="+backgroundImageFolder+"/&imgs="+ topPagebackgroundImages +"&txts=" + topPageTitles + "&txts2=" + topPageSubtitles + "&urls=" + topPageURLs + "&display_sec=4&fade_sec=2&stage_width=" + calcValue(1538) + "&stage_height=" + calcValue(800) + "&textbox_height=" + calcValue(10),
		    'salign', 'lt'
		    ); //end AC code 
}//LoadFrontPageFlash

function highlightmenu(n){
	
	$(".highlightMenuItem").removeClass("highlightMenuItem");
	$(".item" + (n+1)).addClass("highlightMenuItem")
}//highlightmenu

function loadGalleryFlash(firstImage){

    document.getElementById("divGalleryBoxFlashBox").innerHTML = AC_FL_RunContent(
		    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0',
		    'width', '100%',
		    'height', '100%',
		    'src', 'slide_js',
		    'quality', 'high',
		    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		    'align', 'top',
		    'play', 'true',
		    'loop', 'true',
		    'scale', 'noscale',
		    'wmode', 'transparent',
		    'devicefont', 'false',
		    'id', 'flashGallery',
		    'bgcolor', '#cccccc',
		    'name', 'flashGallery',
		    'menu', 'true',
		    'allowScriptAccess','sameDomain',
		    'allowFullScreen','false',
		    'movie', 'slide_js',
		    'FlashVars', "test=false&intern=false&id=largeFlash&lib=img_gallery/&imgs="+firstImage+"&display_sec=4&fade_sec=1&stage_width=100%&stage_height=100%",
		    'salign', 'lt'
		    ); //end AC code 
}//

function resValue(value1, value2, value3){

    switch(websiteSize)
    {
        case 0:
            return value1;
        break;
        case 1:
            return value2;
        break;
        case 2:
            return value3;
        break;
    }
}//resValue

/*******************************************/
/**         Script service methods         */
/*******************************************/
var galleryTimer = null;
var galleryImageArr = null;
var currentImageIndex = 0;
function onGetGalleryImagesDataComplete(args){

    //Prepare data for slideshow
    galleryImageArr = args;

    //Load flash
    loadGalleryFlash(galleryImageArr[currentImageIndex]);
    
    //Start update timer.
    galleryTimer = setInterval("UpdateGalleryFlash()", 5000);
}//

function closeFlashGallery(){

    //Stop timer
    clearInterval(galleryTimer);
    
    //Hide gallery
    $("#divGalleryBox").css({"display":"none"});
    $("#divGalleryFlashFrame").css({"display":"none"});
}

function UpdateGalleryFlash(){

    //Update image index
    if(currentImageIndex < galleryImageArr.length -1)
        currentImageIndex++;
    else
        currentImageIndex = 0;

    thisMovie("flashGallery").displayImage(galleryImageArr[currentImageIndex]);
}

function flashGalleryBack(){

    //Stop timer
    clearInterval(galleryTimer);
    
    //Update index
    if(currentImageIndex > 0)
        currentImageIndex--;
    else
        currentImageIndex = galleryImageArr.length -1;
    
    //Show new index
    thisMovie("flashGallery").displayImage(galleryImageArr[currentImageIndex]);
    
    //Check if restart gallery
    if($(".tdGalleryPause").hasClass("show")){
    
        //Start update timer.
        galleryTimer = setInterval("UpdateGalleryFlash()", 5000);
    }
}

function flashGalleryPlay(){
    
    //Stop timer (just in case..)
    clearInterval(galleryTimer);
    
    //Start update timer.
    galleryTimer = setInterval("UpdateGalleryFlash()", 5000);
}

function flashGalleryPause(){

    //Stop timer
    clearInterval(galleryTimer);
}

function flashGalleryNext(){

    //Stop timer
    clearInterval(galleryTimer);
    
    //Update index
    if(currentImageIndex < galleryImageArr.length -1)
        currentImageIndex++;
    else
        currentImageIndex = 0;
    
    //Show new index
    thisMovie("flashGallery").displayImage(galleryImageArr[currentImageIndex]);
    
    //Check if restart gallery
    if($(".tdGalleryPause").hasClass("show")){
    
        //Start update timer.
        galleryTimer = setInterval("UpdateGalleryFlash()", 5000);
    }//if
}

function onGetPackageDealDataComplete(args){

    //Update text content
    $(".divTextDocument").html("<h1>"+ args[0] +"</h1>" + args[1]);

    //Stop background image flash
    clearInterval(backgroundImageTimer);

    //Update background images
    $("#backgroundGallery").html(args[2]);
    $("#backgroundImage").html(args[2]);
    
    firstBackgroundImage = args[3];
    UpdateBackgroundFlash();

    //Reset document top
    $(".divTextDocument").css({"top":"0px"});

    //Init scrollbar (main field)
	InitScrollBar('textFieldCenter','divTextContainer', 'divTextDocument','divScrollbarContainer', false);

	//show text field
    $(".contentTextFieldRoot").animate({left: "" + calcValue(449) + "px", width: "" + calcValue(507)+"px"},1000);
}//

function UpdateBackgroundFlash(){
    
    //Load large background flash
    LoadLargeBackgroundFlash();
    
    //Execute the slideShow
    if(animatedBackground){
        startSlideShow();
    }//if
    else{
        LoadSmallBackgroundFlash();
        startSmallSlideShow();
        
        $(".divBackgroundImagePrev").click(function(){

            //Show previous background image
            prevGallery();
        });
        
        $(".divBackgroundImageNext").click(function(){

            //Show next background image
            gallery();
        });
    }//else
}//

function onGetNewsDataComplete(args){
     
    $(".divRightTextDocument").html("<h1>"+ args[0] +"</h1><span class=\"spanNewsDate\">"+ args[2] +"</span><br />"+ args[1]);

    //Reset document top
    $(".divRightTextDocument").css({"top":"0px"});

    //Init scrollbar (news field)
	InitScrollBar('rightTextFieldCenter','divRightTextContainer', 'divRightTextDocument','divRightScrollbarContainer', false);
                    
    //show right text field
    $(".contentRightTextFieldRoot").animate({width: calcValue(507) + "px"},1000);
}

function onGetEventDataComplete(args){

    //Hide outer container
    $(".divCalenderEventDetailsOuterContainer").css({"top": calcValue(658) + "px"});

    //Update content
    $(".divCalenderEventDetailsDocument").html(args[2] + "<h1>" + args[0] + "</h1>" + args[1]);
    $(".divCalenderEventDetailsImage").attr("src", args[3]);
    $(".divCalenderEventDetailsDocument").css({"top": 0 + "px"});

    //Show root
    $(".divCalenderEventDetailsRoot").css({"display":"block"});
    
    //Init scroll bars
    InitScrollBar('divCalenderEventDetailsOuterContainer','divCalenderEventDetailsContainer', 'divCalenderEventDetailsDocument','divCalenderEventDetailsScrollbarContainer', false);
    
    //Show outer container with slide effect
    $(".divCalenderEventDetailsOuterContainer").animate({top: "0px"},500);
}

function onVoidComplete(args){

}

function OnTimeOut(args) {
    
    //Reload page    
    alert("Service call timed out." + args);
}

function OnError(args) {
    alert("Error calling service method.");
}

function getViewportWidth() {
    
    var width = self.innerWidth;  // Safari
    var mode = document.compatMode;
    if (mode || isIE) { // IE, Gecko, Opera
        width = (mode == 'CSS1Compat') ?
        document.documentElement.clientWidth : // Standards
        document.body.clientWidth; // Quirks
    }
    return width;
}

function getViewportHeight() {
    var height = self.innerHeight; // Safari, Opera
    var mode = document.compatMode;
    if ( (mode || isIE) && !isOpera ) { // IE, Gecko
        height = (mode == 'CSS1Compat') ?
        document.documentElement.clientHeight : // Standards
        document.body.clientHeight; // Quirks
    }
    return height;
}

var continueLeftRoll = true;
var continueRightRoll = true;

function galleryListRollLeft(containerId){

    if(continueLeftRoll){
    
        $(".galleryImage1", $("#"+containerId)).css({"z-index": "2"}).animate({top: calcValue(10) +"px", left: calcValue(50) + "px"},1000, "", function(){
        
            $(this).addClass("galleryImage2").removeClass("galleryImage1");
        });
            
        $(".galleryImage2", $("#"+containerId)).css({"z-index": "3"}).animate({top: calcValue(20) +"px", left: calcValue(100) + "px"},1000, "", function(){
        
            $(this).addClass("galleryImage3").removeClass("galleryImage2");
        });
        $(".galleryImage3", $("#"+containerId)).css({"z-index": "2"}).animate({top: calcValue(10) +"px", left: calcValue(150) + "px"},1000, "", function(){
        
            $(this).addClass("galleryImage4").removeClass("galleryImage3");
        });
        $(".galleryImage4", $("#"+containerId)).css({"z-index": "1"}).animate({top: calcValue(0)  +"px", left: calcValue(200) + "px"},1000, "", function(){
        
            $(this).addClass("galleryImage5").removeClass("galleryImage4");
        });
        $(".galleryImage5", $("#"+containerId)).css({"z-index": "1", opacity: 0.0}).animate({top: calcValue(0)  +"px", left: calcValue(0) + "px"},1000, "", function(){
        
            $(this).addClass("galleryImage1").removeClass("galleryImage5");
            $(this).css({opacity: 1.0});
            
            if(continueLeftRoll){
            
                galleryListRollLeft(containerId);
            }//if
        });
    }
}



function stopGalleryListRollLeft(){

    continueLeftRoll = false;
}

function galleryListRollRight(containerId){

    if(continueRightRoll){
    
        $(".galleryImage3", $("#"+containerId)).css({"z-index": "2"}).animate({top: calcValue(10) +"px", left: calcValue(50) + "px"},1000, "", function(){
        
            $(this).addClass("galleryImage2").removeClass("galleryImage3");
        });
            
        $(".galleryImage4", $("#"+containerId)).css({"z-index": "3"}).animate({top: calcValue(20) +"px", left: calcValue(100) + "px"},1000, "", function(){
        
            $(this).addClass("galleryImage3").removeClass("galleryImage4");
        });
        $(".galleryImage5", $("#"+containerId)).css({"z-index": "2"}).animate({top: calcValue(10) +"px", left: calcValue(150) + "px"},1000, "", function(){
        
            $(this).addClass("galleryImage4").removeClass("galleryImage5");
        });
        $(".galleryImage1", $("#"+containerId)).css({"z-index": "1",opacity: 0.0}).animate({top: calcValue(0)  +"px", left: calcValue(200) + "px"},1000, "", function(){
        
            $(this).addClass("galleryImage5").removeClass("galleryImage1");
            $(this).css({opacity: 1.0});
        });
        $(".galleryImage2", $("#"+containerId)).css({"z-index": "1"}).animate({top: calcValue(0)  +"px", left: calcValue(0) + "px"},1000, "", function(){
        
            $(this).addClass("galleryImage1").removeClass("galleryImage2");
            
            if(continueRightRoll){
            
                galleryListRollRight(containerId);
            }//if
        });
    }
}

function stopGalleryListRollRight(){

    continueRightRoll = false;
}