$(document).ready(function() {
	$("#listUrbanAssaults img").mouseover(function(){
		window.ciwidth = $(this).width();
		window.ciheight = $(this).height();
		$(this).removeAttr("width"); 
		$(this).removeAttr("height");
		var iwidth = $(this).width();
		var iheight = $(this).height();
		$(this).removeClass("outimg");
		$(this).addClass("overimg");
		$(this).parent().removeClass("out");
		$(this).parent().addClass("over");
    });
	$("#listUrbanAssaults img").mouseout(function(){
		$(this).attr({ 
          width: window.ciwidth,
          height: window.ciheight
        });

		$(this).parent().removeClass("over");
		$(this).parent().addClass("out");
		$(this).addClass("outimg");
		$(this).removeClass("overimg");
    });
	$('input[type="text"]').addClass("idleField");  
	$('input[type="text"]').focus(function() {  
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){  
			this.value = '';  
		}  
		if(this.value != this.defaultValue){  
			this.select();  
		}  
	});  
	$('input[type="text"]').blur(function() {  
		$(this).removeClass("focusField").addClass("idleField");  
		if ($.trim(this.value == '')){  
			this.value = (this.defaultValue ? this.defaultValue : '');  
		}  
	});
	$("input[type=file]").filestyle({ 
		image: "images/browse-button.gif",
		imageheight : 26,
		imagewidth : 70,
		width : 120
	});		   
	$("#ua_form").validate({
		rules: {
			fname: "required",
			lname: "required",
			email: {
				required: true,
				email: true
			},
			picturefile: "required",
			iname: "required",
			uaterms: "required"
		},
		messages: {
			fname: "Please enter your first name",
			lname: "Please enter your last name",
			email: "Please enter a valid email address",
			picturefile: "<<",
			iname: "Please name your image",
			uaterms: "You must agree to the terms"
		},
		errorPlacement: function(error, element) {
			error.appendTo( element.parent("div") );
		}
	});
	$("#iagreetrterms,.votebutton").fancybox({
		'frameWidth':320,
		'frameHeight':280,
		'hideOnContentClick':false
	});
});
