var danceLib = {
	favoritesDelInit: function() {
		$(".del").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=dance&a=doFavoritesDel&callback=?", "did=" + escape(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() {}
			});
		});
	},
	vfavoritesDelInit: function() {
		$(".del").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=doFavoritesDel&callback=?", "did=" + escape(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() {}
			});
		});
	},
	vdownDelInit: function() {
		$(".del").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=doDownDel&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() {}
			});
		});
	},
	listenDelInit: function() {
		$(".del").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=dance&a=doListenDel&callback=?", "did=" + escape(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() {}
			});
		});
	},
	downDelInit: function() {
		$(".del").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=dance&a=doDownDel&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() {}
			});
		});
	},
	passDelInit: function() {
		$(".del").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=dance&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 $danceAddMain = $('#danceAddMain');
		var $rdanceName = $('#rdanceName');
		var $mdanceName = $('#mdanceName');
		var $rSingerID = $('#rSingerID');
		var $mSingerID = $('#mSingerID');
		var $rclassId = $('#rclassId');
		var $mclassId = $('#mclassId');
		var $rSpecialID = $('#rSpecialID');
		var $mSpecialID = $('#mSpecialID');
		var $rUrl = $('#rUrl');
		var $mUrl = $('#mUrl');
		var $rServer = $('#rServer');
		var $rPic = $('#rPic');
		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 $Playtime = $('#Playtime');
		var $Bitkbps = $('#Bitkbps');
		var $danceNewAdd = $('#danceNewAdd');
		$rdanceName.focus(function() {
			$(this).addClass('input_focus');
			$mdanceName.removeClass('input_tag2');
			$mdanceName.addClass('input_tag1');
			$mdanceName.html('作为音乐名称请您认真填写，合理的名称审核才会通过。');
		}).blur(function(){
			if($(this).val() == ''){
				$mdanceName.removeClass('input_tag1');
				$mdanceName.addClass('input_tag2');
				$mdanceName.html('<span class="errIcon"></span>歌曲名字不能为空！');
				return false;
			}else if($(this).val().length<3){
				$mdanceName.removeClass('input_tag1');
				$mdanceName.addClass('input_tag2');
				$mdanceName.html('<span class="errIcon"></span>歌曲名字最少要三个字以上！');
				return false;
			}else if($(this).val().length>50){
				$mdanceName.removeClass('input_tag1');
				$mdanceName.addClass('input_tag2');
				$mdanceName.html('<span class="errIcon"></span>歌曲名字必须少于要少于五十个字！');
				return false;
			}else{
				$mdanceName.removeClass('input_tag1');
				$mdanceName.removeClass('input_tag2');
				$mdanceName.html('<span class="rightIcon"></span>');
			}
		}).keyup(function(){
		   $(this).triggerHandler("blur");
		});
		$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>');
			}
		});
		$rUrl.focus(function() {
			$(this).addClass('input_focus');
			$mUrl.removeClass('input_tag2');
			$mUrl.addClass('input_tag1');
			$mUrl.html('<span class="errIcon"></span>');
		}).blur(function() {
			$(this).removeClass('input_focus');
			$(this).triggerHandler('keyup');
		}).keyup(function() {
			if ($(this).val() == '') {
				$mUrl.removeClass('input_tag1');
				$mUrl.addClass('input_tag2');
				$mUrl.html('<span class="errIcon"></span>');
				return false;
			} else {
				$mUrl.removeClass('input_tag1');
				$mUrl.removeClass('input_tag2');
				$mUrl.html('<span class="rightIcon"></span>');
			}
		});
		$danceNewAdd.click(function() {
			$("#danceAddMain :input").trigger('keyup');
			$rSingerID.triggerHandler('change');
			$rclassId.triggerHandler('change');
			$rSpecialID.triggerHandler('change');
			var numError = $('#danceAddMain .errIcon').length;
			if (!numError) {
				if (this.ajaxRequest_ != undefined && this.ajaxRequest_.readyState < 4) {
                   $.tipMessage('请耐心等待,切勿重复提交!！', 2, 3000,0);
                    return false;
                }
				this.ajaxRequest_ =$.ajax({
					type: "POST",
					global: false,
					url: zone_domain + "do.php?p=dance&a=doShare",
					data: {
						CD_Name: escape($rdanceName.val()),
						CD_Singer: escape($rSingerID.val()),
						CD_ClassID: $rclassId.val(),
						CD_SpecialID: $rSpecialID.val(),
						CD_Url: escape($rUrl.val()),
						CD_Server: $rServer.val(),
						CD_Pic: escape($rPic.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())
					},
					dataType: "text",
					success: function(data) {
						if (data == 1001) {
						$.tipMessage('验证码不正确！', 1, 2000);changeimg();return false;
						} else if(/[\u4E00-\u9FA5]/g.test(data)){
							$mdanceName.removeClass('input_tag1');
							$mdanceName.addClass('input_tag2');
							$mdanceName.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 = "login.php"});
						}else if(data==1005){
							$.tipMessage('音乐分享成功，请等待审核！', 0, 3000, 0,
							function() {
							        location.href = zone_domain + "space.php?do=upmusic&view=passed&day=" + $rclassId.val()
							});
						}else if(data==1006){
							$.tipMessage('音乐分享成功！', 0, 3000, 0,
							function() {
							        location.href = zone_domain + "space.php?do=upmusic&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;
						}
					}
				});
			}
		});
	}
}