// DETECT BROWSERS
function Browser(){
  var ua,s,i
  ua = navigator.userAgent
  this.isIE=false; this.isMacIE=false; this.isGecko=false; this.isSafari=false; this.version=null;
  s="MSIE"
  if ((i=ua.indexOf("MSIE"))>=0){
    this.isIE=true
	if ((i=ua.indexOf("MSIE"))>=0 && (ua.indexOf("Mac"))>=0)
		this.isMacIE=true
    this.version=parseFloat(ua.substr(i+s.length))
    return
  }
  s="Gecko/"
  if ((i=ua.indexOf(s))>=0){
    this.isGecko=true
    this.version=parseInt(ua.substr(i+s.length))
    return
  }
  s="Safari/"
  if ((i=ua.indexOf(s))>=0){
    this.isSafari=true
    this.version=parseFloat(ua.substr(i+s.length))
    return
  }
}
var browser=new Browser()


// FORM COLORIZER
var alertFlashColor="#747AE1".toLowerCase()
var alertColor="#BFC0DC".toLowerCase()
var focusInput="#76C7FE".toLowerCase()
var focusButton="#4D90B9".toLowerCase()
var mouseoverButton="#8AA8BA".toLowerCase()
function fncColorForm(){
	for(var i=0; i<document.forms.length; i++){
		theForm=document.forms[i]
		for(var ii=0; ii<theForm.length; ii++){
			theForm[ii].onfocus=fncColor;theForm[ii].onblur=fncColor;theForm[ii].onmouseover=fncColor;theForm[ii].onmouseout=fncColor}
		}
	}
function fncColor(e){
	if(!e) var e=window.event
	if(e.target) targ=e.target
	else if(e.srcElement) targ=e.srcElement
	if(targ.style.backgroundColor!==alertColor && targ.style.backgroundColor!==alertFlashColor && targ.id!=="noEffect"){
		if(e.type=='focus'){
			if(targ.type!='submit' && targ.type!='button' && targ.type!='reset')
				targ.style.backgroundColor=focusInput
			else if(targ.type=='submit' || targ.type=='button' || targ.type=='reset')
				targ.style.backgroundColor=focusButton
			}
		else if(e.type=='mouseover' && (targ.type=='submit' || targ.type=='button' || targ.type=='reset'))
			targ.style.backgroundColor=mouseoverButton
		else if(e.type=='mouseout' && (targ.type=='submit' || targ.type=='button' || targ.type=='reset'))
			targ.style.backgroundColor=''
		else if(e.type=='blur')
			targ.style.backgroundColor=''
		}
	}
// select form item
function form_selectfirst(){
if (document.forms[0]){
for (var i = 0; i<document.forms[0].elements.length; i++){
if (document.forms[0].elements[i].type != 'hidden' && document.forms[0].elements[i].disabled != 'true'){
switch (document.forms[0].elements[i].type) {
	case "hidden":
		break;
	case "text":
		document.forms[0].elements[i].select();
		document.forms[0].elements[i].click();
		break;
	case "file":
		document.forms[0].elements[i].select();
		document.forms[0].elements[i].focus();
		break;
	case "password":
		document.forms[0].elements[i].select();
		document.forms[0].elements[i].click();
		break;
	case "select-multiple":
		document.forms[0].elements[i].focus();
		break;
	case "select-one":
		document.forms[0].elements[i].focus();
		break;
	case "checkbox":
		document.forms[0].elements[i].focus();
		break;
	case "radio":
		document.forms[0].elements[i].focus();
		break;
	case "submit":
		document.forms[0].elements[i].focus();
		break;
	case "reset":
		document.forms[0].elements[i].focus();
		break;
	case "image":
		document.forms[0].elements[i].focus();
		break;
	case "button":
		document.forms[0].elements[i].focus();
		break;
}
i = document.forms[0].elements.length;
}
}
}
}

	
// DYNAMIC ONLOAD
ua=navigator.appVersion
isMac=(ua.indexOf("Mac")!=-1) ? true : false
IEmac=((document.all)&&(isMac)) ? true : false
IE4=((document.all)&&(ua.indexOf("MSIE 4.")!=-1)) ? true : false
var gSafeOnload = new Array()
function SafeAddOnload(f){
	if(IEmac&&IE4){
		window.onload=SafeOnload;gSafeOnload[gSafeOnload.length]=f}
	else if(window.onload){
		if (window.onload!=SafeOnload){
			gSafeOnload[0]=window.onload;window.onload=SafeOnload}		
		gSafeOnload[gSafeOnload.length]=f
		}
	else
		window.onload=f
	}
function SafeOnload(){
	for(var i=0;i<gSafeOnload.length;i++)
		gSafeOnload[i]()
	}