function blockError()
{
	return true;
}
window.onerror = blockError;

// pop-up edit lyrics
function lyricEdit(type, id) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/lyricEdit.php?type=' + type + '&id=' + id;	window.open(direc,'lyricEdit','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=350,height=700,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// pop-up add lyrics
function lyricAdd(type, id) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/lyricAdd.php?type=' + type + '&id=' + id;	window.open(direc,'lyricAdd','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=350,height=700,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// pop-up comments and message
function postMsgCmt(type, id) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/postMsgCmt.php?type=' + type + '&id=' + id;	window.open(direc,'MsgCmt','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=515,height=550,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// pop-up comments and message
function chat() 
{  	
	var direc = 'http://www.jpopasia.com/chat/chatJPA/';	window.open(direc,'chat','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=950,height=620,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// pop-up add friends
function addFriendFan(action, toID) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/addFriendFan.php?action=' + action + '&toID=' + toID;	window.open(direc,'addFriendFan','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=515,height=200,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// pop-up fav video
function fav(id) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/fav.php?id=' + id;	window.open(direc,'favID','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=515,height=150,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// pop-up play settings
function playSettings(id) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/playSettings.php?id=' + id;	window.open(direc,'playSet','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=515,height=470,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// pop-up house biddings
function houseBid(action, userID, houseID, strNr, pr, offerTime) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/houseBid.php?action=' + action + '&uid=' + userID + '&hid=' + houseID + '&strNr=' + strNr + '&pr=' + pr + '&offerTime=' + offerTime;	window.open(direc,'houseBid','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=515,height=500,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// pop-up actions
function actions(toID, action) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/actions.php?toID=' + toID + '&action=' + action;	window.open(direc,'actions','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=515,height=500,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// add any video to PL
function addVideoPL(id) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/addVideoPL.php?editID=' + id;	window.open(direc,'addVidPL','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=515,height=650,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// edit PL
function editPL(id) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/editPL.php?editID=' + id;	window.open(direc,'editPL','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=515,height=555,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// pop-up play settings
function showCmt(type, id) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/pop/showCmt.php?type=' + type + '&id=' + id;	window.open(direc,'showCmt','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=515,height=700,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}

// pop-up delete artistProfiles
function artistProfileDelete(artistProfileDeleteID, artistProfileDeleteType) 
{  	 	
	var direc = 'http://www.jpopasia.com/pag/popUp/artistProfileDelete.php?artistProfileDeleteID=' + artistProfileDeleteID + '&artistProfileDeleteType=' + artistProfileDeleteType;	window.open(direc,'addFriends','fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=455,height=600,left=0,top=100,screenX=0,screenY=100');return false;   	 	 
}


// more and less artist info @ play
function showInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "inline";
	}
	}
function hideInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "none";
	}
}


function reload(form)
{
	var val=form.title.options[form.title.options.selectedIndex].value;
	self.location='testDropdown.php?artist=' + val ;
}













var aExpandedAnswer = new Array();
var aExpandedCategory = new Array();

function toggleAnswer(answerId)
{
	var answerDiv = $('answer' + answerId);
	var questionDiv = $('question' + answerId);
	//answerDiv.style.display = (answerDiv.className == '') ? 'block' : 'none';
	questionDiv.className = (questionDiv.className == 'faqExpanded') ? '' : 'faqExpanded';
	answerDiv.className = (answerDiv.className == 'faqExpanded') ? '' : 'faqExpanded';
	hideAllAnswers(answerId);
	aExpandedAnswer = new Array();
	aExpandedAnswer.push(answerId);
}

function hideAllAnswers(chosenId)
{
	for(var i=0; i<aExpandedAnswer.length; i++) 
	{
		if(chosenId != aExpandedAnswer[i])
		{
			hideAnswer(aExpandedAnswer[i]);
		}
	}
}

function hideAnswer(answerId)
{
	var answerDiv = $('answer' + answerId);
	var questionDiv = $('question' + answerId);
	//answerDiv.style.display = 'none';
	answerDiv.className = '';
	questionDiv.className = '';
}

function toggleCategory(category, categoryId)
{
	var listElement = $(category + 'list');
	var readMoreDiv = $('readMore' + category);
	listElement.className = (listElement.className == 'faqCollapsedList') ? '' : 'faqCollapsedList';
	//readMoreDiv.childNodes[1].className = "collapse";
	//readMoreDiv.childNodes[1].innerHTML = (listElement.className == 'faqCollapsedList') ? '<span>Show all</span>' : '<span>Collapse</span>';
	if (listElement.className == 'faqCollapsedList') hideAllAnswers();
	
	for(var i=0; i<aExpandedCategory.length; i++) 
	{
		//hideCategory(aExpandedCategory[i]);
	}

	aExpandedCategory = new Array();
	aExpandedCategory.push(category); 
	//window.location.href = '#category' + categoryId;
}

function hideCategory(category)
{
	var readMoreDiv = $('readMore' + category);
	readMoreDiv.style.display = 'block';
}








































/* -----------------------------------------------------------------------------------------------------------------------
imgRollover
----------------------------------------------------------------------------------------------------------------------- */

/*
	Header Information------------------------------------[Do Not Remove This Header]--
	Title: OO Dom Image Rollover
	Description: This script makes it easy to add rollover/ mousedown 
  	effects to any image on the page, including image submit buttons. Automatically 
  	preloads images as well. Script works in all DOM capable browsers- IE5+, NS6+, 
  	Opera7+.
	
	Legal: Copyright 2005 Adam Smith
	Author Email Address: ibulwark@hotmail.com
	Date Created: June 6, 2005
	Website: Codevendor.com | eBadgeman.com
	Script featured on Dynamic Drive: http://www.dynamicdrive.com
	-----------------------------------------------------------------------------------
*/

function imageholderclass(){
	this.over=new Array();
	this.down=new Array();
	this.src=new Array();
	this.store=store;
	
	function store(src, down, over){
		var AL=this.src.length;
		this.src[AL]=new Image(); this.src[AL].src=src;
		this.over[AL]=new Image(); this.over[AL].src=over;
		this.down[AL]=new Image(); this.down[AL].src=down;
	}
}

var ih = new imageholderclass();
var mouseisdown=0;

function preloader(t){
	for(i=0;i<t.length;i++){
		if(t[i].getAttribute('srcover')||t[i].getAttribute('srcdown')){
			
			storeimages(t[i]);
			var checker='';
			checker=(t[i].getAttribute('srcover'))?checker+'A':checker+'';
			checker=(t[i].getAttribute('srcdown'))?checker+'B':checker+'';
			
			switch(checker){
			case 'A' : mouseover(t[i]);mouseout(t[i]); break;
			case 'B' : mousedown(t[i]); mouseup2(t[i]); break;
			case 'AB' : mouseover(t[i]);mouseout(t[i]); mousedown(t[i]); mouseup(t[i]); break;
			default : return;			
			}
			
			if(t[i].src){t[i].setAttribute("oldsrc",t[i].src);}
		}
	}
}
function mouseup(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");this.oldmouseup();}

	}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");}}
	t.onmouseup=newmouseup;
}

function mouseup2(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");this.oldmouseup();}
		}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");}}
	t.onmouseup = newmouseup;
}

function mousedown(t){
	var newmousedown;
	if(t.onmousedown){
		t.oldmousedown=t.onmousedown;
		newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");this.oldmousedown();}}
	}
	else{newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");}}}
	t.onmousedown=newmousedown;
}

function mouseover(t){
	var newmouseover;
	if(t.onmouseover){
		t.oldmouseover=t.onmouseover;
		newmouseover=function(){this.src=this.getAttribute("srcover");this.oldmouseover();}
	}
	else{newmouseover=function(){this.src=this.getAttribute("srcover");}}
	t.onmouseover=newmouseover;
}

function mouseout(t){
	var newmouseout;
	if(t.onmouseout){
		t.oldmouseout=t.onmouseout;
		newmouseout=function(){this.src=this.getAttribute("oldsrc");this.oldmouseout();}
	}
	else{newmouseout=function(){this.src=this.getAttribute("oldsrc");}}
	t.onmouseout=newmouseout;
}

function storeimages(t){
	var s=(t.getAttribute('src'))?t.getAttribute('src'):'';
	var d=(t.getAttribute('srcdown'))?t.getAttribute('srcdown'):'';
	var o=(t.getAttribute('srcover'))?t.getAttribute('srcover'):'';
	ih.store(s,d,o);
}

function preloadimgsrc(){
	if(!document.getElementById) return;
	var it=document.getElementsByTagName('IMG');
	var it2=document.getElementsByTagName('INPUT');
	preloader(it);
	preloader(it2);
}

if(window.addEventListener){window.addEventListener("load", preloadimgsrc, false);} 
else{
	if(window.attachEvent){window.attachEvent("onload", preloadimgsrc);}
	else{if(document.getElementById){window.onload=preloadimgsrc;}}
}

/* -----------------------------------------------------------------------------------------------------------------------
anCollapse
----------------------------------------------------------------------------------------------------------------------- */

//Animated Collapsible DIV- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated Aug 1st, 07'. Fixed bug with "block" parameter not working when persist is enabled
//Updated June 27th, 07'. Added ability for a DIV to be initially expanded.

var uniquepageid=window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, "") //get current page path and name, used to uniquely identify this page for persistence feature

function animatedcollapse(divId, animatetime, persistexpand, initstate){
	this.divId=divId
	this.divObj=document.getElementById(divId)
	this.divObj.style.overflow="hidden"
	this.timelength=animatetime
	this.initstate=(typeof initstate!="undefined" && initstate=="block")? "block" : "contract"
	this.isExpanded=animatedcollapse.getCookie(uniquepageid+"-"+divId) //"yes" or "no", based on cookie value
	this.contentheight=parseInt(this.divObj.style.height)
	var thisobj=this
	if (isNaN(this.contentheight)){ //if no CSS "height" attribute explicitly defined, get DIV's height on window.load
		animatedcollapse.dotask(window, function(){thisobj._getheight(persistexpand)}, "load")
		if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
			this.divObj.style.visibility="hidden" //hide content (versus collapse) until we can get its height
	}
	else if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //just collapse content if CSS "height" attribute available
	if (persistexpand)
		animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload")
}

animatedcollapse.prototype._getheight=function(persistexpand){
	this.contentheight=this.divObj.offsetHeight
	if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes"){ //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //collapse content
		this.divObj.style.visibility="visible"
	}
	else //else if persistence is enabled AND this content should be expanded, define its CSS height value so slideup() has something to work with
		this.divObj.style.height=this.contentheight+"px"
}


animatedcollapse.prototype._slideengine=function(direction){
	var elapsed=new Date().getTime()-this.startTime //get time animation has run
	var thisobj=this
	if (elapsed<this.timelength){ //if time run is less than specified length
		var distancepercent=(direction=="down")? animatedcollapse.curveincrement(elapsed/this.timelength) : 1-animatedcollapse.curveincrement(elapsed/this.timelength)
	this.divObj.style.height=distancepercent * this.contentheight +"px"
	this.runtimer=setTimeout(function(){thisobj._slideengine(direction)}, 10)
	}
	else{ //if animation finished
		this.divObj.style.height=(direction=="down")? this.contentheight+"px" : 0
		this.isExpanded=(direction=="down")? "yes" : "no" //remember whether content is expanded or not
		this.runtimer=null
	}
}


animatedcollapse.prototype.slidedown=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Please wait until document has fully loaded then click again")
		else if (parseInt(this.divObj.style.height)==0){ //if content is collapsed
			this.startTime=new Date().getTime() //Set animation start time
			this._slideengine("down")
		}
	}
}

animatedcollapse.prototype.slideup=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Please wait until document has fully loaded then click again")
		else if (parseInt(this.divObj.style.height)==this.contentheight){ //if content is expanded
			this.startTime=new Date().getTime()
			this._slideengine("up")
		}
	}
}

animatedcollapse.prototype.slideit=function(){
	if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
		alert("Please wait until document has fully loaded then click again")
	else if (parseInt(this.divObj.style.height)==0)
		this.slidedown()
	else if (parseInt(this.divObj.style.height)==this.contentheight)
		this.slideup()
}

// -------------------------------------------------------------------
// A few utility functions below:
// -------------------------------------------------------------------

animatedcollapse.curveincrement=function(percent){
	return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
}


animatedcollapse.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
}

animatedcollapse.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

animatedcollapse.setCookie=function(name, value){
		document.cookie = name+"="+value
}

/* -----------------------------------------------------------------------------------------------------------------------
toolTip (Profiles)
----------------------------------------------------------------------------------------------------------------------- */

// Tooltip (fuer Vorschau in Navigation)

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

/* -----------------------------------------------------------------------------------------------------------------------
ajaxAct
----------------------------------------------------------------------------------------------------------------------- */

var xmlHttp
// Function called ie onClick with given values onClick();
function ajaxAct(id, valueid1, valueid2, valueid3, valueid4, valueid5)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	// Show a loading element during... the loading :D
	document.getElementById('ajaxActPrint').innerHTML="<div align=\"center\" width=\"100%\"><img src=\"http://i1.jpopasia.com/gen/loadingMedium.gif\"></div>"; 
	
	// Load and pass values to given URL
	var url="http://www.jpopasia.com/i2/ajax/ajaxAct.php"
	url=url+"?saveid="+id
	url=url+"&valueid1="+valueid1
	url=url+"&valueid2="+valueid2
	url=url+"&valueid3="+valueid3
	url=url+"&valueid4="+valueid4
	url=url+"&valueid5="+valueid5
	xmlHttp.onreadystatechange=stateChangedAct
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

// Print result to designated div ID
function stateChangedAct() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("ajaxActPrint").
		innerHTML=xmlHttp.responseText;
	} 
} 













function ajaxTB(id, valueid1, valueid2, valueid3, valueid4, valueid5, valueid6)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	// Show a loading element during... the loading :D
	document.getElementById('printTB').innerHTML="<div align=\"center\" width=\"100%\"><img src=\"http://i1.jpopasia.com/gen/loadingMedium.gif\"></div>"; 
	
	// Load and pass values to given URL
	var url="http://www.jpopasia.com/i2/ajax/ajaxTB.php"
	url=url+"?saveid="+id
	url=url+"&valueid1="+valueid1
	url=url+"&valueid2="+valueid2
	url=url+"&valueid3="+valueid3
	url=url+"&valueid4="+valueid4
	url=url+"&valueid5="+valueid5
	
	if (document.getElementById("formVal1")) {	
		url = url+"&valueid6=" + encodeURIComponent( document.getElementById("formVal1").value );
	}	
	
	xmlHttp.onreadystatechange=stateChangedTB
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

// Print result to designated div ID
function stateChangedTB() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("printTB").
		innerHTML=xmlHttp.responseText;
	} 
} 









function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}



















var http_request = false;
function makePOSTRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Cannot create XMLHTTP instance');
	 return false;
  }
  
  // Show a loading element during... the loading :D
  document.getElementById('printTB').innerHTML="<div align=\"center\" width=\"100%\"><img src=\"http://i1.jpopasia.com/gen/loadingMedium.gif\"></div>";
  
  http_request.onreadystatechange = alertContents;
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
}

function alertContents() {
  if (http_request.readyState == 4) {
	 if (http_request.status == 200) {
		//alert(http_request.responseText);
		result = http_request.responseText;
		document.getElementById('printTB').innerHTML = result;            
	 } else {
		alert('There was a problem with the request.');
	 }
  }
}

function getMsgCmt(id, valueid1, valueid2, valueid3, valueid4, valueid5) {
 
  var poststr = "saveid=" + id +
 				"&valueid1=" + valueid1 +
 				"&valueid2=" + valueid2 +
   				"&valueid3=" + valueid3 +
   				"&valueid4=" + escape( document.getElementById("messageBox").value );
  if (document.getElementById("text1")) {	
  	poststr = poststr+"&valueid5=" + encodeURIComponent( document.getElementById("text1").value );
  }			
   				
   				
  makePOSTRequest('http://www.jpopasia.com/i2/ajax/ajaxTB.php', poststr);
}









function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function POSTRequest(elementID, id, valueid1, valueid2, valueid3, valueid4, valueid5) {
    createXMLHttpRequest();
    
    var url = "http://www.jpopasia.com/i2/ajax/ajaxArr.php";
   
    var poststr = "printid=" + elementID + 
    			"&saveid=" + id;
    			
    			//var txtMsg= escapeAmp(document.getElementById("messageBox").value);
    			//function escapeAmp(txtMsg) {
					//var r = txtMsg;
					//re = new RegExp('&','g');
    				//r = r.replace(re,'%26');
    				
    				//return r;
				//}
    			
    			
				if (document.getElementById("messageBox")) {	
					//poststr = poststr+"&text=" + encodeURI( txtMsg );
					poststr = poststr+"&text=" + encodeURIComponent( document.getElementById("messageBox").value );
				}	
				
				if (document.getElementById("title")) {	
					poststr = poststr+"&title=" + escape( document.getElementById("title").value );
				}						
    			
				if (valueid1) {
					poststr = poststr+"&valueid1=" + escape( valueid1 );
				}
				
				if (valueid2) {
					poststr = poststr+"&valueid2=" + escape( valueid2 );
				}
				
				if (valueid3) {
					poststr = poststr+"&valueid3=" + escape( valueid3 );
				}
				
				if (valueid4) {
					poststr = poststr+"&valueid4=" + escape( valueid4 );
				}
				
				if (valueid5) {
					poststr = poststr+"&valueid5=" + escape( valueid5 );
				}
				
				if (document.getElementById("formVal1")) {	
				  	poststr = poststr+"&formVal1=" + encodeURIComponent( document.getElementById("formVal1").value );
				}		
		
    xmlHttp.open("POST", url, true);
    
      // Show a loading element during... the loading :D
	document.getElementById('ajaxActArr' + elementID).innerHTML="<div align=\"center\" width=\"100%\"><img src=\"http://i1.jpopasia.com/gen/loadingMedium.gif\"></div>"; 
    
    xmlHttp.onreadystatechange = function() {
			if(xmlHttp.readyState == 4) {
				if(xmlHttp.status == 200) {
					document.getElementById("ajaxActArr" + elementID).
					innerHTML=xmlHttp.responseText;
				}
			}
		};
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
    xmlHttp.send(poststr);
    
}




/* -----------------------------------------------------------------------------------------------------------------------
Scroll
----------------------------------------------------------------------------------------------------------------------- */


// JavaScript Document
/******************************************
* Scrollable content script III- (Modified from II) © Dynamic Drive (www.dynamicdrive.com)
* Visit http://www.dynamicdrive.com/ for full source code
* This notice must stay intact for use
******************************************/

function SCWindow(name,width,height){
  this.name = name
  this.objname = name
  this.width = width
  this.height = height
  this.contentwidth = this.width - 4
  //specify speed of scroll (greater=faster)
  this.speed = 5
}

SCWindow.prototype.initialize = function(){
    var id = this.name + "content"
    var id2 = this.name + "content2"
    this.crossobj = document.getElementById? document.getElementById(id2) : document.all[id2]
    this.contentbox = document.getElementById? document.getElementById(id) : document.all[id]
    this.contentheight=this.crossobj.offsetHeight
    this.contentbox.style.height = this.contentheight + "px"
    this.limit = this.height-this.contentheight
}

SCWindow.prototype.movedown = function (){
  var thisthis = this
  var topint = parseInt(this.crossobj.style.top)
  if (topint>=this.limit){
    this.crossobj.style.top=topint-this.speed+"px"
    this.movedownvar=setTimeout(function(){thisthis.movedown()},30)
  }
}

SCWindow.prototype.moveup = function (){
  var thisthis = this
  var topint = parseInt(this.crossobj.style.top)
  if (topint<0){
    this.crossobj.style.top=topint+this.speed+"px"
    this.moveupvar=setTimeout(function(){thisthis.moveup()},30)
  }
}

SCWindow.prototype.pagedown = function (){
  var thisthis = this
  var topint = parseInt(this.crossobj.style.top)
  if (topint>=this.limit){
    val = topint -(this.height - 10)
    if (val<this.limit){val=this.limit}
    this.crossobj.style.top=val+"px"
  }
}

SCWindow.prototype.pageup = function (){
  var thisthis = this
  var topint = parseInt(this.crossobj.style.top)
  if (topint<0){
    var val = (topint+this.height) - 10
    if(val > 0){val = 0}
    this.crossobj.style.top=val+"px"
  }
}

SCWindow.prototype.stop = function (){
  clearTimeout(this.moveupvar)
  clearTimeout(this.movedownvar)
}

SCWindow.prototype.control = function(cont){
  this.stop()
  switch (cont) {
    case "up"     : this.moveup(); break;
    case "down"   : this.movedown(); break;
    case "pgup"   : this.pageup(); break;
    case "pgdn"   : this.pagedown(); break;
    case "play"   : this.movedown(); break;
    case "reverse": this.moveup();
  }
}

SCWindow.prototype.startblock = function (contentstyle){
  var s = ""
  if(contentstyle){s = contentstyle}
  document.write('<div class="scwd1" id="' + this.name + 'container" style="width: ' + this.width + 'px; height: ' + this.height + 'px;">')
  document.write('<div class="scwd2" id="' + this.name + 'content2" style="width: ' + this.width + 'px; left: 0pt; top: 0px;">')
  document.write('<div class="scwd3" id="' + this.name + 'content" style="width: ' + this.contentwidth + 'px; clip: rect(0pt, 0pt, ' + this.width + 'px, ' + this.height + 'px);' + s + '">')
}

SCWindow.prototype.endblock = function (){
  document.write('</div></div></div>')
}

SCWindow.prototype.makecontrols = function (upimage,downimage){
  document.write('<div class="scwscrollcontrol" id="' + this.name + 'scroll">')
  document.write('<a class="scwbuttons" href="#" onClick="return false" onmouseover="' + this.objname + '.control(\'up\')" onmouseout="' + this.objname + '.stop()">')
  if(upimage){document.write('<img src="' + upimage + '" border="0" alt="/\\ ">')}else{document.write('/\\ ')}
  document.write('&nbsp;&nbsp;<a class="scwbuttons" href="#" onClick="return false" onmouseover="' + this.objname + '.control(\'down\')" onmouseout="' + this.objname + '.stop()">')
  if(downimage){document.write('<img src="' + downimage + '" border="0">')}else{document.write('\\/')}
  document.write('</a></div>')
}

SCWindow.prototype.makepagecontrols = function (upimage,downimage){
  document.write('<div class="scwpagecontrol" id="' + this.name + 'page">')
  document.write('<a class="scwbuttons" href="javascript: ' + this.objname + '.control(\'pgup\')">')
  if(upimage){document.write('<img src="' + upimage + '" border="0">')}else{document.write('//\\\\ ')}
  document.write('</a><a class="scwbuttons" href="javascript: ' + this.objname + '.control(\'pgdn\')">')
  if(downimage){document.write('<img src="' + downimage + '" border="0">')}else{document.write('\\\\//')}
  document.write('</a></div>')

}

SCWindow.prototype.makeplaycontrols = function (stopimage,playimage,reverseimage){
  document.write('<div class="scwplaycontrol" id="' + this.name + 'play">')
  document.write('<a class="scwbuttons" href="javascript: ' + this.objname + '.control(\'reverse\')">')
  if(reverseimage){document.write('<img src="' + reverseimage + '" border="0">')}else{document.write('< ')}
  document.write('</a><a class="scwbuttons" href="javascript: ' + this.objname + '.stop()">')
  if(stopimage){document.write('<img src="' + stopimage + '" border="0">')}else{document.write('0')}
  document.write('</a><a class="scwbuttons" href="javascript: ' + this.objname + '.control(\'play\')">')
  if(playimage){document.write('<img src="' + playimage + '" border="0">')}else{document.write(' >')}
  document.write('</a></div>')

}

/* -----------------------------------------------------------------------------------------------------------------------
Poplyrics
----------------------------------------------------------------------------------------------------------------------- */

// http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm

// instance.setPersist(false) //No persistence
// instance.setPersist(true) //Enable session-only persistence
// instance.setPersist(true, 7) //Set persistence to 7 days

// instance.defaultExpanded(0) //1st content expanded
// instance.defaultExpanded(0,1) //1st and 2nd content expanded
// instance.defaultExpanded(3,5) //3rd and 5th content expanded

function switchcontent(className, filtertag){
	this.className=className
	this.collapsePrev=false //Default: Collapse previous content each time
	this.persistType="none" //Default: Disable persistence
	//Limit type of element to scan for on page for switch contents if 2nd function parameter is defined, for efficiency sake (ie: "div")
	this.filter_content_tag=(typeof filtertag!="undefined")? filtertag.toLowerCase() : ""
}

switchcontent.prototype.setStatus=function(openHTML, closeHTML){ //PUBLIC: Set open/ closing HTML indicator. Optional
	this.statusOpen=openHTML
	this.statusClosed=closeHTML
}

switchcontent.prototype.setColor=function(openColor, closeColor){ //PUBLIC: Set open/ closing color of switch header. Optional
	this.colorOpen=openColor
	this.colorClosed=closeColor
}

switchcontent.prototype.setPersist=function(bool, days){ //PUBLIC: Enable/ disable persistence. Default is false.
	if (bool==true){ //if enable persistence
		if (typeof days=="undefined") //if session only
			this.persistType="session"
		else{ //else if non session persistent
			this.persistType="days"
			this.persistDays=parseInt(days)
		}
	}
	else
		this.persistType="none"
}

switchcontent.prototype.collapsePrevious=function(bool){ //PUBLIC: Enable/ disable collapse previous content. Default is false.
	this.collapsePrev=bool
}


switchcontent.prototype.sweepToggle=function(setting){ //PUBLIC: Expand/ contract all contents method. (Values: "contract"|"expand")
	if (typeof this.headers!="undefined" && this.headers.length>0){ //if there are switch contents defined on the page
		for (var i=0; i<this.headers.length; i++){
			if (setting=="expand")
				this.expandcontent(this.headers[i]) //expand each content
			else if (setting=="contract")
				this.contractcontent(this.headers[i]) //contract each content
		}
	}
}


// -------------------------------------------------------------------
// PUBLIC: defaultExpanded(indices_of_contents)- Set contents that should be expanded by default when the page loads.
// Note that the persistence feature (if enabled) overrides this setting.
// Pass in the position of the contents relative to the rest of the contents ie: defaultExpanded(0,2,3) would expand the 1st, 3rd, and 4th contents by default
// -------------------------------------------------------------------

switchcontent.prototype.defaultExpanded=function(){
	var expandedindices=[] //Array to hold indices (position) of content to be expanded by default
	//Loop through function arguments, and store each one within array
	//Two test conditions: 1) End of Arguments array, or 2) If "collapsePrev" is enabled, only the first entered index (as only 1 content can be expanded at any time)
	for (var i=0; (!this.collapsePrev && i<arguments.length) || (this.collapsePrev && i==0); i++)
		expandedindices[expandedindices.length]=arguments[i]
	this.expandedindices=expandedindices.join(",") //convert array into a string of the format: "0,2,3" for later parsing by script
}


//PRIVATE: Sets color of switch header.

switchcontent.prototype.togglecolor=function(header, status){
	if (typeof this.colorOpen!="undefined")
		header.style.color=status
}


//PRIVATE: Sets status indicator HTML of switch header.

switchcontent.prototype.togglestatus=function(header, status){
	if (typeof this.statusOpen!="undefined")
		header.firstChild.innerHTML=status
}


//PRIVATE: Contracts a content based on its corresponding header entered

switchcontent.prototype.contractcontent=function(header){
	var innercontent=document.getElementById(header.id.replace("-title", "")) //Reference content for this header
	innercontent.style.display="none"
	this.togglestatus(header, this.statusClosed)
	this.togglecolor(header, this.colorClosed)
}


//PRIVATE: Expands a content based on its corresponding header entered

switchcontent.prototype.expandcontent=function(header){
	var innercontent=document.getElementById(header.id.replace("-title", ""))
	innercontent.style.display="block"
	this.togglestatus(header, this.statusOpen)
	this.togglecolor(header, this.colorOpen)
}

// -------------------------------------------------------------------
// PRIVATE: toggledisplay(header)- Toggles between a content being expanded or contracted
// If "Collapse Previous" is enabled, contracts previous open content before expanding current
// -------------------------------------------------------------------

switchcontent.prototype.toggledisplay=function(header){
	var innercontent=document.getElementById(header.id.replace("-title", "")) //Reference content for this header
	if (innercontent.style.display=="block")
		this.contractcontent(header)
	else{
		this.expandcontent(header)
		if (this.collapsePrev && typeof this.prevHeader!="undefined" && this.prevHeader.id!=header.id) // If "Collapse Previous" is enabled and there's a previous open content
			this.contractcontent(this.prevHeader) //Contract that content first
	}
	if (this.collapsePrev)
		this.prevHeader=header //Set current expanded content as the next "Previous Content"
}


// -------------------------------------------------------------------
// PRIVATE: collectElementbyClass()- Searches and stores all switch contents (based on shared class name) and their headers in two arrays
// Each content should carry an unique ID, and for its header, an ID equal to "CONTENTID-TITLE"
// -------------------------------------------------------------------

switchcontent.prototype.collectElementbyClass=function(classname){ //Returns an array containing DIVs with specified classname
	var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)", "i") //regular expression to screen for classname within element
	this.headers=[], this.innercontents=[]
	if (this.filter_content_tag!="") //If user defined limit type of element to scan for to a certain element (ie: "div" only)
		var allelements=document.getElementsByTagName(this.filter_content_tag)
	else //else, scan all elements on the page!
		var allelements=document.all? document.all : document.getElementsByTagName("*")
	for (var i=0; i<allelements.length; i++){
		if (typeof allelements[i].className=="string" && allelements[i].className.search(classnameRE)!=-1){
			if (document.getElementById(allelements[i].id+"-title")!=null){ //if header exists for this inner content
				this.headers[this.headers.length]=document.getElementById(allelements[i].id+"-title") //store reference to header intended for this inner content
				this.innercontents[this.innercontents.length]=allelements[i] //store reference to this inner content
			}
		}
	}
}


//PRIVATE: init()- Initializes Switch Content function (collapse contents by default unless exception is found)

switchcontent.prototype.init=function(){
	var instanceOf=this
	this.collectElementbyClass(this.className) //Get all headers and its corresponding content based on shared class name of contents
	if (this.headers.length==0) //If no headers are present (no contents to switch), just exit
		return
	//If admin has changed number of days to persist from current cookie records, reset persistence by deleting cookie
	if (this.persistType=="days" && (parseInt(switchcontent.getCookie(this.className+"_dtrack"))!=this.persistDays))
		switchcontent.setCookie(this.className+"_d", "", -1) //delete cookie
	// Get ids of open contents below. Four possible scenerios:
	// 1) Session only persistence is enabled AND corresponding cookie contains a non blank ("") string
	// 2) Regular (in days) persistence is enabled AND corresponding cookie contains a non blank ("") string
	// 3) If there are contents that should be enabled by default (even if persistence is enabled and this IS the first page load)
	// 4) Default to no contents should be expanded on page load ("" value)
	var opencontents_ids=(this.persistType=="session" && switchcontent.getCookie(this.className)!="")? ','+switchcontent.getCookie(this.className)+',' : (this.persistType=="days" && switchcontent.getCookie(this.className+"_d")!="")? ','+switchcontent.getCookie(this.className+"_d")+',' : (this.expandedindices)? ','+this.expandedindices+',' : ""
	for (var i=0; i<this.headers.length; i++){ //BEGIN FOR LOOP
		if (typeof this.statusOpen!="undefined") //If open/ closing HTML indicator is enabled/ set
			this.headers[i].innerHTML='<span class="status"></span>'+this.headers[i].innerHTML //Add a span element to original HTML to store indicator
		if (opencontents_ids.indexOf(','+i+',')!=-1){ //if index "i" exists within cookie string or default-enabled string (i=position of the content to expand)
			this.expandcontent(this.headers[i]) //Expand each content per stored indices (if ""Collapse Previous" is set, only one content)
			if (this.collapsePrev) //If "Collapse Previous" set
			this.prevHeader=this.headers[i]  //Indicate the expanded content's corresponding header as the last clicked on header (for logic purpose)
		}
		else //else if no indices found in stored string
			this.contractcontent(this.headers[i]) //Contract each content by default
		this.headers[i].onclick=function(){instanceOf.toggledisplay(this)}
	} //END FOR LOOP
	switchcontent.dotask(window, function(){instanceOf.rememberpluscleanup()}, "unload") //Call persistence method onunload
}


// -------------------------------------------------------------------
// PRIVATE: rememberpluscleanup()- Stores the indices of content that are expanded inside session only cookie
// If "Collapse Previous" is enabled, only 1st expanded content index is stored
// -------------------------------------------------------------------

//Function to store index of opened ULs relative to other ULs in Tree into cookie:
switchcontent.prototype.rememberpluscleanup=function(){
	//Define array to hold ids of open content that should be persisted
	//Default to just "none" to account for the case where no contents are open when user leaves the page (and persist that):
	var opencontents=new Array("none")
	for (var i=0; i<this.innercontents.length; i++){
		//If persistence enabled, content in question is expanded, and either "Collapse Previous" is disabled, or if enabled, this is the first expanded content
		if (this.persistType!="none" && this.innercontents[i].style.display=="block" && (!this.collapsePrev || (this.collapsePrev && opencontents.length<2)))
			opencontents[opencontents.length]=i //save the index of the opened UL (relative to the entire list of ULs) as an array element
		this.headers[i].onclick=null //Cleanup code
	}
	if (opencontents.length>1) //If there exists open content to be persisted
		opencontents.shift() //Boot the "none" value from the array, so all it contains are the ids of the open contents
	if (typeof this.statusOpen!="undefined")
		this.statusOpen=this.statusClosed=null //Cleanup code
	if (this.persistType=="session") //if session only cookie set
		switchcontent.setCookie(this.className, opencontents.join(",")) //populate cookie with indices of open contents: classname=1,2,3,etc
	else if (this.persistType=="days" && typeof this.persistDays=="number"){ //if persistent cookie set instead
		switchcontent.setCookie(this.className+"_d", opencontents.join(","), this.persistDays) //populate cookie with indices of open contents
		switchcontent.setCookie(this.className+"_dtrack", this.persistDays, this.persistDays) //also remember number of days to persist (int)
	}
}


// -------------------------------------------------------------------
// A few utility functions below:
// -------------------------------------------------------------------


switchcontent.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
}

switchcontent.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

switchcontent.setCookie=function(name, value, days){
	if (typeof days!="undefined"){ //if set persistent cookie
		var expireDate = new Date()
		var expstring=expireDate.setDate(expireDate.getDate()+days)
		document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()
	}
	else //else if this is a session only cookie
		document.cookie = name+"="+value
}




/* -----------------------------------------------------------------------------------------------------------------------
Rate
----------------------------------------------------------------------------------------------------------------------- */

var V_RATING_IMG = 'starRated';
var V_RATING_IMG_HALF = 'starRated_half';
var V_RATING_IMG_GREY = 'star';
var V_RATING_IMG_BG = 'star';
var V_RATING_IMG_USER = 'starRated';
var V_RATING_IMG_USER_EMPTY = 'star';
var V_RATING_IMG_HOVER='starRated_self';

function veohRating(maxStars, objectName, mediaName, averageRating, userRating, objectId, recommendationId )
{
	this.maxStars = maxStars;
	this.objectName = objectName;
	this.mediaName = mediaName;
	this.averageRating = averageRating;
	this.userRating = userRating;
	this.objectId = objectId;
	this.recommendationId = recommendationId;

	this.starTimer = null;
	this.starCount = 0;
	
	function getElement( elementName )
	{
		return document.getElementById( mediaName + '_' + elementName );
	}

	function showStars(starNum) 
	{
		this.clearStarTimer();
		//this.greyStars();
		this.colorStars(starNum);
		this.setMessage(starNum);
	}

	function showUserRating()
	{
		this.greyStars();
		var roundedAverage = Math.floor( userRating );
		
		for( var i = 1; i <= roundedAverage; i++ )
		{
			getElement( 'star_' + i ).className = V_RATING_IMG_USER;
		}
	}
	
	function showAverageRating()
	{
		this.blankStars();
		var roundedAverage = Math.floor( averageRating );
		
		for( var i = 1; i <= roundedAverage; i++ )
		{
			getElement( 'star_' + i ).className = V_RATING_IMG;
		}
		
		var remainder = averageRating - roundedAverage;
		
		if( (averageRating - roundedAverage) >= 0.5 )
		{
			getElement( 'star_' + (roundedAverage + 1) ).className = V_RATING_IMG_HALF;
		}

	}

	function setMessage(starNum) {
		messages = new Array("Rate this video", "My ears! T_T", "Nothing special", "Worth watching", "Pretty cool ^-^", "OMG! Awesomeness!");
		document.getElementById('ratingMessage').innerHTML = messages[starNum];
	}

	function colorStars(starNum) 
	{
		for (var i=1; i <= starNum; i++)
		{
			getElement('star_' + i).className = V_RATING_IMG_HOVER;
		}
		
		for (var i=starNum+1; i <= this.maxStars; i++)
		{
			getElement('star_' + i).className = V_RATING_IMG_USER_EMPTY;
		}
		
	}

	function greyStars() 
	{
		for (var i=1; i < this.maxStars + 1; i++)
		{
			getElement('star_' + i).className = V_RATING_IMG_USER_EMPTY;
		}
	}

	function blankStars() 
	{
		for (var i=1; i < this.maxStars + 1; i++)
		{
			getElement('star_' + i).className = V_RATING_IMG_BG;
		}
	}

	function drawStars(starNum) 
	{
		this.clearStarTimer();
		this.showStars(starNum);
	}

	function clearStars() 
	{
		this.starTimer = setTimeout(this.objectName + ".resetStars()", 100);
	}

	function resetStars() 
	{
		this.clearStarTimer();

		if ( this.starCount )
		{
			this.drawStars( this.starCount );
		}
		else if( this.averageRating )
		{
			this.showAverageRating();
		}
		else if( this.userRating )
		{
			this.showUserRating();
		}
		else
		{
			this.greyStars();
		}
		this.setMessage(0);
	}

	function clearStarTimer() 
	{
		if (this.starTimer) 
		{
			clearTimeout(this.starTimer);
			this.starTimer = null;
		}
	}
	
	function setStars(starNum) 
	{
		this.starCount = starNum;
		this.drawStars( starNum );
		ajaxMethodHandler.rateMedia( ratingResponse, objectId, this.starCount, this.recommendationId);
		//ratingResponse( { 'userRating': starNum } );
	}	
	
	function ratingResponse( model )
	{	
		if( model['errors'] != null )
		{
			alert( trim( model['errors'] ) );
		}else
		{
			//getElement('votes').innerHTML = model['numVotes'];
			this.userRating = model['userRating'];
			new Effect.Appear( getElement('ratingsToFlash'), {duration:2.0, transition:Effect.Transitions.wobble} );
			//showCommentBox();
		}	
	}
    
	this.showUserRating = showUserRating;
	this.showAverageRating = showAverageRating;
	this.clearStars = clearStars;
	this.clearStarTimer = clearStarTimer;
	this.greyStars = greyStars;
	this.blankStars = blankStars;
	this.colorStars = colorStars;
	this.resetStars = resetStars;
	this.setStars = setStars;
	this.drawStars = drawStars;
	this.showStars = showStars;
	this.setMessage = setMessage;
}
