$(document).ready(function(){
	$(".add_file_field").click(function(){
		
		l = document.location.href.split("/").reverse()[0];
		reg = new RegExp(/new/);
		r = reg.exec(l);
		if(r == "new"){
			$(".files_upload_wrap").eq(0).append("<div class='file_field_wrap'>\n<input type='text' class='smfield' value='filename' name='filetitle[]'>\n<input type='file' class='smfieldform' name='file[]'>\n<a href='#' class='remove_file_field'>X</a>\n</div>");
		}else{
			$(".files_upload_wrap").eq(1).append("<div class='file_field_wrap'>\n<input type='text' class='smfield' value='filename' name='filetitle[]'>\n<input type='file' class='smfieldform' name='file[]'>\n<a href='#' class='remove_file_field'>X</a>\n</div>");
			
		}
		return false;
	});
	
	
	
	$(".remove_file_field").live("click",function(){
		$(this).parent("div").remove();
		return false;
	});
	$(".cancel_form").click(function(){
		document.location = "index.php";
		return false;
	});
	$(".list_table tr:odd").css({
		backgroundColor: '#eee'
	});
	$(".list_table tr:odd").css({
		backgroundColor: '#eee'
	});
	$(".st tr:odd").css({
		backgroundColor: '#eee'
	});
	$(".delete_hip").click(function(){
		var conf = confirm("Are you sure you wish to delete this HIP?\n This process cannot be undone.");
		if(conf){
			return true;
		}else{
			return false;
		}
	});
	$(".delete_file").click(function(){
		var conf = confirm("Are you sure you wish to delete this file?\n This process cannot be undone.");
		if(conf){
			return true;
		}else{
			return false;
		}
	});
	$(".show_change_password_form").click(function(){
		$(".overlay").fadeIn();
		$(".box").fadeIn();
		return false;
	});
	$(".hide_change_password_form").click(function(){
		$(".overlay").fadeOut();
		$(".box").fadeOut();
		return false;
	});
	$(".check_form").click(function(){
		p = $(".password").val();
		pc = $(".password_conf").val();
		
		if(p == ""){
			alert("Passwords cannot be blank. Please Check your input.");
		}else{
			if( p == pc ){
				$(".update_password").submit();
			}else{
				alert("Password do not match. Please Check your input.");
			}
		}
		return false;
	});
	$(".close_alert").click(function(){
		$(this).parent().fadeOut();
		return false;
	});
	
	removeNotice = function(){
		$(".close_alert").parent().fadeOut();
	}
	
	setTimeout("removeNotice()", 1000);
	
});