/**
 *    Copyright (c) 2010-2012 Just Another Video script
 *
 *    This file is part of Just Another Video script.
 *    Come to website for support or buying additional plugins/modules.
 *    http://justanothervideoscript.com/
 */
 
$(document).ready(function(){
	function Display_Load() {
		$("body").append("<div id='overlay'></div>");
	    $("#allvideoloading").fadeIn(900,0);
		$("#allvideoloading").html("<img src='images/bigLoader.gif' />");
	}
	function Hide_Load() {
		$("#allvideoloading").fadeOut('fast');
		$("#overlay").remove();
	}
//plugin manager
	$("input[id^=Plugload_]").click(function() {
		var splitfirst = this.id.split("_");
		var dataString = "plugfunc=load" + "&plugname=" + splitfirst[1];
			$.ajax({
				type: "GET",
				url: "modules/ajaxfunc.php",
				async: false,
				cache: "false",
				data: dataString,
				success: function() {
					location.reload();
				}
			});
		return false;
	});
	$("input[id^=Plugunload_]").click(function() {
		var splitfirst = this.id.split("_");
		var dataString = "plugfunc=unload" + "&plugname=" + splitfirst[1];
			$.ajax({
				type: "GET",
				url: "modules/ajaxfunc.php",
				cache: "false",
				data: dataString,
				success: function() {
					location.reload();
				}
			});
		return false;
	});

//advertisement ajax load before the rest
	$("input[id^=ad_delete]").click(function() {
		Display_Load();
			if (this.id.match(/^ad_delete(\d+)$/)) {
				var addeleteid = RegExp.$1;
			}
			var dataString = "adfunc=funcdel" + "&siteadid=" + addeleteid;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function() {
							location.reload();
							Hide_Load();
						}
				});
			return false;
	});
	$("input[id^=ad_edit]").click(function() {
			if (this.id.match(/^ad_edit(\d+)$/)) {
				var adeditid = RegExp.$1;
			}
			$("html").scrollTop(0);
			$("body").append("<div id='overlay'></div>");
			$("#editbox").css({'visibility' : 'visible'});
			$("#editbox").fadeOut('slow', function(){
				$(this).load('modules/ajaxfunc.php?siteadedit=' + adeditid, function(){
					$(this).fadeIn('slow', function(){
					});
				});
			});
			return false;
	});
	$("input[id^=ad_edit_close]").live('click', function(){
		$('#editbox').fadeOut('slow');
		$("#overlay").remove();
		return false;
	});
	$("#ad_edit_submit").live('click', function(){
			var ad_edit_text = encodeURIComponent($("#ad_edit_text").val());
			var ad_edit_id = $("#ad_edit_id").val();
			var ad_edit_size = $("#ad_edit_size").val();
			var dataString = 'adfunc=funcedit' + '&ad_edit_id=' + ad_edit_id + '&ad_edit_text=' + ad_edit_text + '&ad_edit_size=' + ad_edit_size;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function() {
							$('#editbox').fadeOut('slow');
							$("#overlay").remove();
							 location.reload();
							$('html,body').animate({scrollTop: $("#listingtableheader"+ad_edit_id).offset().top},'slow');
						}
				});
		return false;
	});
	$("input[id^=ad_preview]").click(function() {
			if (this.id.match(/^ad_preview(\d+)$/)) {
				var adpreviewid = RegExp.$1;
			}
			$("html").scrollTop(0);
			$("body").append("<div id='overlay'></div>");
			$("#editbox").css({'visibility' : 'visible'});
			$("#editbox").fadeOut('slow', function(){
				$(this).load('modules/ajaxfunc.php?adfunc=funcpre' + '&ad_pre_id=' + adpreviewid, function(){
					$(this).fadeIn('slow', function(){
					});
				});
			});
		return false;
	});



//category Add, edit and delete
	$("#cat_edit_thumb").live('change', function(){
			$("#preview").html('');
			$("#preview").html('<img src="../images/bigLoader.gif" alt="Uploading...."/>');
			$("#catimageform").ajaxForm({
				target: '#preview'
			}).submit();
			return false;
	});
	$("input[id^=cat_thumb]").click(function() {
			if (this.id.match(/^cat_thumb(\d+)$/)) {
				var thumbcatid = RegExp.$1;
			}
			$("html").scrollTop(0);
			$("body").append("<div id='overlay'></div>");
			$("#editbox").css({'visibility' : 'visible'});
			$("#editbox").fadeOut('slow', function(){
				$(this).load('modules/ajaxfunc.php?categorythumb=' + thumbcatid, function(){
					$(this).fadeIn('slow', function(){
					});
				});
			});
			return false;
	});
	$("input[id^=cat_delete]").click(function() {
			if (this.id.match(/^cat_delete(\d+)$/)) {
				var delcatid = RegExp.$1;
			}
			var dataString = "categoryfunc=funcdel" + "&delid=" + delcatid;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function() {
							$('#listingtableheader' + delcatid).fadeOut('slow');
						}
				});
			return false;
	});
	$("input[id^=edit_cat_close]").live('click', function(){
			if (this.id.match(/^edit_cat_close(\d+)$/)) {
				var scrollid = RegExp.$1;
			}
		$('#editbox').fadeOut('slow');
		$("#overlay").remove();
		location.reload();
 		$('html,body').animate({scrollTop: $("#listingtableheader"+scrollid).offset().top},'slow');
		return false;
	});
	$("input[id^=cat_add_close]").live('click', function(){
			if (this.id.match(/^cat_add_close(\d+)$/)) {
				var scrollid = RegExp.$1;
			}
		$('#editbox').fadeOut('slow');
		$("#overlay").remove();
		location.reload();
		return false;
	});



	$("input[id^=cat_edit]").click(function() {
			if (this.id.match(/^cat_edit(\d+)$/)) {
				var editcatid = RegExp.$1;
			}
			$("html").scrollTop(0);
			$("body").append("<div id='overlay'></div>");
			$("#editbox").css({'visibility' : 'visible'});
			$("#editbox").fadeOut('slow', function(){
				$(this).load('modules/ajaxfunc.php?catedit=' + editcatid, function(){
					$(this).fadeIn('slow', function(){
					});
				});
			});
		return false;
	});

	$("#edit_cat_submit").live('click', function(){
			var cat_edit_catname = encodeURIComponent($("#cat_edit_catname").val());
			var cat_edit_catid = $("#cat_edit_catid").val();
			var dataString = 'categoryfunc=funcedit' + '&cat_edit_catid=' + cat_edit_catid + '&cat_edit_catname=' + cat_edit_catname;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function() {
							$('#editbox').fadeOut('slow');
							$("#overlay").remove();
							 location.reload();
							$('html,body').animate({scrollTop: $("#listingtableheader"+com_edit_id).offset().top},'slow');
						}
				});
		return false;
	});
	$("input[id^=cat_add]").click(function() {
			if (this.id.match(/^cat_add(\d+)$/)) {
				var addcatid = RegExp.$1;
			}
			$("html").scrollTop(0);
			$("body").append("<div id='overlay'></div>");
			$("#editbox").css({'visibility' : 'visible'});
			$("#editbox").fadeOut('slow', function(){
				$(this).load('modules/ajaxfunc.php?catadd=' + addcatid, function(){
					$(this).fadeIn('slow', function(){
					});
				});
			});
		return false;
	});

	$("#edit_add_submit").live('click', function(){
			var cat_add_name = encodeURIComponent($("#cat_add_name").val());
			var cat_add_id = $("#cat_add_id").val();
			var dataString = 'categoryfunc=funcadd' + '&cat_add_id=' + cat_add_id + '&cat_add_name=' + cat_add_name;
				$.ajax({
						type: 'GET',
						url: "modules/ajaxfunc.php",
						async: false,
						cache: false,
						data: dataString,
						success: function(result) {
								$("#caterrormsg").html('');
								if (result == 1) {
									$('#editbox').fadeOut('slow');
									$("#overlay").remove();
									location.reload();
								}
								if (result == 2) {
									$("#caterrormsg").html('<h5>Enter a Category name</h5>');
								}
								if (result == 3) {
									$("#caterrormsg").html('<h5>ID must a number</h5>');
								}
								if (result == 4) {
									$("#caterrormsg").html('<h5>Category ID already exists, choose another ID</h5>');
								}
								if (result == 5) {
									$("#caterrormsg").html('<h5>Category NAME already exists, choose another NAME</h5>');
								}
						}
				});

		return false;
	});


//comment ajax load before the rest
	$("input[id^=com_edit]").click(function() {
			if (this.id.match(/^com_edit(\d+)$/)) {
				var editcomid = RegExp.$1;
			}
			$("html").scrollTop(0);
			$("body").append("<div id='overlay'></div>");
			$("#editbox").css({'visibility' : 'visible'});
			$("#editbox").fadeOut('slow', function(){
				$(this).load('modules/ajaxfunc.php?commentedit=' + editcomid, function(){
					$(this).fadeIn('slow', function(){
					});
				});
			});
			return false;
	});
	$("input[id^=com_delete]").click(function() {
		Display_Load();
			if (this.id.match(/^com_delete(\d+)$/)) {
				var delcomid = RegExp.$1;
			}
			var dataString = "commentfunc=funcdel" + "&delid=" + delcomid;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function() {
							$('#listingtableheader' + delcomid).fadeOut('slow');
							Hide_Load();
						}
				});
			return false;
	});

	$("input[id^=edit_com_close]").live('click', function(){
			if (this.id.match(/^edit_com_close(\d+)$/)) {
				var scrollid = RegExp.$1;
			}
		$('#editbox').fadeOut('slow');
		$("#overlay").remove();
 		$('html,body').animate({scrollTop: $("#listingtableheader"+scrollid).offset().top},'slow');
		return false;
	});

	$("#edit_com_submit").live('click', function(){
			var com_edit_text = encodeURIComponent($("#com_edit_text").val());
			var com_edit_id = $("#com_edit_id").val();
			var dataString = 'commentfunc=funcedit' + '&com_edit_id=' + com_edit_id + '&com_edit_text=' + com_edit_text;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function() {
							$('#editbox').fadeOut('slow');
							$("#overlay").remove();
							 location.reload();
							$('html,body').animate({scrollTop: $("#listingtableheader"+com_edit_id).offset().top},'slow');
						}
				});
		return false;
	});

//flagged ajax load before the rest
	$("input[id^=flag_unflag]").click(function() {
		Display_Load();
			if (this.id.match(/^flag_unflag(\d+)$/)) {
				var unflagflagid = RegExp.$1;
			}
			var dataString = "flagfunc=funcunflag" + "&flagid=" + unflagflagid;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function() {
							$('#listingtableheader' + unflagflagid).fadeOut('slow');
							Hide_Load();
						}
				});
			return false;
	});
	$("input[id^=flag_preview]").click(function() {
			if (this.id.match(/^flag_preview(\d+)$/)) {
				var preflagid = RegExp.$1;
			}
		$("html").scrollTop(20);
		$("body").append("<div id='overlay'></div>");
		$("#editbox").css({'visibility' : 'visible'});
		$("#editbox").fadeOut('slow', function(){
			$(this).load('modules/ajaxfunc.php?previewflag=' + preflagid, function(){
				$(this).fadeIn('slow', function(){
				});
			});
		});
		return false;
	});


//Default Starting Page Results
	if (typeof PageName != 'undefined') {
		Display_Load();
		$("#pagination li:first").css({'color' : '#FF0084'}).css({'border' : 'none'});
		var Pnum = $("#numpages option:selected").val();
		$("#allvideocontent").load("modules/ajaxfunc.php?page=1&PageName=" + PageName + "&Pnum=" + Pnum, Hide_Load());		
	}


	//Pagination Click
	$("#pagination li").live('click', function(){
			Display_Load();

			//CSS Styles
			$("#pagination li").css({'border' : 'solid #dddddd 1px'}).css({'color' : '#0063DC'});

			$(this).css({'color' : '#FF0084'}).css({'border' : 'none'});

			
			//Loading Data
			var pageNum = this.id;
			var Pnum = $("#numpages option:selected").val();
			
			
			if ((PageName == 'allvideos') || (PageName == 'newuploads') || (PageName == 'dbclean')) {
				var stitle = $("#title").val();
				var sdesc = $("#description").val();
				var spos = $("#poster").val();
				var scat = $("#category").val();
				var soby = $("#orderby").val();
				var order = $("#order").val();
				var hdmo = $("#hdmobile").val();
				var viem = $("#videoembed").val();
				$("#allvideocontent").load("modules/ajaxfunc.php?page=" + pageNum + "&PageName=" + PageName + "&Pnum=" + Pnum + "&stitle=" + stitle + "&sdesc=" + sdesc + "&spos=" + spos + "&scat=" + scat + "&soby=" + soby + "&order=" + order + "&hdmo=" + hdmo + "&viem=" + viem, Hide_Load());
			
			}
			if (PageName == 'userlist') {
				var username = $("#username").val();
				var email = $("#email").val();
				var country = $("#country").val();
				var usergender = $("#usergender").val();
				var userorderby = $("#userorderby").val();
				var userorder = $("#userorder").val();
				$("#allvideocontent").load("modules/ajaxfunc.php?page=" + pageNum + "&PageName=" + PageName + "&Pnum=" + Pnum + "&username=" + username + "&email=" + email + "&country=" + country + "&usergender=" + usergender + "&userorderby=" + userorderby + "&userorder=" + userorder, Hide_Load());
			}
	});

	$("#allvideosearch").change(function(){
			Display_Load();
			//css reset
			$("#pagination li").css({'border' : 'solid #dddddd 1px'}).css({'color' : '#0063DC'});

			var Pnum = $("#numpages option:selected").val();
			
			if ((PageName == 'allvideos') || (PageName == 'newuploads') || (PageName == 'dbclean')) {
				var stitle = $("#title").val();
				var sdesc = $("#description").val();
				var spos = $("#poster").val();
				var scat = $("#category").val();
				var soby = $("#orderby").val();
				var order = $("#order").val();
				var hdmo = $("#hdmobile").val();
				var viem = $("#videoembed").val();
				$("#allvideocontent").load("modules/ajaxfunc.php?page=1" + "&PageName=" + PageName + "&Pnum=" + Pnum + "&stitle=" + stitle + "&sdesc=" + sdesc + "&spos=" + spos + "&scat=" + scat + "&soby=" + soby + "&order=" + order + "&hdmo=" + hdmo + "&viem=" + viem, Hide_Load());
			}
			if (PageName == 'userlist') {
				var username = $("#username").val();
				var email = $("#email").val();
				var country = $("#country").val();
				var usergender = $("#usergender").val();
				var userorderby = $("#userorderby").val();
				var userorder = $("#userorder").val();
				$("#allvideocontent").load("modules/ajaxfunc.php?page=1" + "&PageName=" + PageName + "&Pnum=" + Pnum + "&username=" + username + "&email=" + email + "&country=" + country + "&usergender=" + usergender + "&userorderby=" + userorderby + "&userorder=" + userorder, Hide_Load());
			}


	});
	$("#paradigm_all").live('click', function(){
		var checked_status = this.checked;
			$("input[id^=paradigm]").each(function() {
				this.checked = checked_status;
			});
	});
	
//userlist functions
	$("input[id^=banuser]").live('click', function(){
			if (this.id.match(/^banuser(\d+)$/)) {
				var banuserid = RegExp.$1;
			}
			var dataString = "userfunc=banuser" + "&userid=" + banuserid;
			$.ajax({
				type: "GET",
				url: "modules/ajaxfunc.php",
				cache: "false",
				data: dataString,
					success: function() {
						$('#banned' + banuserid).fadeOut('fast');
						$('#banned' + banuserid).fadeIn(900,0);
						$('#banned' + banuserid).html("Banned: Yes");
					}
			});
		return false;
	});
	$("input[id^=unbanuser]").live('click', function(){
			if (this.id.match(/^unbanuser(\d+)$/)) {
				var unbanuserid = RegExp.$1;
			}
			var dataString = "userfunc=unbanuser" + "&userid=" + unbanuserid;
			$.ajax({
				type: "GET",
				url: "modules/ajaxfunc.php",
				cache: "false",
				data: dataString,
					success: function() {
						$('#banned' + unbanuserid).fadeOut('fast');
						$('#banned' + unbanuserid).fadeIn(900,0);
						$('#banned' + unbanuserid).html("Banned: No");
					}
			});
		return false;
	});
	$("input[id^=approveuser]").live('click', function(){
			if (this.id.match(/^approveuser(\d+)$/)) {
				var approveuserid = RegExp.$1;
			}
			var dataString = "userfunc=approveuser" + "&userid=" + approveuserid;
			$.ajax({
				type: "GET",
				url: "modules/ajaxfunc.php",
				cache: "false",
				data: dataString,
					success: function() {
						$('#activated' + approveuserid).fadeOut('fast');
						$('#activated' + approveuserid).fadeIn(900,0);
						$('#activated' + approveuserid).html("Activated: Yes");
					}
			});
		return false;
	});
	$("input[id^=deleteuser]").live('click', function(){
			if (this.id.match(/^deleteuser(\d+)$/)) {
				var deleteuserid = RegExp.$1;
			}
			var dataString = "userfunc=deleteuser" + "&userid=" + deleteuserid;
			$.ajax({
				type: "GET",
				url: "modules/ajaxfunc.php",
				cache: "false",
				data: dataString,
					success: function() {
						$('#listingtableheader' + deleteuserid).fadeOut('slow');
						$('#listingtabletext' + deleteuserid).fadeOut('slow');
					}
			});
		return false;
	});


	$("#submitmassuserfunc").live('click', function(){
		Display_Load();
		var mass = $("#massuserfunc").val();
		var arrayids=new Array();
			$("input[id^=paradigm]").each(function() {
					if (jQuery(this).is(':checked')) {
						if (this.id.match(/^paradigm(\d+)$/)) {
							var userid = RegExp.$1;
						}
						arrayids.push(userid);
					}
			});
			var dataString = 'usermassfunc='+ mass + '&array=' + arrayids;
				$.ajax({
					type: "GET",
					url: "modules/ajaxfunc.php",
					cache: "false",
					data: dataString,
					success: function() {
						if (mass == 'approveall') {
							$("input[id^=paradigm]").attr('checked', false);
							for(var r in arrayids) {
								var value = arrayids[r]
								$('#activated' + value).fadeOut('fast');
								$('#activated' + value).fadeIn(900,0);
								$('#activated' + value).html("Activated: Yes");
							}
						}
						if (mass == 'deleteall') {
							$("input[id^=paradigm]").attr('checked', false);
							for(var r in arrayids) {
								var value = arrayids[r]
								$('#listingtableheader' + value).fadeOut('slow');
								$('#listingtabletext' + value).fadeOut('slow');
							}
						}
						if (mass == 'banall') {
							$("input[id^=paradigm]").attr('checked', false);
							for(var r in arrayids) {
								var value = arrayids[r]
								$('#banned' + value).fadeOut('fast');
								$('#banned' + value).fadeIn(900,0);
								$('#banned' + value).html("Banned: Yes");
							}
						}
						if (mass == 'unbanall') {
							$("input[id^=paradigm]").attr('checked', false);
							for(var r in arrayids) {
								var value = arrayids[r]
								$('#banned' + value).fadeOut('fast');
								$('#banned' + value).fadeIn(900,0);
								$('#banned' + value).html("Banned: No");
							}
						}
						Hide_Load();
					}
				});				
		return false;
	});








//video functions
	
	$("#submitmassvideofunc").live('click', function(){
		Display_Load();
		var mass = $("#massvideofunc").val();
		var arrayids=new Array();

			$("input[id^=paradigm]").each(function() {
					if (jQuery(this).is(':checked')) {
						if (this.id.match(/^paradigm(\d+)$/)) {
							var videoid = RegExp.$1;
						}
						arrayids.push(videoid);
					}
			});
			var dataString = 'videomassfunc='+ mass + '&array=' + arrayids;
					$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function(result) {
							if (mass == 'deleteall') {
								for(var i in arrayids) {
									var value = arrayids[i];
									$('#listingtableheader' + value).fadeOut('slow');
									$('#listingtabletext' + value).fadeOut('slow');
								}
							}
							if (mass == 'approveall') {
								for(var i in arrayids) {
									var value = arrayids[i];
									$('#listingtableheader' + value).fadeOut('slow');
									$('#listingtabletext' + value).fadeOut('slow');
								}
							}
							if (mass == 'genthumb') {
								$("input[id^=paradigm]").attr('checked', false);
								arr_result = result.split(",");

								for(var r in arr_result) {
									arr_dresult = arr_result[r].split("^");
									$('#thumbholder' + arr_dresult[0]).fadeOut('fast');
									$('#thumbholder' + arr_dresult[0]).fadeIn(900,0);
									$('#thumbholder' + arr_dresult[0]).html('<img src="' + arr_dresult[1] + '" width="103" height="80">');
								}
							}
							if (mass == 'gendur') {
								$("input[id^=paradigm]").attr('checked', false);
								arr_result = result.split(",");

								for(var r in arr_result) {
									arr_dresult = arr_result[r].split("^");
									$('#duration' + arr_dresult[0]).fadeOut('fast');
									$('#duration' + arr_dresult[0]).fadeIn(900,0);
									$('#duration' + arr_dresult[0]).html("Duration: " + arr_dresult[1]);
								}
							}
							Hide_Load();
						}
					});



		return false;
	});

	$("input[id^=editvideo]").live('click', function(){
			if (this.id.match(/^editvideo(\d+)$/)) {
				var editid = RegExp.$1;
			}
		$("html").scrollTop(0);
		$("body").append("<div id='overlay'></div>");
		$("#editbox").css({'visibility' : 'visible'});
		$("#editbox").fadeOut('slow', function(){
			$(this).load('modules/ajaxfunc.php?editid=' + editid, function(){
				$(this).fadeIn('slow', function(){
				});
			});
		});
		return false;
	});

	$("#edit_submit").live('click', function(){
			var edit_ti = encodeURIComponent($("#edit_title").val());
			var edit_de = encodeURIComponent($("#edit_description").val());
			var edit_ta = encodeURIComponent($("#edit_tags").val());
			var edit_ca = $("#edit_category").val();
			var edit_id = $("#edit_id").val();
			var edit_ad = encodeURIComponent($("#edit_vidad").val());
			var edit_em = encodeURIComponent($("#edit_embed").val());
			var edit_th = $("#edit_thumbnail").val();

			var dataString = 'edit_id='+ edit_id + '&edit_ti=' + edit_ti + '&edit_de=' + edit_de + '&edit_ta=' + edit_ta + '&edit_ca=' + edit_ca + '&edit_ad=' + edit_ad + '&edit_em=' + edit_em + '&edit_th=' + edit_th;
			$.ajax({
				type: "GET",
				url: "modules/ajaxfunc.php",
				cache: "false",
				data: dataString,
				success: function() {
					Display_Load();
					$('#editbox').fadeOut('slow');
					//update page
			//CSS Styles
			$("#pagination li").css({'border' : 'solid #dddddd 1px'}).css({'color' : '#0063DC'});

			$(this).css({'color' : '#FF0084'}).css({'border' : 'none'});

			//Loading Data

			var pageNum = $("#pagination li em").attr('id') ;
			var Pnum = $("#numpages option:selected").val();
			var stitle = $("#title").val();
			var sdesc = $("#description").val();
			var spos = $("#poster").val();
			var scat = $("#category").val();
			var soby = $("#orderby").val();
			var order = $("#order").val();
			var hdmo = $("#hdmobile").val();
			var viem = $("#videoembed").val();

			$("#allvideocontent").load("modules/ajaxfunc.php?page=" + pageNum + "&PageName=" + PageName + "&Pnum=" + Pnum + "&stitle=" + stitle + "&sdesc=" + sdesc + "&spos=" + spos + "&scat=" + scat + "&soby=" + soby + "&order=" + order + "&hdmo=" + hdmo + "&viem=" + viem, Hide_Load());
			$("#overlay").remove();
			$('html,body').animate({scrollTop: $("#listingtableheader"+edit_id).offset().top},'slow');

				}
			});

		return false;
	});


	$("input[id^=preview]").live('click', function(){
			if (this.id.match(/^preview(\d+)$/)) {
				var previewid = RegExp.$1;
			}
		$("html").scrollTop(20);
		$("body").append("<div id='overlay'></div>");
		$("#editbox").css({'visibility' : 'visible'});
		$("#editbox").fadeOut('slow', function(){
			$(this).load('modules/ajaxfunc.php?previewid=' + previewid, function(){
				$(this).fadeIn('slow', function(){
				});
			});
		});
		return false;
	});



	$("input[id^=edit_close]").live('click', function(){
			if (this.id.match(/^edit_close(\d+)$/)) {
				var scrollid = RegExp.$1;
			}
		$('#editbox').fadeOut('slow');
		$("#overlay").remove();
 		$('html,body').animate({scrollTop: $("#listingtableheader"+scrollid).offset().top},'slow');
		return false;
	});


	$("input[id^=approvevideo]").live('click', function(){
		Display_Load();
			if (this.id.match(/^approvevideo(\d+)$/)) {
				var approveid = RegExp.$1;
			}
			var dataString = "videofunc=funcapp" + "&appid=" + approveid;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function() {
							$('#listingtableheader' + approveid).fadeOut('slow');
							$('#listingtabletext' + approveid).fadeOut('slow');
							Hide_Load();
						}
				});
		return false;
	});




	$("input[id^=deletevideo]").live('click', function(){
		Display_Load();
			if (this.id.match(/^deletevideo(\d+)$/)) {
				var deleteid = RegExp.$1;
			}
			var dataString = "videofunc=funcdel" + "&delid=" + deleteid;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function() {
							$('#listingtableheader' + deleteid).fadeOut('slow');
							$('#listingtabletext' + deleteid).fadeOut('slow');
							Hide_Load();
						}
				});
		return false;
	});
	$("input[id^=reGenthumb]").live('click', function(){
			Display_Load();
			if (this.id.match(/^reGenthumb(\d+)$/)) {
				var reGenthumbid = RegExp.$1;
			}

			var dataString = "videofunc=functhumb" + "&genid=" + reGenthumbid;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function(thumb) {
							$('#thumbholder' + reGenthumbid).fadeOut('fast');
							$('#thumbholder' + reGenthumbid).fadeIn(900,0);
							$('#thumbholder' + reGenthumbid).html('<img src="' + thumb + '" width="103" height="80">');
							Hide_Load();
						}
				});
		return false;
	});
	$("input[id^=reGenDur]").live('click', function(){
			Display_Load();
			if (this.id.match(/^reGenDur(\d+)$/)) {
				var reGenDurid = RegExp.$1;
			}
			var dataString = "videofunc=funcdur" + "&durid=" + reGenDurid;
				$.ajax({
						type: "GET",
						url: "modules/ajaxfunc.php",
						cache: "false",
						data: dataString,
						success: function(duration) {
							$('#duration' + reGenDurid).fadeOut('fast');
							$('#duration' + reGenDurid).fadeIn(900,0);
							$('#duration' + reGenDurid).html("Duration: " + duration);
							Hide_Load();
						}
				});
		return false;
	});


});
