/**
 * JS This is a public document
 *	Mr.Fang QQ:184377367	www.ebycms.com
 *	id Global.js
 */


	//Access to a framework object
	$F = function(oFw){ return document.getElementById(oFw).value; }
	
	//By name to obtain an HTML element
	
	$N = function(em){ return  document.getElementsByName(em); }
	
	//By access to an HTML element ID
	$  = function(em) {
    	if (document.getElementById){ return document.getElementById(em); }
    		else if (document.all){ return document.all[em]; }
    		else if (document.layers){ return document.layers[em]; }
   	 	else{ return null; }
	
	}
	//get this obj classname or set class
	$cls = function(em, g, c){
		if (g == 'g'){
			em.className = c;
			return true;
		}else {
			return em.className;
		}
	}

function getClass(o)
{
	return o.className;
}
function setClass(o,strClassName)
{
	o.setAttribute('class', strClassName);
}

//Create an AJAX object
function createAjax(){
	if (window.XMLHttpRequest) {
		oAjax = new XMLHttpRequest();
	}
		else if (window.ActiveXObject) {
	     		try {
			    	oAjax = new ActiveXObject("Msxml2.XMLHTTP");
	     		    } catch (e) {
		        try{
					oAjax = new ActiveXObject("Micrsost.XMLHTTP");
				} catch(e){}
	     		}
        	}
	}


function createAjaxs(){
	
	if (window.XMLHttpRequest) {
		aj = new XMLHttpRequest();
	}
		else if (window.ActiveXObject) {
	     		try {
			    	aj = new ActiveXObject("Msxml2.XMLHTTP");
	     		    } catch (e) {
		        try{
					aj = new ActiveXObject("Micrsost.XMLHTTP");
				} catch(e){}
	     		}
        	}
	}


function alertWin(title, w, h ,strFurl,intFw,intFh,t_pic){ 
	var titleheight = "10px"; // 窗口标题高度 
	var bordercolor = "#709CD2"; // 提示窗口的边框颜色 
	var titlecolor = "#FFFFFF"; // 窗口标题颜色 
	var titlebgcolor = "#FFFFFF"; // 窗口标题背景色
	var bgcolor = "#FFFFFF"; // 提示内容的背景色
	
	var iWidth = document.documentElement.clientWidth; 
	var iHeight = document.documentElement.clientHeight; 
	var bgObj = document.createElement("div"); 
	
	var _height = document.documentElement.clientHeight||document.body.clientHeight;
    var _top = (_height) ? (_height - 39)/2 + document.documentElement.scrollTop : 0;
   	iHeight = _top+600;
	bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
	document.body.appendChild(bgObj); 
	var msgObj=document.createElement("div");
	msgObj.style.cssText = "position:absolute;font:11px '宋体';top:"+(iHeight-h)/2+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;border:1px solid "+bordercolor+";background-color:"+bgcolor+";padding:1px;line-height:22px;z-index:102;";
	var htmlCouent	 = "<iframe width='"+intFw+"'% style='height:"+intFh+"px;' name='regF' id='regF' src='"+strFurl+"' frameborder='0' scrolling='no'></iframe>";
	document.body.appendChild(msgObj);
	//msgObj.innerHTML = htmlCouent;
	
	var table = document.createElement("table");
	msgObj.appendChild(table);
	table.style.cssText = "margin:0px;border:0px;padding:0px;";
	table.cellSpacing = 0;
	var tr = table.insertRow(-1);
	var titleBar = tr.insertCell(-1);
	titleBar.style.cssText = "background-image: url('"+webroot+webstyleroot+"/images/ajax_login_title.gif'); background-repeat: no-repeat;width:100%;height:25px;text-align:left;padding:3px;margin:0px;font:bold 13px '宋体';border:0px solid " + bordercolor + ";cursor:move;"
	titleBar.style.paddingLeft = "10px";
	titleBar.innerHTML = title;
	var moveX = 0;
	var moveY = 0;
	var moveTop = 0;
	var moveLeft = 0;
	var moveable = false;
	var docMouseMoveEvent = document.onmousemove;
	var docMouseUpEvent = document.onmouseup;
	titleBar.onmousedown = function() {
		var evt = getEvent();
		moveable = true; 
		moveX = evt.clientX;
		moveY = evt.clientY;
		moveTop = parseInt(msgObj.style.top);
		moveLeft = parseInt(msgObj.style.left);
		
		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
				if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
				}
			}	
		};
		document.onmouseup = function () { 
			if (moveable) { 
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false; 
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			} 
		};
	}
	
	var closeBtn = tr.insertCell(-1);
	closeBtn.style.cssText = "cursor:pointer; padding:2px;background-color:" + titlebgcolor;
	closeBtn.innerHTML = "<span style='font-size:15pt; color:"+titlecolor+";'><img src='"+webroot+'/'+webstyleroot+"/images/dialogclose.gif'></span>";

	closeBtn.onclick = function(){ 
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj); 
	} 
	var msgBox = table.insertRow(-1).insertCell(-1);
	msgBox.style.cssText = "font:10pt '宋体';";
	msgBox.colSpan  = 2;
	msgBox.innerHTML = htmlCouent;
	
    // 获得Event对象，用于兼容IE和FireFox
    function getEvent() {
	    return window.event || arguments.callee.caller.arguments[0];
    }
   
} 



function do_alert( msg ){
    var _height = document.documentElement.clientHeight||document.body.clientHeight;
    var _top = (_height) ? (_height - 39)/2 + document.documentElement.scrollTop : 0;
    var msgObj=document.createElement('div');
    msgObj.setAttribute('id', 'msgInfo');
    msgObj.setAttribute('align', 'center');
    msgObj.style.position = 'absolute';
    msgObj.style.top = _top + 'px';
    msgObj.style.left = '0';
    msgObj.style.width = '100%';
    msgObj.style.height = '33px';
    msgObj.style.zIndex = '999';
    msgObj.innerHTML = '<span id="alert">'+ msg +'</span>';
    document.body.appendChild(msgObj);
	setTimeout('close_alert()', 3000);
}



function close_alert(){
    document.body.removeChild($('msgInfo'));
}

function selectAll(o){
	for(var i=0;i<$N(o).length;i++) {
		$N(o)[i].checked=true;
	}

} 

function selectBack(o){
	for(var i=0;i<$N(o).length;i++) {
		$N(o)[i].checked==true?$N(o)[i].checked=false:$N(o)[i].checked=true;
	}
}


function kk(o,p)
{
	
	var intChildLen = $(o).childNodes.length;
	
	for (i=0;i<=intChildLen;i++)
	{

		var obj = $(o).childNodes[i];
		obj.style.display='block';
		
	}	
	
	
	
	
}







function cus(o)
{
	o.style.cursor='hand';
}



function soSaveText(em){
	var v = em.value;
	setTimeout('soDelText()',6000);
	
}
function soDelText(){
	$('q').value=intMusicCount;
}


function getCookie(strName){
	var arrCut = document.cookie.split(';');
	var arrCutLen = arrCut.length;
	for (i=0;i<arrCutLen;i++){
		var strTm = arrCut[i];
		if (strTm.indexOf(strName)!=-1 && strTm.indexOf('[url]')!=-1){
			var arrCut_2  = strTm.split('=');
			var u = arrCut_2[1];
			return u;
		}
	}
}





function getMurl(o){
	var str='';
	var e;
	var strurl='';
	var strHtml = '';
	var len = $N(o).length;
	for(var i=0;i<len;i++){
	   	e = $N(o)[i];
		if (e.checked){
			str+=e.value+"|";
		}
	}
	
	window.open(webroot+webhd+'?do=plays&id='+str,'plays');
}
		
function getUserCookie(strName){
		var str = strName;
		var arrCut = document.cookie.split(';');
		var arrCutLen = arrCut.length;
		for (i=0;i<arrCutLen;i++){
			var o = arrCut[i];
			if (o.indexOf(strName)!=-1){
				arrCuts = o.split('=');
				return arrCuts[1];
			}
		}
		
	}
	
	
	function getPageUrl(o){
		location.href = o.options[o.selectedIndex].value;
	} 


	function soKeyPress(em){
		var v = em.value;
		

		if(event.keyCode==13 && v !='')  {
			$('imageField').focus();
			location.href = webroot+'do.php?album-so-'+escape(v)+'-false-false-1-1.html';
		}    
	}
	
	function soMouse(){
		var so_type = $('so_type').options[$('so_type').selectedIndex].value;
	
		location.href = webroot+webhd+'?do=search&type='+so_type+'&key='+escape($('q').value);
	}
	
	function getDown(mid){
			
			createAjax();
			//var musicPass = s;
			var strUrl;
			strUrl = webroot+webhd+"?do=ajax&ac=get_musicdownfile&mid="+mid+"&now=" + new Date().getTime();
			//alert(strUrl);
			oAjax.open("GET",strUrl,true);
			oAjax.onreadystatechange = function(){
				if(oAjax.readyState == 4){
					if(oAjax.status == 200){
						var msg = oAjax.responseText;
						if ( msg=='' || msg==0){
							do_alert('请求下载的文件异常'); 
							} else if(msg==1){
							do_alert('下载歌曲请先登陆'); 
							} else if(msg==2){
							do_alert('您所在的用户组已经禁止下载'); 
							} else if(msg==3){
							do_alert('您的积分小于当前歌曲积分!'); 
							} 
						else {
							window.open(msg);
						}
						 
					} else {
						do_alert( '请求页面异常' ); 
					}
				}
			};
			oAjax.send(null);
	}
	
	//歌曲收藏
function keepMusic(mid){
		createAjax();
		var strUrl;
		strUrl = webroot+webhd+"?do=ajax&ac=add_keepmusic&mid="+mid+"&now=" + new Date().getTime();
		oAjax.open("GET",strUrl,true);
		oAjax.onreadystatechange = function(){
			if(oAjax.readyState == 4){
					if(oAjax.status == 200){
						var msg = oAjax.responseText;
						do_alert(msg); 
					}
			}
			
		};
			oAjax.send(null);
	}
	
	
	
	function copy_url(s){
		
    	var copy_str = '推荐一首舞曲给你：'+ s +'（'+ location.href +'）';
    	window.clipboardData.setData('text', copy_str);
    	alert('歌曲网址和标题已复制，您可以粘贴到MySpace、QQ、MSN或通过其它方式发给好友了。');
	}


//专集
	function setSplHist(id){
			
			createAjax();
			var strUrl;
			strUrl = webroot+"do.php?album-hist-splclickcount-&id="+id+"&now=" + new Date().getTime();
			
			oAjax.open("GET",strUrl,true);
			oAjax.onreadystatechange = function(){
				if(oAjax.readyState == 4){
					if(oAjax.status == 200){
						var msg = oAjax.responseText;
					}
				}
			};
			oAjax.send(null);
	}
	function splon(o){
		
		if ($('splinfo_fw').className=='on_spl_info_fw'){
			$('splinfo_fw').className='off_spl_info_fw';
		}else {
			$('splinfo_fw').className='on_spl_info_fw';
		}
		
		if (o.innerHTML == '-收缩专辑介绍'){
			o.innerHTML = '+展开专辑介绍';
		}else {
			o.innerHTML = '-收缩专辑介绍';
		}

	}
	
function CheckAll(form){

	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
			e.checked = true
	}
}


function CheckOthers(form){
	for (var i=0;i<form.elements.length;i++){
					var e = form.elements[i];
						if (e.checked==false){
							e.checked = true;
										}else{
							e.checked = false;
			}
	}
}

//取标签的绝对位置
function getoffset(e) {
	var t = e.offsetTop;
	var l = e.offsetLeft;
	var w = e.offsetWidth;
	var h = e.offsetHeight-2;

	while(e=e.offsetParent)
	{
		t+=e.offsetTop;
		l+=e.offsetLeft;
	}
	return {
		top : t,
		left : l,
		width : w,
		height : h
	}
}

//取标签的绝对位置
function getpos(tag) {
	obj = $(tag);
	var t = obj.offsetTop;
	var l = obj.offsetLeft;
	var w = obj.offsetWidth;
	var h = obj.offsetHeight-2;

	while(obj=obj.offsetParent)
	{
		t+=obj.offsetTop;
		l+=obj.offsetLeft;
	}
	return {
		t : t,
		l : l,
		w : w,
		h : h
	}
}


	function createindexhtml(){
		createAjax();
		var strUrl;
		var strUrl = webroot+"do.php?album-doajax-&a=ajax_makeindexhtml&now=" + new Date().getTime();
		oAjax.open("GET",strUrl,true);
		oAjax.onreadystatechange = function(){
			if(oAjax.readyState == 4){
					if(oAjax.status == 200){
						var msg = oAjax.responseText;
						//do_alert(msg); 
					}
			}
			
		};
			oAjax.send(null);
	}
	

	function killErrors() { return true; } window.onerror = killErrors;



