$(function() {
	$('#nav li a, .nav li a').live('click', function(){
		$.scrollTo($(this).attr('href'), 1000, { offset: 0 });
		return false;
	});
});
function pageReady() {
	Cufon.now();
}
function CufonReplace() {
	Cufon.replace('#nav li a', { fontFamily: 'ArcherSemiBold', hover: false});
	Cufon.replace('#nav li a.active', { fontFamily: 'ArcherBoldIt' , hover: false});
	Cufon.replace('.article h3 span', { fontFamily: 'ArcherMedium'});
	Cufon.replace('.nav li a:not(.active)', { fontFamily: 'ArcherMedium', hover: {
		textShadow: '2px 2px rgba(0,0,0,0.3)',
		color: '-linear-gradient(white, #FFF58F)'
	}});
	Cufon.replace('.nav li a.active', { fontFamily: 'ArcherBoldIt', hover: false});
	Cufon.replace('.frame h4', { fontFamily: 'ArcherSemiBold'});
	Cufon.replace('.article p', { fontFamily: 'ArcherMedium'});
	Cufon.replace('.article h3 em', { fontFamily: 'ArcherSemiBoldIt'});
	Cufon.replace('#footer p', { fontFamily: 'ArcherMedium', hover: {
		textShadow: '2px 2px black',
		color: '-linear-gradient(white, #eee)'
	}
});
	Cufon.replace('#signup label span', { fontFamily: 'ArcherBook', hover: true});
	Cufon.replace('.our-designers h2', { fontFamily: 'ArcherSemiBold'});
}

$(document).ready(function(e){
							   
	/*$('.rightsided').stickyfloat({ 
		duration: 0,
		offsetY: 15
	});*/

	$imageReplace = $('#image-replace');
	$imageWrapper = $('#image-wrapper');
	$image = $('#image-wrapper').find('img:first');

	$('.leftsided li a').live('click',function(e){
		
		e.preventDefault();
		
		newImg = $(this).attr('href');
		newTitle = $(this).parents('li').find('p').html();
		newDescription = $(this).attr('title');
		
		$imageReplace.find('.fade').animate({
			opacity: 0
		}, 500, function() {
			$imageReplace.find('img').attr('src',newImg);
			$imageReplace.find('h4').html(newTitle);
			Cufon.replace('.frame h4', { fontFamily: 'ArcherSemiBold'});
			$imageReplace.find('p').html(newDescription);
			$imageReplace.delay(1000).find('.fade').animate({
				opacity: 1
			}, 500);
		});
		
		
	});
	
	$form_fields = $('form input[type="text"],form input[type="password"],form textarea');
	$form_labels = $('form fieldset label');
	
	$form_fields.each(function(){
		
		if($(this).val().length>0){
			$label = $(this).parents('fieldset').find('label');
			$label.fadeOut(400);
		}
	});
	
	$form_labels.live('click',function(e){
					
		$(this).parents('fieldset').find('input,textarea').focus();

	});
	
	$form_fields.live('focus',function(e){
													
		$label = $(this).parents('fieldset').find('label');
		if($(this).val().length==0){
			$label.fadeTo(400,'0.2');
		}
		
	});
	
	$form_fields.live('blur',function(e){
												 
		$label = $(this).parents('fieldset').find('label');
		if($(this).val().length==0)
			$label.fadeTo(400,'1.0');
		
	});
	
	$form_fields.live('keyup',function(e){
		
		if($(this).val().length>0)
			$label.fadeOut(100);
		else
			$label.fadeIn(500);
	
	});

	//add click handler for show-plain link(s)
	$(".show-plain").live("click", function() {
	
	  //cache selector
	  var input = $(this).prev();
	
	  //create new text input
	  $("<input>").attr({
	    id: input.attr("id"),
	    type: "text",
	    name: input.attr("name")
	  }).val(input.val()).addClass(input.attr("class")).insertAfter(input.prev());
	  input.remove();
	
	  //change link text and attributes
	  $(this).text("Hide password").removeClass("show-plain").addClass("show-hidden").attr({
	    title: "Obscure the text"
	  });
	
	  //stop link being followed
	  return false;
	});

	//add click handler for show-plain link(s)
	$(".show-hidden")
	.live("click", function() {
	
	  //cache selector
	  var input = $(this).prev();
	
	  //create new password input
	  $("<input>").attr({
	    id: input.attr("id"),
	    type: "password",
	    name: input.attr("name")
	  }).val(input.val()).addClass(input.attr("class")).insertAfter(input.prev());
	  input.remove();
	
	  //change link text and attributes
	  $(this).text("Show password").removeClass("show-hidden").addClass("show-plain").attr({
	    title: "Show the password in plain text"
	  });
	
	  //stop link being followed
	  return false;
	  
	});
	
});
