function BrowserDetection(){
  this.appName = "unknown";
  this.appVersion = -1;
  this.isIE = this.isFF = this.isNetscape = this.isOpera = this.isSafari = false;
  this.UA = navigator.userAgent.toLowerCase();

  // IE
  if(this.UA.search(/msie/) != -1){
    this.appName = "IE";
    this.isIE = true;
    this.appVersion = parseFloat(/(msie[^;]*)/.exec(this.UA)[0].split(" ")[1]);
  // Opera
  }else if(this.UA.search(/opera/) != -1){
    this.appName = "Opera";
    this.isOpera = true;
    this.appVersion = parseFloat(/(opera[^\s]*)/.exec(this.UA)[0].split("/")[1]);
  // Firefox
  }else if(this.UA.search(/firefox/) != -1){
    this.appName = "Firefox";
    this.isFF = true;
    this.appVersion = parseFloat(/(firefox[^\s]*)/.exec(this.UA)[0].split("/")[1]);
  // Safari	
  }else if(this.UA.search(/khtml/) != -1){
    this.appName = "Safari (Win)";
    this.isSafari = true;
    this.appVersion = parseFloat(/(version[^\s]*)/.exec(this.UA)[0].split("/")[1]);
  // Safari	
  }else if(this.UA.search(/safari/) != -1){
    this.appName = "Safari";
    this.isSafari = true;
    this.appVersion = parseFloat(/(version[^\s]*)/.exec(this.UA)[0].split("/")[1]);
  // Netscape
  }else if(this.UA.search(/mozilla/) != -1){
    this.appName = "Mozilla";
    this.isNetscape = true;
    this.appVersion = parseFloat(/(mozilla[^\s]*)/.exec(this.UA)[0].split("/")[1]);	
  // Netscape
  }else if(this.UA.search(/netscape/) != -1){
    this.appName = "Netscape";
    this.isNetscape = true;
    this.appVersion = parseFloat(/(netscape[^\s]*)/.exec(this.UA)[0].split("/")[1]);
	}
}
var objUA = new BrowserDetection();

// pseudo-class for IE start

function sfIEStart(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
		});
	}
}

sfHover = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

sfFocus = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
}

sfActive = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmousedown=function() {
			this.className+=" sfactive";
		}
		sfEls[i].onmouseup=function() {
			this.className=this.className.replace(new RegExp(" sfactive\\b"), "");
		}
	}
}

sfTarget = function(sfEls) {
	var aEls = document.getElementsByTagName("A");
	document.lastTarget = null;
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].id) {
			if (location.hash==("#" + sfEls[i].id)) {
				sfEls[i].className+=" sftarget";
				document.lastTarget=sfEls[i];
			}
			for (var j=0; j<aEls.length; j++) {
				if (aEls[j].hash==("#" + sfEls[i].id)) aEls[j].targetEl = sfEls[i];
				aEls[j].onclick = function() {
					if (document.lastTarget) docu.lastTarget.className = document.lastTarget.className.replace(new RegExp(" sftarget\\b"), "");
					if (this.targetEl) this.targetEl.className+=" sftarget";
					document.lastTarget=this.targetEl;
					return true;
				}
			}
		}
	}
}

sfIEStart(sfFocus, "INPUT");
sfIEStart(sfFocus, "TEXTAREA");
sfIEStart(sfFocus, "SELECT");
sfIEStart(sfActive, "SELECT");
// pseudo-class for IE end


// set individual events to tags
  var myEvents = new SetEvents;
  window.onload = function() {myEvents.set();}

  function SetEvents() {
    this.set = function() {
      for (var i = 0; i < document.forms.length; i++) {
				for (var j = 0; j < document.forms[i].length; j++) {
					var el = document.forms[i][j];
					if(el.type && el.value){
						var _type = el.type.toLowerCase();
						var _val = el.value.toUpperCase(); 
						if(-1 != _type.indexOf('text') && -1 != _val.indexOf('TT.MM.JJJJ') ){
							this._setEvent('focus', el, 1);
							this._setEvent('blur', el, 2);
						}	
					}
				}
			}
			for (var i = 0; i < document.links.length; i++){
				this._setEvent('focus', document.links[i], 3);
			}			
		}

    this._setEvent = function(type, el, choice) {
			switch (choice){
				case 1:
							var event = function() {el.value = '';}
							break;
				case 2:
							var event = function() {
								if(!el.value) el.value = 'TT.MM.JJJJ';
							}
							break;	
				case 3:
							var event = function() {el.blur();}
							break;							
			}	
			if(el.addEventListener) {el.addEventListener(type, event, false);}
			else if(el.attachEvent) {el.attachEvent('on'+type, event);}
			else {el['on'+type] = event;}
    }
  }
	
function BlurLinks(){
	lnks=document.getElementsByTagName('a');
	for(i=0;i<lnks.length;i++){lnks[i].onfocus=new Function("this.blur()");}
}

