var oBrowser = {
	agt: navigator.userAgent.toLowerCase(),
	isOpera: function() {
		return (window.opera?true:false);
	},
	
	isSafari: function() {
		if( this.agt.indexOf("safari") != - 1 ) return true;
		
		return false;
	},	
	isMacIE: function() {
		if( this.agt.indexOf("msie") != -1 && this.agt.indexOf("mac") != -1 ) return true;
		return false; 
	}
}

function jsEncodeURI(v) {
	if(window.encodeURIComponent)
		return window.encodeURIComponent(v);
	else
		return escape(v);
}

function href(page) {
	window.document.location.href=page;
}
//trims spaces at the beginning of a string
function trimB(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  
  return s;
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function trimQuote(s) {
	if( s.substr(0,1) == '"' )
		s = s.substr(1);

	if( s.substr(s.length-1, s.length) == '"' )
		s = s.substring(0, s.length -1);
		
	return s;
}

function validateCatName(value) {
	if( value == "" ) return false;

	if( value == " " ) return false;

	if( value.substring(0,1) == " " ) return false;

	return true;
}

function doFocus(input, text){
	if (input.value == '') {
		return;
	}

	if (input.value == text) {
		input.value = ''; 
		input.className = '';
	}
}

function doBlur(input, text){
	if (input.value==text) {
		return;
	}

	if (input.value == '') {
		input.value = text; 
		input.className = 'inputBox';
	}
}

//code get the x and y of an object
var oCoor = {
	//get the x-coor by calculating the offsetLeft of it's parents.
	getLeft: function(o) {
		var left = 0; 
		while(eval(o)) {
			left += o.offsetLeft; 
			o = o.offsetParent; 
		}
		
		return left;
	},
	//get the y-coor by calculating the offsetTop of it's parents.
	getTop: function(o) {
		var top = 0; 
		while(eval(o)) { 
			top += o.offsetTop; 
			o = o.offsetParent; 
		} 
		
		return top; 
	}
}

function getTagObj(o, tagName) {
	while ( o && o.tagName != tagName) o = o.parentNode;
	return o;
}

function getNextSibling(o, tagName) {
	o = o.nextSibling;
	while( o && o.tagName != tagName) o = o.nextSibling;
	return o;
}
