// RateAFace 3, a Roxbox site. Script by Mark Willis.
// Profile JS

function showAbout()
{
	if(document.getElementById('about-2').style.display != "block"){document.getElementById('about-2').style.display = "block"; document.getElementById('about-1').style.display = "none";}
	else if(document.getElementById('about-2').style.display == "block"){document.getElementById('about-2').style.display = "none"; document.getElementById('about-1').style.display = "block";}
	return false;
}

function favUser(uid)
{
	// Duplicate of RATER function.
	document.getElementById('favLink').innerHTML = '<img src="images/famfamfamsilk/heart.png" width="16" height="16" alt="Favourite" title="" border="0" /> Please wait...';

	var d = new Date();
	var tsec = d.getSeconds();

	var ajaxRequest;
	try{ajaxRequest = new XMLHttpRequest(); } catch (e){try{ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try{ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){return true;}}}
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4){
		document.getElementById('favLink').innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = 'includes/interface/favUser.php?user=' + uid + '&t=' + tsec;
	ajaxRequest.open("GET", queryString, true);
	ajaxRequest.send(null);
	return false;
}

function reloadImagePlayground(uid, loadVars)
{
	// Reload, yo
	var d = new Date();
	var tsec = d.getSeconds();
	document.getElementById('imagePlayground').innerHTML = '<object type="application/x-shockwave-flash" data="includes/flash/imagePlayground.swf?time=' + tsec + '" width="350" height="250"><param name="FlashVars" value="' + loadVars + '" /><param name="allowFullScreen" value="true" /><param name="movie" value="includes/flash/imagePlayground.swf?time=' + tsec + '" /><param name="wmode" value="transparent" /><img src="includes/flash/ip-noflash.jpg" height="250" width="350" alt="You need Flash!" title="You need Flash!" border="0" /></object>';
	document.getElementById('imagePlayground').innerHTML += '<div class="NoPhotoLink"><a onclick="return reloadImagePlayground(\'' + uid + '\', \'' + loadVars + '\');" href="javascript:;">Images still not loaded? (Give it a few seconds!)</a></div>';
}

function renderSmallRater(rateID)
{
	// Get the rate bar.
	document.getElementById('smRate').innerHTML = 'Loading...';

	var d = new Date();
	var tsec = d.getSeconds();

	var ajaxRequest;
	try{ajaxRequest = new XMLHttpRequest(); } catch (e){try{ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try{ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){return true;}}}
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4){
		document.getElementById('smRate').innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = 'includes/interface/smallRater.php?user=' + rateID + '&t=' + tsec;
	ajaxRequest.open("GET", queryString, true);
	ajaxRequest.send(null);
	return false;
}

function smallRate(rateID, rateVal)
{
	// Do it, do it now.
	document.getElementById('smRate').innerHTML = '<div class="profileRater"><div class="profileRaterInner">Please wait...</div></div>';

	var d = new Date();
	var tsec = d.getSeconds();

	var ajaxRequest;
	try{ajaxRequest = new XMLHttpRequest(); } catch (e){try{ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try{ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){return true;}}}
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4){
		document.getElementById('smRate').innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = 'includes/interface/smallRater.php?user=' + rateID + '&rate=' + rateVal + '&t=' + tsec;
	ajaxRequest.open("GET", queryString, true);
	ajaxRequest.send(null);
	return false;
}

function delComm(dasType, dasID, dasPole)
{
	// dasType 1 = profile tag
	// dasType 2 = photo comment
	var answer = confirm("Are you sure you want to delete this comment?");
	if (answer){
		document.getElementById('comm-'+dasID).innerHTML = '<center><img src="http://www.rateaface.com/images/loading.gif" width="32" height="32" alt="Loading" title="Loading" border="0" /></center>';
		//alert("deleting "+ dasID + " pole: "+dasPole);
		var d = new Date();
		var tsec = d.getSeconds();

		var ajaxRequest;
		try{ajaxRequest = new XMLHttpRequest(); } catch (e){try{ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try{ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){return true;}}}
		ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4){
			document.getElementById('comm-'+dasID).style.display = "none";
			//document.getElementById('comm-'+dasID).innerHTML = ajaxRequest.responseText;
			}
		}
		var queryString = 'http://www.rateaface.com/includes/interface/deleteComm.php?type=' + dasType + '&id=' + dasID + '&pole=' + dasPole + '&t=' + tsec;
		ajaxRequest.open("GET", queryString, true);
		ajaxRequest.send(null);
	}
	else
	{
		return false;
	}
	
}
