//=======================================================
//函数名称：addBookmark()
//调用方式<a href="javascript:void(0)" onClick="addBookmark();return(false);" target="_self">加入收藏</a>
//函数功能：加入收藏
//=======================================================
function addBookmark(){
var _title=document.title;
var _url=document.location.href;
if (window.sidebar) { window.sidebar.addPanel(_title, _url,""); } else if( document.all ) {window.external.AddFavorite( _url, _title);} else if( window.opera && window.print ) {return true;}}
// JavaScript Document
//========================================================
//		用$(id)代替document.getElementById(id)
//		用$$(id)代替document.getElementByName(name)
//========================================================
function $(s) {
		return document.getElementById(s);
	}
function $$(s) {
		return document.getElementsByName(s);
	}
//===============================================


//===============================================

function addEvent( obj, type, fn ) { 
   if ( obj.attachEvent ) { 
     obj['e'+type+fn] = fn; 
     obj[type+fn] = function(){obj['e'+type+fn]( window.event );} 
     obj.attachEvent( 'on'+type, obj[type+fn] ); 
   } else 
     obj.addEventListener( type, fn, false ); 
}
function removeEvent( obj, type, fn ) { 
   if ( obj.detachEvent ) { 
     obj.detachEvent( 'on'+type, obj[type+fn] ); 
     obj[type+fn] = null; 
   } else 
     obj.removeEventListener( type, fn, false ); 
} 
//用法

//addEvent(window,'load',func1);
//addEvent(window,'load',func2);
//addEvent(window,'load',func3);

//============================================
//		不冲突的window.onload()
//============================================

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}
//

//=======================================================
//		Cookies的操作，如增加，删除等。
//=======================================================
function getCookie( name ) {
    var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;
    if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
        return null;
    }
    if ( start == -1 ) return null;
    var end = document.cookie.indexOf( ';', len );
    if ( end == -1 ) end = document.cookie.length;
    return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
    var today = new Date();
    today.setTime( today.getTime() );
    if ( expires ) {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date( today.getTime() + (expires) );
    document.cookie = name+'='+escape( value ) +
        ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
        ( ( path ) ? ';path=' + path : '' ) +
        ( ( domain ) ? ';domain=' + domain : '' ) +
        ( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
    if ( getCookie( name ) ) document.cookie = name + '=' +
            ( ( path ) ? ';path=' + path : '') +
            ( ( domain ) ? ';domain=' + domain : '' ) +
            ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

function isEmpty(s)
{  
	return ((s == null) || (s.length == 0))
}
function IsAlpha(cCheck)
	{
	return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
	}
//检查字符串是否为数值
function isnumber(str){
	var digits="1234567890xX";
	var i=0;
	var strlen=str.length;
	while((i<strlen)){
		var char=str.charAt(i);
		if(digits.indexOf(char)==-1)return false;i++;
					}
	return true;
}

function Verifyname(str){

	for (nIndex=0; nIndex<str.length; nIndex++)
		{
		cCheck = str.charAt(nIndex);


		if (isnumber(cCheck)|| IsAlpha(cCheck) || cCheck=='-' || cCheck=='_'|| cCheck==' ')
			{
			return false;
			}
		}
	return true;					
}