$(function(){          
    $('.customNyroModal').click(function(e){    
        $('html, body').animate({scrollTop:0}, 'slow');
        var d = new Date();   
        url = $(this).attr('href') + '&dummy=' + d.getTime();
        
        e.preventDefault();
        
        $.nyroModalManual({                 
            'modal': true,
            'url': url,
            'resizable': false
        });                        
        return false; 
    });                                               
});    

function saveModalPageClick(){  
    $('#pagelocation').val(window.location);                               
    $('#PageForm').submit(); 
}

function cancelModalPageClick(){   
    if (window.confirm("Leave form without Saving?")){
        $.nyroModalRemove();      
    }
} 

$(function(){                                                     
    $('.showPageAnchor[pageid]').click(function(e){
        //e.preventDefault();
        //showPageItem($(this).attr('pageid'));
    });
                           
    if ($('.pageItem[pageid=GeneralServices]').length > 0){ 
        //showPageItem('GeneralServices');   
    }
    else if($('.pageItem[pageid=PatientInfo]').length > 0){  
        //showPageItem('PatientInfo');   
    }    
})              

function showPageItem(pageid){
    if ($('.pageItem[pageid=' + pageid + ']').length > 0){ 
        $('#RightPageContent').html($('.pageItem[pageid=' + pageid + ']').html());
        $('.showPageAnchor:not([pageid=' + pageid + '])').removeClass('selected');
        $('.showPageAnchor[pageid=' + pageid + ']').addClass('selected');
        // this causes an infinate loop. . .
        //window.location.search = '?subpage=' + pageid;
    }
}  
