//-------------------------------------------------------------------
// isInteger(value)
// Returns true if value contains all digits
//-------------------------------------------------------------------
function isInteger(val){
	if (isBlank(val)){return false;}
	for(var i=0;i<val.length;i++){
		if(!isDigit(val.charAt(i))){return false;}
	}
	return true;
}
	
//-------------------------------------------------------------------
// isBlank(value)
// Returns true if value only contains spaces
//-------------------------------------------------------------------
function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
	}
	return true;
}
	
//-------------------------------------------------------------------
// isDigit(value)
// Returns true if value is a 1-character digit
//-------------------------------------------------------------------
function isDigit(num) {
	if (num.length>1){return false;}
	var string="1234567890";
	if (string.indexOf(num)!=-1){return true;}
	return false;
}

function addToFavorites() {
	if (document.all){
		window.external.AddFavorite(document.location.href, document.title);
	}else if(window.sidebar){
		window.sidebar.addPanel(document.title, document.location.href,"");
	}else{
		return true;
	}
}

function openPopup(strURL,strType,strHeight,strWidth) {
	var strOptions="";
	if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth+",top=50,left=50";
	if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth+",top=50,left=50";
	if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth+",top=50,left=50";
	window.open(strURL, 'newWin', strOptions);
}

// Tool-Tip
var isMinIE = (document.all)    ? 1 : 0;
		
		
function truebody() {
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function hideTip() {
	document.getElementById('tipMessage').style.display = "none";
}

function followMouse(e, div_id) {
	var div = document.getElementById(div_id);
	div.style.display="block";
	var divh = div.offsetHeight;
	var divw = div.offsetWidth;
	if(isMinIE){
		var x = window.event.x;
		var y = window.event.y;
	 	// prozor
		var winh = truebody().clientHeight;
		// window height
		var offseth = truebody().scrollTop; // scroll up
		var contenth = truebody().scrollHeight; // content height

		var bot = y+divh;
		if(bot > winh) {
			var new_top = y-divh;
			div.style.top=offseth+new_top;
		} else {
			div.style.top=offseth+y;
		}

		var winw = truebody().clientWidth;
		var offsetw = truebody().scrollLeft;
		var contentw = truebody().scrollWidth;
		var right_line = x-offsetw+divw;
		if(right_line > winw) {
			var new_left = x-divw-15;
			div.style.left=new_left;
		} else {
			div.style.left=x+15;
		}
	}else{
		var x = e.pageX;
		var y = e.pageY;
		var winh = window.innerHeight;
		var offseth = truebody().scrollTop;
		var contenth = truebody().scrollHeight;
		var bot = y-offseth+divh;
		if(bot > winh) {
			var new_top = y-divh;
			div.style.top=new_top;
		} else {
			div.style.top=y;
		}
		var winw = window.innerWidth;
		var offsetw = truebody().scrollLeft;
		var contentw = truebody().scrollWidth;
		var right_line = x-offsetw+divw+16; // 16 for scroller width
		if(right_line > winw) {
			var new_left = x-divw-15;
			div.style.left=new_left;
		} else {
			div.style.left=x+15;
		}
	}
}

function hideToolTip(id) {
	document.getElementById(id).style.display = 'none';
}