
//刷新我的收藏
function refreshmycollection(){
    var url = "../memberShare!flexmusic.action";
	$.post(encodeURI(url),function(data){
		if(data=='1'){
		    return "1";
		}else{
		  frame_show(0);
		}
	});	
}

//收藏
function favorites(obj){
var url = "../memberShare!flexmusic.action";
	$.post(encodeURI(url),function(data){
	    //判断是否登陆
		if(data=='1'){
		      var url='../collectionShare!checkfavoritesMusic.action?musicId='+obj;
			  //判断是否已经加入收藏列表
			  $.post(url,function(data){
					if(data==1){
						  var url='../collectionShare!favoritesMusic.action?musicId='+obj;
						 //加入收藏
						  $.post(url,function(data){
							if(data==0){
							   alert('加入到收藏成功!');
						    }
						  });
				    }else{
				         alert('该歌曲已经存在收藏列表中,请不要重复加入!');
				         return;
				    }
			  });
		}else{
		  frame_show(0);
		}
	});	
}

//顶一下
function recommendmusic(obj){
   // var url = "../memberShare!flexmusic.action";
//	$.post(encodeURI(url),function(data){
	//	if(data=='1'){
		     var url1 = "../music!topclickcount.action?musicid="+obj;
		      $.post(encodeURI(url1),function(data){
		         if(data==0){
		            alert('顶一下成功');
		         }else if(data==1){
		           alert('你已经顶过一次了');
		         }else{
		             alert('顶一下失败');
		         }
		     });
			     
	//	}else{
	//	  frame_show(0);
	//	}
	//});	
}

function sharemusic(musicid,musicname){
   frame_show3(1,musicid,'shareMusicinfo',musicname,'../music!musicinfo.action?musicid='+musicid);
}

//音乐分享
function shareMusicinfo(obj){
	var sharecontent=$("#sharecontent").val();
	var addcomment=$("#addcomment").attr("checked")==true?"1":"0";
	if(sharecontent==""){
	   alert("请输入分享的内容");
	}else{
	   //音乐的分享
		var url='../topicsShare!shareMusic.action?sharecontent='+sharecontent+'&musicId='+obj+'&isadd='+addcomment;;
		$.post(encodeURI(url),function(data){
			if(data==0){
				alert('音乐分享成功!'); 
				var loginObj = $('.common-frame');
				if(loginObj.length>0){
				  loginObj.remove();
			       mask_hide();
				}
			}else{
				alert('音乐分享失败!'); 
			}
			
		});
	}
}



function closediv(obj){
 document.getElementById("musicplay"+obj).style.display="block";
 swfobject.removeSWF("swfid"+obj);
 var divobj=document.getElementById("bigdivswf"+obj);
 divobj.style.display="none";
}



function closediv1(obj){
 document.getElementById("musicplay"+obj).style.display="block";
 swfobject.removeSWF("swfid"+obj);
 var divobj=document.getElementById("outdivswf"+obj);
 divobj.style.display="none";
}

function alertstr(str){
   alert(str);
}


$(function(){
	$('.item li').each(function(){
	    if((!$(this).hasClass('operation'))&&(!$(this).hasClass('info'))){
	      $(this).listEmotion();
	    }
	});
	$('.share-detail .detail .frame').listEmotion();	
	//$('.item li:first').listEmotion();		   
});


function callas(obj1,obj2,obj3,obj4,obj5){
if(obj2.indexOf('.mp3')==-1){
    window.open(obj2);
    return;
}

var remoteaddr='../musicallaction!getremoteaddr.action';
				$.post(remoteaddr,function(data){
						if(obj2.indexOf('218.204.174.25:9900')!=-1){
			    		obj2=obj2+data;
						}
					   var bool=false;
					   if(obj5==1){
					       commendmethod(obj1,obj2,obj3,obj4,obj5);
					   }else{
					   		var url='../music!listenmusic.action?musicid='+obj5;
							$.post(url,function(data){
							//音乐试听
								if(data==0){
								    commendmethod(obj1,obj2,obj3,obj4,obj5);
								}
							});
					   }
			        	document.getElementById("musicplay"+obj4).style.display="none";	
						
						});
	}

function commendmethod(obj1,obj2,obj3,obj4,obj5){
//下面为弹出播放器部分
			 var divobj=document.getElementById("bigdivswf"+obj4);
			 divobj.style.display="block";
			var swf = swfobject.getObjectById("swfid"+obj4);
			if(swf==null){
            //document.getElementById("divswf"+obj4).style.display="";
		     var flashvars = {  
			  param1: obj1,
			  param2: obj2,
			  param3:obj3,
		      param4:obj5
		     };  
			  var params = {wmode:"transparent"};  
			  var attributes = {};
			  attributes.id = "swfid"+obj4;
			  var smalldiv=document.getElementById("divswf"+obj4);
			  if(smalldiv==null){
			  //创建一个div用来放swf文件
			     var div1=document.createElement("div");
			     div1.setAttribute("id","divswf"+obj4);
			     //得到swf外层的div
			      var divobj=document.getElementById("outdivswf"+obj4);
			      //把swf文件加入到此div中去
			      divobj.appendChild(div1);
			  }
			  swfobject.embedSWF("../js/frontsmallmusic.swf", "divswf"+obj4, "270", "48", "9.0.0", 
			                     "../js/expressInstall.swf",flashvars,params,attributes);
			} 
}

function callas1(obj1,obj2,obj3,obj4,obj5){
	if(obj2.indexOf('.mp3')==-1){
	    window.open(obj2);
	    return;
	}
	var remoteaddr='../musicallaction!getremoteaddr.action';
				$.post(remoteaddr,function(data){
				       if(obj2.indexOf('218.204.174.25:9900')!=-1){
				    obj2=obj2+data;
				}
				var url='../music!listenmusic.action?musicid='+obj5;
				$.post(url,function(data){
				//音乐试听
					if(data==0){
						//下面为弹出播放器部分
						 var divobj=document.getElementById("outdivswf"+obj4);
			 divobj.style.display="block";
			var swf = swfobject.getObjectById("swfid"+obj4);
			if(swf==null){
			         //document.getElementById("divswf"+obj4).style.display="";
				     var flashvars = {  
					  param1: obj1,
					  param2: obj2,
					  param3:obj3,
				      param4:obj5
				     };  
			
			  var params = {wmode:"transparent"};  
			  var attributes = {};
			  attributes.id = "swfid"+obj4;
			  var smalldiv=document.getElementById("divswf"+obj4);
			  if(smalldiv==null){
			  //创建一个div用来放swf文件
			     var div1=document.createElement("div");
			     div1.setAttribute("id","divswf"+obj4);
			     //得到swf外层的div
			      var divobj=document.getElementById("outdivswf"+obj4);
			      //把swf文件加入到此div中去
			      divobj.appendChild(div1);
			  }
			  swfobject.embedSWF("../js/frontsmallmusic.swf", "divswf"+obj4, "270", "48", "9.0.0", 
			                     "../js/expressInstall.swf",flashvars,params,attributes);
			        
			} 
					}
				});
					document.getElementById("musicplay"+obj4).style.display="none";
				       
	});
			
}
