/*---------------------Creating nodes - Start--------------------------*/
//Function to return attribute value
function getAttribute(sString, oAttrNode){
	if (oAttrNode){
		for(a=0;a<oAttrNode.length;a++){
			if (oAttrNode[a].nodeName==sString){
				return oAttrNode[a].value;
				break;
			}
		}
		return null;
	}
}

//Function to create iframe under a given div
function createDivIframe(div){
   	if( _bw.iFrame ){
     	dw = div.offsetWidth;
     	dh = div.offsetHeight;
     	var els = document.getElementsByTagName("body");
     	var body = els[0];
     	if( !body ) return null;

    	//paste iframe under the modal
	     underDiv = div.cloneNode(false);
	     underDiv.style.zIndex=div.style.zIndex-1;
	     underDiv.style.margin = "0px";
	     underDiv.style.padding = "0px";
	     underDiv.style.display = "block";
	     underDiv.style.width = dw;
	     underDiv.style.height = dh;
	     underDiv.style.border = "0px solid ";
	     underDiv.innerHTML = "<iframe width=\"100%\" height=\"100%\" frameborder=\"0\"></iframe>";
	     body.appendChild(underDiv);
	     return underDiv;
   	}
   	return null;
}

//Function to create a div
function createDiv(id,css,position,left,top,zindex,height,width){
	var div = document.createElement("div");
	if (css) div.className = css;
	if (id){
		div.id = id;
		div.name = id;
	}
	if (height) div.style.height = height+"px";
	if (width) div.style.width = width+"px";
	if (left) div.style.left = left+"px";
	if (top) div.style.top = top+"px";
	if (position) div.style.position = position;
	if (zindex) div.style.zIndex = zindex;
	return div;
}

//Function to create a tr
function createTr(id,css,width,height,align,valign,colspan,rowspan){
	var tr;
	if( _bw.ie ){
		tr = document.createElement("<tr " + ((id)?"name='"+id+"' id='"+id+"'":"")+" "+((width)?""+width:"")+" "+((height)?"height="+height:"")+" "+((align)?"align="+align:"")+" "+((valign)?"valign="+valign:"")+" "+((colspan)?"colspan="+colspan:"")+" "+((rowspan)?"rowspan="+rowspan:"")+">")
	}
	else{
		tr = document.createElement("tr");
		if (id) tr.setAttribute("name",id);
		if (width) tr.setAttribute("width",width);
		if (height) tr.setAttribute("height",height);
		if (align) tr.setAttribute("align",align);
		if (valign) tr.setAttribute("valign",valign);
		if (colspan) tr.setAttribute("colspan",colspan);
		if (rowspan) tr.setAttribute("rowspan",rowspan);
	}
	if (css) tr.className = css;
	return tr;
}

//Function to create a td
function createTd(id,css,width,height,align,valign,colspan,rowspan,nowrap,tag){
	var td;
	if( _bw.ie ){
		td = document.createElement("<"+((tag)?tag:"td")+" " + ((id)?"name='"+id+"' id='"+id+"'":"")+" "+((width)?"width="+width:"")+" "+((height)?"height="+height:"")+" "+((align)?"align="+align:"")+" "+((valign)?"valign="+valign:"")+" "+((colspan)?"colspan="+colspan:"")+" "+((rowspan)?"rowspan="+rowspan:"")+" "+((nowrap)?"nowrap="+nowrap:"")+">")
	}
	else{
		td = document.createElement("td");
		if (id) td.setAttribute("name",id);
		if (id) td.setAttribute("id",id);
        if (width) td.setAttribute("width",width);
		if (height) td.setAttribute("height",height);
		if (align) td.setAttribute("align",align);
		if (valign) td.setAttribute("valign",valign);
		if (colspan) td.setAttribute("colspan",colspan);
		if (rowspan) td.setAttribute("rowspan",rowspan);
		if (nowrap) td.setAttribute("nowrap",nowrap);
	}
	if (css) td.className = css;
	return td;
}

//Function to create a table
function createTable(id,css,cellspacing,cellpadding,border,width,height,align,valign){
	var table = document.createElement("table");
	if (id) table.setAttribute("name",id);
	if (css) table.className = css;
	if (cellspacing) table.setAttribute("cellSpacing",cellspacing);
	if (cellpadding) table.setAttribute("cellPadding",cellpadding);
	if (border) table.setAttribute("border",border);
	if (width) table.setAttribute("width",width);
	if (height) table.setAttribute("height",height);
	if (align) table.setAttribute("align",align);
	if (valign) table.setAttribute("valign",valign);
	return table;
}

// Function to create a textbox
function createTextBox(id,css,value,size,maxlen,style,title,onchange,readonly){
	var txt;
	if( _bw.ie )
		txt = document.createElement("<input type='text' " + ((id)?"name='"+id+"' id='"+id+"'":"")+" "+((value)?"value='"+value+"'":"") +" " + ((size)?"size='"+size+"'":"")+" "+((maxlen)?"maxlength='"+maxlen+"'":"")+" "+((style)?"style='"+style+"'":"")+" "+((title)?"title='"+title+"'":"")+((onchange)?("onchange="+onchange):"")+((readonly)?" readonly='true'":" ")+" >");
	else{
		txt = document.createElement("input");
		txt.setAttribute("type","text");
		if (id){
			txt.setAttribute("name",id);
			txt.setAttribute("id",id);
		}
		if (value) txt.setAttribute("value",value);
		if (size) txt.setAttribute("size",size);
		if (maxlen) txt.setAttribute("maxlength",maxlen);
		if (style) txt.setAttribute("style",style);
		if (title) txt.setAttribute("title",title);
		if (onchange) txt.setAttribute("onchange",onchange);
	}
	txt.className = css;
	return txt;
}

//Function to create a link
function createLink(id,css,text,title,href,control){
	var lnk;
	if( _bw.ie )
		lnk = document.createElement("<a href='"+((href)?href:"#")+"' " + ((id)?"name='"+id+"' id='"+id+"'":"")+" "+ ((title)?"title="+title:"Click") +" >");
	else{
		lnk = document.createElement("a");
		if (id){
			lnk.setAttribute("id",id);
			lnk.setAttribute("name",id);
		}

		lnk.setAttribute("href",((href)?href:"#"));
		lnk.setAttribute("title",((title)?title:"Click"));
		lnk.onmouseover = function(){window.status = ((title)?title:"Click");return true;};
		lnk.onmouseout = function(){window.status = '';return true;};
	}
	if (css) lnk.className = css;
	if (text) lnk.appendChild(document.createTextNode(text));
	if (control) lnk.appendChild(control);
	return lnk;
}

//Function to create input button tag
function createButton(id,css,value,type,style,onclick,disabled,btnIndex){
	var btn;
	if( _bw.ie )
		btn = document.createElement("<input type='"+((type)?type:"button")+"' "+ ((id)?"name='"+id+"' id='"+id+"'":"") + " " + ((value)?"value='"+value+"'":"")+" "+((style)?"style='"+style+"'":"") +((btnIndex)?"tabIndex='"+btnIndex+"'":"") +((onclick)?onclick:"")+((disabled)?"disabled='true'":' ')+" >");
	else{
		btn = document.createElement("input");
		btn.setAttribute("type",((type)?type:"button"));
		if (id){
			btn.setAttribute("name",id);
			btn.setAttribute("id",id);
		}
		if (value) btn.setAttribute("value",value);
		if (style) btn.setAttribute("style",style);
		if (disabled) btn.setAttribute("disabled",disabled);
		if (btnIndex) btn.setAttribute("tabIndex",btnIndex);
	}
	if (css) btn.className = css;
	return btn;
}

//Function to create select tag
function createSelect(id,css,title){
	var select;
	if( _bw.ie )
		select = document.createElement("<select " + ((id)?"id='"+id+"' name='"+id+"'":"")+" "+ ((title)?"title="+title:"")  + ">");
	else{
		select = document.createElement("select");
		if (id){
			select.setAttribute("name",id);
			select.setAttribute("id",id);
		}
	}
	if (css) select.className = css;
	return select;
}

//Function to create option tag
function createOption(value, text,checked){
	var opt;
	opt = document.createElement("option");
	opt.setAttribute("value",value);
	if (text) opt.appendChild(document.createTextNode(text));
	if (checked)
		if(_bw.ie) opt.selected = true;
		else opt.setAttribute("selected",null);
	return opt;
}

//Function to create img tag
function createImage(id,src,border,width,height,align,title,alt){
	var img;
	if( _bw.ie )
		img = document.createElement("<img " + ((id)?"id='"+id+"' name='"+id+"'":"") + " " + ((src)?"src='"+src+"'":"")+" "+((border)?"border='"+border+"'":"")+" " + ((width)?"width='"+width+"'":"") + " " + ((height)?"height='"+height+"'":"")+ " " + ((align)?"align='"+align+"'":"") + " " + ((title)?"title='"+title+"'":"") + ">");
	else{
		img = document.createElement("img");
		if (src) img.setAttribute("src",src);
		if (id){
			img.setAttribute("name",id);
			img.setAttribute("id",id);
		}
		if (border) img.setAttribute("border",border);
		if (width) img.setAttribute("width",width);
		if (height) img.setAttribute("height",height);
		if (height) img.setAttribute("align",align);
		if (title) img.setAttribute("title",title);
		if (alt) img.setAttribute("alt",alt);
	}
	return img;
}
//Function to create input button tag
function createEl(id,css,value,type,style,_event,isDisabled){
	var btn;
	if( _bw.ie ){
		btn = document.createElement("<input type='"+((type)?type:"button")+"' "+ ((id)?"name='"+id+"' id='"+id+"'":"") + " " + ((value)?"value='"+value+"'":"")+" "+((style)?"style='"+style+"'":"") +"  "+((_event)?(_event+"='false' "):"")+" "+((isDisabled || isDisabled=="true")?("disabled='true'"):" ")+"  >");
		//btn = document.createElement("<input type='"+((type)?type:"button")+"' "+ ((id)?"name='"+id+"' id='"+id+"'":"") + " " + ((value)?"value='"+value+"'":"")+" "+((style)?"style='"+style+"'":"") +"  "+((_event)?(_event+"='false' "):"")+" "+((isDisabled)?("disabled='true'"):" ")+"  >");
	}
	else{
		btn = document.createElement("input");
		btn.setAttribute("type",((type)?type:"button"));
		if (id){
			btn.setAttribute("name",id);
			btn.setAttribute("id",id);
		}
		if (value) btn.setAttribute("value",value);
		if (style) btn.setAttribute("style",style);
		if(_event)btn.setAttribute(_event,'true');
		if(isDisabled)btn.setAttribute("disabled",isDisabled);
	}
	if (css) btn.className = css;
	return btn;
}

//Function to create a th
function createTh(id,css,width,height,value,align,noWrap){
	var th;
	if( _bw.ie ){
		th = document.createElement("<th " + ((id)?"name='"+id+"' id='"+id+"'":"")+" "+((width)?""+width:"")+" "+((height)?"height="+height:"")+" "+((align)?"align="+align:"")+" "+" "+" "+((noWrap)?"noWrap="+noWrap:"")+">")
        th.innerHTML=(value)?""+value:"";
	}
	else{
		th = document.createElement("th");
		if (id) th.setAttribute("name",id);
		if (width) th.setAttribute("width",width);
		if (height) th.setAttribute("height",height);
		if (align) th.setAttribute("align",align);
		 th.innerHTML=(value)?""+value:"";
	}
	if (css) th.className = css;
	return th;
}
/*---------------------Creating nodes - End--------------------------*/

