function StatusPhrase(id, phrase)
{
	this.id = id;
	this.phrase = phrase;
}

function updateStatusPhrase(){
	var sessionId;
	for (var i = 0; i < document.cookie.split('; ').length; i++) {
		var crumb = document.cookie.split('; ')[i].split('=');
		if (crumb[0] == "ANY_B" && crumb[1] != null) {
			sessionId = crumb[1];
			break;
		}
	}
	if (!sessionId) {
		return false;
	}
	var phrase = ANY.dom.getVal('myphrase');
	var myId = ANY.dom.getVal('myid');
	if (!phrase || !myId) {
		return false;
	}
	//alert(phrase.length);
	if (phrase.length > 40) {
		alert('ステータスは最大２０文字まで設定可能です。');
		return;
	}
	var phraseNode = ANY.dom.get('myphrase');
	phraseNode.value = '更新中...';
	phraseNode.readOnly = true;
	var jsonStatus = new StatusPhrase(myId, phrase);
	var str = ANY.util.toJsonString(jsonStatus);
	//alert(str);
	var url = "/api/updatephrase?s=" + encodeURIComponent(sessionId) + "&json=" + encodeURIComponent(str);
	ANY.net.asyncRequest(url, updateStatusPhraseCallback);
}
function updateStatusPhraseCallback(resp){
	//alert(resp.responseText);
	try {
		eval ("var jsonStatus = " +  resp.responseText);
	} catch (e) {
		return;
	}
	var phraseNode = ANY.dom.get('myphrase');
	phraseNode.value = jsonStatus.phrase;
	phraseNode.readOnly = false;
}

var myPageColor = new Array(
	"http://i2.myany.jp/_css/mypage.css",
	"/_css/_blue/mypage.css",
	"http://i2.myany.jp/_css/_green/mypage.css",
	"http://i2.myany.jp/_css/_yellow/mypage.css",
	"http://i2.myany.jp/_css/_gray/mypage.css"
);


function changeMyColor(color) {
	if (color < 0 || color > 4) {
		return;
	}
	var node = document.getElementsByTagName('link').item(1);
	node.href = myPageColor[color];
	return;
}
	