// video wid: 49a812a221dbfcf1
// audio wid: 49c0fd97d28ca1cd
// foto wid: 49b7c1ae63c2412b

// video thumbs wid: 49c3b67e6b02d425

function ContentDefault(idregselect, type){

j$.ajax({
	   type: "GET",
	   url: 'multimedia/defaultmultimedia.aspx',
	   dataType: 'json',
	   data: 'idRegSelect='+idregselect+'&idtype='+type,
	   success: function(val){
			switch(type){
				case"2":
				cambiaVideo(val.idvideo, val.pathvideo);
				break;
				case"3":
				cambiaAudio(val.pathaudio);
				break;
				case"4":
				cambiaAlbum(val.pathfhoto);
				break;
			}
	   }
	   
	 });
}

function creaWidget(tipo, path, id_video) {

switch(tipo){
case"video":
$Launchpad.CreateMenu({wid: "49c3b67e6b02d425", menuWidth: 300, menuHeight: 150, actionElement: "share_link", config: { idVideo: id_video, movie: path } });		
break;
case"audio":
$Launchpad.CreateMenu({wid: "49c0fd97d28ca1cd", menuWidth: 300, menuHeight: 150, actionElement: "share_link", config: { file: path } });
break;
case"foto":
$Launchpad.CreateMenu({wid: "49b7c1ae63c2412b", menuWidth: 300, menuHeight: 150, actionElement: "share_link", config: { xmlfile: path } });
break;
}

}

function cambiaAlbum(xmlFilePath) {



j$('#video').html("");

if (xmlFilePath != "") {

j$('#video').flash(
        { 
          src: 'player/slideshowpro.swf',
          id: 'player',
          width: 580,
          height: 390,
          allowFullScreen: true,
          bgColor: '#000',
          quality: 'high',
          allowScriptAccess: 'always',
          wmode: 'transparent',
          flashvars: { xmlfile: xmlFilePath, xmlfiletype: "Default" }
        },
        { version: 8 }
);


var player_url = "http://www.soldini.it/player/slideshowpro.swf";
var player_id = "player";
var player_width = 580;
var player_height = 390;
var xml_path = xmlFilePath;

var embedCode='<object width="'+player_width+'" height="'+player_height+'"><param name="movie" value="'+player_url+'"><\/param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><param name="quality" value="high"></param><param name="bgcolor" value="#000"></param><param name="FlashVars" value="xmlfile='+xml_path+'"></param><embed src="'+player_url+'" type="application/x-shockwave-flash" bgcolor="#000" FlashVars="xmlfile='+xml_path+'" allowscriptaccess="always" wmode="transparent" quality="high" allowfullscreen="true" width="'+player_width+'" height="'+player_height+'"><\/embed><\/object>';

document.Form1.embed_code.value=embedCode;

creaWidget('foto', xmlFilePath);

} else {
	
	j$('#video').html("<img src='images/no_foto.gif' width='580' height='390' alt='' />");

}
	
}

function cambiaAudio(fileAudio) {

j$('#video').html("");

if (fileAudio != "") {

j$('#video').append("<div id='audio'></div>");
j$('#audio').flash(
        { 
          src: 'player/singlemp3player.swf',
          width: 580,
          height: 18,
          wmode: 'transparent',
          flashvars: { showDownload: 'true', file: fileAudio, autoStart: 'true', backColor: '333333', frontColor: 'ffffff', repeatPlay: 'no', songVolume: '50' }
        },
        { version: 8 }
);


var player_url = "http://www.soldini.it/player/singlemp3player.swf";
var player_id = "player";
var player_width = 580;
var player_height = 18;
var audio_path = fileAudio;

var embedCode='<object width="'+player_width+'" height="'+player_height+'"><param name="movie" value="'+player_url+'"><\/param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><param name="quality" value="high"></param><param name="bgcolor" value="#000"></param><param name="FlashVars" value="file='+audio_path+'&showDownload=true&autoStart=true&backColor=333333&frontColor=ffffff&repeatPlay=no&songVolume=50"></param><embed src="'+player_url+'" type="application/x-shockwave-flash" bgcolor="#000" FlashVars="file='+audio_path+'&showDownload=true&autoStart=true&backColor=333333&frontColor=ffffff&repeatPlay=no&songVolume=50" allowscriptaccess="always" wmode="transparent" quality="high" allowfullscreen="true" width="'+player_width+'" height="'+player_height+'"><\/embed><\/object>';

document.Form1.embed_code.value=embedCode;

creaWidget('audio', fileAudio);

j$('a#download_link').attr('href',fileAudio);

} else {
	
	j$('#video').html("<img src='images/no_audio.gif' width='580' height='390' alt='' />");

}
	
}

function cambiaVideo(id_video, path_video) {


j$('#video').html("");

if (path_video != "") {

j$('#video').flash(
        { 
          src: '/player/player_flv.swf',
          id: 'player',
          width: 580,
          height: 390,
          allowFullScreen: true,
          bgColor: '#000',
          quality: 'high',
          allowScriptAccess: 'always',
          wmode: 'transparent',
          flashvars: { idVideo: id_video, movie: path_video }
        },
        { version: 8 }
);

var player_url = "http://www.soldini.it/player/player_flv.swf";
var player_id = "player";
var player_width = 580;
var player_height = 390;
var video_path = path_video;

var embedCode='<object width="'+player_width+'" height="'+player_height+'"><param name="movie" value="'+player_url+'"><\/param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><param name="quality" value="high"></param><param name="bgcolor" value="#000"></param><param name="FlashVars" value="idVideo='+id_video+'&movie='+video_path+'"></param><embed src="'+player_url+'" type="application/x-shockwave-flash" bgcolor="#000" FlashVars="idVideo='+id_video+'&movie='+video_path+'" allowscriptaccess="always" wmode="transparent" quality="high" allowfullscreen="true" width="'+player_width+'" height="'+player_height+'"><\/embed><\/object>';

document.Form1.embed_code.value=embedCode;

creaWidget('video', path_video, id_video);

j$('a#download_link').attr('href',path_video);

} else {
	
	j$('#video').html("<img src='images/no_video.gif' width='580' height='390' alt='' />");
	
}
	
}


jQuery(document).ready(function() {

_cmbregcorrente = null;

_cmbregcorrente = j$('select#cmbregcorrente').combobox( 

	{ 
	comboboxContainerClass: "comboboxContainer",
	comboboxValueContainerClass: "comboboxValueContainer",
	comboboxValueContentClass: "comboboxValueContent",
	comboboxDropDownClass: "comboboxDropDownContainer",
	comboboxDropDownButtonClass: "comboboxDropDownButton",
	comboboxDropDownItemClass: "comboboxItem",
	comboboxDropDownItemHoverClass: "comboboxItemHover",
	comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader",
	comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer"
  },
  {
	animationType: "slide",
	width: "300px"
});

_cmbregcorrente.combobox.onChange = function() {

if (j$("#cmbregcorrente").val() != 0) {

var val = j$("#cmbregcorrente").val();

var SplitVal = val.split("-");

var type = SplitVal[0];
var idPage = SplitVal[1];

switch(type) {
   case"1":
   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();
   }
   break;
   case"2":
   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();
   }
   break;
   case"3":
   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();
   }
   break;
   case"4":
   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();
   }
   break;
   default:
   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();
   }
   break;
}

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='+type,
	   success: function(html){
	     j$('div#slides').html("");
	     j$('div#slides').append(html);
	     ContentDefault(idPage, type);
	     j$('#slides').cycle({
			    fx:'scrollHorz',
			    speed:500,
			    timeout:0,
			    next:'.next',
			    prev:'.prev'
			});	
	   }
	   
	 });
	 
}, 500);	 

}

};



j$('a#embed_link').click( function() {
			if (j$("div#embedarea").is(":hidden")) {
					j$("div#embedarea").slideDown();														
			} else { 
					j$("div#embedarea").slideUp();									
			}		
});



j$('#slides').cycle({
    fx:'scrollHorz',
    speed:500,
    timeout:0,
    next:'.next',
    prev:'.prev',
    height: 284
});

});





