jQuery(document).ready(function() {	
	jQuery('.portfolio .text .textwidget').css({width: '580px', padding: '20px 10px 20px 20px', top: '70px'});
	jQuery('#disciplines_all .caption, .portfolio .text .textwidget, #disciplines_all li .caption').css('position', 'absolute');

	var close = "<button class='close'><img src=\"/images/layout/close.gif\" alt=\"Close\" /></button>";

	jQuery('.size-thumbnail').parent('div').css('width', '170px')
	jQuery('#nav ul').each(function() {jQuery(this).children("li:first").css('background-image', 'none');})
	jQuery('#callout li:last').css('background-image', 'none');
	// jQuery('#signupform').hide()
	// jQuery('#newsletter a').click(function() {
	// 	if (jQuery('#signupform').is(":hidden")) {
	// 		jQuery('#signupform').show("slow");
	// 	} else {
	// 		jQuery('#signupform').hide("slow");
	// 	};
	// 	return false;
	// });

function getFormValues(form) {
	var str = jQuery(form).serialize();
	return str;
}
function getFormAction(form) {
	var url = jQuery(form).attr("action");
	return url;
}

jQuery('#contact #Submit').click(function() {
	var datastr = getFormValues("#contact")+"&url="+getFormAction("#contact");
	jQuery.ajax({
		type: "POST",
		url: "/proxy.php",
		data: datastr,
		success: function(data){
			if (data.match("invalid email") || data.match("required information")) {
				jQuery('#msg').replaceWith("<div id=\"msg\">"+data+"</div>");
				} else if (data.match("Thank you!")) {
					window.location="http://www.lemleydesign.com/thank-you";
				} else {
				jQuery('#contact').replaceWith("<div id=\"contact\">"+data+"</div>");
			}
		}
	});
	return false;
});


jQuery('#signup #submit').click(function() {
	var datastr = getFormValues("#signup")+"&url="+getFormAction("#signup");
	jQuery.ajax({
		type: "POST",
		url: "/proxy.php",
		data: datastr,
		success: function(data){
			if (data.match("invalid email") || data.match("required information")) {
				jQuery('#msg').replaceWith("<div id=\"msg\">"+data+"</div>");
				} else {
				jQuery('#iframe').replaceWith("<div id=\"iframe\">"+data+"</div>");
			}
		}
	});
	return false;
});
	// jQuery('#result .close').click(function() {
	// 		jQuery('#result').remove();
	// 		jQuery('#content > div, #disciplines_all').css('position', 'relative').css('left', '0');
	// 		jQuery('#sidebar').css('position', 'static');
	// });

	jQuery('#roger').click(function () {
		if (jQuery('#manifesto').length > 0) {
			jQuery('#manifesto').remove();
			jQuery('#content > div').css({position: 'relative', left: '0'});
			jQuery('#disciplines_all').css({right: '10px', display: 'block', left: 'auto'});
			jQuery('#sidebar').css('position', 'static');
			jQuery('body').removeClass("manifesto");
			jQuery(this).css('margin-right', '15px');
		} else {
				jQuery.ajax({
				   type: "GET",
				   url: "/index.php",
				   data: "pagename=manifesto",
				   success: function(data){
					jQuery('#content > div, #disciplines_all').css({position: 'absolute', left: '-9999px'});
					jQuery('#content').append(data);
					jQuery('#manifesto').hide().fadeIn("fast");
					jQuery('body').addClass("manifesto");
					jQuery("#roger").css('margin-right', '-2px');
				   }
				 });
		}
		return false;
	})
	jQuery('a.media').media();
		
	jQuery('.flash').each(function() {
			var flashsrc = jQuery('.flash').attr("href");
			if (flashsrc.match("swf")) {
			jQuery('.flash').media({ src: flashsrc, width:730, height:326 });
			}
			jQuery(this).parent('div').css('float', 'left')		
	}) 

	jQuery('.portfolio .text h3').next(".textwidget").hide();
	jQuery('.caption, .portfolio .textwidget').prepend(close)

	jQuery('.caption .close, .textwidget .close').click(function() {
		jQuery('.caption, .textwidget').hide();
		jQuery(".scope").removeClass("active");
		
	});

	jQuery('.portfolio .text h3').click(function() {
		jQuery(".scope").removeClass("active");
		if (jQuery(this).next(".textwidget").is(":visible")) {
			jQuery(this).next(".textwidget").hide();
		} else {
			jQuery(this).next(".textwidget").fadeIn("fast");
			jQuery('#disciplines_all .caption').hide()
		}

	});	



s = 1;


var options = {
	flvPlayer: '/flvplayer.swf'
};
// Shadowbox.loadLanguage('en', 'build/lang');
// Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], 'wp-content/themes/lemley/script/shadowbox/player');
Shadowbox.init(options);


	jQuery('form#contact').validate({
		rules: {
			Firstname: "required",
			Lastname: "required",
			Email: {
				required: true,
				email: true
			},
			Message: "required"
		},
		messages: {
			Firstname: "Please enter your first name",
			Lastname: "Please enter your last name",
			Email: "Please enter a valid email address",
			Message: "Please enter a comment"
		}
	})


	jQuery('#signup').validate({
		rules: {
			Firstname: "required",
			Lastname: "required",
			Email: {
				required: true,
				email: true
			}
		},
		messages: {
			Firstname: "Please enter your first name",
			Lastname: "Please enter your last name",
			Email: "Please enter a valid email address"
		}
	})


});
		
		
		// 
		// if ( ) {
		// 	
		// 	jQuery("#content").remove('#manifesto');
		// 	
		// 	} else {
		// 		
		// 		
		// }
		
		
		



