$(document).ready( 
  function() {
	  var subheaderWidth = 550;
	  autoAdjustFontSize($("#subheader"),$("#subheader"),subheaderWidth,36);
    // we register
    // collapse/expand click events
    $('.repsheet_right_header_holder').click(
		function() {		  
			if(/repsheet_right_header_holder/i.test($(this).attr("class"))){
				if ($(this).parent().find('.repsheet_right_body_body').is(':hidden')) {
					$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/collapse.png");
					$(this).parent().find('.repsheet_right_body_head').show('slow');
					$(this).parent().find('.repsheet_right_body_body').show('slow');
					$(this).parent().find('.repsheet_right_body_footer').show('slow');
			  	}
			  	else {
					$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/expand.png");
					$(this).parent().find('.repsheet_right_body_head').hide('slow');
					$(this).parent().find('.repsheet_right_body_body').hide('slow');
					$(this).parent().find('.repsheet_right_body_footer').hide('slow');
			  	}
			}else{
			  if ($(this).parent().find('.repsheet_left_body_body').is(':hidden')) {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/collapse.png");
				$(this).parent().find('.repsheet_left_body_head').show('slow');
				$(this).parent().find('.repsheet_left_body_body').show('slow');
				$(this).parent().find('.repsheet_left_body_footer').show('slow');
			  }
			  else {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/expand.png");
				$(this).parent().find('.repsheet_left_body_head').hide('slow');
				$(this).parent().find('.repsheet_left_body_body').hide('slow');
				$(this).parent().find('.repsheet_left_body_footer').hide('slow');
			  }
			}
		 }
    );
	$('.repsheet_left_header_holder').click(
		  function() {
			if(/repsheet_left_header_holder/i.test($(this).attr("class"))){
			  if ($(this).parent().find('.repsheet_left_body_body').is(':hidden')) {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/collapse.png");
				$(this).parent().find('.repsheet_left_body_head').show('slow');
				$(this).parent().find('.repsheet_left_body_body').show('slow');
				$(this).parent().find('.repsheet_left_body_footer').show('slow');
			  }
			  else {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/expand.png");
				$(this).parent().find('.repsheet_left_body_head').hide('slow');
				$(this).parent().find('.repsheet_left_body_body').hide('slow');
				$(this).parent().find('.repsheet_left_body_footer').hide('slow');
			  }
			}else{
			  if ($(this).parent().find('.repsheet_right_body_body').is(':hidden')) {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/collapse.png");
				$(this).parent().find('.repsheet_right_body_head').show('slow');
				$(this).parent().find('.repsheet_right_body_body').show('slow');
				$(this).parent().find('.repsheet_right_body_footer').show('slow');
			  }
			  else {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/expand.png");
				$(this).parent().find('.repsheet_right_body_head').hide('slow');
				$(this).parent().find('.repsheet_right_body_body').hide('slow');
				$(this).parent().find('.repsheet_right_body_footer').hide('slow');
			  }
			}
		 }
    );

	
	$('.repsheet_right_body_subhead').click(
		  function() {
			  if ($(this).next().is(':hidden')) {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/collapse.png");
				$(this).next().show('slow');
			  }
			  else {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/expand.png");
				$(this).next().hide('slow');
			  }
		 }
    );

	$('.repsheet_left_body_subhead').click(
		  function() {
			  if ($(this).next().is(':hidden')) {
				$(this).find('img[class="repsheetbox_body_h3_img_col_ex"]').attr("src", idconf_tld +"/image/id_repsheets/icons/collapse.png");
				$(this).next().show('slow');
			  }
			  else {
				$(this).find('img[class="repsheetbox_body_h3_img_col_ex"]').attr("src", idconf_tld +"/image/id_repsheets/icons/expand.png");
				$(this).next().hide('slow');
			  }
		 }
    );
	
	$('.accomplishments_bar').click(
		  function() {
			  if ($(this).parent().next('span').is(':hidden')) {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/collapse.png");
				$(this).parent().next('span').show('slow');
			  }
			  else {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/expand.png");
				$(this).parent().next('span').hide('slow');
			  }
		 }
    );
    
    $('.patents_bar').click(
		  function() {
			  if ($(this).parent().next('span').is(':hidden')) {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/collapse.png");
				$(this).parent().next('span').show('slow');
			  }
			  else {
				$(this).find('img').attr("src", idconf_tld +"/image/id_repsheets/icons/expand.png");
				$(this).parent().next('span').hide('slow');
			  }
		 }
    );
    
	$('#aboutme').jTruncate({ 
		length: 250,  
		minTrail: 0,  
		moreText: "More",  
		lessText: "Less",  
		ellipsisText: " ...",  
		moreAni: "false",  
		lessAni: 200  
	});
	$('.x-accomplishments').jTruncate({ 
		length: 1000,  
		minTrail: 0,  
		moreText: "More",  
		lessText: "Less",  
		ellipsisText: " ...",  
		moreAni: "false",  
		lessAni: 200  
	});
	autoAdjustFontSize($("#urlAddress"),$("#urlAddress"),635,$("#urlAddress").css('fontSize'));
	autoAdjustFontSize($(".given-name"),$(".given-name"),135,$(".given-name").css('fontSize'));
	autoAdjustFontSize($(".additional-name"),$(".additional-name"),135,$(".additional-name").css('fontSize'));
	autoAdjustFontSize($(".family-name"),$(".family-name"),135,$(".family-name").css('fontSize'));
	
    // Verified basic attributes 
	$(".family-name, .given-name, .bday, .x-gender").each(function() { 
	$this = $(this); 
	id = $this.attr("id"); 
	value = $this.text(); 
	//the last parameter is used to check whether the user is login.
	attrVerify(id, value, false, page_user_id, true);
	});

    // Verified school attributes 
	$(".x-year").each(function() { 
	$this = $(this); 
	id = $this.attr("id"); 
	value = $this.text(); 
	//the last parameter is used to check whether the user is login.
	attrVerify(id, value, false, page_user_id, true);
	});
	autoAdjustBasicInfoBox($(".photo"),$(".repsheet_left_basic_info"));
	
	//verified attribute
	//var verified_attributes = eval('<?php echo json_encode($verified_attribute_array); ?>');
	loadVerifyRepSheet(page_user_id);

  });
function resize_profile_photo(this_image){
	var img_width	= this_image.width;
	var img_height	= this_image.height;

	if(img_width <= 100 && img_height <= 100){
		return true;
	}else if(img_width > 100 && img_height <= 100){
		this_image.width = 100;
		return true;
	}else if(img_width <= 100 && img_height > 100){
		this_image.height = 100;
		return true;
	}

	if(img_width >= img_height ){
		this_image.width = 100;
		return true;
	}else{
		this_image.height = 100;
		return true;
	}
}

function popVerify(t){
	$.get($(t).attr('href'), {},
   function(data){
		$.prompt(data,{buttons:{Close:1}}).children('#jqi').find(".jqiclose").css("display","none");
   } 
); 
	return false;
}