Accordion roll-up button not working.

Accordion roll-up button not working.

Hi There

I'm re-developing a site to be mobile friendly and have little knowledge of programming; however I do have a fair understanding. 

I was having difficulties getting a close button to work from within the accordion drop-down content, until I found the following script:

  $(function() {
$( ".selector" ).accordion({
heightStyle: "content",
collapsible: true,
active: true,
animate: 500,
activate: function( event, ui ) {
if(!$.isEmptyObject(ui.newHeader.offset())) {
$('html:not(:animated), body:not(:animated)').animate({ scrollTop: ui.newHeader.offset().top }, 'slow');
}
}
});
});
 
$('.rollUp').on('click', function () { /* this closes the accordion drop-down */
$( ".selector" ).accordion({
heightStyle: "content",
collapsible: true,
active: true,
activate: function( event, ui ) {
if(!$.isEmptyObject(ui.newHeader.offset())) {
$('html:not(:animated), body:not(:animated)').animate({ scrollTop: ui.newHeader.offset().top }, '5000');
}
}
});
});

This works! until I tested it in my test phones (iPhone 5 & Samsung Galaxy S2) It works in the iPhone 5 in both portrait and landscape; however it only works in portrait, in the Samsung S2. The close button wont roll-up the screen in landscape. It also works in both orientations in a cheap Android pad.

Any suggestions? Your help would be greatly appreciated.