// JavaScript Document

if(window.ActiveXObject) {
	try {
		var oHTTP = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
		var oHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
} else {
	var oHTTP = new XMLHttpRequest();
}


function fan_add(uid, fid,space,style){
	if(uid!="" && fid!="" && space!=""){
		document.getElementById(space).innerHTML='<img src="images/wait_saving.gif" >';
		fan_add_M('fan.php?action=add&uid='+uid+'&fid='+fid+'', space,style,uid,fid);
	}
}

function fan_add_M(page,space,style,uid,fid) {
	oHTTP.open("GET", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;			
			if (getValue == '1') {
				switch(style){
					case '1': // profile style

							document.getElementById(space).innerHTML='<a class="profilebutton-grey" href="javascript:fan_del(\''+uid+'\',\''+fid+'\',\''+space+'\',\'1\')"><span>REMOVE</span> </a>'

							break;

						case '2': // account page style

							document.getElementById(space).innerHTML=''

							break;

						case '3':

							document.getElementById(space).innerHTML='Added in your fan list'

							break;
					}
			}
			else{
				alert(getValue);
			}
		}
	}
	oHTTP.send(null);
}





function fan_del(uid, fid,space,style){
	if(uid!="" && fid!="" && space!=""){
		document.getElementById(space).innerHTML='<img src="images/wait_saving.gif" >';
		fan_del_M('fan.php?action=del&uid='+uid+'&fid='+fid+'', space,style,uid,fid);
	}
}

function fan_del_M(page,space,style,uid,fid) {
	oHTTP.open("GET", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;			
			if (getValue == '1') {
				switch(style){
						case '1': // profile style

							document.getElementById(space).innerHTML='<a class="profilebutton-orange" href="javascript:fan_add(\''+uid+'\',\''+fid+'\',\''+space+'\',\'1\')"> <span>BECOME A FAN</span></a>'

							break;

						case '2': // account page style

							document.getElementById(space).innerHTML=''

							break;
					}
			}
			else{
				alert(getValue);
			}
		}
	}
	oHTTP.send(null);
}







