$(document).ready(function() {

//Slide Form Open////////////////////////////////////////
$('.hidebox').hide();
$('a.openbox').click(function() {$('div.hidebox').slideToggle(300);
return false;
});


$('.project-img').beforeAfter({
	animateIntro : true,
        introDelay : 500,
        introDuration : 100,
        showFullLinks : false
});


$('.project-img').hover(function() {$('span.draghere').hide(); 

}); 

//Inline Form Labels////////////////////////////////////////

$.fn.setCursorPosition = function(pos) {
	if ($(this).get(0).setSelectionRange) {
		$(this).get(0).setSelectionRange(pos, pos);
	} else if ($(this).get(0).createTextRange) {
		var range = $(this).get(0).createTextRange();
		range.collapse(true);
		range.moveEnd('character', pos);
		range.moveStart('character', pos);
		range.select();
	}
}

// loop through all of the labels, grab the next form element and set the value to that of this label
$(".formbox label").each(function (i) {
$(this).next("input").attr("value",$(this).html());
	$(this).hide();
});

$(".formbox input.text").focus(function() {
	if($(this).prev("label").html() == this.value){
		$(this).addClass("focus").setCursorPosition(0);
	}
});
$(".formbox input.text").keypress(function() {
	if($(this).prev("label").html() == this.value){
		this.value = "";
		$(this).removeClass("focus").addClass("typing");
	}
});
$(".formbox input.text").blur(function() {
	$(this).removeClass("focus typing");
	if(this.value == ""){
		this.value = $(this).prev("label").html();
	}
});

$(".formbox label").each(function (i) {
	$(this).next("textarea").attr("value",$(this).html());
	$(this).hide();
});

$(".formbox textarea").focus(function() {
	if($(this).prev("label").html() == this.value){
	$(this).addClass("focus").setCursorPosition(0);
}
});

$(".formbox textarea").keypress(function() {
	if($(this).prev("label").html() == this.value){
		this.value = "";
		$(this).removeClass("focus").addClass("typing");
	}
});

$(".formbox textarea").blur(function() {
	$(this).removeClass("focus typing");
	if(this.value == ""){
		this.value = $(this).prev("label").html();
	}
});
	
	var passwordInputs = $('.formbox input[type=password]');
	$(passwordInputs).each(function(i){
		$(this).after('<input id="' + $(this).attr('id') + 'Holder" type="text" value="' + $(this).attr('value') +'" class="text required passwordPlaceholder" autocomplete="off" />');
	});
	
	var placeHolders = $('input.passwordPlaceholder');
	
	$(placeHolders).show();
$(passwordInputs).hide();

$(placeHolders).focus(function() {
	$(this).hide();
	var passID = '#' + $(this).attr('id').slice(0, -6);
	$(passID).show().focus();
});

$(passwordInputs).blur(function() {
	var holderID = '#' + $(this).attr('id') + 'Holder';
	if($(this).prev("label").html() == this.value) {
		$(holderID).show();
		$(this).hide();
	}
});

			
			
			
			}); //Close Document Ready


$(window).load(function() {
    $('#slider').nivoSlider({
        effect: 'sliceDown', // Specify sets like: 'fold,fade,sliceDown'
        slices: 15, // For slice animations
        animSpeed: 300, // Slide transition speed
        pauseTime: 4000, // How long each slide will show
        startSlide: 0, // Set starting Slide (0 index)
        directionNav: false, // Next & Prev navigation
        directionNavHide: true, // Only show on hover
        controlNav: true, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav: true, // Use left & right arrows
        pauseOnHover: true, // Stop animation while hovering
        manualAdvance: false, // Force manual transitions
        captionOpacity: 1, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
});




