/* create a timeOut function in jQuery */
    jQuery.fn.idle = function(time){
        return this.each(function(){
            var i = $(this);
            i.queue(function(){
                setTimeout(function(){
                i.dequeue();
                }, time);
            });
        });
    };
$(document).ready(function(){
	//home slides
	if (document.getElementById("contentHomeSlides")){
		// home slider rotation
		$('#contentHomeSlides').cycle({ 
			fx:    'fade', 
			timeout:  5000,
			pager: '#slideNav',
			pagerAnchorBuilder: function(index, el) {
					return '<a href="#"></a>'; // whatever markup you want
			},
			slideExpr: 'p'
		
		});
	}
	
	
	// set up rollover
	$("img.rollover").hover(
		function()
		{
			this.src = this.src.replace("_off","_on");
		},
		function()
		{
			this.src = this.src.replace("_on","_off");
		}
	);
	// hide them all
	 //$("div#prodWrapper div").hide();
	 // show the first image
	 $(".prod1").fadeIn("fast");
	 
	  $("div#prodThumbWrapper img").hover(function(){
		 var elid = $(this).attr('id')
		 $("div#prodWrapper div").hide();
		 $("div#prodWrapper div." + elid + "").fadeIn("slow");
	   });
	$("#prodLink").mouseover(function(){
		$("#productNav").show().css('visibility', 'visible');
	});
	$("#prodLink").mouseout(function(){
		$("#productNav").hide().css('visibility', 'hidden');
	});
	$("#productNav").mouseover(function(){
		$("#productNav").show().css('visibility', 'visible');
	});
	$("#productNav").mouseout(function(){
		$("#productNav").hide().css('visibility', 'hidden');
	});
})



$(document).ready(function(){

	
	if (document.getElementById("intSubnav")){
		$("#intSubnav").slideDown('slow');
	 }
	
	for (i = 1; i < 10; i++){
		var pauseInc = 200; 
		pauseInc = pauseInc * i;
		if (document.getElementById(i)){
			$("#"+i).idle(pauseInc).fadeIn('fast');
		 }
	}
	// show/hide before/after when first come to page
	for (i = 1; i < 10; i++){
		if(!document.getElementById("after"+i)){
			$("#contentBefore").css('display', 'none');
			$("#contentAfter").css('display', 'none');
		}
	}
	
	//project slides
	if (document.getElementById("contentProject") || document.getElementById("contentProjectNB")){
		// home slider rotation
		$('#projectSlides').cycle({ 
			fx:    'fade', 
			timeout:  15000,
			pager: '#projectNav',
			pagerAnchorBuilder: function(index, el) {
					return '<a href="#"></a>'; // whatever markup you want
			},
			slideExpr: 'p img'
		
		});
	}

});

