// JavaScript Document

// PARSER FACEBOOK

(function($){var current=null;$.fn.rssfeed=function(url,options){var defaults={limit:10,header:true,titletag:'h4',date:true,content:true,snippet:true,showerror:true,errormsg:'',key:null};var options=$.extend(defaults,options);return this.each(function(i,e){var $e=$(e);if(!$e.hasClass('rssFeed'))$e.addClass('rssFeed');if(url==null)return false;var api="http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q="+url;if(options.limit!=null)api+="&num="+options.limit;if(options.key!=null)api+="&key="+options.key;$.getJSON(api,function(data){if(data.responseStatus==200){_callback(e,data.responseData.feed,options);}else{if(options.showerror)
if(options.errormsg!=''){var msg=options.errormsg;}else{var msg=data.responseDetails;};$(e).html('<div class="rssError"><p>'+msg+'</p></div>');};});});};var _callback=function(e,feeds,options){if(!feeds){return false;} var html='';var row='odd';
if(options.header)
html+='<ul>';for(var i=0;i<feeds.entries.length;i++){var entry=feeds.entries[i];var entryDate=new Date(entry.publishedDate);
if (entryDate.getDate() < 10) { var Giorno= '0'+entryDate.getDate(); } else { var Giorno=entryDate.getDate(); }
if (entryDate.getMonth() < 10) { var Mese= '0'+(entryDate.getMonth()+1); } else { var Mese=(entryDate.getMonth()+1); }
var Anno=entryDate.getFullYear();var pubDate = Giorno+'/'+Mese+'/'+Anno;
html+='<li class="rssRow '+row+'">'
if(options.content){if(options.snippet&&entry.contentSnippet!=''){var content=entry.contentSnippet;}else{var content=entry.content;}
html+='<a href="'+entry.link+'" title="Leggi tutto" target="_blank">'+content+'</a>'}
html+='</li>';} html+='</ul>'
$(e).html(html);};})(jQuery);


// JQUERY DOCUMENT READY

$(document).ready(function() {

// Scrolling Horizontal Immagini
						
$("div.scrollable").scrollable({size: 3, easing: 'easeInOutBack', items: '.scroll_box', speed: 1000});
$("div#scroll_main").scrollable({size: 1, easing: 'easeInOutQuad', items: '.scroll_main_box', speed: 2000, clickable: false, loop: true}).circular().autoscroll({steps: -1, interval: 8000});


// Facebook Feed

	$('.facebookfeed').rssfeed('http://feeds.feedburner.com/DermalInstituteUsa1956sFacebookWall', { limit: 4});

// YouTube Get Data

	$('#videos').youTubeChannel({ 
		userName: 'DermalInstitute1',
		channel: 'uploads',
		linksInNewWindow: true
	});
	
$('.top_button').click(function(){
		$('body').scrollTo( $('#menu_top'), 500);
});


// Fade effects
	
$('.scrollable a, .box_trattamenti').mouseover(function(){
	$(this).children('img').stop().animate({opacity : 0.5}, 'fast');
}).mouseout(function(){
	$(this).children('img').stop().animate({opacity : 1}, 'fast');
});

$('.press_pdf').mouseover(function(){
	$(this).stop().animate({opacity : 0.5}, 'fast');
}).mouseout(function(){
	$(this).stop().animate({opacity : 1}, 'fast');
});

// Fade effects
	
$('.trattamenti_menu a').mouseover(function(){
	$(this).children('.trat_cat').stop().animate({opacity : 0.5}, 'fast');
	$(this).children('.titolo').stop().css({backgroundPosition : '131px -100px'});
}).mouseout(function(){
	$(this).children('.trat_cat').stop().animate({opacity : 1}, 'fast');
	$(this).children('.titolo').stop().css({backgroundPosition : '131px 0px'});
});

// Pic Fancy
$('.fancy').fancybox({'hideOnContentClick': false, 'overlayColor': '#fff', 'overlayOpacity': '0.8'});


// Rollover Prodotti

$('.video').mouseover(function(){ $('.prod_txt_desc').html('Video'); });
$('.video').mouseout(function(){ $('.prod_txt_desc').html(''); });

$('.scheda').mouseover(function(){ $('.prod_txt_desc').html('Scheda Tecnica'); });
$('.scheda').mouseout(function(){ $('.prod_txt_desc').html(''); });

$('.brochure').mouseover(function(){ $('.prod_txt_desc').html('Brochure'); });
$('.brochure').mouseout(function(){ $('.prod_txt_desc').html(''); });


// Youtube FancyBox

$("a.video").click(function() {
	$.fancybox({
    'overlayColor': '#fff',
	'overlayOpacity': '0.8',
    'autoScale': false,
    'title': this.title,
    'width': 680,
    'height': 495,
    'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
    'type': 'swf',
    'swf': {'allowfullscreen':'true'}
	});
    return false;
}); 

// ACCORDION

$('#sub_main .txt .answer').hide().animate({opacity : 0}, 0);

$('.prod_section').click( function() {
	if( $(this).next().is(':visible')) {
			$(this).next().animate({opacity : 0},'medium', function() {
				$(this).slideUp(600);
			});
			$(this).removeClass('open_box');
		return false;
	} else {
		$(this).next().slideDown(400, function() {
			$(this).animate({opacity : 1},'medium');
		});	
		$(this).addClass('open_box');
		return false;
}
});



});


// OUT OF READING //

// E-Mail repleacer

function abisubstitute(element, action){
	switch (action) {
		case 'click': if (element.value=='E-Mail'){element.value=''}; break;
		case 'blur': if (element.value==''){element.value='E-Mail'}; break; default:;
};
};
