PreloadImages()
//This will NOT preload images. Ross
function PreloadImages()
{
	var img;
	
	img = new Image();
	
	img.setAttribute("src","/images/cards/add_" + fav_string + "_off2.gif");
	img.setAttribute("src","/images/cards/add_" + fav_string + "_on2.gif");
	img.setAttribute("src","/images/cards/add_favourite_load.gif");
	img.setAttribute("src","/images/cards/not_interested_on2.gif");
	img.setAttribute("src","/images/cards/not_interested_off2.gif");
	img.setAttribute("src","/images/cards/not_interested_load.gif");
	
	img = null;
}

function AJAX( objLink, strErrorCall )
{
	var strTargetURL
	
	Initialize();
											
	// Check XMLHTTP support
	if( blnSupportsXMLHTTP )
	{
		strTargetURL = AddValueToURL( objLink.getAttribute("href"), "ajax=1" )
		return SendXMLHTTP( strTargetURL, strErrorCall );
	}
	else
	{
		return true;
	}		
}
function FavouriteRemoved( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "fav_link_" + intMemberId ) )
		{
			document.getElementById( "fav_link_" + intMemberId ).setAttribute("href","/AddFavourite.aspx?m=" + intMemberId + "&amp;url=" + escape(document.location.href) );
			document.getElementById( "fav_img_" + intMemberId ).setAttribute("src","/images/cards/add_" + fav_string + "_off2.gif");
			document.getElementById( "fav_img_" + intMemberId ).setAttribute("alt","Add to " + fav_string + "s");
		};
	}
	setTimeout( tempFunction, 500);
}
function FavouriteAdded( intMemberId )
{
	NotInterestedUnset( intMemberId );
	var tempFunction = function(){
		if( document.getElementById( "fav_link_" + intMemberId ) )
		{
			document.getElementById( "fav_link_" + intMemberId ).setAttribute("href","/RemoveFavourite.aspx?m=" + intMemberId + "&amp;url=" + escape(document.location.href) );
			document.getElementById( "fav_img_" + intMemberId ).setAttribute("src","/images/cards/add_" + fav_string + "_on2.gif");
			document.getElementById( "fav_img_" + intMemberId ).setAttribute("alt","Remove from " + fav_string + "s");
		};
	}
	setTimeout( tempFunction, 500);
}
function FavouriteLoading( intMemberId )
{
	if( document.getElementById( "fav_link_" + intMemberId ) )
	{
		document.getElementById( "fav_link_" + intMemberId ).setAttribute("href","");
		document.getElementById( "fav_img_" + intMemberId ).setAttribute("src","/images/cards/add_favourite_load.gif");
		document.getElementById( "fav_img_" + intMemberId ).setAttribute("alt","Saving");
	};
}

function FavouriteToggle( objLink, intMemberId, strNickName ) 
{
			
	var blnReturn, strImageURL, strAbortText;
	strImageURL = document.getElementById( "fav_img_" + intMemberId ).getAttribute("src")

	if (strImageURL.indexOf("add_favourite_load")>0) return false;

    if (strImageURL.indexOf("add_" + fav_string + "_off")>0){
		strAbortText = "FavouriteRemoved( "+ intMemberId +" );"
    }else{
		strAbortText = "FavouriteAdded( "+ intMemberId +" );"
    }

	blnReturn = AJAX( objLink, strAbortText  );
	
	// Only do if bln return is false ( as blnReturn indicates AJAX was successful )
	if( ! blnReturn )
	{
		FavouriteLoading( intMemberId );					
	}
	
	// ShowPopupInfo( objLink, strNickName );	
	
	return blnReturn;
}
function NotInterestedSet( intMemberId )
{
	FavouriteRemoved( intMemberId );
	var tempFunction = function(){
		if( document.getElementById( "int_link_" + intMemberId ) ) 
		{
			document.getElementById( "int_link_" + intMemberId ).setAttribute("href","/RestoreMatch.aspx?m=" + intMemberId + "&amp;url=" + escape(document.location.href) );
			document.getElementById( "int_img_" + intMemberId ).setAttribute("src","/images/cards/not_interested_on2.gif");
			document.getElementById( "int_img_" + intMemberId ).setAttribute("alt","Restore to matches");
		}
	}
	setTimeout( tempFunction, 500);
}
function NotInterestedUnset( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "int_link_" + intMemberId ) ) 
		{
			document.getElementById( "int_link_" + intMemberId ).setAttribute("href","/RemoveMatch.aspx?m=" + intMemberId + "&amp;url=" + escape(document.location.href) );
			document.getElementById( "int_img_" + intMemberId ).setAttribute("src","/images/cards/not_interested_off2.gif");
			document.getElementById( "int_img_" + intMemberId ).setAttribute("alt","Not interested");
		}
	}
	setTimeout( tempFunction, 500);
}
function NotInterestedLoading( intMemberId )
{
	if( document.getElementById( "int_link_" + intMemberId ) ) 
	{
		document.getElementById( "int_link_" + intMemberId ).setAttribute("href","");
		document.getElementById( "int_img_" + intMemberId ).setAttribute("src","/images/cards/not_interested_load.gif");
		document.getElementById( "int_img_" + intMemberId ).setAttribute("alt","Saving");
	}
}
function NotInterestedToggle( objLink, intMemberId, strNickName ) 
{
	var blnReturn, strImageURL, strAbortText;
	strImageURL = document.getElementById( "int_img_" + intMemberId ).getAttribute("src")

//	if( strImageURL.substring( strImageURL.length-23, strImageURL.length ) == "not_interested_load.gif" )
//		return false;
    if (strImageURL.indexOf("not_interested_load")>0) return false;

    if (strImageURL.indexOf("not_interested_off")>0){
		strAbortText = "NotInterestedUnset( "+ intMemberId +" );"
    }else{
		strAbortText = "NotInterestedSet( "+ intMemberId +" );"
    }
//	if( strImageURL.substring( strImageURL.length-22, strImageURL.length ) == "not_interested_off.gif" )
//	{
//		strAbortText = "NotInterestedUnset( "+ intMemberId +" );"
//	}
//	else
//	{
//		strAbortText = "NotInterestedSet( "+ intMemberId +" );"
//	}
//	
	blnReturn = AJAX( objLink, strAbortText  );	
	
	// Only do if bln return is false ( as blnReturn indicates AJAX was successful )
	if( ! blnReturn )
	{
		NotInterestedLoading( intMemberId );		
	}
	
	// ShowPopupInfo( objLink, strNickName );
	
	return blnReturn;
}

function RemoveProfile( objLink, intMemberId )
{		
	// make sure we support style first
	if( document.getElementById( "rem_txt_" + intMemberId ) && document.getElementById( "rem_txt_" + intMemberId ).innerHTML && document.getElementById( "rem_txt_" + intMemberId ).style )
	{
		objLink.setAttribute( "href", AddValueToURL(objLink.getAttribute("href"), "txt=1") )
		return AJAX( objLink )
	}
	else
	{
		return true;
	}
	return false;
}
function RemoveProfileReturn( intMemberId )
{
	document.getElementById( "rem_txt_" + intMemberId ).innerHTML = "Removed";
	document.getElementById( "rem_txt_" + intMemberId ).style.fontSize = "0.9em";
}

function AddValueToURL( strUrl, strValue )
{
	strUrl = String(strUrl)
	if( strUrl.indexOf("?",0) < 0 )
	{
		strUrl = strUrl + "?"
	} 
	if( strUrl.charAt( strUrl.length-1 ) != "&" && strUrl.charAt( strUrl.length-1 ) != "?" ) 
	{
		strUrl = strUrl + "&"
	}
	strUrl = strUrl + strValue	
	return strUrl;
}