

function showWindow(type,clientid,itemid) {
	_type = type;
	_clientid = clientid;
	_itemid = itemid;
	if(timeout > 0) {
		cur_opacity = 0;

		winbackground.style.opacity = cur_opacity / 100;
		winbackground.style.filter = "alpha(opacity=" + cur_opacity + ")";
		win.style.display = 'block';
		wincontent.style.display = 'none';

		timer = setTimeout("increase_opacity()",timeout);
	}
	else {
		winbackground.style.opacity = end_opacity / 100;
		winbackground.style.filter = "alpha(opacity=" + end_opacity + ")";
		win.style.display = 'block';
		wincontent.style.display = 'block';
	}
}

function increase_opacity() {
	cur_opacity += increase_opacity_by;

	winbackground.style.opacity = cur_opacity / 100;
	winbackground.style.filter = "alpha(opacity=" + cur_opacity + ")";

	if(cur_opacity < end_opacity) {
		timer = setTimeout("increase_opacity()",timeout);
	}
	else {
		wincontent.style.display = 'block';
		loadmedia(_itemid,_clientid,_type);
		//$('mediaplayer').innerHTML = _type+":"+_clientid+":"+_itemid;

	}
}

function hideWindow() {
	win.style.display = 'none';
}

function showrecent(clientid,itemid,type,image)
{

	$('left').style.backgroundImage = "url(/custom/images/left_over.jpg)";
	$('sep1').style.backgroundImage = "url(/custom/images/sep_left_over.jpg)";
	$('middle').style.backgroundImage = "url(/custom/images/middle_under.jpg)";
	$('sep2').style.backgroundImage = "url(/custom/images/sep_all_under.jpg)";
	$('right').style.backgroundImage = "url(/custom/images/middle_under.jpg)";
	$('sep3').style.backgroundImage = "url(/custom/images/sep_right_under.jpg)";
	//alert('/custom/index.php/ajax/lookup/'+clientid+'/'+itemid+'/recent/'+type+'/'+image);
	new Ajax.Updater('mediaarea', '/custom/index.php/ajax/lookup/'+clientid+'/'+itemid+'/recent/'+type+'/'+image, { method: 'get' });

}

function showmostviewed(clientid,itemid,type,image)
{


	$('left').style.backgroundImage = "url(/custom/images/left_under.jpg)";
	$('sep1').style.backgroundImage = "url(/custom/images/sep_right_over.jpg)";
	$('middle').style.backgroundImage = "url(/custom/images/middle_over.jpg)";
	$('sep2').style.backgroundImage = "url(/custom/images/sep_left_over.jpg)";
	$('right').style.backgroundImage = "url(/custom/images/middle_under.jpg)";
	$('sep3').style.backgroundImage = "url(/custom/images/sep_right_under.jpg)";
	//alert('/custom/index.php/ajax/lookup/'+clientid+'/'+itemid+'/most/'+type+'/'+image);
	new Ajax.Updater('mediaarea', '/custom/index.php/ajax/lookup/'+clientid+'/'+itemid+'/most/'+type+'/'+image, { method: 'get' });
}

function showall(clientid,itemid,sort,type,image)
{

	$('left').style.backgroundImage = "url(/custom/images/left_under.jpg)";
	$('sep1').style.backgroundImage = "url(/custom/images/sep_all_under.jpg)";
	$('middle').style.backgroundImage = "url(/custom/images/middle_under.jpg)";
	$('sep2').style.backgroundImage = "url(/custom/images/sep_right_over.jpg)";
	$('right').style.backgroundImage = "url(/custom/images/middle_over.jpg)";
	$('sep3').style.backgroundImage = "url(/custom/images/sep_right_over-07.jpg)";
	//alert('/custom/index.php/ajax/lookup/'+clientid+'/'+itemid+'/all/'+type+'/a/'+sort);
	new Ajax.Updater('mediaarea', '/custom/index.php/ajax/lookup/'+clientid+'/'+itemid+'/all/'+type+'/a/'+sort, { method: 'get' });
}

function dosearch(clientid,topic,sort)
{

//	alert(clientid+':'+topic+':'+sort+':'+$('searchfor').value);
	new Ajax.Updater('mediaarea', '/custom/index.php/ajax/search/'+clientid+'/'+topic+'/'+$('searchfor').value+'/'+sort, { method: 'get' });

}
function closeplayer()
{
	$('mediaplayer').innerHTML='';
	win.style.display = 'none';
}
function loadmedia(id,clientid,mediatype)
{

	self.scrollTo(0, 0);
	new Ajax.Updater('mediaplayer', '/custom/index.php/ajax/setplayer/'+clientid+'/'+id+'/'+mediatype, { method: 'get' });
	//$('mediaplayer').innerHTML="<table width=550 cellspacing=0 cellpadding=0 border=0><tr><td align=right valign=top><a href=javascript:closeplayer()><img border='0' src=/custom/images/close.jpg></a></td></tr><tr><td align=center><object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0 width=400 height=300 id=freeflow align=middle><param name=allowScriptAccess value=sameDomain /><param name=allowFullScreen value=true /><param name=movie value=/custom/images/freeflowplayer.swf?id="+id+"&clientid="+clientid+"&mediatype="+mediatype+"/><param name=quality value=high /><param name=bgcolor value=#000000 /><embed src=/custom/images/freeflowplayer.swf?id="+id+"&clientid="+clientid+"&mediatype="+mediatype+" quality=high bgcolor=#000000 width=400 height=300 name=freeflow align=middle allowfullscreen=true allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer /></object></td></tr></table>";
	//alert($('mediaplayer').innerHTML);

}

function addcomment(id,clientid)
{
	addcommentwin = window.open('/custom/index.php/home/comment/'+id+'/'+clientid,'comment','left=200,top=200,width=600,height=380,scrollbars=yes');
	addcommentwin.focus();
}

function verifycomment()
{


	if (document.getElementById('mc_author_name').value == '')
	{
		alert('Name is required');
		document.getElementById('mc_author_name').focus();
		return false
	}

	if (document.getElementById('mc_title').value == '')
	{
		alert('A Title is required');
		document.getElementById('mc_title').focus();
		return false
	}

	if (document.getElementById('mc_text').value == '')
	{
		alert('Some Text for your comment is required');
		document.getElementById('mc_text').focus();
		return false
	}
	return true;
}

function showcommentoptions()
{
	document.getElementById('commentoptions').style.visibility='visible';
}
function hidecommentoptions()
{
	document.getElementById('commentoptions').style.visibility='hidden';
}
function viewcomments(id,clientid)
{
	$('commentoptions').style.visibility='hidden';
	viewcommentwin = window.open('/sc_customplayer/viewcomments/'+id+'/'+clientid,'viewcomments','left=200,top=100,width=720,height=500,scrollbars=yes');
	viewcommentwin.focus();
}

function sendtofriend(id,clientid)
{

	sendtofriendwin = window.open('/custom/index.php/home/sendtofriend/'+id+'/'+clientid,'sendtofriend','left=200,top=200,width=600,height=420,scrollbars=yes');
	sendtofriendwin.focus();
}

function verifysendtofriend()
{
	if (document.getElementById('fromname').value == '')
	{
		alert('Your name is required');
		document.getElementById('fromname').focus();
		return false;
	}

	if (document.getElementById('frommail').value == '')
	{
		alert('Your email address is required');
		document.getElementById('frommail').focus();
		return false;
	}

	if (document.getElementById('tomail').value == '')
	{
		alert('A friends email is required');
		document.getElementById('tomail').focus();
		return false;
	}
	return true;
}

function showcasts(clientid)
{

	document.getElementById('podcast').style.visibility='visible';
	makeRequest('/sc_customplayer/showpodcasts/'+clientid,'podcast');
}

function showcomments(id,clientid)
{
	viewcommentwin = window.open('/custom/index.php/home/viewcomments/'+id+'/'+clientid,'viewcomments','left=200,top=100,width=720,height=500,scrollbars=yes');
	viewcommentwin.focus();
}