﻿function openmsg(){
	window.open("/message.aspx");
}
function getobj(id){
	return document.getElementById(id);	
}

function selecttab(obj, act, def, special, areaname){
	var node = childs(obj.parentNode.parentNode.childNodes);
	for(var i=0;i<node.length;i++){
		if(node[i].className != special){
			node[i].className = def;	
			if(getobj(areaname + "_" + i))
				getobj(areaname + "_" + i).style.display = "none";
		}
	}
	obj.parentNode.className = act;
	for(var i=0;i<node.length;i++){
		if(node[i].className != special){
			if(node[i].className == act){
				if(getobj(areaname + "_" + i))
					getobj(areaname + "_" + i).style.display = "";
			}
		}
	}
}
function showimg(obj)
{
	var imgsrc = obj.src;
	var img = "<img src="+imgsrc.replace('_76-106','').replace('_72-101','')+">";
	ztip.s(img);
	}
function tipimg(obj)
{
	var imgsrc = obj.rel;
	var img = "<img src="+imgsrc+">";
	ztip.s(img);
	}

//兼容FF下的childNodes
function childs(nodes)
{
    if(!nodes.length) 
        return [];
    var ret=[];
    for(var i=0;i<nodes.length;i++)
    {
        if(nodes[i].nodeType!=1) 
            continue;
        ret.push(nodes[i]);
    }
    return ret;
}

//֤
function ChangeVerifyImgNew(url){
	document.getElementById("verifyimg").src = url + 'member/verifyimg.aspx?d=' + escape(Date());
}

function zaktabtool()
{
	var obj = this;
	this.tabbuttons = document.getElementById(arguments[0]);
	this.tabcontents = document.getElementById(arguments[1]);
	this.tabonclass = arguments[2];
	var toc = this.tabonclass;
	this.starttab = arguments[3];
	var tabcontentlist = this.tabcontents.getElementsByTagName("div");
	var tabbuttonlist = this.tabbuttons.getElementsByTagName("li");
	this.rc = function(){
		for(var i=0;i<tabcontentlist.length;i++){tabcontentlist[i].style.display = "none";} 
		for(var i=0;i<tabbuttonlist.length;i++){tabbuttonlist[i].className = "";} 
		}
	this.register = function(){
		for(var i=0;i<tabbuttonlist.length;i++)
		{
			tabbuttonlist[i].index = i;
			tabbuttonlist[i].onmouseover = function(){
					  obj.rc();
				      this.className = toc;
					  tabcontentlist[this.index].style.display = "block";
				}
			}
		}    
	this.init = function(){	
		if(tabcontentlist.length != tabbuttonlist.length){ alert("初始化失败！请检查元素设置！"); return false;}
		obj.rc();
		if(this.starttab == 0){this.starttab =1;}
		tabbuttonlist[this.starttab-1].className = this.tabonclass;
		tabcontentlist[this.starttab-1].style.display = "block";
		obj.register();
		 }
	obj.init();
	} 

function setStyle(el,prop,value){ 
	if(prop == "opacity" && !+"\v1"){ 
    	//IE7 bug:filter 滤镜要求 hasLayout=true 方可执行（否则没有效果） 
    	if (!el.currentStyle || !el.currentStyle.hasLayout) el.style.zoom = 1; 
     	prop = "filter"; 
    	if(!!window.XDomainRequest){ 
         value ="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity="+value*100+")"; 
     }else{ 
        value ="alpha(opacity="+value*100+")"
    } 
 } 
  el.style.cssText += ';' + (prop+":"+value); 
} 
 
function getStyle(el, style){ 
  if(!+"\v1"){ 
   style = style.replace(/\-(\w)/g, function(all, letter){ 
     return letter.toUpperCase(); 
   }); 
   return el.currentStyle[style]; 
   }else{ 
     return document.defaultView.getComputedStyle(el, null).getPropertyValue(style) 
   } 
}

var loadEvent = function(fn) { 
    var oldonload = window.onload; 
   if (typeof window.onload != 'function') { 
        window.onload = fn; 
   }else { 
         window.onload = function() { 
            oldonload(); 
            fn();         } 
        }
    }
function $Z(obj){
	return document.getElementById(obj);
	}
function tabChange(length,no,aprefix,dprefix,outClass,onClass)
{
	for(var i=1;i<=length;i++)
	{
		$Z(aprefix+i.toString()).className = outClass;
		$Z(dprefix+i.toString()).style.display = "none";
		}
	$Z(aprefix+no).className = onClass;
	$Z(dprefix+no).style.display = "block";
	}

var ztip=function(){
  var id = 'tt';
  var top = 3;
  var left = 3;
  var maxw = 600;
  var speed = 100;
  var timer = 20;
  var endalpha = 100;
  var alpha = 100;
  var tt,t,c,b,h;
  var ie = document.all ? true : false;
  return{
	  s:function(v,w){
		  if(tt == null){
			  tt = document.createElement('div');
			  tt.setAttribute('id',id);
			  t = document.createElement('div');
			  t.setAttribute('id',id + 'top');
			  c = document.createElement('div');
			  c.setAttribute('id',id + 'cont');
			  b = document.createElement('div');
			  b.setAttribute('id',id + 'bot');
			  tt.appendChild(t);
			  tt.appendChild(c);
			  tt.appendChild(b);
			  document.body.appendChild(tt);
			  tt.style.opacity = 100;
			  tt.style.filter = 'alpha(opacity=100)';
			  document.onmousemove = this.pos;
		  }
		  tt.style.display = 'block';
		  c.innerHTML = v;
		  tt.style.width = w ? w + 'px' : 'auto';
		  if(!w && ie){
			  t.style.display = 'none';
			  b.style.display = 'none';
			  tt.style.width = tt.offsetWidth;
			  t.style.display = 'block';
			  b.style.display = 'block';
		  }
		  if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
		  h = parseInt(tt.offsetHeight) + top;
		  clearInterval(tt.timer);
		  tt.timer = setInterval(function(){ztip.fade(1)},timer);
	  },
	  pos:function(e){
		  var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
		  var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
		  var tw = tt.clientWidth  || tt.style.pixelWidth;
		  tt.style.top = (u - h) + 'px';
		  tt.style.left = (l + left-tw/3) + 'px';
	  },
	  fade:function(d){
		  var a = alpha;
		  if((a != endalpha && d == 1) || (a != 0 && d == -1)){
			  var i = speed;
			  if(endalpha - a < speed && d == 1){
				  i = endalpha - a;
			  }else if(alpha < speed && d == -1){
				  i = a;
			  }
			  alpha = a + (i * d);
			  tt.style.opacity = alpha * .01;
			  tt.style.filter = 'alpha(opacity=' + alpha + ')';
		  }else{
			  clearInterval(tt.timer);
			  if(d == -1){tt.style.display = 'none'}
		  }
	  },
	  h:function(){
		  clearInterval(tt.timer);
		  tt.style.display = "none";
		  tt.timer = setInterval(function(){ztip.fade(-1)},timer);
	  }
  };
}();

