$(document).ready(function(){
	var img = $('#refreshimg');
	img.click(function(){
		$.post('userpass.php');
		var url = 'inc/captcha.php?v=1&m=' + Math.random();
		img.attr('src', url);
	});

	$emailMsg = "<div class=\"error_msg\" id=\"emailMsg\" style=\"display: none;\"><B>Sorry...</B><br /></div>";
	$("#contactform").before($emailMsg);
	$("#emailMsg").hide();
	$("#contact_form").validate({
		errorLabelContainer: $("#emailMsg"),
		rules: {
			"contact[name]": {
				required: true,
				minlength: 2,
				maxlength:30
			},
			"contact[email]": {
				required: true,
				email: true,
				minlength: 2
			},
			"contact[subject]": {
				required: true,
				minlength: 2,
				maxlength:50
			},
			"contact[category]": {
				required: true
			},
			"contact[message]": {
				required: true,
				minlength: 2,
				maxlength:500
			},
			"contact[userpass]": {
				required: true,
				remote: "userpass.php"
			}
		}, 
		messages: {
			"contact[name]": {
				required: "Your Name field is regdfgquired.",
				minlength: "Your Name must be between 2 and 30 Characters long."
				
			},
			"contact[email]": {
				required: "Your E-Mail field is regdfgquired.",
				email: "Please enter a valid E-Mail address."
			},
			"contact[subject]": {
				required: "Subject field is regdfgquired.",
				minlength: "Subject must be between 2 and 50 Characters long."
			},
			"contact[category]": {
				required: "Category field is regdfgquired."
			},
			"contact[message]": {
				required: "Message field is regdfgquired.",
				minlength: "Message must be between 2 and 500 Characters long."
			},
			"contact[userpass]": {
				required: "Captcha Code field is regdfgquired.",
				remote: "Captcha Code wrong."
			}
		}
	});
	
	$(".video").click(function() {
        
        	$url = $(this).attr("href");
        	$id = $(this).attr("id");

       		$dialog = $("<div id="+$id+" style=\"display: none;\"></div>");
			$("body").append($dialog);
			$dialog.load($url, function() {
       			$dialog.dialog({
				height: 550,
				width: 688,
				title: "Sunny Jane Rose",
				modal: true,
				close: function() {
					$(this).parent().detach();
				}
			});
        	});
        	return false;
	});
	
	$('a.dele').click(function(event) {
		event.preventDefault();
		$thisHref = $(this).attr('href');
		if(confirm('Are you sure?')) {
			window.location = $thisHref;
		}
	});
	
	$('img.delete').click(function(event) {
		event.preventDefault();
		$thisHref = $(this).parent().attr('href');
		if(confirm('Are you sure?')) {
			window.location = $thisHref;
		}
	});
});

