
/****************************************************************************************************************************/	
/** OVERLAY *****************************************************************************************************************/
/****************************************************************************************************************************/	

	function ShowInfoOverlay(title, text, text2, link)
	{
		if(!(document && document.getElementById && (overlay = document.getElementById('infooverlay')) && (contents = document.getElementById('infooverlaycontents')))) return;

		coords = GetElementPosition(link); if(!(coords[0] && coords[1])) return;
		size = GetElementSize(link);
		windowsize = GetWindowSize();
		
		if(coords[0] > windowsize[0] / 2)
		{
			leftposition = coords[0] + size[0]/2 - 236;
			classname = 'infooverlaycontentsright';
		}
		else
		{
			leftposition = coords[0] + size[0]/2 - 26;
			classname = '';
		}

		html  = '<h2>'+title+'<'+'/h2>';
		html += '<div id="infooverlaycontents2"><div id="infooverlaycontents3">';
		html += '<div id="infooverlaysep"></div>';
		html += '<p class="infooverlaytext">'+text+'<'+'/p>';
		if(text2) html += '<p class="infooverlaynotice">'+text2+'</p>';
		html += '</div></div>';

		overlay.style.display = 'block';
		overlay.style.visibility = 'visible';
		overlay.style.left = leftposition+'px';
		overlay.style.top = (coords[1]+20)+'px';
		contents.innerHTML = html;
		contents.className = classname;
		link.title = '';
	}

	function HideInfoOverlay()
	{
		if(!(document && document.getElementById && (overlay = document.getElementById('infooverlay')) && (contents = document.getElementById('infooverlaycontents')))) return;
		
		overlay.style.display = 'none';
		overlay.style.visibility = 'hidden';
		contents.innerHTML = '';
	}

/****************************************************************************************************************************/	
/** CONTACT INFO ************************************************************************************************************/
/****************************************************************************************************************************/	

	function SetContactInfo(fromid, toid, field, value)
	{
		if(!(pic = new Image())) return false;
		if(!(date = new Date())) return false;
		pic.src = url = 'http://www.'+whichdomain+'/p/setcontact/?fromid='+fromid+'&toid='+toid+'&c='+checksum+'&what='+field+'&val='+value+'&'+date.getHours()+''+date.getMinutes()+''+date.getSeconds();
		//window.open(url);
		if(!pic.src) return false;
		return true;
	}
	
	
	function SetContactRating(fromid, toid, value)
	{
		staron = (value < 3 ? 'red' : 'on');

		if(!SetContactInfo(fromid, toid, 'RATING', value)) return false;
		if(!(document && document.getElementById)) return window.location.reload();
		for(j = 1; j <= 4; j++)
		{
			a = document.getElementById('contactrating'+j+'link'+fromid);
			i = document.getElementById('contactrating'+j+'image'+fromid);
			
			a.href = 'javascript:SetContactRating('+fromid+', '+toid+', '+(j == value ? 0 : j)+');void(0);';
			
			if(j > value) i.src = 'http://static.webispink.com/w/img/profile2/metothem-star2-off.gif';
			else i.src = 'http://static.webispink.com/w/img/profile2/metothem-star2-'+staron+'.gif';

			if(j == value) 
			{
				switch(j)
				{
					case 1: i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_RATING_REMOVE[1]); }; break;
					case 2: i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_RATING_REMOVE[2]); }; break;
					case 3: i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_RATING_REMOVE[3]); }; break;
					case 4: i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_RATING_REMOVE[4]); }; break;
					case 5: i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_RATING_REMOVE[5]); }; break;
				}
			}
			else
			{
				switch(j)
				{
					case 1: i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_RATING[1]); }; break;
					case 2: i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_RATING[2]); }; break;
					case 3: i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_RATING[3]); }; break;
					case 4: i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_RATING[4]); }; break;
					case 5: i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_RATING[5]); }; break;
				}
			}
		}

		if(value >= 3)
			SetContactBookmark(toid, 1);
			
		HideInfoOverlay();
	}
	
	function SetContactFriend(fromid, toid, value)
	{
		if(!SetContactInfo(fromid, toid, 'FRIEND', value)) return false;
		if(!(document && document.getElementById)) return window.location.reload();

		a = document.getElementById('contactfriendlink'+fromid);
		i = document.getElementById('contactfriendimage'+fromid);
		
		a.href = 'javascript:SetContactFriend('+fromid+', '+toid+', '+(1-value)+');void(0);';
		
		if(value) i.src = 'http://static.webispink.com/w/img/profile2/metothem-friend-on.gif';
		else i.src = 'http://static.webispink.com/w/img/profile2/metothem-friend-off.gif';

		if(value) i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_FRIEND_REMOVE); };
		else i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_FRIEND_ADD); };
		
		if(value)
			SetContactBookmark(toid, 1);

		HideInfoOverlay();
	}
	
	function SetContactHeart(fromid, toid, value)
	{
		if(!SetContactInfo(fromid, toid, 'HEART', value)) return false;
		if(!(document && document.getElementById)) return window.location.reload();

		a = document.getElementById('contactheartlink'+fromid);
		i = document.getElementById('contactheartimage'+fromid);
		
		a.href = 'javascript:SetContactHeart('+fromid+', '+toid+', '+(1-value)+');void(0);';
		
		if(value) i.src = 'http://static.webispink.com/w/img/profile2/metothem-heart-on.gif';
		else i.src = 'http://static.webispink.com/w/img/profile2/metothem-heart-off.gif';

		if(value) i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_HEART_REMOVE); };
		else i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_HEART_ADD); };

		if(value)
			SetContactBookmark(toid, 1);

		HideInfoOverlay();
	}



	function SetContactBookmark(toid, value)
	{
		if(!(pic = new Image())) return false;
		if(!(date = new Date())) return false;
		pic.src = url = 'http://www.'+whichdomain+'/p/setnotes/?toid='+toid+'&c='+checksum+'&what=BOOKMARK&value='+encodeURIComponent(value)+'&'+date.getHours()+''+date.getMinutes()+''+date.getSeconds();
		if(!pic.src) return false;

		if(!(document && document.getElementById)) return window.location.reload();

		a = document.getElementById('contactbookmarklink');
		i = document.getElementById('contactbookmarkimage');
		
		a.href = 'javascript:SetContactBookmark('+toid+', '+(1-value)+');void(0);';
		
		if(value) i.src = 'http://static.webispink.com/w/img/profile2/metothem-plus-on.gif';
		else i.src = 'http://static.webispink.com/w/img/profile2/metothem-plus-off.gif';

		if(value) i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_BOOKMARK_REMOVE); };
		else i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_BOOKMARK_ADD); };
		
		HideInfoOverlay();

		return true;
	}


	function SetContactBlacklist(toid, value)
	{
		if(!(pic = new Image())) return false;
		if(!(date = new Date())) return false;
		pic.src = url = 'http://www.'+whichdomain+'/p/setblacklist/?toid='+toid+'&c='+checksum+'&value='+encodeURIComponent(value)+'&'+date.getHours()+''+date.getMinutes()+''+date.getSeconds();
		if(!pic.src) return false;
		
		//window.open(url);

		if(!(document && document.getElementById)) return window.location.reload();

		a = document.getElementById('contactblacklistlink');
		i = document.getElementById('contactblacklistimage');
		
		a.href = 'javascript:SetContactBlacklist('+toid+', '+(1-value)+');void(0);';
		
		if(value) i.src = 'http://static.webispink.com/w/img/profile2/metothem-blacklist-on.gif';
		else i.src = 'http://static.webispink.com/w/img/profile2/metothem-blacklist-off.gif';

		if(value) i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_BLACKLIST_REMOVE); };
		else i.onmouseover = function() { eval(MOUSEOVER_METOTHEM_BLACKLIST_ADD); };
		
		HideInfoOverlay();

		return true;
	}

/****************************************************************************************************************************/	
/** CONTACT NOTES ***********************************************************************************************************/
/****************************************************************************************************************************/	

	function ToggleContactNotes(toid)
	{
		if(true)
		{
			$('#PROFILE_HEADER_NOTES').show();
			$('#buttoncontactnotes').hide();
			StartEditingContactNotes(toid);
		}
		else
		{
			StopEditingContactNotes(toid);
			$('#PROFILE_HEADER_NOTES').hide();
		}
	}
	
	function StartEditingContactNotes(toid)
	{
		$('#PROFILE_HEADER_NOTES').unbind('click');
		$('#PROFILE_HEADER_NOTES').html('<textarea id="inputcontactnotes" cols="50" rows="4" style="width: 100%;"></textarea>');
		$('#inputcontactnotes').val($('#hiddencontactnotes').val());
		$('#inputcontactnotes').focus();
		$('#inputcontactnotes').blur(function() { StopEditingContactNotes(toid); } );
	}

	function StopEditingContactNotes(toid)
	{
		var notes = $('#inputcontactnotes').val();
		$('#hiddencontactnotes').val(notes);
		$('#PROFILE_HEADER_NOTES').html('<p>'+notes+'&nbsp;</p>');
		$('#PROFILE_HEADER_NOTES').click(function() { StartEditingContactNotes(toid); } );
		if(!notes.replace(/([\s]*)/, '')) $('#PROFILE_HEADER_NOTES').hide();
		//alert('"'+notes+'"');

		if(!(pic = new Image())) return false;
		if(!(date = new Date())) return false;
		pic.src = url = 'http://www.'+whichdomain+'/p/setnotes/?toid='+toid+'&c='+checksum+'&what=NOTES&notes='+encodeURIComponent(notes)+'&'+date.getHours()+''+date.getMinutes()+''+date.getSeconds();
		if(!pic.src) return false;
		return true;
	}

/****************************************************************************************************************************/	
/** CONTACT OPTIONS *********************************************************************************************************/
/****************************************************************************************************************************/	

	function SetContactShowOnline(checkbox)
	{
		/*
		if(checkbox.checked) 
		{
			if(metothem_heart || metothem_friend) value = 1;
			else return checkbox.checked = false;
		}
		else value = 0;
		*/
		if(checkbox.checked) value = 1;
		else value = 0;
		SetContactNotes('SHOWONLINE', value);
	}
	function SetContactShowUpdates(checkbox)
	{
		/*
		if(checkbox.checked) 
		{
			if(metothem_heart || metothem_friend) value = 1;
			else return checkbox.checked = false;
		}
		else value = 0;
		*/
		if(checkbox.checked) value = 1;
		else value = 0;
		SetContactNotes('SHOWUPDATES', value);
	}
	
/****************************************************************************************************************************/	
/** NEXT/PREV PROFILE *******************************************************************************************************/
/****************************************************************************************************************************/	

	function DisplayNextPrevProfile()
	{
		//RETURN;
		
		//XXX CAN'T ACCESS WINDOW.OPENER BECAUSE DIFFERENT DOMAIN NAME
		
		if(window.opener)
		{
			//alert(window.opener.location);
			$('#TOOLBARTOP').hide();
			$('#TOOLBARBOTTOM').hide();
			$('#HIDDENTOOLBARTOP').show();
			$('#HIDDENTOOLBARBOTTOM').show();
		}
	}




