﻿// JavaScript Document
   function $x(id){
	   return document.getElementById(id);
	   }
	 function setclass(id,name){
	   $x(id).className=name;
	 }
	 function setcolor(id,clor){
  	  $x(id).style.color=clor;
    }
	//----------设置div 的字体大小----------
function setHS(id,size,height) { 
    $(id).css({ "line-height":height , "font-size": size});
 }
	
//读写cookie
function readCookie(name){
	cookieValue = "";
	search = name + "=";
	if(document.cookie.length > 0){ 
		offset = document.cookie.indexOf(search);
		if (offset != -1){ 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}
	return cookieValue;
}


function writeCookie(name, value, day){
	if(day==null || day <=0) day=1;
	expire = "";
	expire = new Date((new Date()).getTime() + day * 86400000);
	expire = ";expires=" + expire.toGMTString();
	document.cookie = name + "=" + escape(value) + expire;
	//alert("保存成功！");
}

  function DeleteCookie(name) {
      var date = new Date();
      date.setTime(date.getTime() - 10000); //删除一个cookie，就是将其过期时间设定为一个过去的时间
      document.cookie = name + "=删除" + "; expires=" + date.toUTCString();
            //document.cookie = " " + name + "=删除" + "; expires=" + date.toGMTString();
 }

//显示日期
function showDate() { var day=""; var month=""; var ampm=""; var ampmhour=""; var myweekday=""; var year=""; mydate=new Date(); myweekday=mydate.getDay(); mymonth=mydate.getMonth()+1; myday= mydate.getDate(); myyear= mydate.getYear(); year=(myyear > 200) ? myyear : 1900 + myyear; if(myweekday == 0) weekday=" 星期日"; else if(myweekday == 1) weekday=" 星期一"; else if(myweekday == 2) weekday=" 星期二"; else if(myweekday == 3) weekday=" 星期三"; else if(myweekday == 4) weekday=" 星期四"; else if(myweekday == 5) weekday=" 星期五"; else if(myweekday == 6) weekday=" 星期六"; document.write(year+"年"+mymonth+"月"+myday+"日"+weekday); }  

 //--------加载图片---------
 function loadImg(url,div,w,h){
   var obj=$(div);
   var img=new Image();
   obj.innerHTML="<p>图片加载中...</p>";
   img.onload=function(){obj.innerHTML="";obj.style.width=w+"px";obj.style.height=h+"px";obj.appendChild(img);};
   img.onerror=function(){obj.innerHTML="图片加载错误，请检查网络或URL地址！"};
   img.src=url; //img.src一定要写在img.onload之后，否则在IE中会出现问题

}
/*
 //在vs2010中可能不支持
function innerFlashX(path,w,h,var_){
pp = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'                    codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' width='"+w+"' height='"+h+"'><param name='movie' value='"
+path+"?variable1="+var_ +"' /><param name='quality' value='high' /><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='true' /><param name='wmode' value='transparent' /><embed src='"+path+"?variable1="+var_+"' quality='high'"
+"pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash'  allowScriptAccess='sameDomain' allowFullScreen='true'  type='application/x-shockwave-flash' wmode='transparent'  width='"+w+"' height='"+h+"'></embed></object>";
return pp;
}
*/

    function innerFlashX(path, w, h, var_) {
        pp = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'  codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version==10,0,0,0' width='" + w + "' height='" + h + "'><param name='movie' value='"
        + path  + "' />      <param   name='FlashVars'   value='variable1="+var_+"' />      <param name='quality' value='high' /><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='true' /><param name='wmode' value='transparent' /><embed src='" + path + "' quality='high'"
        + "FlashVars='variable1=" + var_ + "'   pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash'  allowScriptAccess='sameDomain' allowFullScreen='true'  type='application/x-shockwave-flash' wmode='transparent'  width='" + w + "' height='" + h + "'></embed></object>";
        return pp;
    }
	
 //======================================================
 			 
//调用xml文档
  function   loadXML(xmlFile)    
    {    
        var xmlDoc;   
            if(window.ActiveXObject) {    
                xmlDoc=new ActiveXObject("Microsoft.XMLDOM");    
                xmlDoc.async=false;   
                xmlDoc.load(xmlFile);   
            }   
            else if(document.implementation&&document.implementation.createDocument){    
                xmlDoc=document.implementation.createDocument( "", "",null);    
                xmlDoc.async=false;   
                xmlDoc.load(xmlFile);   
            } else{   
                alert('Your browser cannot handle this script');    
            }   
        return xmlDoc;   
    }   
 //关闭窗口
　function closeWin() {	
　　window.close (); 
　　}
//设置收藏
    function addFavourite()
 {
       var sURL=location.href
       var sTitle=document.title
	
       try
       {
       if(document.all)
       {
       window.external.addFavorite(sURL,sTitle);
       }
       else if(window.sidebar)
       {
       window.sidebar.addPanel(sTitle, sURL, "");
       }
       }
       catch(e)
       {
       alert("添加收藏失败,使用组合快捷键'Ctrl+D'添加!") 
      }

 }
	
//设置首页
 function homePage(obj,vrl)
 {
  	 try
        {
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                        } 
                        catch (e) { 
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }


 }
 //打印
  function printsetup(){ 
　　// 打印页面设置 
　　wb.execwb(8,1); 
　　} 
function printpreview(){ 
　　// 打印页面预览 　　　　 
　　wb.execwb(7,1); 　　　　　 　　　　 
　　} 
function printit() 
　{ 
　　if (confirm('确定打印吗？')) { 
　//　wb.execwb(60,60) 
　　} 
　} 
//------------获取当前GetUrl的值并返回数组-----
	function goGetUrl(){
			var url = location.href; 
			var paraString = url.substring(url.indexOf("?")+1,url.length).split("&");
			return paraString; 		 
			}
//alert(88);

String.prototype.trimc=function(char){	
	return this.replace(new RegExp("^"+char+"|"+char+"$"),"");
}
//--------------------------------------------
function setIdClass(id,ol,ne){
	this.obj=$x(id);
              if(this.obj==null)return;
	this.obj.onmouseover=function(){		
		this.className=ne;
	}
	this.obj.onmouseout=function(){
		this.className=ol;
	}	
}



