    var ajax_script = '/doAjax';
	var advertFinished = false;
    
    $().ready(function() {
    	/*@cc_on
    	(function(f){
    	 window.setTimeout =f(window.setTimeout);
    	 window.setInterval =f(window.setInterval);
    	})(function(f){return function(c,t){var a=[].slice.call(arguments,2);return f(function(){c.apply(this,a)},t)}});
    	@*/
    	
    	if($('.hotel-features-list').length > 0) {
    		$('.hotel-features-list a').css({'cursor':'default'})
    		$('.hotel-features-list a').click(function() {
    			return false;
    		});
    		
    	}
		
		// luxos recommends
		if($('.recommends-link').length >0){
			$('#feature-name').hide();
			
			$('.recommends-link').hover(
				function() {
					$('.recommends-link').css({opacity:'0.4'});
					$(this).css({opacity:'1'});
					$('#feature-name').html($('a',this).attr('rel')).show();
				},
				function() {
					$('.recommends-link').css({opacity:'1'});
					$('#feature-name').hide();
				}
			)
			
		}
		
		$('.image-Ad').hover(
			function() {
				if($('.image-Ad img').length) {
					$('#mainImageCaption').slideDown();
				}
			},
			function() {
				if($('.image-Ad img').length) {
					$('#mainImageCaption').slideUp();
				}
			}
		)
		
		$('.image-Ad').hover(
			function() {
				if($('#article-slideshow').css('display') != 'none') {
					$('#slideshow-caption-text').addClass('caption-active');
					if($('#slideshow-caption-text span').html() != '&nbsp;') {
						$('#slideshow-caption-text').slideDown();
					}
				}
			},
			function() {
				if($('#article-slideshow').css('display') != 'none') {
					$('#slideshow-caption-text').removeClass('caption-active');
					$('#slideshow-caption-text').slideUp();
				}
			}
		)
		
		if($('.fashion-credits-link a').length > 0) {
			
			$('.fashion-credits-box-close').click(function() {
				$('.fashion-credits-link').fadeOut('500');
				$('.fashion-credits-box').fadeOut('1000', function() {
					$('.fashion-credits-link').css({left:''})
					$('.fashion-credits-link').fadeIn('1000');
					$('.fashion-article-thumbs-goleft').fadeIn('1000');
					$('.fashion-article-thumbs-goright').fadeIn('1000');
					$('.fashion-article-thumbs-content').fadeIn('1000');
					$('.fashion-article-thumbs-title').fadeIn('1000');
				});
				return false;
			});
			
			
			$('.fashion-credits-box').hide();
			$('.fashion-credits-link a').click(function() {
				$('.fashion-article-thumbs-goleft').fadeOut('1000');
				$('.fashion-article-thumbs-goright').fadeOut('1000');
				$('.fashion-article-thumbs-content').fadeOut('1000');
				$('.fashion-article-thumbs-title').fadeOut('1000');
				$('.fashion-credits-link').fadeOut('1000',function() {
					$(this).css({left:'0px'}).fadeIn('500');
					$('.fashion-credits-box').fadeIn('500');
				});
				return false;
			});
		}
		
		generateTagCloud();
		
	
		if ($('#home-main').length > 0) {
			var homePageFlashVars = {};
			homePageFlashVars.strXMLPath = "/xml/featured-articles-xml.php";
			var homePageParams = {};
			var homePageAttributes = {};
			homePageParams.allowscriptaccess = "always";
			swfobject.embedSWF("/interface/flash/home_slideshow.swf", "home-main", "504", "433", "9.0.0", "/interface/flash/expressInstall.swf", homePageFlashVars, homePageParams, homePageAttributes);
		}
		
        if($('.countries').length > 0) {
            $('.countries').change(function() {
                // get cities
                $.post(ajax_script,{action:'get_cities',id:$(this).val()},function(r) {
                    if(r != '') {
                        eval('response='+r);
                        var html = '<option value="0">Please choose a city</option>';
                        html += '<option value="0">All</option>';
                        for(var i=0; i<response.length; i++) {
                            html += '<option value="' +response[i].id +'">'+response[i].name+'</option>';
                        }
                        $('.cities').html(html);
                    }
                });
            });
        }
		
		if($('.mag-home-main img').attr('src') == '/interface/images/video_placeholder.jpg') {
			var catId = 0;
			
			// check if a magazine category page has been accessed manually via a url
			// if so show the appropriate slideshow
			
			if($('.manual-access').length > 0) {
				catId = $('#this-issue').attr('class');
				catId = catId.match(/cat_(\d+)/)[1];
			}
			
			if(location.href.match(/\/magazine\/fashion/)) {
				catId = 2;
			}
			
			hasFaded(catId);
		}
		
        if($('.magazine-link').length > 0) {
            $('.magazine-link').click(function() {
                var catId = $(this).attr('id');
                catId = catId.match(/cat_(\d+)/)[1];
				//magazine page slideshow
				if($('#this-issue img').length) {
					hasFaded(catId);
				} else {
					$('#this-issue')[0].endClip(catId );
				}		
				
                $.post(ajax_script,{action:'get_latest_articles',catId:catId},function(r) {
                    eval('response='+r);
                    if(response.status == 'success') {
                        $('#mag-home-recent').fadeOut(250,function() {
                            $('#mag-home-recent').html(response.html).fadeIn(250);
                            viewLatestArticlesListener();
                        });
                    }
                });

                return false;
            });
        }

        if($('#mag-home-viewlatest').length > 0) {
           viewLatestArticlesListener();
        }

        if($('#worldmap').length > 0) {
            var amfURL = "http://"+$('#worldmap').html()+"/amf-service.php";
            swfobject.embedSWF('/interface/flash/WorldMap.swf', 'worldmap', 503, 434, '9.0.0', '', {"amfBootstrap": amfURL}, {wmode: "transparent"}, {});
        }

        if($('#streetmap').length > 0) {
            var amfURL = escape("http://"+$('#streetmap').html()+"/amf-service.php");
            var cityId = $('.city-map-img').attr('id');
            cityId = cityId.match(/city_(\d+)/)[1];

            swfobject.embedSWF('/interface/flash/StreetMap.swf', 'streetmap', 714, 414, '9.0.0', '', {
                "locationId": cityId,
                "mapURL": $('#map-img').attr('src'),
                "amfBootstrap": amfURL
            }, {wmode: "transparent"}, {});
            $('#map-img').remove()
        }

        if($('#localtime').length > 0) {
            setTime();
            setInterval("setTime()",1000);
        }

        if($('#hotel-gallery').length > 0) {
            $('.gallery').click(function() {
                var hotelId = $('#hotel-gallery').attr('class');
                hotelId = hotelId.match(/hotel_(\d+)/)[1];
                
                var imageId = $(this).attr('id');
                imageId = imageId.match(/image_(\d+)/)[1];

                doGallerySlideshow(hotelId,imageId);
                return false;
            }); 
        }

        if($('#inline-advert').length > 0) {
        	$('#article-image dl dt,#article-image dl dd').hide();
			$('#slideshow-captions-background, #slideshow-captions').hide();

            var advertId = $('.advert').attr('id');
            advertId = advertId.match(/ad_(\d+)/)[1];
            var params = {};
            var flashvars = {};
			params.allowscriptaccess = "always";
			flashvars.strXMLPath = "/xml/inline-advert-xml.php?id="+advertId;
            swfobject.embedSWF("/interface/flash/inline-advert.swf","inline-advert","426","433","9.0.0","/interface/flash/expressInstall.swf", flashvars, params, {"wmode": "transparent"});
        }

        if($('#full-advert').length > 0) {
            var fullAdvertId = $('.full-advert').attr('id');
            fullAdvertId = fullAdvertId.match(/ad_(\d+)_\d+/)[1];
			var flashvars = {};
			flashvars.strXMLPath = "/xml/full-advert-xml.php?id="+fullAdvertId;
			var params = {};
			var attributes = {};
			params.allowscriptaccess = "always";
			params.wmode = "opaque";
            $('#full-advert').css({zindex:5});
            swfobject.embedSWF("/interface/flash/large_inline-advert.swf", "full-advert", "904", "455", "9.0.0", "/interface/flash/expressInstall.swf", flashvars, params, attributes);
        }
		
        if($('#article-slideshow').length > 0) {
        	initCaptions();
        	$('#article-image dl dt,#article-image dl dd,#mainImageCaption').hide();
			$('#slideshow-captions').hide();
			$('#slideshow-caption-text').hide();
            var articleId = $('.article').attr('id');
            articleId = articleId.match(/article_(\d+)/)[1];
            var articleParams = {advertId:articleId,Id:articleId};
            var articleFlashvars = {advertId:articleId,Id:articleId};
			if ($('.article').hasClass("hotel")) {
				articleFlashvars.strXMLPath = "/xml/hotel-slideshow-xml.php?id=" + articleId;
			} else if($('.article').hasClass("other")) {
				articleFlashvars.strXMLPath = "/xml/other-slideshow-xml.php?id=" + articleId;
			} else {
				articleFlashvars.strXMLPath = "/xml/slideshow-xml.php?id=" + articleId;
			}
			swfobject.embedSWF("/interface/flash/article-slideshow.swf","article-slideshow","426","433","9.0.0","/interface/flash/expressInstall.swf", articleFlashvars, articleParams,  {"wmode": "transparent"});
        }

        // external urls
        $('a').click(function(){
    	    if((this.href.match(/^http/i) && !this.href.match(location.host)) || this.rel=='external'){
    		    window.open(this.href,'_');
    		    return false;
    	    }
    	});
        
        doLoginForm();
        doLogOut();
        if($('#loginform').length > 0) {
            $('#loginform').hide();
        }

        if($('#hotel-contact-map').length > 0) {
            var address = $('#hotel-contact-address').html();
            loadGoogleMap(address,'hotel-contact-map');
        }
		
		if($('#search-map').length > 0) {
			loadSearchPageGoogleMap('search-map')
		}

        
        if($('#country').length > 0) {
            $('#country').change(function() {
                // get cities
                $.post(ajax_script,{action:'get_cities',id:$(this).val()},function(r) {
                    if(r != '') {
                        eval('response='+r);
                        var html = '<option value="0">Please choose a city</option>';
                        for(var i=0; i<response.length; i++) {
                            html += '<option value="' +response[i].id +'">'+response[i].name+'</option>';
                        }
                        $('#city').html(html);
                    }
                });
            });
        }
        
        
        if($('.advert_link').length > 0) {
            $('.advert_link').click(function() {
                var href = $(this).attr('href');
                var bits = window.screen.colorDepth;
                var colours = Math.pow (2, bits);
                var width = screen.width
                var height = screen.height
                var query = 'ajaxRequest=1&colours='+colours+'&bits='+bits+'&width='+width+'&height='+height+'&js=1';
                var url = '/advert';
                
                $.ajax({
                    type:       "GET",
                    url:        url,
                    data:       query,
                    success:    function(r) {
                                    if(r == '') {
                                        location.href=href;
                                    }
                                }
                });
                    
                
                return false;
            });
        }
        
        if($('.advert').length > 0) {
            $('.advert').hide();
        }
        
        if($('.full-advert').length > 0) {
            $('.full-advert').hide();
            var timeIn = $('.full-advert').attr("data");
            timeIn = timeIn.match(/(\d+):\d+/)[1] * 1000;
            setTimeout("showFullPageAd()",timeIn);
        }
        
        if($('.article').length > 0) {
            $('.article').hide();
            $('.title').append('<a id="read_article" class="read-more-button" href="#">Read More</a>');
            $('#read_article').click(function() {
                $('#title-image').fadeOut(1000,function(){
                    $('#article-slideshow').fadeIn(1000,function() {
                        $('#title-image').remove();
                    });
                });
                
                
                $('.title').fadeOut(1000,function() {
					// check for members access
					if (!$('.article').hasClass('membersonly')) {
					
						// add paging div
						$('.article').append('<div id="paging"></div>');
						
						// get the number of p tags as these will become pages
						var pages = $('.article p').length;
						
						// add an id to each paragraph to repesent the page number
						// also add an a tag to the paging div to represent a click for each page
						for (var i = 0; i < pages; i++) {
							$('.article p:nth(' + i + ')').attr("id", "page-" + (i + 1));
							$('#paging').append('<a class="page page-'+(i+1)+'" href="#page-' + (i + 1) + '">' + (i + 1) + '</a>&nbsp;');
						}
						
						// setup prev and next pages after all the page links have been added
						$('#paging').prepend('<a class="prev" href="#prev"><</a>&nbsp;');
						$('#paging').append('<a class="next" href="#next">></a>&nbsp;');
						
						// now hide the prev link cos we're on the first page
						$('.prev').hide();
						
						// now hide the next link if the article is only one page long
						if (pages == 1) {
							$('.next').hide();
						}
						
						// hide all pages and give them the class hidden
						$('.article p').hide().addClass("hidden");
						
						// show the first page and remove class hidden and add a class if current
						$('.article p:nth(0)').show().removeClass("hidden").addClass("current");
						
						// inject the h2 and small tags into the first page
						// and remove them
						var title = $('.article h2').html();
						$('.article h2').remove();
						var subline = $('.article small').html();
						$('.article small').remove();
						if (title && subline) {
							$('.article p:nth(0)').prepend('<h2>' + title + '</h2><small>' + subline + '</small><br />');
						}
						// show the article div
						$('.article').fadeIn(1000);
						
						// setup the paging links so that they show the appropriate page
						// when clicked
						$('.page').click(function() {
							var nextPage = $(this).attr("href");
							var currentPage = $('p.current');
							showPage(nextPage, currentPage, $(this));
							return false;
							
						});
						
						// setup next link so that when it is click the appropriate
						// page will show
						$('.next').click(function() {
							var currentPage = $('p.current');
							var nextPageId = $('.current').next().attr('id');
							var nextPage = '#'+nextPageId;
							var currentLink = $('.'+nextPageId);
							advertFinished = true;
							showPage(nextPage, currentPage, currentLink);
							return false;
						});
						
						// setup prev link so that when it is click the appropriate
						// page will show
						$('.prev').click(function() {
							var currentPage = $('.current');
							var nextPageId = $('.current').prev().attr('id');
							var nextPage = '#'+nextPageId;
							var currentLink = $('.'+nextPageId);
							showPage(nextPage, currentPage, currentLink);
							return false;
						});
						showAdvert("#page-1");
						$('.page:first').css({
							color: "#000000"
						});
					} else {
						
						$('.article-members-info').fadeIn(1000);
					}
                });
                
                return false;
            });
        }

    }); // end of document.ready

	function hasFaded(catId) {
		var magFlashvars = {};
		magFlashvars.strXMLPath = "/xml/magazine-articles-xml.php?catId="+catId;
		var magParams = {};
		var magAttributes = {};
		magParams.allowscriptaccess = "always";
		magParams.wmode = "transparent";
		swfobject.embedSWF("/interface/flash/magazine-home.swf", "this-issue", "355", "436", "9.0.0", "/interface/flash/expressInstall.swf", magFlashvars, magParams, magAttributes);
	}
	
    function setTime() {
        var offset = $('.city-map-header').attr('id');
        offset = offset.match(/utc_(.+)/)[1];
        var date = convertTime(offset);
        var hours = date.getHours();
        var mins = date.getMinutes();
        var secs = date.getSeconds();
        if(secs <=9) {secs = '0'+secs}
        if(mins <=9) {mins = '0'+mins}
        if(hours <=9) {hours = '0'+hours}
        var time = hours +':'+mins+':'+secs;
        
        $('#localtime').html(time);
    }

    function convertTime(offset) {
        // create Date object for current location
        d = new Date();
        if(d.dst()) {
            offset = parseInt(offset)+1;
        }
        // convert to msec
        // add local time zone offset
        // get UTC time in msec
        utc = d.getTime() + (d.getTimezoneOffset() * 60000);

        // create new Date object for different city
        // using supplied offset
        nd = new Date(utc + (3600000*offset));

        // return time as a string
        
        return nd;
    }
    
    function doLoginForm() {
       /* $('#btn_login').click(function() {
            $('#login_img').attr('src','/interface/images/submit.jpg');
            $('#btn_login').attr('id','btn_submit');
            $('#loginform').fadeIn(function() {
                addSubmitHandler();
            });
            
            return false;
        });*/
    }
    
    function doLogOut() {
       /* $('#logout').click(function() {
            var id = $(this).attr('href');
            id = id.match(/.+\/(\d+)/)[1];
            $.ajax({
                type:       "GET",
                dataType:   "json",
                url:        '/logout',
                data:       'ajaxRequest=1&id='+id,
                loading:    $('#loginform').html('<p><img src="/interface/images/ajax-loader.gif" alt='' /> Processing logout..</p>'),
                complete:   '',
                success:    function(r) {
                                if(r.status == 'SUCCESS') {
                                    $('#login-wrapper').fadeOut(function() {
                                        $('#login-wrapper').html(r.content);
                                        $('#loginform').hide();
                                        doLoginForm();
                                        $('#login-wrapper').fadeIn(1000);
                                    });
                                    
                                    
                                }
                            }
            });
            return false;
        });*/
    }
    
    function addSubmitHandler() {
        $('#btn_submit').click(function() {
            var email = $('.email').val();
            var password = $('.password').val();
            $.ajax({
                type:      "POST",
                dataType:   "json",
                url:       '/login',
                data:      'submit=1&ajaxRequest=1&email='+email+'&password='+password,
                loading:   $('#loginform').html('<p><img src="/interface/images/ajax-loader.gif" alt="Loading..." /> Processing login..</p>'),
                complete:  '',
                success:    function(r) {
                                if(r.status == 'SUCCESS') {
                                    $('#login-wrapper').fadeOut(function() {
                                        $('#login-wrapper').html(r.content).fadeIn();
                                        doLogOut();
                                    });
                                } else if(r.status == 'FAILED') {
                                    //$('#loginform').show();
                                    $('#login-wrapper').html(r.content).fadeIn();
                                    $('#try').click(function() {
                                        $('#login-wrapper').fadeOut(function() {
                                            $('#login-wrapper').html(r.form);
                                            $('#login_img').attr('src','/interface/images/submit.jpg');
                                            $('#btn_login').attr('id','btn_submit');
											$('#btn_login').attr('alt','submit');
                                            $('#login-wrapper').fadeIn();
                                            addSubmitHandler();
                                        });
                                        return false;
                                    });
                                    //location.href = '/login';
                                }
                                doLoginForm();
                            }
                
            });
            
            return false;
        });
    }

    function showPage(nextPage,currentPage,obj) {
		//IE fix
		nextPage = nextPage.match(/(.*)?(#page\-\d+)(.*)?/)[2];

        showAdvert(nextPage);
        $(currentPage).fadeOut(500,function() {
            $('.article p').hide().addClass("hidden").removeClass("current");
            $(nextPage).fadeIn(500).removeClass("hidden").addClass("current");
            $('a.page').css({"font-weight":"normal"});
            $('.page').attr('style','');
            $(obj).css({"font-weight":'bold',color:'#000000'});
            var nextLink = $(obj).next();
            var prevLink = $(obj).prev();
            if($(nextLink).hasClass('next')) {
                $('.next').hide();
            } else {
                $('.next').show();
            }
            
            if($(prevLink).hasClass('prev')) {
                $('.prev').hide();
            } else {
                $('.prev').show();
            }
            
        },nextPage);
    }
    
    function hideFullPageAd() {
        //$('.full-advert').fadeOut(1000);
    	 $('.full-advert').animate({left:'-906px'},1000,'linear');	 
    }
    
    function showFullPageAd() {
        $('#wrapper').css({'overflow-x':'hidden'});
        $('.full-advert').css({left:'906px',display:'block'});
        //$('.full-advert').fadeIn(1000, function() {
        $('.full-advert').animate({left:'0px'},1000,'linear', function() {
            $('#close_full_advert').click(function() {
                hideFullPageAd();
            })
            var id = $('.full-advert').attr('id');
            id = id.match(/ad_(\d+)/)[1];
            var bits = window.screen.colorDepth;
            var colours = Math.pow (2, bits);
            var width = screen.width
            var height = screen.height
            var query = 'ajaxRequest=1&id='+id+'&colours='+colours+'&bits='+bits+'&width='+width+'&height='+height+'&page='+location.pathname+'&js=1';
            var url = '/tracker';
            
            $.ajax({
                type:   "GET",
                url:    url,
                data:   query
            });
            
            var timeOut = $('.full-advert').attr("data");
            timeOut = timeOut.match(/\d+:(\d+)/)[1] * 1000;
            setTimeout("hideFullPageAd()",timeOut);
        });
    }
    
    function showAdvert(page) {
        if(page == '#page-1' && $('.advert').length > 0) {
        	$('#slideshow-captions-background, #slideshow-captions').hide();
			
        	$('#article-image dl dt,#article-image dl dd').hide();
            $('.image-Ad').fadeOut(500,function() {
                var id = $('.advert').attr('id');
                id = id.match(/ad_(\d+)/)[1];
                var bits = window.screen.colorDepth;
                var colours = Math.pow (2, bits);
                var width = screen.width
                var height = screen.height
                var query = 'ajaxRequest=1&id='+id+'&colours='+colours+'&bits='+bits+'&width='+width+'&height='+height+'&page='+location.pathname+'&js=1';
                var url = '/tracker';
                
                //$('.advert').after('<img id="tracker" src="'+url+query+'" />');
                $('.advert').fadeIn(500, function() {
                    $.ajax({
                        type:   "GET",
                        url:    url,
                        data:   query
                    });
                });

				if ($('.advert').attr("data")) {
					var timeOut = $('.advert').attr("data");
		            if(timeOut) {
						timeOut = timeOut.match(/\d+:(\d+)/)[1] * 1000;
						if(timeOut > 0) {
							setTimeout('hideAdvert()', timeOut);
						}
		            }
				}
            });
        } else {
            $('.advert').fadeOut(500,function() {
                $('.image-Ad').show();
                $('#tracker').remove();
            });
        }
    }
	
	function hideAdvert() {
		 $('.advert').fadeOut(500,function() {
			advertFinished = true;
            $('.image-Ad').show();
            $('#tracker').remove();
			if(!$('#article-slideshow').length) {
				$('#title-image').fadeIn(500);
			}
        });
	}

    function doGallerySlideshow(hotelId,imgId) {
		 var current = 0;
         var images = 0; //$('#hotel-gallery dd').length;
        $.ajax({
            type:       "POST",
            dataType:   "json",
            url:        "/doAjax",
            data:       "action=load_gallery_images&id="+hotelId+"&current="+imgId,
            success:    function(r) {
                            if(r.status == "success") {
                            	images = r.images;
                            	
                                //$('#hotel-gallery').css({height:"100%"});
                                $('#hotel-gallery').fadeOut(1000, function() {
                                    $('#hotel-gallery').html(r.html);
                                    $('#hotel-gallery').wrap('<div id="hotel-slideshow-viewport"></div>');

                                    //$('.hotel-home-recommend-row').after('<div id="slideshow-paging"></div>');
                                    $('#content').append('<div id="slideshow-paging"></div>');
                                    // setup prev and next pages after all the page links have been added
                                    $('#slideshow-paging').prepend('<a class="prev" href="#prev"><</a>&nbsp;');
                                    $('#slideshow-paging').append('<a class="next" href="#next">></a>&nbsp;');

                                                                       
                                    $('#hotel-gallery').attr('id','hotel-gallery-slideshow').fadeIn(1000);
                                    var selected = r.position * 615;
                                    $("#hotel-gallery-slideshow").css({left:'-'+selected+'px'});
									$('.hotel-gallery-slideshow:nth('+r.position+')').addClass("current");
									
									nextImgClick();
									prevImgClick();
									
									 // setup next link so that when it is click the appropriate
                                    // page will show
                                    $('.next').click(function() {
                                        nextClick();
										nextImgClick();
										prevImgClick();
                                    });

                                    // setup prev link so that when it is click the appropriate
                                    // page will show
                                    $('.prev').click(function() {
                                      	prevClick();
                                    });
									
                                    current = r.position;
                                   

                                });
                                
                            }
							
							function nextImgClick() {
								
								$('dd').removeClass("nextImg");
								$('.current').next('dd').addClass('nextImg');
								$('.nextImg').unbind('click');
								$('.nextImg').click(function() {
									nextClick();								
									return false;
								});
								
							}
							
							function prevImgClick() {
								$('dd').removeClass("prevImg");
								$('.current').prev('dd').addClass('prevImg');
								$('.prevImg').unbind('click');
								$('.prevImg').click(function() {
									prevClick();
									return false;
								});
							}
							
							function nextClick() {
								if(current < images-1) {
                                        $("#hotel-gallery-slideshow").animate({left: "-=615px"}, 1000);
                                        //showFashionPage($('.currentFashionImg').next(),$('.currentFashionImg'));
                                        $('.current').removeClass("current").next('dd').addClass("current");
                                        current++;
                                    }
									nextImgClick();
									prevImgClick();
                                    return false;	
							}
							
							function prevClick() {
								if(current > 0) {
                                    $("#hotel-gallery-slideshow").animate({left: "+=615px"}, 1000);
                                    //showFashionPage($('.currentFashionImg').prev(),$('.currentFashionImg'));
                                    $('.current').removeClass("current").prev('dd').addClass("current");
                                    current--;
                                }
								nextImgClick();
								prevImgClick();
                                return false;
							}
                        }
      });
    }

    function loadGoogleMap(address,element) {
     	if (GBrowserIsCompatible()) {
       		showAddress(address,element);
      	}
    }
	
	// Creates a marker whose info window displays the letter corresponding
	// to the given index.
	function createMarker(point, index) {
	 	 // Create a lettered icon for this point using our icon class
		  var letter = String.fromCharCode("A".charCodeAt(0) + index);
		  var letteredIcon = new GIcon(baseIcon);
		  letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
		
		  // Set up our GMarkerOptions object
		  markerOptions = { icon:letteredIcon };
		  var marker = new GMarker(point, markerOptions);
		
		  GEvent.addListener(marker, "click", function() {
		    marker.openInfoWindowHtml("Marker <b>" + letter + "</b>");
		  });
		  return marker;
	}
	
	
	function loadSearchPageGoogleMap(element) {
		var bounds = new GLatLngBounds();
		var map = new GMap2(document.getElementById(element));
		//map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); 
		var customUI = map.getDefaultUI();
        // Remove MapType.G_HYBRID_MAP
        customUI.maptypes.hybrid = false;
        map.setUI(customUI);
		
		// Create our "tiny" marker icon
		var tinyIcon = new GIcon();
		tinyIcon.image = "/interface/images/small_bub.png";
		//tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		tinyIcon.iconSize = new GSize(22, 28);
		tinyIcon.shadowSize = new GSize(22, 20);
		tinyIcon.iconAnchor = new GPoint(6, 20);
		tinyIcon.infoWindowAnchor = new GPoint(5, 1);
		
		// Set up our GMarkerOptions object literal
		markerOptions = { icon:tinyIcon };
		
		$('.address').each(function() {
			
			var html = $(this).html();
			var address = html;
			html = '<p>'+$(this).prev('div.boutique').html() +'<br />' + html +'</p>';

			var latLng = $(this).attr('id');
			if (latLng.length) {
				var lat = latLng.match(/latlng_(\d+\.\d+).+/)[1];
				var  lng = latLng.match(/latlng_\d+\.\d+:(\d+\.\d+)/)[1];

				var point = new GLatLng(lat, lng);
				if (point) {
					 if(!bounds.containsLatLng(point) ) {
						bounds.extend(point);
						map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
					}
					var marker = new GMarker(point, markerOptions);
					
					GEvent.addListener(marker, "click", function() {

						map.openInfoWindowHtml(point, html);

					});
					map.addOverlay(marker);
				}
			} else {
				var geocoder = new GClientGeocoder();

				geocoder.getLatLng(address, function(point) {
					if (point) {
						var marker = new GMarker(point,markerOptions);
						if (!bounds.containsLatLng(point)) {
							bounds.extend(point);
							map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
						}
						GEvent.addListener(marker, "click", function() {
			   				map.openInfoWindowHtml(point, html);
						});
						map.addOverlay(marker);
					}
				});
			}
		});
	}

    function showAddress(address,element) {
		
		// Create our "tiny" marker icon
		var largeIcon = new GIcon();
		largeIcon.image = "/interface/images/big_bub.png";
		//tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		largeIcon.iconSize = new GSize(29, 38);
		largeIcon.shadowSize = new GSize(22, 20);
		largeIcon.iconAnchor = new GPoint(6, 20);
		largeIcon.infoWindowAnchor = new GPoint(5, 1);
		
		// Set up our GMarkerOptions object literal
		markerOptions = { icon:largeIcon };
		
		if ($('#'+element).hasClass("latLong")) {
			var lat = $('input[name="lat"]','#'+element).val();
			var lng = $('input[name="long"]','#'+element).val();
			
			var map = new GMap2(document.getElementById(element));
			var point = new GLatLng(lat, lng);
			var marker = new GMarker(point,markerOptions);
			map.addOverlay(marker);
			marker.openInfoWindowHtml(address);
			map.setCenter(point, 13);
			var customUI = map.getDefaultUI();
	        // Remove MapType.G_HYBRID_MAP
	        customUI.maptypes.hybrid = false;
	        map.setUI(customUI);



		} else {
			var geocoder = new GClientGeocoder();
			geocoder.getLatLng(address, 
			function(point) {
				var map = new GMap2(document.getElementById(element));
				if (!point) {
				//alert(address + " not found");
				} else {
					map.setCenter(point, 13);
					var marker = new GMarker(point,markerOptions);
					map.addOverlay(marker);
					marker.openInfoWindowHtml(address);
					var customUI = map.getDefaultUI();
			        // Remove MapType.G_HYBRID_MAP
			        customUI.maptypes.hybrid = false;
			        map.setUI(customUI);
				}
			});
		}
    }

    function viewLatestArticlesListener() {
         $('#mag-home-viewlatest').click(function() {
            $.post(ajax_script,{action:'get_latest_articles',catId:0},function(r) {
                    eval('response='+r);
                    if(response.status == 'success') {
                        $('#mag-home-recent').fadeOut(250,function() {
                            $('#mag-home-recent').html(response.html).fadeIn(250);
                        });
                    }
                });
           });
    }
	
	 function generateTagCloud() {
        var catContainer = $('div.blog-menu-cloud');
        // get an array of all the <li>'s
        //var categories = catContainer.find('li');
        var cloudMarkup = '';
        // set maxPercent/minPercent preferences
        var maxPercent = 200, minPercent = 100;
        // note that max is initialized to a number that I know is lower than the max count
        // and that min is set to a number larger than the known min count
        var max = 1, min = 999, count = 0;
        // loop through each li and calculate statistics
        $('a',catContainer).each(function(i) {
            count = parseInt($(this).attr('rel'));
            max = (count > max ? count : max);
            min = (min > count ? count : min);
        });
        var total, link, size;
        var multiplier = (maxPercent-minPercent)/(max-min);
        // loop through each li and generate the markup for the new tag cloud
         $('a',catContainer).each(function(i) {
            count = parseInt($(this).attr('rel'));
            link = $(this); //.find('a');
            size = minPercent + ((max-(max-(count-min)))*multiplier) + '%';
            link.css({'font-size':size});
        });

    }
	

    function onPointOver(data){
        // user has rolled over plot point
		var nameLength = 20;
		var contentLength = 200;
		 $.post(ajax_script,{action:'get_map_point','typeId':data.categoryId,'id':data.id,'cityId':data.locationId},function(r) {
            eval('response='+r);
            if(response.status == 'success') {
			   if (!response.data.fname) {
			   		$('.city-map-info-img img').attr('src', '/interface/images/' + response.data.placeholder);
			   } else {
			   		$('.city-map-info-img img').attr('src', '/uploads' + response.data.fname);
			   }
			   $('.city-map-info-img img').attr('alt','image');
			   $('.city-map-info-img a').attr('href',response.data.url);
			   var name = response.data.name.substr(0,nameLength);
			   if(response.data.name.length > nameLength) {name+= '...';}
			   var content = response.data.content.substr(0,contentLength);
			   if(response.data.content.length > contentLength) {content+='...';}
               $('#name').html(name);
               $('.city-map-info-text').html(content);
            }
        });
       
    }

    function onPointOut(data){
        // user has rolled out of plot point
        
    }

    function onPointClick(data){
        // user has clicked plot point
       
    }
    
    function initCaptions() {
    	$('dl#slideshow-captions').before('<div id="slideshow-caption-text"><span></span></div>');
    	$('#slideshow-caption-text').hide();
    }
    
    
    function changeCaption(domId) {		
    	if($('#caption_'+domId).length > 0 && advertFinished) {
			//$('#slideshow-caption-text').show();#
    		$('#mainImageCaption').hide();
    		
    		$('#slideshow-caption-text span').fadeOut(200,function() {
    			$('#slideshow-caption-text span').html($('#caption_'+domId+' span').html());
    			if($('#slideshow-caption-text').hasClass("caption-active")) {
    				$('#slideshow-caption-text').fadeIn(200);
        		}
    			$('#slideshow-caption-text span').fadeIn(200);
    		})
			
		} else {
			$('#slideshow-caption-text span').html('&nbsp;');
			$('#slideshow-caption-text').hide();
		}
    }

    // extra methods added to the date object to
    // deal with daylight saving
    Date.prototype.stdTimezoneOffset = function() {
        var jan = new Date(this.getFullYear(), 0, 1);
        var jul = new Date(this.getFullYear(), 6, 1);
        return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
    }

    Date.prototype.dst = function() {
        return this.getTimezoneOffset() < this.stdTimezoneOffset();
    }