var toolTip = {
	xCord : 0,
	yCord : 0,
	tipElements : ['input','select','textarea'],
	obj : Object,
	tip : Object,
	statusMsg : "",
	DivObj : Object,
	active : 0,
	init : function(){
		if ( !document.getElementById ||
			!document.createElement ||
			!document.getElementsByTagName ) {
			return;
		}
		this.tip = document.createElement('div');
		this.tip.id = 'toolTip';
		document.getElementsByTagName('body')[0].appendChild(this.tip);
		this.tip.style.top = '0px';
		this.tip.style.left = '0px';
		this.tip.style.position ="absolute";
		this.tip.style.zIndex="5000";
		this.tip.style.visibility = 'hidden';
		this.tip.innerHTML = 'Loding...';
		this.createAttributes();
	},
	createAttributes : function(){
		var i,j,k;
		var tipLen = toolTip.tipElements.length;
		for(i=0;i<ipFields.length;i++){
			for ( j=0; j<tipLen; j++ ) {
				var current = document.getElementsByTagName(toolTip.tipElements[j]);
				for ( k=0; k<current.length;k++){
					if(current[k].name==ipFields[i]){
						try{
							/*if(current[k].getAttribute('onblur')){ addEvent(current[k],'blur',toolTip.tipBlur); }else{addEvent(current[k],'blur',toolTip.tipBlur);}*/
							if(current[k].getAttribute('onblur')) current[k].removeAttribute('onblur');
							if(current[k].getAttribute('onkeyup')) current[k].removeAttribute('onkeyup');
							if(current[k].getAttribute('onfocus')) current[k].removeAttribute('onfocus');
							addEvent(current[k],'blur',toolTip.tipBlur);
							addEvent(current[k],'keyup',toolTip.tipKeyUp);
							addEvent(current[k],'focus',toolTip.tipOver);
						}catch(e){}
					}
				}
			}
		}
	},
	createAttribute : function(Element){
		try{
			if(Element.getAttribute('onblur')) Element.removeAttribute('onblur');
			if(Element.getAttribute('onkeyup')) Element.removeAttribute('onkeyup');
			if(Element.getAttribute('onfocus')) Element.removeAttribute('onfocus');
			addEvent(Element,'blur',toolTip.tipBlur);
			addEvent(Element,'keyup',toolTip.tipKeyUp);
			addEvent(Element,'focus',toolTip.tipOver);
		}catch(e){}
	},
	getposOffset : function(what, offsettype){
		var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
		var parentEl=what.offsetParent;
		while (parentEl!=null){
			totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
			parentEl=parentEl.offsetParent;
		}
		return totaloffset;
	},
	iecompattest : function(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
	},
	clearbrowseredge : function(obj, whichedge){
		var horizontal_offset="9px";
		var vertical_offset="0";
		var ie=document.all;
		var ns6=document.getElementById&&!document.all;
		var Obj = toolTip.tip;
		var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1;
		if (whichedge=="rightedge"){
			var windowedge=ie && !window.opera? toolTip.iecompattest().scrollLeft+toolTip.iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40;
			Obj.contentmeasure=Obj.offsetWidth;
			if (windowedge-Obj.x < Obj.contentmeasure)
			edgeoffset=Obj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset);
		}else{
			var windowedge=ie && !window.opera? toolTip.iecompattest().scrollTop+toolTip.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
			Obj.contentmeasure=Obj.offsetHeight;
			if (windowedge-Obj.y < Obj.contentmeasure)
				edgeoffset=Obj.contentmeasure-obj.offsetHeight;
		}
		return edgeoffset;
	},
	updateXY : function(e) {
		var Obj = toolTip.tip;
		Obj.x=toolTip.getposOffset(e, "left");
		Obj.y=toolTip.getposOffset(e, "top");
		try{
			Obj.style.left=Obj.x-toolTip.clearbrowseredge(e, "rightedge")+e.offsetWidth+"px";
			Obj.style.top=Obj.y-toolTip.clearbrowseredge(e, "bottomedge")+"px";
		}catch(e){}
		Obj.xCord=Obj.x-toolTip.clearbrowseredge(e, "rightedge")+e.offsetWidth+"px";
		Obj.yCord=Obj.y-toolTip.clearbrowseredge(e, "bottomedge")+"px";
	},
	tipOut: function() {
		try{
			if ( window.tID ) {
				clearTimeout(tID);
			}
			if ( window.opacityID ) {
				clearTimeout(opacityID);
			}
			toolTip.tip.innerHTML="";
			toolTip.tip.style.visibility = 'hidden';
		}catch(e){}
	},
	tipOver : function(e) {
		try{toolTip.obj = this;}catch(e){toolTip.obj = e;}
		tID = window.setTimeout("toolTip.tipShow()",500);
		try{toolTip.updateXY(this);}catch(e){toolTip.updateXY(e);}
	},
	tipKeyUp : function(e){
		/*if(e.keyCode==9 || e.keyCode=="9"){
			try{toolTip.obj = this;}catch(er){toolTip.obj = e;}
			tID = window.setTimeout("toolTip.tipShow()",500);
			try{toolTip.updateXY(this);}catch(er){toolTip.updateXY(e);}
		}else{
			toolTip.tipOut(e);
		}*/
	},
	tipBlur: function(e){
		try{
			toolTip.obj = this;
			toolTip.tip.style.visibility='hidden';
			toolTip.DivObj = document.getElementById("Div_"+this.name);
			toolTip.tipShowError();
		}catch(e){}
	},
	tipShowError : function(){
		var scrX = Number(this.xCord);
		var scrY = Number(this.yCord);
		var tp = parseInt(scrY+15);
		var lt = parseInt(scrX+10);
		this.statusMsg = tipStatus(toolTip.obj,"message");
		if(this.statusMsg!=0){
			this.DivObj.innerHTML = '<img src="http://imgs.indiaproperty.com/icons/redarrow.gif" hspace="5" alt="" />' + this.statusMsg;
			this.DivObj.style.display="";
			this.DivObj.style.opacity = '.1';
			this.DivFade(60);
		}else {
			this.DivObj.innerHTML = "";
			this.DivObj.style.display="none";
		}
	},
	tipShow : function(){
		try{
			this.tip.innerHTML="";
			var scrX = Number(this.xCord);
			var scrY = Number(this.yCord);
			var tp = parseInt(scrY+15);
			var lt = parseInt(scrX+10);
			this.statusMsg = tipStatus(toolTip.obj,"tooltip");
			if(this.statusMsg!=0){
				this.tip.innerHTML = this.statusMsg;
				this.tip.style.opacity = '.1';
				this.tip.style.visibility = 'visible';
				this.tipFade(60);
			}else{
				toolTip.tipOut();
			}
		}catch(e){}
	},
	tipFade: function(opac) {
		var passed = parseInt(opac);
		var newOpac = parseInt(passed+10);
		if ( newOpac < 80 ) {
			this.tip.style.opacity = '.'+newOpac;
			this.tip.style.filter = "alpha(opacity:"+newOpac+")";
			opacityID = window.setTimeout("toolTip.tipFade('"+newOpac+"')",20);
		}
		else {
			this.tip.style.opacity = '.80';
			this.tip.style.filter = "alpha(opacity:80)";
		}
	},
	DivFade: function(opac) {
		var passed = parseInt(opac);
		var newOpac = parseInt(passed+10);
		if ( newOpac < 80 ) {
			this.DivObj.style.opacity = '.'+newOpac;
			this.DivObj.style.filter = "alpha(opacity:"+newOpac+")";
			opacityID = window.setTimeout("toolTip.DivFade('"+newOpac+"')",20);
		}
		else {
			this.DivObj.style.opacity = '.80';
			this.DivObj.style.filter = "alpha(opacity:80)";
		}
	}
};
function pageLoader(){
	toolTip.init();
}
addEvent(window,'load',pageLoader);
