﻿function isIE(){ //ie? 
   if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1) 
    return true; 
   else 
    return false; 
} 

if(!isIE()){ //firefox innerText define
   HTMLElement.prototype.__defineGetter__(     "innerText", 
    function(){
     var anyString = "";
     var childS = this.childNodes;
     for(var i=0; i<childS.length; i++) {
      if(childS[i].nodeType==1)
       anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
      else if(childS[i].nodeType==3)
       anyString += childS[i].nodeValue;
     }
     return anyString;
    } 
   ); 
   HTMLElement.prototype.__defineSetter__(     "innerText", 
    function(sText){ 
     this.textContent=sText; 
    } 
   ); 
}
function getA(o,name){
	return o.getAttribute(name);
}
function $(o){
   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 elemShow(o){
	$(o).style.display = "";
}
function elemClose(o){
	$(o).style.display = "none";
}
function setCs(o,value){
	o = $(o);
	for(var i=0;i<o.options.length;i++){
		if(o.options[i].text == value){
			o.options[i].selected = true;
		}
	}
}
function SubString(title,len,sp){
	if(title.length>len){
		return title.substring(0,len)+sp;
	}
	return title;
}
function getR(o){
	var val = "";
	o = document.getElementsByName(o);
	var j=0;
	for(var i=0;i<o.length;i++){
		if(o[i].checked){
			if(j==0){
				val = o[i].value;
			}else{
				val = "," + o[i].value;
			}
			j++;
		}
	}
	return val;
}
function removeElem(element){
	if(element){
		element.parentNode.removeChild(element);
	}
}
function tabit(name,id,total){
	for(var i=0;i<total;i++){
		if(i==id)continue;
		$(name+"_btn"+i).className = "tab_off";
		elemClose(name+"_div"+i);
	}
	$(name+"_btn"+id).className = "tab_on";
	elemShow(name+"_div"+id);
}
function checkAll(val){
    var objs = document.getElementsByTagName("input");
    for(var i=0;i<objs.length;i++){
        if(objs[i].type=="checkbox"){
            objs[i].checked = val;
        }
    }
}
function writeCookie(name, value, m){
  var expire = "";
  if(m != null){
    expire = new Date((new Date()).getTime() + m * 60000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.domain = "uldc.cn";
  document.cookie = name + "=" + escape(value) + expire;
}
function readCookie(name){
  var cookieValue = "";
  var 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 openWindow(url, title, width, height) {
    var top = 300;
    var left = 150;
    if (window.screen) {
        top = (window.screen.width - width) / 2;
        left = (window.screen.height - height) / 2;
    }
    window.open(url, title, 'height=' + height + ',width=' + width + ',top=' + top + ',left=' + left + ',toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no');
} 

function ShowWelCome()
{
	now = new Date(),hour = now.getHours() 
	if (hour <11){document.write("上午好！")} 
	else if (hour <14){document.write("中午好！")} 
	else if (hour <18){document.write("下午好！")} 
	else if (hour <24){document.write("晚上好！")} 
}
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);
}

