$(document).ready(function(){
    var myLoc = document.location.href;
    var myPat = new RegExp(/(gallery=1)/i);
    var checkLoc = myLoc.search(myPat);
    if(checkLoc !== -1) {
            var tn3 = $('#gallery').tn3({
            skinDir: "skins",
            skin: "tn3e",
            external:[{
            origin:"xml",
            url:"gallery.xml"
            }],
            image:{
            transitions:[{
                type:"blinds",
                duration:300,
                direction:"horizontal",
                easing:"sineOut",
                parts:16,
                partDuration:300,
                 partEasing:"quadIn",
                 method:"fade"
                }],
                defaultTransition:{
                type: "fade",
                easing: "linear",
                duration: 800
                }
                },
                autoplay:true,
                delay:4000
            });
            
            setTimeout("openGallery()",2000); 
            setTimeout("showTN3Title()",2000); 
            
            $('#tn3GalleryClose, #galleryHeading').mouseup(function() {
                    closeGallery();
            });
    }
});
        
function closeGallery() {
    $('#galleryContainer').fadeOut(100);
    $("#user_bgrdImgRight").fadeIn(300);
    var wait = setTimeout('destroyGallery()',1000);
}

function openGallery() {
    $('#galleryContainer').fadeIn(300);
    $("#user_bgrdImgRight").fadeOut(100);
    
}

function destroyGallery() {
    $('#galleryContainer').html('');
}
        
function showTN3Title() {
    $('#galleryTitle').fadeIn(700);
}


