// JavaScript Document

$(document).ready(function(){ 

	//fix png transparency for ie 5/6
	//$(document).pngFix();
	
	
	//top navigation rollovers
	$("#top_nav ul").css({opacity:0});
		
	$("#top_nav ul").parent()
		.hover(function() {
			$("#header_wrapper").stop().animate({height:"65px"}, {duration:250, easing:"easeOutCubic"});
			$("#header").stop().animate({height:"65px"}, {duration:250, easing:"easeOutCubic"});
			$("#top_nav ul").stop().animate({opacity:1}, {duration:100});
		},
		function() {
			$("#header_wrapper").stop().animate({height:"40px"}, {duration:500, easing:"easeOutCubic"});
			$("#header").stop().animate({height:"40px"}, {duration:500, easing:"easeOutCubic"});
			$("#top_nav ul").stop().animate({opacity:0}, {duration:200, easing:"easeOutCubic"});
		}
	);
	
	//genre nav menu

  	$('ul.genre_nav').superfish({
		delay:0,
        animation:{height:'show'},
        speed:'fast',
		autoArrows:  false
	});

	
	//genre rollovers	
	$(".event .description")
		.css( {opacity:0} )
		.mouseover(function() {  
                $(this).stop().animate({opacity:1 }, {duration:200, easing:"easeOutCubic"})
                })
		.mouseout(function() {  
                $(this).stop().animate({opacity:0 }, {duration:450, easing:"easeInCubic"});
                });
	
	//slideshow
	$("ul.slideshow").cycle({
		fx: 'fade',
		pause: 0,
		speed:2000,
		timeout:10000,
		slideResize: 0,
		easeIn: 'easeInOutExpo',
		easeOut: 'easeInOutExpo',
		width: 'auto',
		fit: 0, 
		containerResize: 0,
		random: true
	});
	
	//fancybox lightbox
	$("a.lightbox").fancybox({
				'titlePosition'	: 'outside'
			});
	
	
	//twitter feed
	$(".tweets").tweet({
            username: "adelaidefest",
            join_text: "auto",
            count: 1,
            auto_join_text_default: "we said,",
            auto_join_text_ed: "we",
            auto_join_text_ing: "we were",
            auto_join_text_reply: "we replied to",
            auto_join_text_url: "we were checking out",
			refresh_interval:60
        });
		

	//input placeholder fix
	var detect = navigator.userAgent.toLowerCase();
		if (detect.indexOf("safari") > 0) return false;
		var inputs = document.getElementsByTagName("input");
		for (var i=0;i<inputs.length;i++) {
		  if (inputs[i].getAttribute("type") == "text") {
		   if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0) {
			inputs[i].value = inputs[i].getAttribute("placeholder");
			inputs[i].onclick = function() {
			 if (this.value == this.getAttribute("placeholder")) {
			  this.value = "";
			 }
			 return false;
			}
			inputs[i].onblur = function() {
			 if (this.value.length < 1) {
			  this.value = this.getAttribute("placeholder");
			 }
			}
		   }
		  }
		}			
}); 
