﻿function getXMLHttpRequest(){  
	var xmlHttp;
	var xmlHttpRequest = null; 
	if (window.ActiveXObject){
	  var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
	  var xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp;
}

function $(id){
	return document.getElementById(id);
}

//-------显示载入过程--------
function LoadingData(DivId){
	$(DivId).innerHTML="<p align=center><br><img border='0' src='/images/DotIco/loadingSmall.gif'>数据加载中....</p>"
}

//-------添加到收藏--------
function AddFav(Title,Id){
	window.showModalDialog('http://my.zhongguobaobao.com/Manage/UserWeb/MyFavorite/Insert.asp?title='+escape(Title)+'&urlstr=http://video.zhongguobaobao.com/mp3/Play.asp?MP3Id='+Id, window, 'dialogWidth: 700px; dialogHeight: 450px; help: no; scroll: no; status: no');
	}

function DownFile(FileType,Id,File){
	window.showModalDialog('DownInsert.asp?FileType='+FileType+'&Id='+Id+'&File='+File, window, 'dialogWidth: 410px; dialogHeight: 400px; help: no; scroll: no; status: no');
	}

function tagclose(event){
	if(window.newDiv!=null&&newDiv.tagName=="DIV"){		//判断是否已有newDiv层已打开，True就关闭它
		var div = $('newDiv');
		div.parentNode.removeChild(div);
	}
}

//-------Tag--------
function tagshow(event,tagId,url){
	tagclose(event);
	var newElementwidth=410;							//Div宽 
	var newElementheight=400;							//Div高 
    var newElement = document.createElement('div'); 
    document.body.appendChild(newElement); 				//漏了这一句行不通 
    newElement.id = 'newDiv'; 
    newElement.className = 'newDivClass'; 
    newElement.setAttribute('name','newDivName');
    newElement.style.position = 'absolute';
	newElement.style.left = document.body.scrollLeft+document.body.clientWidth/2-newElementwidth/2-20+'px';
	newElement.style.top =  document.body.scrollTop+document.body.clientHeight/2-newElementheight/2-20+'px';
	newElement.style.zIndex = '9999';
    newElement.style.width = newElementwidth+'px'; 
    newElement.style.height = ''; 
    newElement.style.margin = '0 auto'; 
    newElement.style.border = '1px solid #CCCCCC'; 
    newElement.style.backgroundColor = '#FCFFEF';
    newElement.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100,finishOpacity=100,style=0)';
	newElement.style.opacity = 0.99;
    newElement.innerHTML=('<img border="0" src="/images/DotIco/loading2.gif">数据加载中，请稍后....'); 
    xmlHttp=getXMLHttpRequest();
	xmlHttp.open("get", url, true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-Length",length);
	xmlHttp.onreadystatechange = function(){LikeKeyWordReadyStateChange(newElement)};
	xmlHttp.send();	
}
function LikeKeyWordReadyStateChange(newElement){
	if (xmlHttp.readyState == 4){
		if (xmlHttp.status == 200){
			newElement.innerHTML=(xmlHttp.ResponseText);
  		}
  	}
}

//-------载入会员登陆-------
function LoginDivData(DivId,url){
	LoadingData(DivId);
	LoginDivDataHttp=getXMLHttpRequest();
	LoginDivDataHttp.open("get", url, true);
	LoginDivDataHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	LoginDivDataHttp.setRequestHeader("Content-Length",length);
	LoginDivDataHttp.onreadystatechange = function(){LoginDivDataReadyStateChange(DivId)};
	LoginDivDataHttp.send();
}
function LoginDivDataReadyStateChange(DivId){
	if (LoginDivDataHttp.readyState == 4){
		if (LoginDivDataHttp.status == 200){
			$(DivId).innerHTML=(LoginDivDataHttp.ResponseText);		
  		}
  	}
}