

if(typeof com == "undefined")
{
	com = function(){};
}

if(typeof com.ixonos == "undefined")
{
	com.ixonos = function(){};
}

//package name
com.ixonos.aboutme = function(){};


com.ixonos.aboutme.onDeviceReady = function()
{
	//com.ixonos.fsc.addAjaxSend();
	com.ixonos.aboutme.initHtml();

	// points ======================
	com.ixonos.fsc.setPointsNum();
	
	com.ixonos.fsc.initBottomBar("");	
	com.ixonos.aboutme.bindEvent();
	com.ixonos.aboutme.setAboutMe();
	
	fromTop= $(".aboutMeContentText")[0].offsetTop + 80;
	fromLeft=$(".aboutMeContentText")[0].offsetLeft + 15;
	height= $(".aboutMeContentText")[0].offsetHeight;
	width= $(".aboutMeContentText")[0].offsetWidth;
	
	$('#aboutMeTextAreaFrame').css("position","absolute");
	$('#aboutMeTextAreaFrame').css("top",fromTop);
	$('#aboutMeTextAreaFrame').css("height",height);
	$('#aboutMeTextAreaFrame').css("width",width);
	$('#aboutMeTextAreaFrame').css("left",fromLeft);
	$('#aboutMeTextAreaFrame').css("display","block");
	
	com.ixonos.fsc.addCover($('#aboutMeTextAreaFrame')[0], $(".aboutMeContentText")[0]);
};


com.ixonos.aboutme.initHtml = function()
{
	
	//initialize morepage 
		
	html = '';
	html += '<div class="titleBar">';
	html +=		'<div class="logo"><img src="img/navigation/logo-header.png"/></div>';
	html +=		'<a class="deleteShadowButton"><div class="cancelButton">' + public.cancelText + '</div></a>';
	html +=      '<a class="deleteShadowButton"><div class="doneButton">' + public.doneText + '</div></a>';
	html +=	'</div>';
	//html += '<div class="subTitle">' + aboutMe.subTitle + '</div>';
	html += '<div class="subTitle">' + aboutMe.subTitleTips + '</div>';
	
	html += '<div class="aboutMeContent">';
	html +=   '<div class="aboutMeContentTips">' + aboutMe.tips + '</div>';
	html +=   '<textarea placeholder="Type here..." class="aboutMeContentText" onblur="com.ixonos.fsc.moveToOriginal()"></textarea>';
	html += '</div>';
	
	com.ixonos.aboutme.getAboutMe();
	
	$('#aboutMePage').append(html);
	
};

com.ixonos.aboutme.bindEvent =  function()
{
	$('.cancelButton').click(function()
							 {
							 loadPage("html/editProfile.html","com.ixonos.editProfile.onDeviceReady");

							 });
	$('.aboutMeContentText').focus(function(){
							$('.aboutMeContentText').css("color", "#000");
							});
};

com.ixonos.aboutme.getAboutMe = function(){
	var url = server.serverIp + "rest/signUpServer/getAboutMe";
	var memberIdStr = window.localStorage.getItem(loginUser.memberId);
	
	com.ixonos.fsc.loadPage("aboutme", 1);
	$.getJSON(url,{memberId:memberIdStr},function(string){
			  if(typeof string == 'undefined')
			  {
			  com.ixonos.fsc.serverErrorAlert();
			  }else{
			  if(string.status == 1)
			  {
			  $('textarea').val(string.aboutMe);
			  }
			  else if(string.status == -100)
			  {
			  com.ixonos.fsc.requestHeaderError();
			  }
			  else{com.ixonos.fsc.serverErrorAlert();}
			  }
			  com.ixonos.fsc.removeLoadPage();	
			  });
}

com.ixonos.aboutme.setAboutMe = function(){
	var url = server.serverIp + "rest/signUpServer/setAboutMe";
	$('.doneButton').click(function(){
					   com.ixonos.fsc.loadPage("aboutme", 1);
					   var contentTextStr, memberIdStr; 
					   memberIdStr = window.localStorage.getItem(loginUser.memberId);
					   contentTextStr = $('.aboutMeContentText').val();
						
						$.post(url,{ memberId:memberIdStr, aboutMe:contentTextStr },function(string){
							   if(typeof string == 'undefined')
							   {
							      com.ixonos.fsc.serverErrorAlert();
							   }
							   else if(string.status == -100)
							   {
							   com.ixonos.fsc.requestHeaderError();
							   }
							   else{
								  switch(string.status)
								  {
								  case 1:
									loadPage("html/editProfile.html","com.ixonos.editProfile.onDeviceReady");

								  break;
								  default:
							      com.ixonos.fsc.serverErrorAlert();
								  break;
								  }
							   }
							   com.ixonos.fsc.removeLoadPage();
							   }, "json");
						   });
}

