$(document).ready(function(){
$('.out').mouseover(function(){
        $(this).addClass("over");        
    }).mouseout(function(){
        $(this).removeClass("over");        
    });
     P7_initPM(2,0,0,-20,10);
     P8_initPM(1,0,0,-20,10);
     //$(".quick_links_text.open").show();
     $('.content_right_reservations_quick_links').click(function(){
        var quickCon = $(this).parent();
        $(".quick_links_text", quickCon).toggle("fast");        
    });
    if ( $("body").hasClass("zakelijk")){    
        $("a:first",".topMenu_0").css("color", "#F19302");        
    }
    if ( $("body").hasClass("toerisme")){    
        $("a:first",".topMenu_1").css("color", "#F19302");        
    }
    if ( $("body").hasClass("sport")){    
        $("a:first",".topMenu_2").css("color", "#F19302");        
    }
    if ( $("body").hasClass("algemeen")){    
        $("a:first",".topMenu_3").css("color", "#F19302");        
    }
    if ( $("#pviewer").length > 0){
	    var so = new SWFObject("/flash/panoplayer.swf?xmlLink=/flash/pano.xml", "pviewer", "515", "728", "8", "#FFFFFF");
	    so.write("pviewer");
    }
    
    
});


function changeLanguage(language)
{
    // language NL and on papendal.com --> go to papendal.nl
    if (document.location.href.indexOf('papendal.com') != -1 && language == 1)
    {
        document.location.href = document.location.href.replace('papendal.com', 'papendal.nl');
    }

    // language EN and on papendal.nl --> go to papendal.com
    if (document.location.href.indexOf('papendal.nl') != -1 && language == 2)
    {
        document.location.href = document.location.href.replace('papendal.nl', 'papendal.com');
    }
}

$(document).ready(function() {
    /*get prices*/
    var thumbCount = 0;
    var curThumb = 0;
    var albumID = $(".albumID").text();
    $(".thumbBalk").css("left", "0");
    $.ajax({
        type: "GET",
        url: "/getalbum.aspx?album=" + albumID,
        dataType: "xml",
        success: function(xmlP) {
            $(".conMedia").empty();

            var firstImage = $(xmlP).find('path:first').text();

            if (firstImage.indexOf("pano") != "-1") {
                $(".conMedia").append('<div id="flashHeader"></div>');

                var activePano = firstImage.substring(firstImage.indexOf("pano") + 4, firstImage.indexOf("pano") + 6);

                if (activePano != "10") {
                    activePano = activePano.replace("0", "");
                }
                $(".conMedia").css("height", "289px");
                activePano = parseInt(activePano) - 1;
                var so = new SWFObject("/flash/panoplayerheader.swf?xmlLink=/flash/pano.xml&activeP=" + activePano, "flashHeader", "515", "289", "8", "#FFFFFF");
                so.addParam("wmode", "transparent");
                so.write("flashHeader");
            } else if (firstImage.indexOf("youtube") != "-1") {
                $(".conMedia").append('<div id="flashHeader" style="height:314px"></div>');
                $(".conMedia").css("height", "314px");
                $(".fotobalk").css("height", "395px");
              
                var activeMovie = firstImage;

                activeMovie = activeMovie.replace("/watch", "");
                activeMovie = activeMovie.replace("?", "/");
                activeMovie = activeMovie.replace("=", "/");

                $("#flashHeader").append('<object width="515" height="314"><param name="movie" value="' + activeMovie + '&amp;hl=nl_NL&amp;autoplay=1&amp;hd=1&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="opaque"></param><embed src="' + activeMovie + '&amp;hl=nl_NL&amp;autoplay=1&amp;hd=1&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="515" height="314" wmode="opaque"><"></embed></object>');
            }
            else {
                $(".conMedia").css("height", "289px");
                $(".fotobalk").css("height", "370px");
                $(".conMedia").append('<img src="' + firstImage + '/515/0/image.ashx" class="bigImages">');
            }


            //alert( $(xmlP).find ('path').text ());
            $(xmlP).find('path').each(function() {
                var youtubeCheck = $(this).text();
                if (youtubeCheck.indexOf("youtube") != "-1") {
                    $(".thumbBalk").append('<span class="conThumb"><span class="wrapThumb"><img src="/images/b_play.jpg/76/0/image.ashx" class="thumb" alt="' + youtubeCheck + '"></span></span>');

                } else {
                    $(".thumbBalk").append('<span class="conThumb"><span class="wrapThumb"><img src="' + $(this).text() + '/76/0/image.ashx" class="thumb"></span></span>');
                }
                thumbCount++;


            });
            $(".thumbBalk").css("width", thumbCount * 84 + "px");
            $(".conThumb").click(function() {
                $(".conThumb").css("margin", "2px");
                $(".conThumb").css("border", "none");
                var imgSrc = $("img", this).attr("src");
                var imgAlt = $("img", this).attr("alt");
                $(this).css("margin", "0px");
                $(this).css("border", "2px solid #f19302");
                imgSrc = imgSrc.substring(0, imgSrc.length - 16);
                $(".conMedia").empty();
                if (imgSrc.indexOf("pano") != "-1") {
                    $(".conMedia").append('<div id="flashHeader"></div>');
                    var activePano = imgSrc.substring(imgSrc.indexOf("pano") + 4, imgSrc.indexOf("pano") + 6);
                    if (activePano != "10") {
                        activePano = activePano.replace("0", "");
                    }
                    $(".conMedia").css("height", "289px");
                    activePano = parseInt(activePano) - 1;
                    var so = new SWFObject("/flash/panoplayerheader.swf?xmlLink=/flash/pano.xml&activeP=" + activePano, "flashHeader", "515", "289", "8", "#FFFFFF");
                    so.write("flashHeader");
                } else if (imgSrc.indexOf("b_play") != "-1") {
                    $(".conMedia").append('<div id="flashHeader" style="height:314px"></div>');
                    $(".conMedia").css("height", "314px");
                    $(".fotobalk").css("height", "395px");

                    var activeMovie = imgAlt;
                    activeMovie = activeMovie.replace("/watch", "");
                    activeMovie = activeMovie.replace("?", "/");
                    activeMovie = activeMovie.replace("=", "/");

                    $("#flashHeader").append('<object width="515" height="314"><param name="movie" value="' + activeMovie + '&amp;hl=nl_NL&amp;autoplay=1&amp;hd=1&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="opaque"></param><embed src="' + activeMovie + '&amp;hl=nl_NL&amp;autoplay=1&amp;hd=1&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="515" height="314" wmode="opaque"><"></embed></object>');
                }
                else {
                    $(".conMedia").css("height", "289px");
                    $(".fotobalk").css("height", "370px");
                    $(".conMedia").append('<img src="' + imgSrc + '/515/0/image.ashx" class="bigImages">');
                }
            });
            $(".conThumb:first").css("margin", "0px");
            $(".conThumb:first").css("border", "2px solid #f19302");
        }
    });
    $(".goRight").click(function() {
        if ($(".thumbBalk").scrollLeft() > -((thumbCount + 3) * 84) && curThumb + 3 < thumbCount) {
            $(".thumbBalk").css("left", -(curThumb + 1) * 84);
            curThumb++;
        }
    });
    $(".goLeft").click(function() {
        if ($(".thumbBalk").scrollLeft() > -((thumbCount + 3) * 84) && curThumb > 0) {
            $(".thumbBalk").css("left", -(curThumb - 1) * 84);
            curThumb--;
        }
    });
});
