function tp_RatingClick2(i,itemRating,itemID, iMaxRating, sSelectedImage, sUnselectedImage, iItemType, iItemRatingType, iTotalRatings,itemOwnerID,doVmixPost,sSys_ModKey)

{	
    document.getElementById('tp_israted_'+itemID).value = "1";	
	var url = "/community/app/nf/callback/insertrating.aspx";
	var args = "r="+i+"&i="+itemID+"&ot="+iItemType+"&irt="+iItemRatingType+"&o="+itemOwnerID+"&vmix="+doVmixPost+"&Sys_ModKey="+sSys_ModKey;
	//document.write (args);
	iTotalRatings = parseFloat(iTotalRatings) + 1;
	
	MyRatingsPostURL(url,args,0,"tp_RatingEvalResponse")
	
	if(document.getElementById('tp_rating_text_'+itemID)){document.getElementById('tp_rating_text_'+itemID).innerHTML = 'Thank you!';}
	if(document.getElementById('tp_total_ratings_'+itemID)){document.getElementById('tp_total_ratings_'+itemID).innerHTML = iTotalRatings + ' total ratings';}
	
	for (var x = -1; x <= iMaxRating ; x++)
	{
		var imgId = x + "_RATING_"+itemID;		
		var y = document.getElementById(imgId);
		if (y) {
		    y.onclick = null;
		    y.onmouseover = null;
		    y.onmouseout = null;
			//y.onmouseout = tp_OnMouseOut;
			//$(imgId).removeAttribute('onClick');
    		//$(imgId).removeAttribute('onMouseOver');					
	    	//Element.stopObserving($(imgId),'mouseover');	
	    	if (iItemRatingType = "UP_OR_DOWN") {
		        if (x==i) {
			        document.getElementById(imgId).alt = "You have already rated this item";
			        }
		        else {
		           document.getElementById(imgId).style.display="none";
		          }						
	    	}
	    	else {
		            if (x<=i) {
			            document.getElementById(imgId).src = sSelectedImage;
			            document.getElementById(imgId).alt = "You have already rated this item";
			            }
		            else {
			            document.getElementById(imgId).src = sUnselectedImage;
			            document.getElementById(imgId).alt = "You have already rated this item";					
		              }						
		      }
		    }
	}					
}


function tp_RatingClick(i,itemRating,itemID, iMaxRating, sSelectedImage, sUnselectedImage, iItemType, iItemRatingType, iTotalRatings,itemOwnerID,doVmixPost)
{	
    return tp_RatingClick2(i,itemRating,itemID, iMaxRating, sSelectedImage, sUnselectedImage, iItemType, iItemRatingType, iTotalRatings,itemOwnerID,doVmixPost,'');
}

		
function tp_OnMouseOut(iMaxRating,sUnselectedImage, sItemID)
{	
    var f = document.getElementById('tp_israted_'+sItemID);
	if (f.value!="1")
	{
		for (var x = 1; x <= iMaxRating ; x++)
		{
			var imgId = x+"_Rating_"+sItemID;					
			document.getElementById(imgId).src = sUnselectedImage;		
		}
	}
}

function tp_RatingEvalResponse()
{
	
}

function tp_RatingMouseOver(i,iMaxRating, sSelectedImage, sUnselectedImage, sItemID)
{
	for (var x = -1; x <= iMaxRating ; x++)
	{
		var imgId = x+"_Rating_"+sItemID;	
		var y = document.getElementById(imgId);	
		
		if (y) {
		    //y.onmouseout = tp_OnMouseOut(iMaxRating,sUnselectedImage,sItemID);
		    var fn = function( e ){e=window.event||e;if (e.stopPropagation)e.stopPropagation();else e.cancelBubble = true;tp_OnMouseOut(iMaxRating,sUnselectedImage,sItemID);}; AddEventHandlerToObject(y, 'mouseout', fn);
		    if (x<=i)
		    {
			    document.getElementById(imgId).src = sSelectedImage;
			    document.getElementById(imgId).alt = "Please click to rate this item";
		    }
		    else
		    {
			    document.getElementById(imgId).src = sUnselectedImage;
			    document.getElementById(imgId).alt = "Please click to rate this item";
		    }
		}
	}
}

function tp_LoginRedirect(sURL)
{
	window.location = sURL;
}

function tp_LoginRedirectToCurrentURL()
{
	window.location = "/login.aspx?rd="+document.location.href;
}

function AddEventHandlerToObject( obj, type, fn ) 
{
    if (!obj) return;
    if (obj.addEventListener)
	    obj.addEventListener( type, fn, false );
    else if (obj.attachEvent)
    {
	    obj["e"+type+fn] = fn;
		obj.attachEvent( "on"+type, function() { obj["e"+type+fn](); } );
    }
}

function getRatingsXmlhttpObject()
{
	var xmlhttp;
	xmlhttp=false;
	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
	catch (e1) {
		try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
		catch (e2) { xmlhttp = false; }
	}
	if (!xmlhttp) {
		try { xmlhttp = new XMLHttpRequest(); }
		catch (e3) { xmlhttp = false; }
	}
	return xmlhttp;
}



function MyRatingsPostURL(url,args,type,f)
{
	var dest = "";
	if (MyRatingsPostURL.arguments[3]){dest=f;if(type!=4 && type!=5){dest=dest+'('}};
	var xmlhttp = getRatingsXmlhttpObject();
	xmlhttp.open("POST", url, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange=function()
		{if (xmlhttp.readyState==4)
			{
			 if (dest!='' && type!=5){eval(dest+"'"+ escape(xmlhttp.responseText) +"\')");return true;}
			 if (dest!='' && type==5){eval(dest);return true;}
			 if	(type==1) {ParseStream(xmlhttp.responseText);return true;} 
			 if	(type==2) {ParseStream2(xmlhttp.responseText);return true;} 
			 } 	
		};
	if (args=='')
	{xmlhttp.send(null);}
	else {xmlhttp.send(args);}
}

function ParseStream(stream){}
function ParseStream2(stream){alert(stream);}
