var ua = navigator.userAgent.toLowerCase()
var isIE=ua.indexOf('msie') > -1
var isFF=ua.indexOf('firefox') > -1
function SetCookie(name, value){
	var expdate = new Date()
	var argv = SetCookie.arguments
	var argc = SetCookie.arguments.length
	var expires = (argc > 2) ? argv[2] : null
	var path = (argc > 3) ? argv[3] : null
	var domain = (argc > 4) ? argv[4] : null
	var secure = (argc > 5) ? argv[5] : false
	if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ))
	document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
	+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
	+((secure == true) ? "; secure" : "")
}
function top_domain(){
	return document.domain.replace("www.","");
	var domain,tmp=location.host.split('.'),i = tmp.length
	var hz = tmp[(i-1)]
	var hz2 = tmp[(i-2)]
	if( hz2=='net' || hz2=='com' || hz2=='org'  ){return tmp[(i-3)]+"."+hz2+"."+hz}
	return tmp[(i-2)]+"."+tmp[(i-1)]
}
function GetCookie(n){
	var aCookie = document.cookie.split("; ")
	for(var i=0; i < aCookie.length; i++){
		var aCrumb = aCookie[i].split("=")
		if(n == aCrumb[0])	return unescape(aCrumb[1])
	}
	return null
}
function DelCookie(name){
	var exp = new Date()
	exp.setTime (exp.getTime() - 1)
	var cval = GetCookie(name)
	document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString()
}
//历史记录
function his(n,l){
	ll=sE.href.length
	if( location.href.substr(0,13) == sE.href.substr(0,13) ) return
	if(l.substr(0,4)!='http' ) return
	l = (l.replace(/</g,"&lt;")).replace(/>/g,"&gt;")
	n = n.replace(/<[^>]+>/g,"")
	if(n.length>12) n = n.substring(0,12)
	var hisstr=GetCookie('ckhis'),hisarr=new Array()
	if( hisstr != null ) hisarr=hisstr.split('^^')
	if(n=='' || l=='') return
	var tmp = new Array(),row
	if(typeof(hisarr) == 'object'){
		if(hisarr.length > 14) delete(hisarr[0])
		for(v in hisarr){
			row = hisarr[v].split('**');
			tmp[row[0]] = row[1]
		}
		if( typeof(tmp[n]) != 'undefined' ) delete(tmp[n])
		hisarr=new Array()
		for(v in tmp)
			if( tmp[v] != 'undefined') hisarr.push(v+'**'+tmp[v])
	}
	hisarr.push(n+'**'+l)
	ck('ckhis',hisarr.join('^^'))
	if($('nav2') && $('nav2').src==G_dirUrl+'images/history/history.html?r='+G_dirUrl)	frame('nav2').location.reload()
}
function ck(n,v){SetCookie(n,v,94608000,'/',top_domain())}
function frame(n){return (isFF)?document.getElementById(n).contentWindow:document.frames[n]}
function getPos(el){
	var r = {'x':el.offsetLeft,'y':el.offsetTop}
	if(el.offsetParent){
		var tmp = getPos(el.offsetParent)
		r.x += tmp.x;r.y += tmp.y
	}return r
}
function regE(n,e,f){if(window.attachEvent)	n.attachEvent(e,f);	else n.addEventListener(e.replace(/^on/,''),f,false)}
function $(obj){return document.getElementById(obj)}
function os(obj){return $(obj).style}


//----index---
//删除对象
function delobj(obj){var e,dele;for(var i=0;i<obj.elements.length;i++){e = obj.elements[i];if(e.type=="hidden"){e.parentNode.removeChild(e);i=-1}}}
//增加一个input表单
function addIt$(fm,nam,v){var ur=document.createElement('input');ur.type = "hidden";ur.name = nam;ur.value = v;fm.appendChild(ur)}
function mover(ob){ob.focus();ob.style.backgroundColor="#FFFFD8"}
function mout(ob){ob.style.backgroundColor="#FFFFFF"}
function mfocus(ob){ob.select()}
function $(ev){return document.getElementById(ev)}
function os(obj){return $(obj).style}
