$(document).ready(function(){
	var counter = 1;
	$(".roomImage").each(function(){
		var children = $(this).children();
		var src = children[0].src;
		var alt = children[0].alt;
		src = src.substring(0, src.length - 4);

		$(this).children('img').attr("rel", "#imageOverlay"+counter);
		
		$('body').append('<div class="simple_overlay" style="display:none;" id="imageOverlay'+counter+'"><img src="'+src+'" alt="'+alt+'" title="'+alt+'" style="max-width:980px;"/></div>');
		counter++;
	});
	
	$(".roomImage img[rel]").overlay({
		mask: {
			color: '#848484',
			loadSpeed: 200,
			opacity: 0.9
		},
		closeOnClick: true
	});
});

function moveOverlay() {
    var modalObjects = $(".outerPopup, .modalBackground", "#contentBox");
    //modalObjects.remove();
    /*$(".outerPopup").each(function () {
      $(this).remove();
       });
    $(".modalBackground").each(function () {
        $(this).remove();
    });
    $("form").append(modalObjects);*/
}

$(document).ready(function () {
    var searchRoomId = 1;
    var slidingId = 1;
    $(".searchRoomsResults").each(function () {
        $(this).attr("roomId", searchRoomId);
        searchRoomId++;
    });
    $(".slidingDiv").each(function () {
        $(this).attr("roomId", slidingId);
        slidingId++;
    });

    try {
        var valueOfSelectedRooms = document.getElementById("ctl00_PageContent_ContentControl_ctl00_selectedOption").value;

        var array = valueOfSelectedRooms.split("|");

        for (var i = 0; i < array.length; i++) {
            $(".slidingDiv").each(function () {
                if ($(this).attr("roomId") == array[i]) {
                    $(this).show();
                }
            });
        }        

        setTimeout("scrollContent()", 500);
    }
    catch (error) {
    }
});

function scrollContent() {
    var scrollPosition = parseInt(document.getElementById("ctl00_PageContent_ContentControl_ctl00_currentScrollPosition").value);
    if (scrollPosition != 0) {        
        var scrollItem = document.getElementById("contentBox");
        scrollItem.fleXcroll.setScrollPos(false, scrollPosition);
    }
}
