var rwTabs = ['','','',''];

function initRooms(){
	if (typeof(roomOrd)!="undefined" && typeof(roomOrd[1])!="undefined") {

        function rwTabsInit(nr)
		{
			if (typeof(roomOrd[nr])!="undefined") {
                var jq=jQuery(jQuery('#rooms-list ul li').get(nr-1)).children();
				if (jq.attr('href')!='/' && jq.attr('title')!='') rwTabs[nr] += '<a href="'+jq.attr('href')+'" class="top-link">'+jq.attr('title')+'</a> ';

				for (var i=0;i<roomOrd[nr].length;i++) {
					jq = jQuery('#rw-box-'+roomOrd[nr][i]);
			        rwTabs[nr] += '<div class="'+ jq.attr('class') +'">' +jq.html() + '</div>';
				}
			}
		}
        rwTabsInit(1);
		rwTabsInit(2);
		rwTabsInit(3);
		jQuery('#rooms-list ul li.notactive').removeClass('notactive');
		rwTab(1,true);
		//if (typeof(trackOutgoing) != "undefined") trackOutgoing(jQuery('#rooms-list').get(0));
	}
}

function rwTab(nr,ignore)
{
	var lis = jQuery('#rooms-list ul li');
    jQuery(lis).addClass('tab').removeClass('tab-active');
	jQuery(lis.get(nr-1)).addClass('tab-active').removeClass('tab');

    jQuery('#rooms-list div.container').html(rwTabs[nr]);
	if (nr==2) jQuery('#rooms-list div.container p').hide();
	else jQuery('#rooms-list div.container div.bonuscode').hide();
	if (typeof(trackOutgoing) != "undefined" && !ignore) {
		trackOutgoing(jQuery('#rooms-list').get(0));
	}
    return false;
}