// JavaScript Document

var ajax;

function createAJAX() {
	if (window.ActiveXObject) {
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				return null;
			}
		}
	} else if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else {
		return null;
	}
}

//----------------------------------------------------------------------

function favorTagsColor(){
	
	//change all tags color back
	var favor_tags_area = document.getElementById('favor_keyword_area');
	var favor_tags = favor_tags_area.getElementsByTagName('a');
	for(var i=0; i<favor_tags.length; i++){
		favor_tags[i].style.color="#1b7bdd";
	}	
}


//----------------------------------------------------------------------

function favorDrink(id,no) {	

	favorTagsColor();
	document.getElementById('drink_'+no).style.color="#665e54";
		
	//get whom like it
	ajax = createAJAX(); 
	var url = "client/2m_3m_2m.php?val=" +escape(id);
	ajax.onreadystatechange = onRequest;	
	ajax.open("GET", url, true);
	ajax.send (null);

}

function onRequest() {
	if ((ajax.readyState == 4)&&(ajax.status == 200)) {
		update_drink_user(ajax.responseText);
		opArea('#favor_drink_list');
	} 
}

//----------------------------------------------------------------------
/*
function favorMusic(id,no) {	

	favorTagsColor();
	document.getElementById('music_'+no).style.color="#665e54";
	
	//get whom like it
	ajax = createAJAX();
	var url = "client/2m_3m_4m.php?val="+id;
	ajax.onreadystatechange = onRed;
	ajax.open ("GET", url, true);
	ajax.send ("");
}

function onRed() {
	if ((ajax.readyState == 4)&&(ajax.status == 200)) {
		update_music_user(ajax.responseText);
		opArea('#favor_music_list');
	}
}
*/
//----------------------------------------------------------------------

function favorStatus(id,no) {	

	favorTagsColor();
	document.getElementById('status_'+no).style.color="#665e54";
	
	//get whom like it
	ajax = createAJAX();
	var url = "client/2m_3m_5m.php?val="+id;
	ajax.onreadystatechange = onStatus;
	ajax.open ("GET", url, true);
	ajax.send ("");
}

function onStatus() {
	if ((ajax.readyState == 4)&&(ajax.status == 200)) {
		update_status_user(ajax.responseText);
		opArea('#favor_status_list');
	}
}

//----------------------------------------------------------------------

function favorLookfor(id,no) {	

	favorTagsColor();
	document.getElementById('lookfor_'+no).style.color="#665e54";
	
	//get whom like it
	ajax = createAJAX();
	var url = "client/2m_3m_6m.php?val="+id;
	ajax.onreadystatechange = onLookfor;
	ajax.open ("GET", url, true);
	ajax.send ("");
}

function onLookfor() {
	if ((ajax.readyState == 4)&&(ajax.status == 200)) {
		update_lookfor_user(ajax.responseText);
		opArea('#favor_lookfor_list');
	}
}

//----------------------------------------------------------------------

function favorInterests(id,no) {	

	favorTagsColor();
	document.getElementById('interests_'+no).style.color="#665e54";
	
	//get whom like it
	ajax = createAJAX();
	var url = "client/2m_3m_7m.php?val="+id;
	ajax.onreadystatechange = onInterests;
	ajax.open ("GET", url, true);
	ajax.send ("");
}

function onInterests() {
	if ((ajax.readyState == 4)&&(ajax.status == 200)) {
		update_interests_user(ajax.responseText);
		opArea('#favor_interests_list');
	}
}

//----------------------------------------------------------------------

function favorStyle(id,no) {	

	favorTagsColor();
	document.getElementById('style_'+no).style.color="#665e54";
	
	//get whom like it
	ajax = createAJAX();
	var url = "client/2m_3m_8m.php?val="+id;
	ajax.onreadystatechange = onStyle;
	ajax.open ("GET", url, true);
	ajax.send ("");
}

function onStyle() {
	if ((ajax.readyState == 4)&&(ajax.status == 200)) {
		update_style_user(ajax.responseText);
		opArea('#favor_style_list');
	}
}

//----------------------------------------------------------------------

function favorIndustry(id,no) {	

	favorTagsColor();
	document.getElementById('industry_'+no).style.color="#665e54";
	
	//get whom like it
	ajax = createAJAX();
	var url = "client/2m_3m_9m.php?val="+id;
	ajax.onreadystatechange = onIndustry;
	ajax.open ("GET", url, true);
	ajax.send ("");
}

function onIndustry() {
	if ((ajax.readyState == 4)&&(ajax.status == 200)) {
		update_industry_user(ajax.responseText);
		opArea('#favor_industry_list');
	}
}

//----------------------------------------------------------------------

function opArea(id){
	closeArea();
	$(id).show('normal');
}
//----------------------------------------------------------------------

function closeArea(){
	$('#favor_drink_list').hide();
	//$('#favor_music_list').hide();
	$('#favor_status_list').hide();
	$('#favor_lookfor_list').hide();
	$('#favor_interests_list').hide();
	$('#favor_style_list').hide();
	$('#favor_industry_list').hide();
}

//----------------------------------------------------------------------
