﻿// JScript 文件

showMessage=function(s)
{
    alert(s);
}

String.prototype.getRealLength=function(){return this.replace(/[^\x00-\xff]/g,"aa").length;};

//功能介绍：打开新的窗口 
function OpenImpeach(url)
{
    var Width=550;
    var Height=500;
  	var top  = (screen.height - Height) / 2 ;
	var left = (screen.width  - Width) / 2 ;
	window.open('/Impeach.aspx?url='+url,"_blank","toolbar=no,left="+left+",top="+top+",width="+Width+",height="+Height+",directories=no,status=no,scrollbars=no,resizable=no,menubar=no");
}

//空格截取
String.prototype.Trim = function()
{
   var regEx = /(^\s+)|(\s+$)/g;
   return this.replace(regEx,'');              
}

function resizeImg(_oObj, _iWidth)
{
    var tMark = true;var iWidth = 0;var sOuterHtml;var aNode = _oObj.attributes;
    for(var i = 0; i < aNode.length; i++){if(aNode[i].specified){if(aNode[i].name == "width" || aNode[i].name == "height"){tMark = false;}}}
    if(tMark){if(_iWidth){setTimeout("resize()",500);}}
    this.resize = function(){if(_oObj.width > _iWidth){_oObj.width = _iWidth;}}
}


//获取屏幕的分辩率 
function getWinSize() 
{
	var windowWidth, windowHeight;
	if(self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	return {height:windowHeight,width:windowWidth};
}


////////////////////////////////////////////////////以下为页面所用到的脚本////////////////////////////////////////////////////
function HW_setTab(ulid,liid,hoverid,divid,id) {
	var tabs = document.getElementById(ulid).getElementsByTagName('li');
	for (i=0; i<tabs.length; i++){
		if(i==liid-1){
			tabs[i].className =hoverid;
		}else{
			tabs[i].className = '';	
		}
	}
	tabs[i-1].className = 'options_li_more';	
	
	var contents =document.getElementById(divid).getElementsByTagName('div');
	for (i=0; i<contents.length; i++) {
		if (contents[i].className=='table_qh') { contents[i].style.display = 'none';}
	}
	document.getElementById(id).style.display = '';
}


function Collapse(divid,imgid,zd,zk){
	if(document.getElementById(divid).style.display ==''){
		document.getElementById(imgid).alt=zk;
		document.getElementById(divid).style.display ='none';
	}else{
		document.getElementById(imgid).alt=zd;
		document.getElementById(divid).style.display ='';
		
	}
}

function Bgnav(divid,i){
	var zdl =document.getElementById(divid).getElementsByTagName('dl');
	for(j=0; j<zdl.length; j++){
		if(j==i-1){
			zdl[j].style.background='url(/images/bg_znav.gif) repeat-x center center';
		}else{
			zdl[j].style.background='';
		}
	}
}


function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}



//选中所有
function  selectAll()  
{  
   var  arrObj  =  document.all;  
   for(var  i  =  0;  i  <  arrObj.length;i++)  
   {  

	 if(typeof  arrObj[i].type  !=  "undefined"  &&  arrObj[i].type=='checkbox')  
	   arrObj[i].checked  =true;  
   }  
}

//反选
function selectCharge()
{
	 var  arrObj  =  document.all;  
	for(var  i  =  0;  i  <  arrObj.length;i++)  
	{  

		if(typeof  arrObj[i].type  !=  "undefined"  &&  arrObj[i].type=='checkbox')  
		arrObj[i].checked  = !arrObj[i].checked;  
	}  
}  

//全选(特定控件内)
function  selectAllFrom(id){
	inputs = $(id).getElementsByTagName("input");
	for (i=0;i<inputs.length;i++){
		if(inputs[i].type=="checkbox"){
			inputs[i].checked="checked";
		}
	}
	
}	

//反选(特定控件内)
function selectChargeFrom(id){
	inputs = $(id).getElementsByTagName("input");
	for (i=0;i<inputs.length;i++){
		if(inputs[i].type=="checkbox" && inputs[i].checked){
			inputs[i].checked=false;
		}else if(inputs[i].type=="checkbox" && !inputs[i].checked){
			inputs[i].checked=true;
		}
	}
}  



var screenHeight = document.documentElement.clientHeight;
var screenWidth = document.documentElement.clientWidth;


//显示等待
function showWait()
{
	if($("soholife_div_wait_ajax") != null)
	{
		return ;
	}
	 
	var width_x = document.body.clientWidth;
	var box_width = 35;
	var box_height = 300;
	var box_left = width_x/2-box_width/2;	
	
	var divTemp = document.createElement("div");
	divTemp.id = "soholife_div_wait_ajax";
	divTemp.style.display   ="block";   
	divTemp.style.backgroundColor='yellow';   
	divTemp.style.left   =   box_left+"px";   
	divTemp.style.top   =   box_height+"px";   
	divTemp.style.position   =     "absolute"; 
	divTemp.innerHTML   =   "<img src=\"/images/ajax-loader.gif\"  border=0 >";   
	document.body.appendChild(divTemp);   
}

//隐藏等待
function hideWait()
{
	if($("soholife_div_wait_ajax") != null)
	{
		document.body.removeChild($("soholife_div_wait_ajax"));
	}
}



//播放视频
function small_PlayMovie(divID,sMovieUrl)
{
	var s = "&nbsp;<object width='400' height=340'><param name='movie' value='" + sMovieUrl + "'></param>"
		+ "<param name='allowScriptAccess' value='always'></param>"
		+ "<param name='wmode' value='transparent'></param>"
		+ "<embed src='" + sMovieUrl + "' type='application/x-shockwave-flash' width='400' height='340' allowFullScreen='true' wmode='transparent' allowScriptAccess='always'></embed></object>"
		+ "";
	
	$("Pic_" + divID).style.display = "none";
	$("Movie_" + divID).innerHTML =  s ;	
	$("Movie_" + divID).style.display = "";		
}

//播放音乐
function small_PlayMusic(divID,t,url)
{
   var list= $(divID);   

   if(t=="mp3")
   {
       list.innerHTML='<embed src="/images/mediaplayer.swf" width="300" height="20" allowscriptaccess="always" allowfullscreen="true" flashvars="width=300&height=20&file='+url+'&autostart=true"/>';
   }else{
       list.innerHTML='<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="352" height="70" ><param name="autostart" value="1" ><param name="showstatusbar" value="1"><param name="Filename" value="'+url+'"><embed type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" flename="mp" src="'+url+'" width="352" height="70"></embed></object>';
   }   
}


//显示弹出层
function boxjs(id)
{
	var scrollPos; 
    
    if (typeof window.pageYOffset != 'undefined') 
    { 
        scrollPos = window.pageYOffset; 
    } 
    else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') 
    { 
        scrollPos = document.documentElement.scrollTop; 
    } 
    else if (typeof document.body != 'undefined') 
    { 
        scrollPos = document.body.scrollTop; 
    }	
	
	var width_x = document.body.clientWidth;
	var box_width = 500;
	var box_height = getHeight();
	var box_left = width_x/2-box_width/2;
	$(id).style.left = box_left+"px";
	$(id).style.top = (box_height-$(id).clientHeight)/2+scrollPos +"px";	
}


//得到高度
function getHeight()
{
	var myHeight = 0;

    if( typeof( window.innerWidth ) == 'number' ) {
       myHeight = window.innerHeight;

    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {

    myHeight = document.documentElement.clientHeight;

    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myHeight = document.body.clientHeight;
	}
    return myHeight;
}