/*
 * jQuery ifixpng plugin
 */
 var blank = new Image();
 blank.src = 'images/blank.gif';
 
 // Default jQuery Behaviours
$(function() {
	// run the code in the markup!
	$('code.jquery').each(function() {	eval($(this).text());	});
	// Add proper quotes to "q" elements
	$("q").prepend("&ldquo;").append("&rdquo;");
	$("q q").prepend("&lsquo;").append("&rsquo;");
	// Add classes to input pseudotypes
	$("input[type='text'], input[type='password']").addClass("text");
	$("input[type='text'], input[type='password']").focus(function(){	$(this).addClass("text-focus");	});
	$("input[type='text'], input[type='password']").blur(function(){	$(this).removeClass("text-focus");	});
	$("input[type='button'], input[type='submit'], input[type='checkbox'], input[type='image'], input[type='radio'], input[type='reset'], button").addClass("nontext");
	$("input[type='button'], input[type='submit'], input[type='reset'], button").addClass("button");
	$(".external").attr("target","_blank");	
	// Hide elements
	$('.hide').hide();
	//Add .hover to HTML elements other than "a"
	$('#topNav li').hover(function(){$(this).addClass("hover");}, function(){$(this).removeClass('hover');});
	//Add CSS and HTML elements
	$('#topNav ul, .postNav').append('<span class="left"></span><span class="right"></span>');
	$("#bottomNav li").append("&nbsp; &nbsp;")

// Plugin Behaviours 
	// Show/Hide title of input
	$("input[type='text']").labelify();
	// Add class="email" and href="mailto:name(at)example.com" to an email address link
	$('.obfuscated').defuscate();
	// Add tooltips to links with class="tooltip" and title="[insert content here]" 
	tooltip();
	// Apply IE6 only Scripts
	var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
	if (badBrowser) {
		// apply to all png images
		$('img[@src$=.png], #header h1 a, #vinCalculator a').ifixpng(); 
	}
	// Form Validation
	$("form").validate({
               rules: {
                confirm_password: {
                    equalTo: "#password"
                }
               },
               messages: {
                firstname: "Please enter your firstname",
                lastname: "Please enter your lastname",
                username: {
                    required: "Please enter a username",
                    minlength: "Your username must consist of at least 2 characters"
                },
                password: {
                    required: "Please provide a password",
                    minlength: "Your password must be at least 5 characters long"
                },
                confirm_password: {
                    required: "Please provide a password",
                    minlength: "Your password must be at least 5 characters long",
                    equalTo: "Please enter the same password as above"
                },
                email: "Please enter a valid email address",
                agree: "Please accept our policy"
            }
        }
 
            );


            $("button[type='cancel']").click(function() {
                    $(".required").removeClass("required");
            });
            $("button.cancel").click(function() {
                    $(".required").removeClass("required");
            });
}); // End jQuery Behaviours

