/**************************************************************************/
var $ = function(id,parent){
	if(parent == null) parent = document;
	var o = parent.getElementById(id);
	return o;
}

var GetObject = function(id,parent){
	if(parent == null) var parent = document;
	var o = parent.getElementsByName(id);
	if(o.length>1) return o; 
	else if(o.length==1) return o[0];
	else if(o.length==0) var o = parent.getElementById(id); if(o){ return o; }
	else alert('Error! Element \''+id+'\'does not exists!'); 
	return false;
}
var GetObjectParent = function(id){
	return GetObject(id).parentNode;
}
var GetObjectChildren = function(id){
	return GetObject(id).childNodes;
}
/*
var $ = function(id,parent){
	if(parent == null) parent = document;
	var o = parent.getElementById(id);
	return o;
}
*/
function getChildIndex(o,type,back){
	var tmp = o.parentNode;
	for(i=0;i<back;i++) tmp = tmp.parentNode;
	if(type!='') var childs = tmp.getElementsByTagName(type);
	else var childs = tmp.childNodes;
	for(i=0;i<childs.length;i++){ if(childs[i]==o) return i; }
}

var getParentTag = function(o,t){
	var p = o.parentNode;
	if(!p){
		return false;
	}else{
		if(p.tagName.toLowerCase()==t) return p;
		else return getParentTag(p,t);
	}
}
/*
var getElementsByClassName = function(str,type,child){
        var tmp = new Array();
        var o = child.getElementsByTagName(type);
        for(var i=0;i<o.length;i++){
                if(o[i].className.match(str)) tmp.push(o[i])
        }
        return tmp;
}
*/
function getElementsByClassName(str,type,child){
	str = str.replace(/\-/g, "\\-");
	var regexp = new RegExp("(^|\\s)" + str + "(\\s|$)");
	var tmp = new Array();
	var o = child.getElementsByTagName(type);
	for(var i=0;i<o.length;i++){
		if(regexp.test( o[i].className )) tmp.push(o[i]);
	}
	return tmp;
}

var createTag = function(type,params){
	if(type){
		var o = document.createElement(type);
		for(var key in params){
			if(key=='id') o.setAttribute('id',params[key]);
			if(key=='name') o.setAttribute('name',params[key]);
			if(key=='value') o.setAttribute('value',params[key]);
			if(key=='className') o.setAttribute('class',params[key]);
			if(key=='src') o.src = params[key];
			if(!(key=='id' | key=='name' | key=='value' | key=='className' | key=='src' )) o.style[key] = params[key];
		}
		return o;
	}
	return false;
}


var isArray = function(o){
	if(o.constructor.toString().indexOf("Array") == -1) return false;
	return true;
}

function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}
function isFunction(a) {
    return typeof a == 'function';
}
function stripHTML(t){
	return t.replace(/(<([^>]+)>)/ig,"");
}                
/**************************************************************************/
/*
document.layers  	The surfer is using NS 4
document.all 	The surfer is using IE 4+
window.opera 	The surfer is using Opera of some version
document.getElementById 	The surfer is using IE5+ OR NS6+/ Firefox
document.getElementById &&
!document.all

var isFF = function(){ if(document.getElementById && !document.all) return true; }
var isOP = function(){ if(window.opera) return true; }
var isIE = function(){ return false; }
*/

isFF = function(){
	if (navigator.appName.indexOf("Netscape")!=-1) return true;
}
isIE = function(){
	if (navigator.appName.indexOf("Microsoft")!=-1) return true;
}
isOP = function(){
	if (navigator.appName.indexOf("Opera")!=-1) return true;
}

if (!isIE()) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMousePosition;
  var _x;
  var _y;

function getMousePosition(e) {
  if (!isIE()) {
    _x = e.pageX;
    _y = e.pageY;
  }
  if (isIE()) {
//    _x = event.clientX + document.body.scrollLeft;
//    _y = event.clientY + document.body.scrollTop;
	try{
		_x = event.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;
		_y = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}catch(e){}
  }
  return true;
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
/**************************************************************************/

var GetOpacity = function(o){
	if(isFF()) return o.style.MozOpacity*1;
	if(isIE()) return (o.filters.alpha.opacity)/100;
	if(isOP()) return o.style.opacity*1;
}

var SetOpacity = function(o,value){
	if(isFF()) o.style.MozOpacity = value;
	if(isIE()) o.filters.alpha.opacity = (value*100);
//	if(isIE()) o.filters = 'Alpha(Opacity='+(value*100)+')';
	if(isOP()) o.style.opacity = value;
}

var GetW = function(o){ return parseInt(o.style.width); }
var GetH = function(o){ return parseInt(o.style.height); }
var SetW = function(o,val){ o.style.width = val+'px'; }
var SetH = function(o,val){ o.style.height = val+'px'; }

var GetL = function(o){ return parseInt(o.style.left); }
var GetT = function(o){ return parseInt(o.style.top); }
var SetL = function(o,val){ o.style.left = val+'px'; }
var SetT = function(o,val){ o.style.top = val+'px'; }


function stripHTML(val){
	var re= /<\S[^><]*>/g
	//for (i=0; i<arguments.length; i++)
	//arguments[i].value=arguments[i].value.replace(re, "")
	return val.replace(re, "")
}

