var d=document;
var ddiv;
function init(){
 ddiv=document.getElementById("DivContent");
var a="rr";
}
//Adding Text using javascript
function txt(string){
return d.createTextNode(string);
}
//Appending the Text to the existing document so now we have
//d.getElementById("DivContent").appendChild(txt("Hello World"));
function lnk(url,text){
var a=d.createElement('a');// Create a element of type hyperlink
a.setAttribute('href',url);// Set the Url
a.appendChild(txt(text));
// Set the displayed text
return a;
}
//example usage document.getElementById("DivContent").appendChild(lnk("http://www.google.com","Hello World"));
function table(column,name){
	var rowcount=0;
	t=d.createElement('table');
	if(name)
		t.setAttribute("class",name);
	h=t.createTHead();
	b=t.appendChild(d.createElement('tbody'));
	function insrow(h,cols,classv){
		var r=h.insertRow(-1);
		if (classv){
			r.setAttribute('class',classv);
		}
		for (var i=0;i<cols.length;i++){
			var c=r.insertCell(-1);
			c.appendChild(cols[i]);
		}
	}
	function ah(cols){//Add header row
		this.insrow(h,cols);
	}
	function ar(cols){//Add a row
		if(rowcount%2)
		{this.insrow(b,cols,"erow");}
		else
		{this.insrow(b,cols,"orow");}
		rowcount++;
	}
	this.ar=ar;
	this.ah=ah;
	this.insrow=insrow;
	this.t=t;
}
// Converting an array to table.
// if we want to convert this array to a html table
 var myArray=[
 [txt("h1"),txt("h2"),txt("h3")],
 [txt("b1"),txt("b2"),txt("b3")],
 [txt("b1"),txt("b2"),txt("b3")],
 [txt("b1"),txt("b2"),txt("b3")],
 [txt("b1"),txt("b2"),txt("b3")]
 ];
// we declare a function arr2tab(array,name)
function arr2tab(array,name){
var length=array[0].length;
t=new table(length,name);
t.ah(array[0]);
for(var i=1;i<array.length;i++){
t.ar(array[i]);
}
return t;
}
//document.getElementById("DivContent").appendChild(arr2tab(myArray,"table").t);
//Showing and hiding a dialog box
//document.getElementById("DivContent").style.display='none';
//document.getElementById("DivContent").style.display='block'
//Movable elements
//document.getElementById("DivContent").style.left='400px'
//document.getElementById("DivContent").style.top='100px'
function mousefollow(event){
posy=event.clientY +2;
posx=event.clientX +2;
//ddiv=document.getElementById("DivContent");
if(!ddiv)return;
ddiv.style.top=posy+"px";
ddiv.style.left=posx+"px";
}
//document.addEventListener('mousemove', drag,false);
function dragstart(event){
mx=event.clientX;
my=event.clientY;
posx=parseInt(ddiv.style.left);
posy=parseInt(ddiv.style.top);
if(!posx)posx=0;
if(!posy)posy=0;
mx=mx-posx;
my=my-posy;
document.addEventListener('mousemove', drag,false);
document.addEventListener('mouseup', dragend,false);
}
function dragend(){
document.removeEventListener('mousemove', drag,false);
document.removeEventListener('mouseup', dragend,false);
}
function drag(event){
posy=event.clientY -my;
posx=event.clientX -mx;
//ddiv=document.getElementById("DivContent");
if(!ddiv)return;
ddiv.style.top=posy+"px";
ddiv.style.left=posx+"px";
}
//document.addEventListener('mousemove', drag,false);
//ddiv.addEventListener('mousedown', dragstart,false);
//myarray= new Array()

//var myarray = [] ;
// var myobject={ 
// a:10, 
// b:15.4, 
// c:"text" 
// }
