// 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 contact_add(uid, fid,space,style){
	if(uid!="" && fid!="" && space!=""){
		document.getElementById(space).innerHTML='<img src="images/wait_saving.gif" >';
		contact_add_M('ex_contact.php?action=add&uid='+uid+'&fid='+fid+'', space,style,uid,fid);
	}
}

function contact_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 href="javascript:contact_del(\''+uid+'\',\''+fid+'\',\''+space+'\',\'1\');">Remove From Contacts</a>';
						break;

					case '2': // account page style
						document.getElementById(space).innerHTML='';
						break;
					case '3':
						document.getElementById(space).innerHTML='Added in your contact list';
						break;
					}
			}
			else{
				alert(getValue);
			}
		}
	}
	oHTTP.send(null);
}


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

function contact_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 href="javascript:contact_add(\''+uid+'\',\''+fid+'\',\''+space+'\',\'1\');"> Exchange Contacts</a>';
							break;
						case '2': // account page style
							document.getElementById(space).innerHTML='';
							break;
						}
			}
			else{
				alert(getValue);
			}
		}
	}
	oHTTP.send(null);
}

function showdetailsContact(uid,space,style){
	if(uid!="" && space!=""){
		document.getElementById(space).innerHTML='<img src="images/wait_saving.gif">';
		showdetailsContact_M('ex_contact.php?action=details&uid='+uid+'',space,style);
	}
}

function showdetailsContact_M(page,space,style) {
	oHTTP.open("GET", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			document.getElementById(space).innerHTML=oHTTP.responseText;
	
		}
	}
	oHTTP.send(null);
}
