_anno = null;
_regata = null;

function RegataOnChange(type){

_regata.combobox.onChange = function() {

if (j$("#regata").val() != 0) {

if (this.timer) clearTimeout(this.timer);

j$('div#slides').html("");
j$('div#slides').append("<div style='width:298px;height:58px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div>");



this.timer = setTimeout(function () {	

j$.ajax({
	   type: "GET",
	   url: 'multimedia/page_brothers_by_type.aspx',
	   dataType: 'html',
	   data: 'Lang=ITA&idPage='+j$("#regata").val()+'&type='+type,
	   success: function(html){
	     j$('div#slides').html("");
	     j$('div#slides').append(html);
		 j$('#slides').cycle({
			    fx:'scrollHorz',
			    speed:500,
			    timeout:0,
			    next:'.next',
			    prev:'.prev'
			});
			ContentDefault(j$("#regata").val(), type);	
	   }
	   
	 });
	 
}, 500);	 

} else {
	j$('#video').html("");
}

};

}

function settaRegataAttuale(){

if (j$("#cmbregcorrente").val() != 0) {

var val = j$('#cmbregcorrente').val();

SplitVal = val.split("-");


var idPage = SplitVal[1];

if (this.timer) clearTimeout(this.timer);

j$('div#slides').html("");
j$('div#slides').append("<div style='width:298px;height:58px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div>");



this.timer = setTimeout(function () {	

j$.ajax({
	   type: "GET",
	   url: 'multimedia/page_brothers_by_type.aspx',
	   dataType: 'html',
	   data: 'Lang=ITA&idPage='+idPage+'&type=2',
	   success: function(html){
	     j$('div#slides').html("");
	     j$('div#slides').append(html);
	     j$('#slides').cycle({
			    fx:'scrollHorz',
			    speed:500,
			    timeout:0,
			    next:'.next',
			    prev:'.prev'
			});	
	   }
	   
	 });
	 
}, 500);

}

}

function rinizializzaComboAnno(){

_anno = j$('select#anno').combobox( 

  { 
	comboboxContainerClass: "comboboxContainer",
	comboboxValueContainerClass: "comboboxValueContainer",
	comboboxValueContentClass: "comboboxValueContent",
	comboboxDropDownClass: "comboboxDropDownContainer",
	comboboxDropDownButtonClass: "comboboxDropDownButton",
	comboboxDropDownItemClass: "comboboxItem",
	comboboxDropDownItemHoverClass: "comboboxItemHover",
	comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader",
	comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer"
  },
  {
	animationType: "slide",
	width: "300px" 
});


_anno.combobox.onChange = function() { 

if (j$("#anno").val() != 0) {

if (this.timer) clearTimeout(this.timer);

_regata.next().find('div.comboboxValueContent').prepend("<img src='images/loader.gif' alt='' style='float:left;margin-right:10px;margin-top:2px;' />");



this.timer = setTimeout(function () {	

j$.ajax({
	   type: "GET",
	   url: 'multimedia/regate.aspx',
	   dataType: 'html',
	   data: 'idFolder='+j$("#anno").val(),
	   success: function(html){
	     _regata.html("");
	     _regata.append(html);
	     _regata.combobox.update();
	   }
	   
	 });
	 
}, 500);

}	 

	
};


}

function rinizializzaComboRegata(){

_regata = j$('select#regata').combobox( 

	{ 
	comboboxContainerClass: "comboboxContainer",
	comboboxValueContainerClass: "comboboxValueContainer",
	comboboxValueContentClass: "comboboxValueContent",
	comboboxDropDownClass: "comboboxDropDownContainer",
	comboboxDropDownButtonClass: "comboboxDropDownButton",
	comboboxDropDownItemClass: "comboboxItem",
	comboboxDropDownItemHoverClass: "comboboxItemHover",
	comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader",
	comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer"
  },
  {
	animationType: "slide",
	width: "300px"
});


/*_regata.combobox.onChange = function() {

if (j$("#regata").val() != 0) {

if (this.timer) clearTimeout(this.timer);

j$('div#slides').html("");
j$('div#slides').append("<div style='width:298px;height:58px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div>");



this.timer = setTimeout(function () {	

j$.ajax({
	   type: "GET",
	   url: 'multimedia/page_brothers_by_type.aspx',
	   dataType: 'html',
	   data: 'Lang=ITA&idPage='+j$("#regata").val()+'&type='+type,
	   success: function(html){
	     j$('div#slides').html("");
	     j$('div#slides').append(html);
	     j$('#slides').cycle({
			    fx:'scrollHorz',
			    speed:500,
			    timeout:0,
			    next:'.next',
			    prev:'.prev'
			});	
	   }
	   
	 });
	 
}, 500);	 

}

};*/

}

function cercaRegate(type){

if (this.timer) clearTimeout(this.timer);

j$('div#slides').html("");
j$('div#slides').append("<div style='width:298px;height:58px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div><div style='width:298px;height:58px;margin-top:12px;border:1px solid #3c3c3c;text-align:center;'><img src='images/bigLoader.gif' alt='' style='margin-top:10px;' /></div>");



this.timer = setTimeout(function () {	

j$.ajax({
	   type: "GET",
	   url: 'multimedia/page_brothers_by_type.aspx',
	   dataType: 'html',
	   data: 'Lang=ITA&idPage='+j$("#regata").val()+'&type='+type,
	   success: function(html){
	     j$('div#slides').html("");
	     j$('div#slides').append(html);
	     
	     ContentDefault(j$("#regata").val(), type);
	     
	     j$('#slides').cycle({
			    fx:'scrollHorz',
			    speed:500,
			    timeout:0,
			    next:'.next',
			    prev:'.prev',
			    height: 284
			});	
	   }
	   
	 });
	 
}, 500);	

}

function settaComboRegate(sel,idregcorr) {

if (j$("#anno").val() != 0) {

if (this.timer) clearTimeout(this.timer);

_regata.next().find('div.comboboxValueContent').prepend("<img src='images/loader.gif' alt='' style='float:left;margin-right:10px;margin-top:2px;' />");



this.timer = setTimeout(function () {	

j$.ajax({
	   type: "GET",
	   url: 'multimedia/regate.aspx',
	   dataType: 'html',
	   data: 'idSelected='+idregcorr+'&idFolder='+j$("#anno").val(),
	   success: function(html){
	     _regata.html("");
	     _regata.append(html);
	     _regata.combobox.update();
	     if (sel == 1) {
			 cercaRegate('2');
	     }
	   }
	   
	 });
	 
}, 500);

}	 


}






jQuery(document).ready(function() {

/*j$("#tab01").click( function() {

	if (j$(this).attr("className") == 'tab_off') {
	
		j$(this).attr('class','tab_on');
		j$("#tab02").attr('class','tab_off');
		j$("#tab03").attr('class','tab_off');
		j$("#tab04").attr('class','tab_off');	
		j$("div.prev").attr('class','prev p_video');
		j$("div.next").attr('class','next n_video');
		setMultimedia('1');
		j$("#regata_attuale").attr("style","display:block;");
		j$("#archivio").attr("style","display:none;");
		_anno.combobox.remove();
		_regata.combobox.remove();
		_anno = null;
		_regata = null;
		_cmbregcorrente[0].options[0].selected = true;
		_cmbregcorrente.combobox.update();
		
	}	
		
});*/

j$("#tab02").click( function() {

	if (j$(this).attr("className") == 'tab_off') {

		j$(this).attr('class','tab_on');
		j$("#tab01").attr('class','tab_off');
		j$("#tab03").attr('class','tab_off');
		j$("#tab04").attr('class','tab_off');
		
		j$("div.prev").attr('class','prev p_video');
		j$("div.next").attr('class','next n_video');
		
		j$('a#rss_link').attr('href','RssGen.aspx?pagetype=VIDEO');

		if(j$('a#download_link').hide()) {
			j$('a#download_link').show();
		}
		
		//setMultimedia('2');	
		//j$("#regata_attuale").attr("style","display:none;");
		//j$("#archivio").attr("style","display:block;");
		
		j$('div#slides').html("");
		if (_anno == null) {
			rinizializzaComboAnno();
		}
		if (_regata == null) {
			rinizializzaComboRegata();
			RegataOnChange('2');
		} else {
			RegataOnChange('2');
		}
		if (_regata.val() != 0) {
			cercaRegate('2');
		}
		
		
	}	
		
});

j$("#tab03").click( function() {

	if (j$(this).attr("className") == 'tab_off') {

		j$(this).attr('class','tab_on');
		j$("#tab02").attr('class','tab_off');
		j$("#tab01").attr('class','tab_off');
		j$("#tab04").attr('class','tab_off');
		
		j$("div.prev").attr('class','prev p_audio');
		j$("div.next").attr('class','next n_audio');
		
		j$('a#rss_link').attr('href','RssGen.aspx?pagetype=PODCAST');

		if(j$('a#download_link').hide()) {
			j$('a#download_link').show();
		}
				
		//setMultimedia('3');
		//j$("#regata_attuale").attr("style","display:none;");
		//j$("#archivio").attr("style","display:block;");
		
		j$('div#slides').html("");
		if (_anno == null) {
			rinizializzaComboAnno();
		}
		if (_regata == null) {
			rinizializzaComboRegata();
			RegataOnChange('3');
		} else {
			RegataOnChange('3');
		}
		if (_regata.val() != 0) {
			cercaRegate('3');
		}
		
	}	
		
});

j$("#tab04").click( function() {

	if (j$(this).attr("className") == 'tab_off') {

		j$(this).attr('class','tab_on');
		j$("#tab02").attr('class','tab_off');
		j$("#tab03").attr('class','tab_off');
		j$("#tab01").attr('class','tab_off');
		
		j$("div.prev").attr('class','prev p_foto');
		j$("div.next").attr('class','next n_foto');
		
		j$('a#rss_link').attr('href','RssGen.aspx?pagetype=FOTO');
		if(j$('a#download_link').show()) {
			j$('a#download_link').hide();
		}
			
		//setMultimedia('4');
		//j$("#regata_attuale").attr("style","display:none;");
		//j$("#archivio").attr("style","display:block;");
		
		j$('div#slides').html("");
		if (_anno == null) {
			rinizializzaComboAnno();
		}
		if (_regata == null) {
			rinizializzaComboRegata();
			RegataOnChange('4');
		} else {
			RegataOnChange('4');
		}
		if (_regata.val() != 0) {
			cercaRegate('4');
		}
		
	}
		
});



});