function tabs_z(o,o2,n,otag,o2tag){
			var m_n = document.getElementById(o).getElementsByTagName(otag);
			var c_n = document.getElementById(o2).getElementsByTagName(o2tag);
			for(i=0;i<m_n.length;i++){
				 m_n[i].className=i==n?"s":"nos";
 				 c_n[i].className=i==n?"dis":"undis";
				 }
		}
		
var current_div = "divA1" 
var current_divB = "divB1" 
function showDiv(id) 
{ 
   document.getElementById(current_div).style.display = 'none' 
   document.getElementById('div'+id).style.display = 'block' 
   current_div = 'div'+id 
} 
function showDivB(id) 
{ 
   document.getElementById(current_divB).style.display = 'none' 
   document.getElementById('div'+id).style.display = 'block' 
   current_divB = 'div'+id 
} 

function showDivI(div, newdiv) 
{ 
	document.getElementById(div).innerHTML = document.getElementById(newdiv).innerHTML;
} 

function tabs_zz(o,n,otag,o2tag){
			var m_n = document.getElementById(o).getElementsByTagName(otag);
		//	var c_n = document.getElementById(o2).getElementsByTagName(o2tag);
			for(i=0;i<m_n.length;i++){
				 m_n[i].className=i==n?"s":"nos";
 				// c_n[i].className=i==n?"dis":"undis";
				 }
		}

function __getIE() {
    if (window.ActiveXObject) {
        var v = navigator.userAgent.match(/MSIE ([^;]+)/)[1];
        return parseFloat(v.substring(0, v.indexOf(".")))
    }
    return false
};
Array.prototype.foreach = function(func) {
    if (func && this.length > 0) {
        for (var i = 0; i < this.length; i++) {
            func(this[i])
        }
    }
};
String.format = function() {
    if (arguments.length == 0) return null;
    var str = arguments[0];
    for (var i = 1; i < arguments.length; i++) {
        var regExp = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
        str = str.replace(regExp, arguments[i])
    }
    return str
};
String.prototype.startWith = function(s) {
    return this.indexOf(s) == 0
};
String.prototype.startWith = function(s) {
    var d = this.length - s.length;
    return (d >= 0 && this.lastIndexOf(s) === d)
};
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, '')
};
function getid(id) {
    return (typeof id == 'string') ? document.getElementById(id) : id
};

document.getElementsByClassName = function(name) {
    var tags = document.getElementsByTagName('*') || document.all;
    var els = [];
    for (var i = 0; i < tags.length; i++) {
        if (tags[i].className) {
            var cs = tags[i].className.split(' ');
            for (var j = 0; j < cs.length; j++) {
                if (name == cs[j]) {
                    els.push(tags[i]);
                    break
                }
            }
        }
    }
    return els
};

function getOffsetTop(el, p) {
    var _t = el.offsetTop;
    while (el = el.offsetParent) {
        if (el == p) break;
        _t += el.offsetTop
    }
    return _t
};
function getOffsetLeft(el, p) {
    var _l = el.offsetLeft;
    while (el = el.offsetParent) {
        if (el == p) break;
        _l += el.offsetLeft
    }
    return _l
};
function attach(o, e, f) {
    if (document.attachEvent)
        o.attachEvent("on" + e, f);
    else if (document.addEventListener)
        o.addEventListener(e, f, false);
}

//--------- menu ------------
var tt;
var curMenu;
var par;
function mouseover(th, menu) {
    if (tt) clearTimeout(tt);
	par=menu;
    displayMenu(false);
    menu = document.getElementById('menu' + menu);
    menu.style.left = getOffsetLeft(th)+ 'px';
    menu.style.top = getOffsetTop(th) + th.offsetHeight + 'px';
    curMenu = menu;
    displayMenu(true)
}
function mouseout() {
    tt = setTimeout('displayMenu(false)', 200)
}
function _mouseover() {
    if (tt) clearTimeout(tt);
    displayMenu(true)
}
function _mouseout() {
    displayMenu(false)
}
function displayMenu(display) {
    if (curMenu) {
        curMenu.style.display = display ? 'block' : 'none'
    }
}


function openwin(val,width,height,left,top){
//window.open (val, 'newwindow', 'height=400, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=yes,location=no, resizable=no,status=no')
var temp = "channelmode=no,location=no,menubar=no,toolbar=no,directories=no,scrollbars=no,resizable=yes";
var width=790;
var height=400;
 if (width) {
  temp += ',width=' + width;
 } else {
  width = 0;
 }
 if (height) {
  temp += ',height=' + height;
 } else {
  height = 0;
 }
 if (left) {
  temp += ',left=' + left;
 } else {
  temp += ',left='
    + Math.round((window.screen.width - parseInt(width)) / 2);
 }
 if (top) {
  temp += ',top=' + top;
 } else {
  temp += ',top='
    + Math.round((window.screen.height - parseInt(height)) / 2);
 }
   window.open(val, '_blank', temp);
}

function go(formname)
{
var url = "http://www.baidu.com/baidu";
formname.method = "get";
if (formname.myselectvalue.value == "1") {
document.search_form1.word.value = document.search_form1.word.value+" site:niceboy.cnblogs.com";
}
formname.action = url;
return true;
}
//-->
