if( typeof("web2js") == "undefined")
{
	web2js = new Object();
}

// sets the background color
web2js.setBgColor = function (obj,strClr)
{	
	obj.style.backgroundColor = strClr;
}

// makes an ID for given object so it can be used in eval statements
web2js.makeId = function (obj)
{
	obj.id = "obj" + web2js.ID_COUNTER;
	obj.id += "obj";
	eval(obj.id + "=obj");
	web2js.ID_COUNTER ++;
}

// returns the object form the document with the given id
web2js.$ = function (strId)
{
	return document.getElementById(strId);
}

// returns the objects with the given tag name in an array
web2js.$ByTags = function (strTagNme)
{
	return document.getElementsByTagName(strTagNme);
}

// adds the given object to the document
web2js.addObj = function(obj,objParent)
{
	var objParent = objParent == null?document.body:objParent;
	objParent.appendChild(obj);
	
}

// creates the dom element
web2js.make = function (strTag)
{
	return window.document.createElement(strTag);
}

// sets the content of the given element
web2js.setCon=function(obj,strTxt)
{
	obj.innerHTML = strTxt;
}


// returns the width  of the object
web2js.gW=function (obj)
{
	return parseInt(obj.style.width);
}

// returns the height  of the object
web2js.gH=function (obj)
{
		return parseInt(obj.style.height);
}

// returns the left position of the object
web2js.gX=function (obj)
{
		return parseInt(obj.style.left);
}

// return the top position of the object
web2js.gY=function (obj)
{
	return parseInt(obj.style.top);
}

web2js.makeAbs=function (obj)
{
    
	alert("in web2js.makeAbs");

	/*
		web2js.sAbs(obj);
		web2js.gX(obj.offsetLeft);
		web2js.gY(obj.offsetTop);
		web2js.gW(obj.offsetWidth);
		web2js.gH(obj.offsetHeight);
	*/

}
web2js.sAbs=function (obj)
{
	if(obj.style.position != "absolute") 
		obj.style.position = "absolute";
}

// sets the size of the given element
web2js.sDim=function(obj,w,h)
{
	obj.style.width =  w + ("px");
	obj.style.height =  h + ("px");
}

// sets the position of the given element
web2js.sPos=function (obj,x,y)
{
	obj.style.left = x + ("px");
	obj.style.top = y + ("px");
}

// adds a layer pushing all others down below it
web2js.add=function (obj,isInline)
{
	var strVal = (isInline == null || isInline == false)?"block":"inline";
	obj.style.display = strVal;
}
// removes a layer pulling all other layers towards it
web2js.remove=function (obj)
{
	obj.style.display = "none";
}
// shows a hidden layer with absolute dimensions
web2js.show=function (obj)
{
	this.sAbs(obj);
	obj.style.visibility = "visible";
}

// hides a hidden layer with absolute dimensions
web2js.hide=function (obj)
{
	this.sAbs(obj);
	obj.style.visibility = "hidden";
}

// add trim methodm to string object
String.prototype.trim = function()
{
	var a = this.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
};

// shows all info related to the given object
web2js.debug=function (obj)
{
	var msg = "";
	var count = 0;
	var it= "	";
	for (property in obj)
	{
		// if the property starts with a number skip it as it makes an error
		if (!isNaN( parseInt( property) ) )
		{
			continue;
		}
		msg += property + "="  + eval(obj.id + "." + property  )  +  it;
		count++
		if(count == 3)
		{
			it = "\n";
		}
		else
		{
			count = 0;
			it = "	";
		}
	}
	alert(msg);
}

// shows all properties of this object
web2js.showProp=function (obj)
{
	var msg = "";
	var count = 0;
	var it= "	";
	for (property in obj)
	{
		msg += property + it;
		count++
		if(count == 3)
		{
			it = "\n";
		}
		else
		{
			count = 0;
			it = "	";
		}
	}
	alert(msg);
}

// normalise the event object into a normal one
web2js.normalise=function (objEvent)
{
    e = new Object();
    
    if( web2js.isIe() )
	{
        e.x = event.x;                 
        e.y = event.y;    
        e.src = event.sourceElement;   
    }
    else // ff
    {
        e.x = objEvent.pageX;
        e.y = objEvent.pageY;
        e.src = objEvent.target; 
    }
    return e;
        
}


// returns true if the browser is i.e.
web2js.isIe=function ()
{
	return  ( navigator.appName.indexOf("Explorer") >=0 )
}

// returns the screen width
web2js.gScreenW=function ()
{	
	if( this.isIe() )
	{
		return document.body.offsetWidth;
	}
	else
	{
		return window.innerWidth;
	}

}

// returns the screen height, doc type must not be set for this to work
//eg: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
web2js.gScreenH=function ()
{	
	if(   this.isIe() )
	{
		return document.body.offsetHeight;
	}
	else
	{
		return window.innerHeight;
	}
}

// returns all the real children for this element
web2js.$Children=function (parent)
{
	var arrObj = new Array();
		
	for(var i=0; i< parent.childNodes.length; i++)
	{
		// fire fox and Safari count blank lines ,must ignore these
		if( parent.childNodes[i].tagName == null) continue;
		arrObj[arrObj.length] = parent.childNodes[i];
	}
	return arrObj;
}

web2js.disbaleUI=function (shouldDisable)
{
	alert( IE );

	//if (Object.findObject('js.ui.adapters.IE.hideShowDDLs'))
	//{
		//js.ui.adapters.IE.hideShowDDLs(shouldDisable);
	//}
}



// used for making id's
web2js.ID_COUNTER = 0;

