var videoLib = {
	passDelInit: function() {
		$(".delete").click(function() {
			var did = $(this).attr("did");
			$.dialog({
				id: 'delDance',
				title: false,
				border: false,
				follow: $(this)[0],
				content: '确认要删除这个视频么？',
				okValue: '确认',
				ok: function() {
					$.getJSON(zone_domain + "do.php?p=video&a=doShareDel&callback=?", "did=" + did,
					function(data) {
						if (data['error'] == 001) {
						$.tipMessage("您需要先登录才能进行此操作!", 1, 3000, 0, function(){location.href = "login.php"});
					} else	if (data['error'] == 002) {
						$.tipMessage("您的帐号金币不足，不能进行此操作", 1, 2000);return false;
					} else	if (data['error'] == 003) {
						$.tipMessage("抱歉，请不要试图删除别人的数据！", 1, 2000);return false;
					} else	if (data['error'] == 004) {
						$.tipMessage("操作执行成功！", 0, 1500, 0,function() {location.href = location.href;});
						} else {
							$.tipMessage("未知结果，请与管理员联系！", 0, 1500, 0,
							function() {
								location.href = location.href;
							});
						}
					});
				},
				cancelValue: '取消',
				cancel: function() {}
			});
		});
	},
	shareAddInit: function() {
		var $videoAddMain = $('#videoAddMain');
		var $rvideoName = $('#rvideoName');
		var $mvideoName = $('#mvideoName');
		var $rSingerID = $('#rSingerID');
		var $mSingerID = $('#mSingerID');
		var $rclassId = $('#rclassId');
		var $mclassId = $('#mclassId');
		var $rSpecialID = $('#rSpecialID');
		var $mSpecialID = $('#mSpecialID');
		var $rPlay = $('#rUrl');
		var $mPlay = $('#mUrl');
		var $rPic = $('#rPic');
		var $mPic = $('#mPic');
		var $rLrc = $('#rLrc');
		var $rnote = $('#rnote');
		var $rtag = $('#rtag');
		var $price = $('#price');
		var $grade = $('#grade');
		var $seccode = $('#seccode');
		var $rfrom = $('#rfrom');
		var $rsiz = $('#rsiz');
		var $rmd5 = $('#rmd5');
		var $ruid = $('#ruid');
		var $rServer = $('#rServer');
		var $Playtime = $('#Playtime');
		var $Bitkbps = $('#Bitkbps');
		var $yijianvideo = $('#yijianvideo');
		var $videoNewAdd = $('#videoNewAdd');
		$rvideoName.focus(function() {
			$(this).addClass('input_focus');
			$mvideoName.removeClass('input_tag2');
			$mvideoName.addClass('input_tag1');
			$mvideoName.html('作为视频名称请您认真填写，合理的名称审核才会通过。');
		}).blur(function() {
			$(this).removeClass('input_focus');
			$(this).triggerHandler('keyup');
		}).keyup(function() {
			if ($(this).val() == '') {
				$mvideoName.removeClass('input_tag1');
				$mvideoName.addClass('input_tag2');
				$mvideoName.html('<span class="errIcon"></span>视频名称不能为空！');
				return false;
			} else {
				$mvideoName.removeClass('input_tag1');
				$mvideoName.removeClass('input_tag2');
				$mvideoName.html('<span class="rightIcon"></span>');
			}
		});
		$rSingerID.focus(function() {
			$(this).addClass('select_focus');
			$mSingerID.removeClass('input_tag2');
			$mSingerID.addClass('input_tag1');
			$mSingerID.html('请输入视频的所属歌手。');
		}).blur(function() {
			$(this).removeClass('select_focus');
			$(this).triggerHandler('change');
		}).change(function(event) {
			if ($(this).val() == '') {
				$mSingerID.removeClass('input_tag1');
				$mSingerID.addClass('input_tag2');
				$mSingerID.html('<span class="errIcon"></span>请输入视频的所属歌手！');
				return false;
			} else {
				$mSingerID.removeClass('input_tag1');
				$mSingerID.removeClass('input_tag2');
				$mSingerID.html('<span class="rightIcon"></span>');
			}
		});
		$rclassId.focus(function() {
			$(this).addClass('select_focus');
			$mclassId.removeClass('input_tag2');
			$mclassId.addClass('input_tag1');
			$mclassId.html('视频的所属分类，请正确选择。');
		}).blur(function() {
			$(this).removeClass('select_focus');
			$(this).triggerHandler('change');
		}).change(function(event) {
			if ($(this).val() == '0') {
				$mclassId.removeClass('input_tag1');
				$mclassId.addClass('input_tag2');
				$mclassId.html('<span class="errIcon"></span>请选择视频的所属分类！');
				return false;
			} else {
				$mclassId.removeClass('input_tag1');
				$mclassId.removeClass('input_tag2');
				$mclassId.html('<span class="rightIcon"></span>');
			}
		});
		$rSpecialID.focus(function() {
			$(this).addClass('select_focus');
			$mSpecialID.removeClass('input_tag2');
			$mSpecialID.addClass('input_tag1');
			$mSpecialID.html('只显示您创建的专辑，请选择加入一个。');
		}).blur(function() {
			$(this).removeClass('select_focus');
			$(this).triggerHandler('change');
		}).change(function(event) {
			if ($(this).val() == '') {
				$mSpecialID.removeClass('input_tag1');
				$mSpecialID.addClass('input_tag2');
				$mSpecialID.html('<span class="errIcon"></span>请选择视频的所属专辑！');
				return false;
			} else {
				$mSpecialID.removeClass('input_tag1');
				$mSpecialID.removeClass('input_tag2');
				$mSpecialID.html('<span class="rightIcon"></span>');
			}
		});
		$rPlay.focus(function() {
			$(this).addClass('input_focus');
			$mPlay.removeClass('input_tag2');
			$mPlay.addClass('input_tag1');
			$mPlay.html('<span class="errIcon"></span>');
		}).blur(function() {
			$(this).removeClass('input_focus');
			$(this).triggerHandler('keyup');
		}).keyup(function() {
			if ($(this).val() == '') {
				$mPlay.removeClass('input_tag1');
				$mPlay.addClass('input_tag2');
				$mPlay.html('<span class="errIcon"></span>');
				return false;
			} else {
				$mPlay.removeClass('input_tag1');
				$mPlay.removeClass('input_tag2');
				$mPlay.html('<span class="rightIcon"></span>');
			}
		});
		$rPic.focus(function() {
			$(this).addClass('input_focus');
			$mPic.removeClass('input_tag2');
			$mPic.addClass('input_tag1');
			$mPic.html('<span class="errIcon"></span>');
		}).blur(function() {
			$(this).removeClass('input_focus');
			$(this).triggerHandler('keyup');
		}).keyup(function() {
			if ($(this).val() == '') {
				$mPic.removeClass('input_tag1');
				$mPic.addClass('input_tag2');
				$mPic.html('<span class="errIcon"></span>');
				return false;
			} else {
				$mPic.removeClass('input_tag1');
				$mPic.removeClass('input_tag2');
				$mPic.html('<span class="rightIcon"></span>');
			}
		});
		$videoNewAdd.click(function() {
			$("#videoAddMain :input").trigger('keyup');
			$rSingerID.triggerHandler('change');
			$rclassId.triggerHandler('change');
			$rSpecialID.triggerHandler('change');
			var numError = $('#videoAddMain .errIcon').length;
			if (!numError) {
				$.ajax({
					type: "POST",
					global: false,
					url: zone_domain + "do.php?p=video&a=doShare",
					data: {
						videoName: escape($rvideoName.val()),
						SingerID: escape($rSingerID.val()),
						classId: $rclassId.val(),
						CD_SpecialID: $rSpecialID.val(),
						CD_Url: escape($rPlay.val()),
						Pic: escape($rPic.val()),
						CD_Server: $rServer.val(),
						CD_Lrc: escape($rLrc.val().replace(/[\r\n]/g, "<br>")),
						CD_Word: escape($rnote.val().replace(/[\r\n]/g, "<br>")),
						CD_from: escape($rfrom.val()),
						CD_Points: $price.val(),
						CD_Grade: $grade.val(),
						seccode: escape($seccode.val()),
						CD_Tag: escape($rtag.val()),
						CD_siz: escape($rsiz.val()),
						CD_md5: escape($rmd5.val()),
						CD_uid: escape($ruid.val()),
						CD_Playtime: escape($Playtime.val()),
						CD_Bitkbps: escape($Bitkbps.val()),
						CD_yijianvideo: escape($yijianvideo.val())
						
					},
					dataType: "text",
					success: function(data) {
						if (data == 1001) {
						$.tipMessage('验证码不正确！', 1, 2000);changeimg();return false;
						} else if(/[\u4E00-\u9FA5]/g.test(data)){
							$mvideoName.removeClass('input_tag1');
							$mvideoName.addClass('input_tag2');
							$mvideoName.html(data);
						}else if(data==1002){
						$.tipMessage("金币售价超过限制，请修改！", 1, 2000);return false;
						}else if(data==1003){
						$.tipMessage("您还有部分栏目没有填写！", 1, 2000);return false;
						}else if(data==1004){
						$.tipMessage("您需要登录后，才能进行此操作！", 1, 3000, 0, function(){location.href = "space.php?do=login"});
						}else if(data==1005){
							$.tipMessage('视频发布成功，请等待审核！', 0, 3000, 0,
							function() {
							        location.href = zone_domain + "space.php?do=upvideo&view=passed&day=" + $rclassId.val()
							});
						}else if(data==1006){
							$.tipMessage('视频发布成功！', 0, 3000, 0,
							function() {
							        location.href = zone_domain + "space.php?do=upvideo&view=list&day=" + $rclassId.val()
							});
						}else if(data==1007){
						$.tipMessage("视频地址错误！", 1, 2000);return false;
						}else if(data==1008){
						$.tipMessage("视频封面地址错误！", 1, 2000);return false;
						}
						else {
						$.tipMessage("发生未知错误，请与管理员联系！", 1, 2000);return false;
						}
					}
				});
			}
		});
	}
}