function switchActive(modget_id){
    var $active = $('#'+modget_id+' tr.active');
    if ( $active.length == 0 ) $active = $('#'+modget_id+' tr:last');
    var $next =  $active.next().length ? $active.next()
        : $('#'+modget_id+' tr:first');
    $active.addClass('last-active');
    $next.css()
        .addClass('active');
        $active.removeClass('active last-active');
}
function switchActiveWinery() {
    var modget_id = 'modget-wineries';
    if($('#'+modget_id)!=undefined)
		switchActive(modget_id);
}
function switchActiveWine() {
    var modget_id = 'modget-wines';
    if($('#'+modget_id)!=undefined)
		switchActive(modget_id);
}
/*function switchActiveRegion() {
    var modget_id = 'modget-subregions';
    if($('#'+modget_id)!=undefined)
		switchActive(modget_id);
}*/
function switchActiveWineryWines() {
    var modget_id = 'modget-wwines';
    if($('#'+modget_id)!=undefined)
		switchActive(modget_id);
}
//modget-wwines
function switchActiveHotel() {
    var modget_id = 'modget-hotels';
    if($('#'+modget_id)!=undefined)
		switchActive(modget_id);
}

var oTables=[];
$(document).ready(function() {
    //if($('#modget-wineries'))setInterval( "switchActiveWinery()", 5000 );
    //if($('#modget-wines'))setInterval( "switchActiveWine()", 5500 );
    //if($('#modget-wwines'))setInterval( "switchActiveWineryWines()", 5500 );
    //if($('#modget-hotels'))setInterval( "switchActiveHotel()", 5500 );
    
	var typeArr=['winery','wine','subregion','wwine','hotel','blog'];
	for(var i=0;i<typeArr.length;i++) {
		if($('#'+typeArr[i]+'-tbl'))
		{
			if(i==0||i==2||i==5){
				oTables[typeArr[i]] = $('#'+typeArr[i]+'-tbl').dataTable( {
					//"sPaginationType": "full_numbers",
					//"aaSorting": [[ 1, "asc" ]],
					"aoColumns": [
						{ "sType": "html" }
					],
					//"bStateSave": false,
					"bAutoWidth": false
				} ).css("width", "100%").css("float", "left");
			}
			else {
				//var col_set=[{ "bSortable": true, "sType": "html" }, { "bSortable": true, "sType": "numeric" }];
				//if(i==0){ col_set[{ "bSortable": true, "sType": "html" }];}
				//alert(typeArr[i]);
				oTables[typeArr[i]] = $('#'+typeArr[i]+'-tbl').dataTable( {
					//"sPaginationType": "full_numbers",
					"aaSorting": [[ 1, "asc" ]],
					"aoColumns": [
						{  "sType": "html" }, 
						{ "sType": "numeric" }
					],
					//"bStateSave": false,
					"bAutoWidth": false
				} ).css("width", "100%").css("float", "left");
			}
		}
	}
});

