var xmlhttp;
var recorder_window;


function rifflyFinishedRecording (riffly_id, riffly_type) {
	db_add(riffly_id);
}

function db_add(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
			{
				alert ("Browser does not support HTTP Request");
				return;
			}
	var url="db.php";
	url=url+"?id="+str;
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
	
		recorder_window.innerHTML=xmlhttp.responseText;
	}
}

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
		   {
			   // code for IE7+, Firefox, Chrome, Opera, Safari
			   return new XMLHttpRequest();
		   }
	if (window.ActiveXObject)
		   {
			   // code for IE6, IE5
			   return new ActiveXObject("Microsoft.XMLHTTP");
		   }
	return null;
}

function rifflyShowRecorder (recorder_window_id, recorder_type, callback) {

recorder_window = document.getElementById(recorder_window_id);


recorder_window.style.display = 'inline';

if (recorder_type == 'audio') {
	recorder_window.innerHTML = '<object width="320" height="138"><param name="movie" value="http://riffly.com/static/flash/rifflyrecorder.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="quality" value="high"></param><param name="scale" value="noscale"></param><param name="flashvars" value="recordLimit=3600&callback=' + encodeURIComponent(callback) + '&mode=audio&url=' + encodeURIComponent(location.href) + '&post_title=' + encodeURIComponent(document.title) + '"></param><embed id="riffly_recorder_object" src="http://riffly.com/static/flash/rifflyrecorder.swf" quality="high" bgcolor="#ffffff" name="riffly_recorder_object" allowscriptaccess="always" scale="noscale" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" align="middle" width="320" height="138" wmode="transparent" flashvars=recordLimit=3600&callback=' + encodeURIComponent(callback) + '&mode=audio&url=' + encodeURIComponent(location.href) + '&post_title=' + encodeURIComponent(document.title) + '"></embed></object>';
} else {
	recorder_window.innerHTML = '<object width="320" height="260"><param name="movie" value="http://riffly.com/static/flash/rifflyrecorder.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="quality" value="high"></param><param name="scale" value="noscale"></param><param name="flashvars" value="recordLimit=3600&callback=' + encodeURIComponent(callback) + '&mode=video&url=' + encodeURIComponent(location.href) + '&post_title=' + encodeURIComponent(document.title) + '"></param><embed id="riffly_recorder_object" src="http://riffly.com/static/flash/rifflyrecorder.swf" quality="high" bgcolor="#ffffff" name="riffly_recorder_object" allowscriptaccess="always" scale="noscale" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" align="middle" width="320" height="260" wmode="transparent" flashvars="recordLimit=3600&callback=' + encodeURIComponent(callback) + '&mode=video&url=' + encodeURIComponent(location.href) + '&post_title=' + encodeURIComponent(document.title) + '" ></embed>';
}

}

