function checkAdminVerifyAttributes(name, attribute_id, rs, targetType, obj, verify_user_id, verify_address_id) {
	if(rs.test(obj.attr("id")) && !$(document).find("#jqi").attr("class") 
	&& (jQuery.inArray(name+"-"+verify_user_id,admin_verified_attribute_array) != -1 || jQuery.inArray(name+"-"+verify_address_id,admin_verified_attribute_array) != -1)
	&& $(document).find("span[id='"+attribute_id+"']").attr("not_verified") != "yes") {
			$.prompt("<span style='color:red'>Warning</span> - this attribute has been notarized you can not change it!<br/>If you insist on change it the notarization of this attribute will be removed!", {
				opacity: 0.75,
				buttons: { Continue: true, Cancel:false },
				focus: 1,
				callback: function(v,m) {
					if (v){
						$.getJSON("/repsheet/profile_attribute.php", { cmd: "delete_verified_attribute", be_verified_user_id:page_user_id, label: attribute_id, type:"va" },
						function(json) {
							if (json && json.error) {
								if (attribute_id) {
									$("#"+attribute_id).append('<span class="error">' + json.error + '</span>');
								}
								else {
									alert(json.error);
								}
								return false;
							}
							if(/address/i.test(obj.attr("id"))) {
								obj.parents(".repsheet_right_body_content").find("img").each(function() {
									if(/address/i.test($(this).attr("id"))) {
										$(this).css("display","none");
									}
								});
							}else{
								$(document).find("img[id='verify_"+attribute_id+"']").css("display","none");
							}
							$(document).find("img[id='verify_"+attribute_id+"']").css("display","none");
						});
							$(document).find("span[id='"+attribute_id+"']").attr("not_verified","yes");
						if($.browser.msie) {
							$(document).find("span[id='"+attribute_id+"']").click();
						}
						$(document).find(targetType+"[name='"+name+"']").focus();
					}else{
						$(document).find(targetType+"[name='"+name+"']").blur();
					}
				}
			}).children('#jqi').corner();
			return false;
	}
}

function autoAdjustHintBox(obj) {
	if(hintsStatusGlobal == 0) {
		$("#shiny_box_" + obj.attr("id")).css({display:"none"});
	}
	if($("#shiny_box_" + obj.attr("id")).attr("state") != "ready") {
		var incrementLeft = 20;
		var marginForIE = 0;
		if( /first_name/i.test(obj.attr("id")) || /last_name/i.test(obj.attr("id")) || /birthday/i.test(obj.attr("id")) || /gender/i.test(obj.attr("id")) || /marital_status/i.test(obj.attr("id")) || /ethnicity/i.test(obj.attr("id")) || /language/i.test(obj.attr("id")) || /timezone/i.test(obj.attr("id"))) {
			incrementLeft = incrementLeft + 110;
		}
		var left = obj.find("input").width() + incrementLeft + 5 + ($.browser.safari ? 5 : ($.browser.msie ? 10 : ($.browser.mozilla ? 6 : 0)));
		if(obj.find("input").width() == null) {
			left = obj.find("select").width() + incrementLeft + 5 + ($.browser.safari ? 5 : ($.browser.msie ? 10 : ($.browser.mozilla ? 6 : 0)));
		}
		if(obj.find("input").width() == null && obj.find("select").width() == null ) {
			left = obj.find("textarea").width() + incrementLeft + 5 + ($.browser.safari ? 5 : ($.browser.msie ? 10 : ($.browser.mozilla ? 6 : 0)));
		}
		if($.browser.msie){
			marginForIE = "25px";
		}
		$("#shiny_box_" + obj.attr("id")).css({left:left,padding:"5px","margin-top":marginForIE}).attr("state","ready").corner();
	}
}
function notarization_check(obj,focus) {
var target = obj;
var focusTarget = focus;
	$(target).click(function() {
		$(target).unbind();
		$(target).click(function() {
			$.prompt("<span style='color:red'>Warning</span> - this attribute has been notarized you can not change it!", {
				opacity: 0.75,
				buttons: { Ok: true },
				focus: 1,
				callback: function(v,m) {
					if (v){
	
					}else{
						
					}
				}
			}).children('#jqi').corner();
			return false;
		});
		$.prompt("<span style='color:red'>Warning</span> - this attribute has been notarized you can not change it!", {
			opacity: 0.75,
			buttons: { Ok: true },
			focus: 1,
			callback: function(v,m) {
				if (v){

				}else{
					
				}
			}
		}).children('#jqi').corner();
		return false;
	});
}

function attrDelete(label, prompt, deleteElms) {
	$.prompt(prompt, {
		opacity: 0.75,
		buttons: { Ok: true, Cancel: false },
		focus: 1,
		callback: function(ok) {
			if (!ok){
				return;
			}
			$.getJSON("/repsheet/profile_attribute.php", { cmd: "delete", label: label },
				function(json) {
					if (json && json.error) {
						if (deleteElms && deleteElms[0]) {
							$(deleteElms[0]).append('<span class="error">' + json.error + '</span>');
						}
						else {
							alert(json.error);
						}
						return false;
					}
					for (var key in deleteElms){
						if(key) {
							deleteElms[key].slideUp(function() { $(this).remove(); });
						}
					}
				}
			);
		}
	}).children('#jqi').corner();
	return false;
}

function readyVerifications(label) {
	$("span[id='" + label + "']").parent().next(".detail_box_right_ver")
		.click(function() {
			$this = $(this);

			// Verify the attribute
			var href = $this.find("a").attr("href");
			if (href.charAt(href.length-1) != "#") {
				var img = $this.find("img");
				imgSrc = img.attr("src");
				img.attr("src", gTLD + "/image/loading-16.gif");

				// Hit the verifier's login
				$.getJSON($this.find("a").attr("href"),
					function(json) {
						img.attr("src", imgSrc);
						if (json && json.error) {
							$(".error").remove();
							$(".repsheet_mainbox:first").before('<div class="error">' + json.error + '</div>');
							return false;
						}

						$.prompt('<iframe width="' + json.width + '" height="' + json.height + '" src="' + json.url + '" name="vframe" />', {
							opacity: 0.75,
							buttons: { Done: true },
							focus: 0,
							callback: function(ok) {
								window.location.reload();
							}
						})
						.children('#jqi').corner()
						.find("#jqibuttons button").css("display", "none");
					}
				);
			}

			// Show the verify card
			else {
				var markup = "This attribute has been verified by a teacher as part of the <a href=\"http://www.isafe.org/\" target=_isafe>i-SAFE</a> Internet safety education program.";
				$.prompt(markup, {
					opacity: 0.75,
					buttons: { Ok: true },
					focus: 0
				}).children('#jqi').corner();
			}

			return false;
		});
}

function attrVerify(label, value, profile, userId, flags) {
	if (!value || value === ''){
		return;
	}
	flags = flags ? 1 : 0;
	profile = profile ? 1 : 0;
	var name = $("span[id='" + label + "']").parent().parent().find("label").text().replace(":", "");

	var data = { cmd: "verify", label: label, value: value, profile: profile, uid: userId };
	data.vurl = "/verify/trufina/login.php";	// BUGBUG: hard-code Trufina for now
	if (name.length > 1){
		data.name = name;
	}
	if (flags){
		data.flags = flags;
	}
	// Need to do this in "jsonp callback" mode since this will be called from user.identity.net
	$.getJSON(gTLD + "/repsheet/profile_attribute.php?callback=?", data,
		function(json) {
			if (json && json.error) {
				var p = $("#" + label).parents(".detail_box_bg");
				p.find(".error").remove();
				p.find(".detail_box_right").append("<span class='error'>" + json.error + "</span>");
				return false;
			}
			if (json && json.markup) {
				var parent = $("span[id='" + label + "']").parent();
				var ver = parent.next(".detail_box_right_ver");
				if (ver.length) {
					ver.remove();
				}
				parent.after(json.markup);
				readyVerifications(label);
			}
		}
	);
}

function check_access(json) {
	if(json.type && json.type == 'redirect') {
		window.location = json.action;
	}
}

function cmdsAdd(self) {
	var $self = $(self);

	var markup;
	// Deletes
	if ($self.attr("deletable") == "true") {
		$self.siblings(".delete-cmd").remove();
		markup = '';
		markup +=	'<span class="delete-cmd"><a href="#" title="delete" onclick=" ';
		markup +=	'$this = $(this); ';
		markup +=	'return attrDelete( ';
		markup +=	'	$this.parent().siblings(\'span:first\').next().attr(\'id\'), ';
		markup +=	'		\'Are you sure you want to remove this?\', ';
		markup +=	'		[$this.parents().filter(\'div.detail_box_repsheet\')] ';
		markup +=	'	);" ';
		markup +=	'><img height="10" width="10" alt="" src="'+ idconf_tld +'/image/id_repsheets/icons/delete_red.png"/>Delete</a></span> ';
		$self.after(markup);
	}

	// Edits
	if (typeof $self.attr('editable') == 'undefined' || $self.attr('editable') == 'true') {
		$self.siblings('.edit-cmd').remove();
		markup = '';
		markup +=	'<span class="edit-cmd">';
		markup +=	'</span> ';
		$self.after(markup);
		$self.parent().parent().find('.remove-cmd-main').attr('style","display:inline;');
	}
}

function editCancel(self) {
	var $self = $(self);
	if (!$self.text().length) {
		$self.parent().prev().remove();
		$self.parent().remove();
	}
	else{
		$self.siblings(".edit-cmd, .delete-cmd").show();
	}
		$self.parent().parent().find(".remove-cmd-main, .remove-cmd-accomplishment").attr("style","display:inline;");
}

function editSubmitted(self, json, next) {
	$self = $(self);
	if (json && json.error) {
		var p = $self.parent("p");
		p.find(".error").remove();
		p.append("<span class='error'>" + json.error + "</span>");
	}
	cmdsAdd(self);

	// Check verification
	if ($self.parent().next('.detail_box_right_ver').length){
		attrVerify($self.attr('id'), $self.text(), true);
	}

	if($.browser.msie && !this.submitsource){
		next = true;
	}
	if($.browser.msie && this.submitsource!="blur"){
		next = true;
	}
	if(/address_country/i.test($self.attr("id"))){
		country = $self.html();
	}

	$self.parent().parent().find(".remove-cmd-main, .remove-cmd-accomplishment").attr("style","display:inline;");

	// Click the next item
	if (next) {

		var n = $self;
		var e;
		for (var i = 0;i < 5 ;i++ ) {
			n	= n.parent();
			e = n.next('div').find(".edit-text, .edit-select, .edit-textarea");
			if (e.length == 1){
				if(/address_region/i.test(e.attr("id"))){
					countryLoadRepSheet(2,country,e.attr('id'),1);
				}else{
					e.click();
				}
				return true;
			}else if(e.length > 1){
				return false;
			}
			e = n.next('div').next('div span').find('.edit-text, .edit-select, .edit-textarea');
			if (e.length == 1 ){
				if(/address_region/i.test(e.attr("id"))){
					countryLoadRepSheet(2,country,e.attr('id'),1);
				}else{
					e.click();
				}
				return true;
			}else if(e.length > 1){
				return false;
			}

			e = n.next('span').find('.edit-text, .edit-select, .edit-textarea');
			if (e.length == 1 ){
				if(/address_region/i.test(e.attr("id"))){
					countryLoadRepSheet(2,country,e.attr('id'),1);
				}else{
					e.click();
				}
				return true;
			}else if(e.length > 1){
				return false;
			}

			e = n.next('span').next('span').find('.edit-text, .edit-select, .edit-textarea');
			if (e.length == 1 ){
				if(/address_region/i.test($(this).attr("id"))){
					countryLoadRepSheet(2,country,e.attr('id'),1);
				}else{
					e.click();
				}
				return true;
			}else if(e.length > 1){
				return false;
			}
			// this is master of onclick with basic
			e = n.next('h5').find('.edit-text, .edit-select, .edit-textarea');
			if (e.length == 1 ){
				if(/address_region/i.test($(this).attr("id"))){
					countryLoadRepSheet(2,country,e.attr('id'),1);
				}else{
					e.click();
				}
				return true;
			}else if(e.length > 1){
				return false;
			}
			// this is master of onclick with basic
			e = n.next('h5').next('p').find('.edit-text, .edit-select, .edit-textarea');
			if (e.length == 1 ){
				if(/address_region/i.test($(this).attr("id"))){
					countryLoadRepSheet(2,country,e.attr('id'),1);
				}else{
					e.click();
				}
				return true;
			}else if(e.length > 1){
				return false;
			}	
			
		}
		return false;
	}
	
}

function readySelects() {
	$(".edit-select")
		.each(function() {
			$this = $(this);
			var name = $this.attr("id").match(/(\w+)-(\d+)/) ? $this.attr("id").match(/(\w+)-(\d+)/)[1] : $this.attr("id");
			var submitHtml = "";
			if(/phone_type/i.test($this.attr("id")) || /im_type/i.test($this.attr("id")) || /email_type/i.test($this.attr("id"))) {
				submitHtml = '<span class="edit-cmd"><a href="#" title="save"><img height="7" width="7" src="'+idconf_tld+'/image/id_repsheets/icons/save.png"/>Save</a></span>';
			}else{
				submitHtml = '<span class="edit-cmd"><a href="#" title="save"><img height="7" width="7" src="'+idconf_tld+'/image/id_repsheets/icons/save.png"/>Save</a></span>';
			}
			$this.editable("/repsheet/profile_attribute.php", {
				submitdata: { cmd: "save" },
				type: "select",
				data: function() {return $(this).attr("data");},
				id: "label",
				value: $this.attr("id"),
				name: name,
				hint: $this.attr("hint"),
				indicator: "<img src='" + "/image/loading-16.gif'>",
				tooltip: $(this).siblings(".edit-placeholder").html(),
				placeholder: '<span class=\"editable\">' + $(this).siblings(".edit-placeholder").html() + '</span>',
				style: "inherit",
				cancel: '<span class="edit-cmd"><a href="#" title="cancel"><img height="10" width="10" alt="" src="'+idconf_tld+'/image/id_repsheets/icons/delete.png"/>Cancel</a></span>',
				submit: submitHtml,
				ontab: "submit",
				onsubmit: function(value, settings, json) {
					if(settings.name == "address_type") {
						address_id = $(this).attr("id").split("-");
						$("#repsheet_subhead_address-" + address_id[1]).text(value);
					}
					if(settings.name == "patents_country_code") {
						var subheadStr = "";
						patents_id = $(this).attr("id").split("-");
						patents_patents_num_id = "span[id='patents_patents_num-"+patents_id[1]+"']";
						patents_country_code_id = "span[id='patents_country_code-"+patents_id[1]+"']";
						if($(patents_patents_num_id).text() != "Add Patent Number" && value != ""){
							subheadStr = $(patents_country_code_id).text()+" Patent No. "+$(patents_patents_num_id).text();
						}else{
							subheadStr = "";
						}
						$("#repsheet_subhead_patents_name-" + patents_id[1]).text(subheadStr);
					}
					check_access(json);
					//alert(settings.html());
					editSubmitted(this, json, this.submitsource != "blur");
				},
				oncancel: function(value, settings) { editCancel(this); },
				onblur: "cancel"
			});
			cmdsAdd(this);
		})
		.click(function() {
			$this = $(this);
			if(/gender/i.test($this.attr("id")) || /country_code/i.test($this.attr("id"))) {
				$this.find("select").css("width","110px");
			}
			var name = $this.attr("id").match(/(\w+)-(\d+)/) ? $this.attr("id").match(/(\w+)-(\d+)/)[1] : $this.attr("id");
			var attribute_id = $this.attr("id").match(/(\w+)-(\d+)/) ? $this.attr("id").match(/(\w+)-(\d+)/)[0] : $this.attr("id");
			$(this).siblings(".edit-cmd, .delete-cmd").hide();
			$(this).parent().parent().find(".remove-cmd-main").hide();
			autoAdjustHintBox($(this));
			var rs = new RegExp(name,"i");
			if(rs.test($(this).attr("id")) && !$(document).find("#jqi").attr("class") 
			&& (jQuery.inArray(name+"-"+page_user_id,verified_attribute_array) != -1 || jQuery.inArray(name+"-"+page_attr_school_id,verified_attribute_array) != -1)
			&& $(document).find("span[id='"+attribute_id+"']").attr("not_verified") != "yes") {
					$.prompt("<span style='color:red'>Warning</span> - this attribute has been notarized you can not change it!<br/>If you insist on change it the notarization of this attribute will be removed!", {
						opacity: 0.75,
						buttons: { Continue: true, Cancel:false },
						focus: 1,
						callback: function(v,m) {
							if (v){
								$.getJSON("/repsheet/profile_attribute.php", { cmd: "delete_verified_attribute", label: attribute_id, repsheet_id: page_repsheet_id },
								function(json) {
									if (json && json.error) {
										if (attribute_id) {
											$("#"+attribute_id).append('<span class="error">' + json.error + '</span>');
										}
										else {
											alert(json.error);
										}
										return false;
									}
								});
									$(document).find("span[id='"+attribute_id+"']").attr("not_verified","yes");
								if($.browser.msie) {
									$(document).find("span[id='"+attribute_id+"']").click();
								}
								$(document).find("select[name='"+name+"']").focus();
							}else{
								$(document).find("select[name='"+name+"']").blur();
							}
						}
					}).children('#jqi').corner();
					return false;
			}
			//for admin verified
			checkAdminVerifyAttributes(name, attribute_id, rs, "select", $(this), page_user_id, 0);
			var obj_this = $(this);
			if(jQuery.inArray($(this).attr("id"),admin_verified_attribute_array) != -1) {
				$.each(address_id_array,function(i, n){
					checkAdminVerifyAttributes(name, attribute_id, rs, "select", obj_this, 0, n);
				});
			}
		});
}

function readyTextBoxes(validate) {
	$(".edit-text")
		.each(function() {
			$this = $(this);
			if ($this.siblings(".edit-cmd").length) {	// already initialized
				return;
			}
			var name = $this.attr("id").match(/(\w+)-(\d+)/) ? $this.attr("id").match(/(\w+)-(\d+)/)[1] : $this.attr("id");
			/*Modified for ticket 471*/
			var textWidth = "";
			var submitHtml = "";
			var birthday = "";
			if(/phone_number/i.test($this.attr("name"))) {
				textWidth = $this.width()*2 || 180;
				if(textWidth > 180){
					textWidth = 180;
				}
				submitHtml = '<span class="edit-cmd"><a href="#" title="save"><img height="7" width="7" src="'+idconf_tld+'/image/id_repsheets/icons/save.png"/>Save</a></span>';
			}else if(/address_extended/i.test($this.attr("id")) || /address_street/i.test($this.attr("id"))){
				textWidth = 140;
				submitHtml = '<span class="edit-cmd"><a href="#" title="save"><img height="7" width="7" src="'+idconf_tld+'/image/id_repsheets/icons/save.png"/>Save</a></span>';
			}else if(/im_screen_name/i.test($this.attr("id")) || /birthday/i.test($this.attr("id"))){
				textWidth = 70;
				submitHtml = '<span class="edit-cmd"><a href="#" title="save"><img height="7" width="7" src="'+idconf_tld+'/image/id_repsheets/icons/save.png"/>Save</a></span>';
			}else if(/email/i.test($this.attr("id"))){
				textWidth = 120;
				submitHtml = '<span class="edit-cmd"><a href="#" title="save"><img height="7" width="7" src="'+idconf_tld+'/image/id_repsheets/icons/save.png"/>Save</a></span>';
			}else{
				textWidth = 100;
				submitHtml = '<span class="edit-cmd"><a href="#" title="save"><img height="7" width="7" src="'+idconf_tld+'/image/id_repsheets/icons/save.png"/>Save</a></span>';
			}
			/*end*/
			$this.editable("/repsheet/profile_attribute.php", {
				submitdata: { cmd: "save", data: $this.attr("data") },
				type: "validate",
				onvalidate: validate,
				id: "label",
				value: $this.attr("id"),
				name: name,
				hint: $this.attr("hint"),
				mask: $this.attr("mask"),
				indicator: "<img src='" + "/image/loading-16.gif'>",
				tooltip: $(this).siblings(".edit-placeholder").html(),
				placeholder: '<span class=\"editable\">' + $(this).siblings(".edit-placeholder").html() + '</span>',
				style: "inherit",
				width: textWidth,
				height: parseInt($("body").css("fontSize")),
				cancel: '<span class="edit-cmd"><a href="#" title="cancel"><img height="10" width="10" alt="" src="'+idconf_tld+'/image/id_repsheets/icons/delete.png"/>Cancel</a></span>',
				submit: submitHtml,
				ontab: "submit",
				onsubmit: function(value, settings, json) {
					if(settings.name == "workplace_employer") {
						workplace_employer_id = $(this).attr("id").split("-");
						value = value.replace("&amp;","&");
						$("#repsheet_subhead_employer-" + workplace_employer_id[1]).text(value);
					}
					if(settings.name == "school_name") {
						school_id = $(this).attr("id").split("-");
						$("#repsheet_subhead_school_name-" + school_id[1]).text(value);
					}
					if(settings.name == "patents_patents_num") {
						var subheadStr = "";
						var country_name = "";
						patents_id = $(this).attr("id").split("-");
						patents_country_code_id = "span[id='patents_country_code-"+patents_id[1]+"']";
						if($(patents_country_code_id).text() != "Select Country" && value != ""){
							subheadStr = $(patents_country_code_id).text()+" Patent No. "+value;
						}else{
							subheadStr = "";
						}
						$("#repsheet_subhead_patents_name-" + patents_id[1]).text(subheadStr);
					}
					if(settings.name == "xfn_name") {
						xfn_id = $(this).attr("id").split("-").pop();
						$("#repsheet_subhead_xfn-" + xfn_id).text(value);
					}
					
					if(settings.name == "xfn_url") {
						xfn_id = $(this).attr("id").split("-").pop();
						getXfnAvatar(xfn_id);
/* 						xfn_id = $(this).attr("id").split("-").pop();
						
						re = /^(http:\/\/)?([0-9a-zA-Z-_]{0,32})\.identity\.net/i; 
						r = value.match(re);
						qdata = {};
						qdata["cmd"] = 'getXfnAvarta';
						qdata["name"] = r[2];

						$.post("/repsheet/profile_attribute.php",qdata,
							function(data){
								//alert("Data Loaded:   " + data);
								$('#repsheet_subhead_xfn-'+xfn_id).find('.xfn_avatar_s').attr('src',data);
								$('#detail-box-content-xfn-'+xfn_id).find('.xfn_avatar_b').attr('src',data);
							}
						);  */
					}

					if(settings.name == "birthday") {
						birthday = value.split("-");
						if(birthday[0] == "00" && birthday[1] == "00") {
							if ($('#birthday_filter-' + page_repsheet_id).attr("checked") === false) {
								if ($.browser.safari) { 
									$('#birthday_filter-' + page_repsheet_id).attr("checked",true);
									$('#birthday_filter-' + page_repsheet_id).click().change();
									$('#birthday_filter-' + page_repsheet_id).attr("checked",true);
								}else{
									$('#birthday_filter-' + page_repsheet_id).click().change();
								}
							} else {
							}
						}
					}
					check_access(json);
					editSubmitted(this, json, this.submitsource != "blur");
					if($(this).attr("title") == 'Add First Name'){
						$('#welcomeUser').html('Welcome ' + $(this).text());
					}
					autoAdjustFontSize($("span[title='Add First Name']"),$("span[title='Add First Name']"),90,36);
					autoAdjustFontSize($("span[title='Add Middle Name']"),$("span[title='Add Middle Name']"),90,36);
					autoAdjustFontSize($("span[title='Add Last Name']"),$("span[title='Add Last Name']"),90,36);
				},
				oncancel: function(value, settings) {
					editCancel(this);
					autoAdjustFontSize($("span[title='Add First Name']"),$("span[title='Add First Name']"),90,36);
					autoAdjustFontSize($("span[title='Add Middle Name']"),$("span[title='Add Middle Name']"),90,36);
					autoAdjustFontSize($("span[title='Add Last Name']"),$("span[title='Add Last Name']"),90,36);
				},
				onblur: "cancel"
			});
			cmdsAdd(this);
		})
		.click(function() {
			$this = $(this);
			$(this).siblings(".edit-cmd, .delete-cmd").hide();
			$(this).parent().parent().find(".remove-cmd-main").hide();
			autoAdjustHintBox($(this));
			var name = $this.attr("id").match(/(\w+)-(\d+)/) ? $this.attr("id").match(/(\w+)-(\d+)/)[1] : $this.attr("id");
			var attribute_id = $this.attr("id").match(/(\w+)-(\d+)/) ? $this.attr("id").match(/(\w+)-(\d+)/)[0] : $this.attr("id");
			var rs = new RegExp(name,"i");
			//for admin verified
			checkAdminVerifyAttributes(name, attribute_id, rs, "input", $(this), page_user_id, 0);
			var obj_this = $(this);
			if(jQuery.inArray($(this).attr("id"),admin_verified_attribute_array) != -1) {
				$.each(address_id_array,function(i, n){
					checkAdminVerifyAttributes(name, attribute_id, rs, "input", obj_this, 0, n);
				});
			}
		 });
}

function readyTextAreas() {
	$(".edit-textarea")
		.each(function() {
			$this = $(this);
			var colsNum = 25;
			var name = $this.attr("id").match(/(\w+)-(\d+)/) ? $this.attr("id").match(/(\w+)-(\d+)/)[1] : $this.attr("id");
			if(/accomplishments_accomplishment/i.test($this.attr("id"))) {
				colsNum = 20;
			}else{
				colsNum = 25;
			}
			$this.editable("/repsheet/profile_attribute.php", {
				submitdata: { cmd: "save" },
				type: "textarea",
				id: "label",
				value: $this.attr("id"),
				name: name,
				hint: $this.attr("hint"),
				indicator: "<img src='" + "/image/loading-16.gif'>",
				tooltip: $(this).siblings(".edit-placeholder").html(),
				placeholder: '<span class=\"editable\">' + $(this).siblings(".edit-placeholder").html() + '</span>',
				style: "inherit",
				cols: colsNum,
				rows: 5,
				cancel: '<span class="edit-cmd"><a href="#" title="cancel"><img height="10" width="10" alt="" src="'+idconf_tld+'/image/id_repsheets/icons/delete.png"/>Cancel</a></span>',
				submit: '<span class="edit-cmd"><a href="#" title="save"><img height="7" width="7" src="'+idconf_tld+'/image/id_repsheets/icons/save.png"/>Save</a></span>',
				ontab: "submit",
				onsubmit: function(value, settings, json) {
					if(settings.name == "accomplishments_accomplishment") {
						if($(this).parent().parent().next("div").find("span[class='edit-textarea']").attr("id")) {

						}else{
							workplace_id = $(this).parent().parent().parent().parent().parent().prev().find("input").attr("id").split("-");
							if(value != null && value != "") {
								delete_element = '<span id="accomplishment-'+$(this).attr("id")+'" class="remove-cmd-accomplishment"><a onclick="$this = $(this); return attrDelete(\'accomplishments_accomplishment-'+$(this).attr("id")+'\', \'Are you sure you want to remove this accomplishment?\', [$this.parent().parent().parent(\'.accomplishments_item\')]);" title="remove this accomplishment" href="#"><img height="10" width="10" alt="" src="'+ idconf_tld +'/image/id_repsheets/icons/delete_red.png"/>Delete</a></span>';
							}else{
								delete_element = "";
							}
							$(this).next().after(delete_element);
							//accomplishmentAdd($(this),workplace_id[1],hintsObj);
						}
						check_access(json);
					}else{
						check_access(json);
						if(settings.name != "workplace_description" && settings.name != "description" && settings.name != "patents_descriptions") {
							editSubmitted(this.parent(), json, this.submitsource != "blur");
						}else{
							editSubmitted(this, json, this.submitsource != "blur");
						}
					}
				},
				oncancel: function(value, settings) { editCancel(this); },
				onblur: "cancel"
			});
			cmdsAdd(this);
		})
		.click(function() {
			if($(this).find("textarea").attr("name") == "workplace_accomplishments") {
				set_tab_indent_for_textareas($(this).find("textarea"));
			}
			// get value object is wrong in ie 6
			if(/<span/i.test($(this).children().children("textarea").val())){
				$(this).children().children("textarea").val('');
			}
			$(this).siblings(".edit-cmd, .delete-cmd").hide();
			$(this).parent().parent().find(".remove-cmd-main, .remove-cmd-accomplishment").hide();
			autoAdjustHintBox($(this));
		 });
}

function readyTextAreasNew() {
	$(".edit-textarea")
		.each(function() {
			$this = $(this);
			var name = $this.attr("id").match(/(\w+)-(\d+)/) ? $this.attr("id").match(/(\w+)-(\d+)/)[1] : $this.attr("id");
			$this.editable("/repsheet/profile_attribute.php", {
				submitdata: { cmd: "save" },
				type: "textarea",
				id: "label",
				value: $this.attr("id"),
				name: name,
				hint: $this.attr("hint"),
				indicator: "<img src='" + "/image/loading-16.gif'>",
				tooltip: $(this).siblings(".edit-placeholder").html(),
				placeholder: '<span class=\"editable\">' + $(this).siblings(".edit-placeholder").html() + '</span>',
				style: "inherit",
				cols: 20,
				rows: 5,
				cancel: '<span class="edit-cmd">[ <a href="#" title="cancel">Cancel</a> ]</span>',
				submit: '<span class="edit-cmd">[ <a href="#" title="save">Save</a> ]</span>',
				ontab: "submit",
				onsubmit: function(value, settings, json) {
					check_access(json);
					editSubmitted(this, json, this.submitsource != "blur");
				},
				oncancel: function(value, settings) { editCancel(this); },
				onblur: "submit"
			});
			cmdsAdd(this);
		})
		.click(function() { $(this).siblings(".edit-cmd, .delete-cmd").hide();
			$("textarea").bind("keyup", function(){
			 if($(this).val().length > 1024)
			 {
			 	var string = $(this).val().substring(0,1024);
			  	$(this).val(string);
			  	$(".detail_box_right #message").remove();
			  	$(".detail_box_right").append("<span style='color:red' id='message'><br/>Content length must be less than 1024 Bytes</span>");
			 }else{
			  	$(".detail_box_right #message").remove();
			 }
			});
			autoAdjustHintBox($(this));
		 });
}

function getXfnAvatar(xfn_id){
	var url = $('#xfn_url-'+xfn_id).text();
	var reg = /^(http:\/\/)?([0-9a-zA-Z-_]{0,32})\.identity\.net/i; 
	var result = url.match(reg);
	if(result!=null){
		qdata = {};
		qdata["cmd"] = 'getXfnAvarta';
		qdata["name"] = result[2];
		$.post("/repsheet/profile_attribute.php",qdata,
			function(data){
				$('#repsheet_subhead_xfn-'+xfn_id).find('.xfn_avatar_s').attr('src',data);
				$('#detail-box-content-xfn-'+xfn_id).find('.xfn_avatar_b').attr('src',data);
			}
		); 
	}else{
		$('#repsheet_subhead_xfn-'+xfn_id).find('.xfn_avatar_s').attr('src','/image/avatar/blank.gif');
		$('#detail-box-content-xfn-'+xfn_id).find('.xfn_avatar_b').attr('src','/image/avatar/blank.gif');
	}
}
