$(document).ready(function(){  
  
    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)  
  
    $("ul.navmain li.menu").hover(function() { // trigger 
  
        //Following events are applied to the subnav itself (moving subnav up and down)  
        $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click  
  
        $("ul.navmain li.menu").hover(function() {  
        }, function(){  
            $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up  
        });  
 
    });  
  
});  

//did you know animation

$(document).ready(function(){

	$('#didyouknowinner').animate({opacity: 0}, 0); 
		
	$('#didyouknow').hover(function(){ 
		$("#didyouknowinner").stop().animate({opacity: 1}); 
	}, function() { 
		$("#didyouknowinner").stop().animate({opacity: 0}, "slow"); 
	});
	
	$("#didyouknowinner").click(function(){
	  window.location="#"; return false;
	});
}); 

//page flip animation

$(document).ready(function(){
 
	$("#banner-leftcontainer").hover(function() {
		$("#banner-left").animate({top: "-=400"}, 300);
	}, function() {
		$("#banner-left").animate({top: "0"}, 600);
	});	 
	
	$("#pageflip").hover(function() { //On hover...
		$("#pageflip img , .msg_block").stop()
			.animate({ //Animate and expand the image and the msg_block (Width + height)
				width: '180px',
				height: '105px'
			}, 500);
		} , function() {
		$("#pageflip img").stop() //On hover out, go back to original size 50x52
			.animate({
				width: '147px',
				height: '86px'
			}, 220);
		$(".msg_block").stop() //On hover out, go back to original size 50x50
			.animate({
				width: '147px',
				height: '86px'
			}, 200); //Note this one retracts a bit faster (to prevent glitching in IE)
	});
 
});

//DID YOU KNOW JAVASCRIPT ////////////////////////////////////////////////////////////////////////

function didYouKnowLinkHome() {
	//location.href = dynLinks[curDyn];
	window.location.href = 'http://printbetter.com/did-you-know.htm';
}

function didYouKnowLink(section) {
	//location.href = dynLinks[curDyn];
	window.location.href = 'http://printbetter.com/did-you-know-' + section + '.htm';
}

var dynTimer;
var dynTimerOn = 0;
//var dynLinks = new Array('news/index.htm','about-us.htm','client-resources.htm','contact-us.htm')
var curDyn = 0;
var nextDyn = 1;

function dynTimedCount() {
    if (dynTimerOn) {
        cycleDidYouKnow();
        dynTimer = setTimeout("dynTimedCount()", 4000);
    }
}

function dynStartTimer() {
    dynTimerOn = 1;
    dynTimer = setTimeout("dynTimedCount()", 4000);
}

function dynClearTimer() {
    dynTimerOn = 0;
    clearTimeout(dynTimer);
}

function cycleDidYouKnow() {
	$('#dynText' + curDyn).hide();
	$('#dynText' + nextDyn).slideDown();
	if (curDyn == 25)
		curDyn = 0;
	else
		curDyn++;
	if (nextDyn == 25)
		nextDyn = 0;
	else
		nextDyn++;
}
