function getWindowHeight(x)
{
	var h = 0;
	
	if( typeof( window.innerWidth ) == 'number' )
	{
		h = window.innerHeight;
	} 
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		h = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		h = document.body.clientHeight;
	}

	h = h * (x/100);
	h = Math.round(h);
	return h;
}

/**
 * Create a new node
 * @param {String} name Kind of node you want (i.e. DIV; SPAN etc.)
 * @returns node
 */
function newnode (name)
{
	return document.createElement(name);
}

/**
 * Create a new textnode
 * @param {String} text Content of the new Textnode
 * @returns Textnode
 */
function newtextnode (text)
{
	return document.createTextNode(text);
}

/**
 * Create a new Attribute Node
 * @param {String} attr Name of the new Attribute Node
 * @param {String} val Content of the new Attribute Node
 * @returns Attribute Node
 */
function newAttribute(attr,val)
{
	var ret = document.createAttribute(attr);
	ret.nodeValue=(val);
	return ret;
}

/**
 * Add a new Attribute Node to a Node
 * @param {DOM} node Node you want to add the Attribute to
 * @param {String} attr Name of the new Attribute Node
 * @param {String} val Content of the new Attribute Node
 * @returns Attribute Node
 */
function addNewAttribute(node,attr,val)
{
	if (attr === "style")
	{
		var valarr = val.split(":");
		if (valarr[0]==="text-indent")
		{
			node.style.textIndent=valarr[1].split(";")[0];
		}
		else node.style.valarr[0]=valarr[1].split(";")[0];
	}
	else node.setAttributeNode(newAttribute(attr,val));
}

/**
 * Creates a new div node
 * @param {String} divid id of the div (null to not set id)
 * @param {String} divclass class of the div (null to not set class)
 * @returns new div node
 *
 */
function createDiv (divid,divclass)
{
	var node = document.createElement("div"),
		idattr = document.createAttribute("id"),
		classattr = document.createAttribute("class");
	
	if (divid)
	{
		idattr.nodeValue=divid;
		node.setAttributeNode(idattr);
	}
	
	if (divclass)
	{
		classattr.nodeValue=divclass;
		node.setAttributeNode(classattr);
	}
		
	return node;
}

/**
 * Creates a new link node
 * @param {String} text Text of the Link Node
 * @param {String} url URL of the Link Node
 * @returns new link node
 *
 */
function newLink (text,url)
{
	var ret = newnode("a");
	addNewAttribute(ret,"href",url);
	ret.appendChild(newtextnode(text));
	
	return ret;
}

/**
 * Creates a new image node
 * @param {String} src Filename of image file
 * @param {String} alt alternative display text
 * @returns new image node
 *
 */
function newImg (src,alt)
{
	var ret = newnode("img");
	addNewAttribute(ret,"src",src);
	addNewAttribute(ret,"alt",alt);
	
	return ret;
}

function newTable(node)
{
	var tablenode,tdnode,trnode;
	tablenode = newnode ("table");
	addNewAttribute(tablenode,"class","intextimagetbl");
	trnode = newnode("tr");
	tdnode = newnode("td");
	
	tdnode.appendChild(node);
	trnode.appendChild(tdnode);
	tablenode.appendChild(trnode);
	
	return tablenode;
	
}

function newTable2(tdnode)
{
	var tablenode,trnode;
	tablenode = newnode ("table");
	addNewAttribute(tablenode,"class","intextimagetbl");
	trnode = newnode("tr");
	// tdnode = newnode("td");
	
	// tdnode.appendChild(node);
	trnode.appendChild(tdnode);
	tablenode.appendChild(trnode);
	
	return tablenode;
	
}


