function ViewDump(id)
{
	
		window.view_item = list_items[id];

		ratingComponent.starCount	= window.view_item.rating;
		//alert(ratingComponent.starCount);



	
		showPopUp('dialog');
		var dlg = document.getElementById('dialog')
		dlg.style.height = "600px"
		dlg.style.overflow = "hidden"
		//dlg.style.backgroundImage = 'url(/img/'+ color.bg_group +'/popup_bg.png)';
		
	Display('items_view','dialog','');
	//TDViewItemOverView(id);
	
	



	//return;
		
}



function TDViewComments(id)
{

	Display('items_view_comments','dialog','cmd=comments&id='+ id +'');
	
}





function TDGetDLKey()
{

		var dlg = document.getElementById('itemdesc')
		dlg.style.height = "400px"
		
		var dlg = document.getElementById('keycode')
		dlg.style.display = "block"		
		
		
	Display('download_keycode','keycode','cmd=loadkeycode');
	
}



function ViewDLLinks2()
{
	
	
	
	//alert(gid.item_id);
	Display('items_view_description','dialog','');
	
	
	
}





function TDCheckKey(id,key)
{
	
			var lkey = key.toLowerCase();
			var tkey = document.getElementById('keyverify').value;
			var tkey = tkey.toLowerCase();			
			
			
			if (tkey == "")
			{
				var error =  'Your Must enter the Download Key';
				alert(error);
				
					TDGetDLKey(id);
					
					
			}else{
				
				if (tkey == lkey )
				{
					//alert("keymatch");
					
Display('items_view_links','dialog','cmd=loadlinks&drop_id='+ id +'&key='+ tkey +'');


//document.getElementById("").innerHTML = "32432423";	
				//window.time = 5; 
				//TDDLKey()
					
				}else{
				//	alert("keyMOmatch");
					TDGetDLKey(id);
					
				}
			
			
			}
	
	
}



function TDDLKey()
{
	



if(window.time>0){document.getElementById("loadkeycode").innerHTML = "<b>Your Download Slot has been Reserved.</b> Please wait <b>" +  time.toFixed(1) +'</b> <img src=/ver-1.0/img/ajax-loader02.gif align=absbottom> seconds...';
		window.time = window.time - .1;
		
		setTimeout("TDDLKey()", 100)
		} else {
		
		document.getElementById("loadkeycode").innerHTML = "Your Download Link is Ready, please click Free Download below:";
		
document.getElementById("dllink").innerHTML = "<a  href=\"/?dlcounter=1&domain=dirtygroups.com&file_type=1&size=8896133&file_id=69&file_name=139.rm&src=LzIwMDgwMjA2LzM4ODgvMTIwMjMwNzQwMy0zODg4LnJt\"><strong>Free Download</a></strong>	";	

					
		
		}
		

		
		
	
	
}




function LoadDropHome(page)
{
	
		Display('drop_home','body','cmd=drop_home&drop_id='+ drop.drop_id +'', page, 'LoadDropHome');
	
	
}



//function TDGetDLKey()
//{

//	Display('download_keycode','loadkeycode','cmd=loadkeycode');
	
//}







function TDViewItemOverview()
{

	Display('items_view','dialog','');
	
}




function TDListCatagories(id)
{
	
if (id == "")
{
			var outputEl  = document.getElementById('TDCatagories');
		outputEl.innerHTML = '';
		
}else{
	
LoaderIcon('TDCatagories');
	//alert(gid.item_id);
	Display('bar_catagories','TDCatagories','cmd=cat_list&type_id='+ id +'');
	
}
	
	
}







function TDSearchItems()
{
	
	TDListCatagories('');
	// setTimeout('TDdisplayUserItemCount()',36000);
	
	
	
	var query = escape(document.getElementById('tditemsearch').value);
	//var timestamp = fetch_unix_timestamp();
	//var database = '/index.php?action=database&cmd=search_items&query='+ query +'&timestamp='+ timestamp;


	Display('items_list','body','cmd=search_items&query='+ query +'');
	return;
	
	
	//alert(tem_url );
	eval(getFile(database));
	
	
	
	
		var tmp = "items_list";
		var tem_url = ''+ site_info.site_version +'/templates/tmp_java/'+ tmp +'.htm';
		
		//alert(tem_url);
		
		if (document.getElementById(tmp).value == "")
		{
		
		
  	    myRequest = new ajaxObject(tem_url );
		myRequest.callback = function(responseText, responseStatus)
		{
			if (responseStatus==200) {
			
			
			
			responseText = responseText.replace( /\r\n/g, " " );
			responseText = responseText.replace( /\r/g, " " );
			responseText = responseText.replace( /\n/g, " " );
			document.getElementById(tmp).value = responseText; 	

		var outputEl  = document.getElementById("body");
		var go = function() {
		outputEl.innerHTML = TrimPath.processDOMTemplate("items_list", site_info);
			
		}
		
		go();
	

			} else {
			alert('Error while loading template, please try again');
			}
  
  
			
		} 
		myRequest.update();
		
		
		
		
		}else{
			
			
		var outputEl  = document.getElementById("body");
		var go = function() {
		outputEl.innerHTML = TrimPath.processDOMTemplate("items_list", site_info);
			
				}
		
		go();
		
		}
		
	
	
	
	//return "1";
	


}



function Freshenup(id)
{
	
	Display('bar_refresh','backup_'+ id +'','cmd=freshenup&id='+ id +'');
	return;
	
}



function DeleteItem(id)
{
	
	Display('bar_delete','backup_'+ id +'','cmd=deleteitem&id='+ id +'');
	return;
	
}


function Backup(id)
{
	
	
	
	Display('bar_backup','backup_'+ id +'','cmd=backup&id='+ id +'');
	return;
	

}





function TDUserHave()
{
	
	
	
	Display('user_list_have','body','cmd=user_have');
	return;
	

}






function TDBrowseTypes(id)
{
	
	
	
var page = "1";
		

TDListCats(id,page)		
TDListCatagories(id);			
			
	
	//setTimeout('TDdisplayUserItemCount()',86000);
	
	
	//Display('items_list','body','cmd=list_cat&id='+ id +'',page,'TDListCats',id);
	return;
	
	
	


}




function TDListCats(id,page)
{
	
	LoaderIcon('body');
	
	

			
			
	
	//setTimeout('TDdisplayUserItemCount()',86000);
	
	
	Display('items_list','body','cmd=list_cat&id='+ id +'',page,'TDListCats',id);
	return;
	
	
	


}




function TDdisplayUserItemCount()
{
	
	//LoaderIcon('useritemcount');
	///setTimeout('TDdisplayUserItemCount()',98000);
	
	
	//Display('bar_useritemcount','useritemcount','cmd=user_stats');
	return;
	
	
	


}





function TDUserRegister()
{
	
	Display('user_register','body','');
	return;

}




function TDUserSignIn()
{
	
	Display('user_login','body','');
	return;

}





function TDDisplayVisiters()
{
	
	Display('user_visiters','usercounting','cmd=visiters');
	//isUserLoggedIn()
	setTimeout('TDDisplayVisiters()',36000);
	return;

}



function TDUserSignOut()
{
	
	Display('error_msg','body','cmd=user_logout');
	isUserLoggedIn()
	
	//setTimeout("location.href='/'",100)
	
	
	return;

}




function TDRegisterUser()
{
	
		var timestamp = fetch_unix_timestamp();

		
			myRequest = new ajaxObject('/index.php?action=database&cmd=user_reg');
			myRequest.callback = function(responseText) 
			{
				//alert(responseText);
				eval(responseText);
			var trimmed =   responseText.replace(/^\s+|\s+$/g, '') ;
			responseText = trimmed;
			
				if (responseText == "1")
				{
					
					document.getElementById('error').innerHTML = "Username already in system";
					
				}
					
					
				if (responseText == "0")
				{
					
					location.href='/';
					
				}					
					
				
				
			}
			
			
			
			
			
			var error = "";
				
			if (document.getElementById('username').value == "")
			{
				error =  error +'Your Must enter a Username\n';
			}
	
			if (document.getElementById('password').value == "")
			{
				error =  error +'Your Must enter a Password\n';
			}	


			if (error)
			{
				
				document.getElementById('error').innerHTML = error;
				//alert(error);
			}else{
			
			
     var poststr = 'username=' + document.getElementById('username').value + 
	 				'&password=' + document.getElementById('password').value;
				   
				//   alert(poststr);
						
			myRequest.update(''+ poststr +'','POST');
			
			}
	
	
	
}





function TDSubmitUserLogin()
{
	
		var timestamp = fetch_unix_timestamp();

		
			myRequest = new ajaxObject('/index.php?action=database&cmd=user_login');
			myRequest.callback = function(responseText) 
			{
				//alert(responseText);
				eval(responseText);
			var trimmed =   responseText.replace(/^\s+|\s+$/g, '') ;
			responseText = trimmed;
			
				if (responseText == "1")
				{
					
					document.getElementById('error').innerHTML = "Username and Password did not match a user";
					
				}
					
					
				if (responseText == "0")
				{
					
					location.href='/';
					
				}					
					
				
				
			}
			
			
			
			
			
			var error = "";
				
			if (document.getElementById('username').value == "")
			{
				error =  error +'Your Must enter a Username\n';
			}
	
			if (document.getElementById('password').value == "")
			{
				error =  error +'Your Must enter a Password\n';
			}	


			if (error)
			{
				
				document.getElementById('error').innerHTML = error;
				//alert(error);
			}else{
			
			
     var poststr = 'username=' + document.getElementById('username').value + 
	 				'&password=' + document.getElementById('password').value;
				   
				//   alert(poststr);
						
			myRequest.update(''+ poststr +'','POST');
			
			}
	
	
	
}



var UT_RATING_IMG				=	new Image();
	UT_RATING_IMG.src			=	'/ver-1.0/img/star_bg_yellow_s.gif';
var UT_RATING_IMG_BG			=	new Image();
	UT_RATING_IMG_BG.src		=	'/ver-1.0/img/star_bg_wh__off.gif';




function UTRating(ratingElementId, maxStars, objectName, formName, ratingMessageId, componentSuffix, size) {
	this.ratingElementId	=	ratingElementId;
	this.maxStars			=	maxStars;
	this.objectName			=	objectName;
	this.formName			=	formName;
	this.ratingMessageId	=	ratingMessageId;
	this.componentSuffix	=	componentSuffix;

	this.starTimer = null;
	this.starCount = 0;

	function showStars(starNum, skipMessageUpdate) {
		this.clearStarTimer();
		this.greyStars();
		this.colorStars(starNum);
		if(!skipMessageUpdate)
			this.setMessage(starNum);
	}

	function setMessage(starNum) {
		messages = new Array("Rate this "+type_rating, "Poor", "Nothing special", "Worth watching", "Pretty cool", "Awesome!");
		document.getElementById(this.ratingMessageId).innerHTML = messages[starNum];
	}

	function colorStars(starNum) {
		for (var i=0; i < starNum; i++)
			document.getElementById('star_'  + this.componentSuffix + "_" + (i+1)).src = UT_RATING_IMG.src;
	}

	function greyStars() {
		for (var i=0; i < this.maxStars; i++)
			if (i <= this.starCount)
				document.getElementById('star_' + this.componentSuffix + "_"  + (i+1)).src = UT_RATING_IMG_BG.src; // UT_RATING_IMG_REMOVED;
			else
				document.getElementById('star_' + this.componentSuffix + "_"  + (i+1)).src = UT_RATING_IMG_BG.src;
	}

	function setStars(starNum) {
		this.starCount = starNum;
		this.drawStars(starNum);
		document.forms[this.formName]['rating'].value = this.starCount;
		var ratingElementId = this.ratingElementId;
		postForm(this.formName, true, function (req) { replaceDivContents(req, ratingElementId); });
	}

	function drawStars(starNum, skipMessageUpdate) {
		this.starCount=starNum;
		this.showStars(starNum, skipMessageUpdate);
	}

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

	function resetStars() {
		this.clearStarTimer();
		if (this.starCount)
			this.drawStars(this.starCount);
		else
			this.greyStars();
		this.setMessage(0);
	}

	function clearStarTimer() {
		if (this.starTimer) {
			clearTimeout(this.starTimer);
			this.starTimer = null;
		}
	}

	function submitRtg(rtg) {
		var id  = document.getElementById('citem_id').value;
		Display('bar_ratingsaved','ratingDiv','cmd=save_rating&id='+ id +'&rate='+ rtg +'');
		
		//ratingForm.urtg.value = rtg;
		//ratingForm.submit();
		//return false;
	}

	this.clearStars		=	clearStars;
	this.clearStarTimer	=	clearStarTimer;
	this.greyStars		=	greyStars;
	this.colorStars		=	colorStars;
	this.resetStars		=	resetStars;
	this.setStars		=	setStars;
	this.drawStars		=	drawStars;
	this.showStars		=	showStars;
	this.setMessage		=	setMessage;
	this.submitRtg		=	submitRtg;
}
