//Dropdown Menu Code
var timeout = 0;
var closetimer = 0;
var ddmenuitem = 0;

function asDD_open() {
	asDD_canceltimer();
	asDD_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
}

function asDD_close() {
	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
}

function asDD_timer() {
	closetimer = window.setTimeout(asDD_close, timeout);
}

function asDD_canceltimer() {
	if(closetimer) {
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

$(document).ready(function() {
	$('#ddMenu > li').bind('mouseover', asDD_open);
	$('#ddMenu > li').bind('mouseout',  asDD_timer);
	}
);
document.onclick = asDD_close;


// Text Resizer Script
$(document).ready(function() {
	$('.reSize a').click(function() {
		var textSize = $(this).parent().attr('class');
		$('body').removeClass('small medium large').addClass(textSize);
		return false;
	});
});

//Clears search box on click
$(document).ready(function() {
	$('.search').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if (this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if (this.value == '') {
				this.value = default_value;
			}
		});
	});
});

// Fancybox video feature About Page
$(document).ready(function() {
	$(".Iluvien").fancybox({
		'padding'		: 0,
		'autoScale'		: false,
		'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'title'			: 'ILUVIEN: Investigational Treatment for DME',
		'width'			: 640,
		'height'		: 480,
		'centerOnScroll': true,
		'overlayColor': "#666666",
		'href'			: '/_flash/YoutubeAPI.swf',
		'type'			: 'swf',					
		'swf'			: {
							'wmode'				: 'transparent',
							'allowfullscreen'	: 'true',
							'flashvars'			: 'ytSwf=http://www.youtube.com/apiplayer?version=3&ytVideo=9fhMV7Tj6Us&ytTitle=ILUVIEN: Investigational Treatment for DME'
						  }
	});
	
	$(".insideEye").fancybox({
		'padding'		: 0,
		'autoScale'		: false,
		'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'title'			: 'Diabetes and the Eye',
		'width'			: 640,
		'height'		: 480,
		'centerOnScroll': true,
		'overlayColor': "#666666",
		'href'			: '/_flash/YoutubeAPI.swf',
		'type'			: 'swf',					
		'swf'			: {
							'wmode'		: 'transparent',
							'allowfullscreen'	: 'true',
							'flashvars' :'ytSwf=http://www.youtube.com/apiplayer?version=3&ytVideo=Z6be-ySzmHs&ytTitle=Diabetes and the Eye'
						  }
	});
	
});
