
function drawGradient(startColor, endColor,tag,fixHeight){
try{
// get tag size
var iWidth = 0, iHeight = 0;
if( typeof( tag.innerWidth ) == 'number' ) {
//Non-IE

iWidth = tag.innerWidth;
iHeight = tag.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
iWidth = tag.clientWidth;
iHeight = tag.clientHeight;
}

// set the gradiant background
if (document.all && !window.opera) {
// for IE use DXImageTransform
tag.style.filter="progid:DXImageTransform.Microsoft.Gradient(startColorStr='" + startColor + "', endColorStr='" + endColor + "', gradientType='0')";
} else {
if(fixHeight>0) {
	iHeight = iHeight+fixHeight;
	tag.style.height = iHeight+"px";
}
// set document margin/pading
tag.style.overflow = 'hidden';
tag.style.padding  = '0px';
tag.style.margin   = '0px';

// create DIV that will be used for the canvas and background Image
var oDiv = document.createElement("DIV");
oDiv.style.position    = 'relative';
oDiv.style.height      = iHeight;
oDiv.style.width       = iWidth;
oDiv.style.overflow    = 'hidden';
oDiv.style.zIndex=1;
oDiv.setAttribute("id","canvasDiv");

// create DIV that will contain the whole document
var oDocDiv = document.createElement("DIV");
oDocDiv.style.position    = 'absolute';
oDocDiv.style.height      = iHeight;
oDocDiv.style.width       = iWidth;
oDocDiv.style.overflow    = 'hidden';
oDocDiv.style.zIndex=2;
oDocDiv.setAttribute("id","canvasDiv");
var content = tag.innerHTML;
tag.innerHTML = "";
oDocDiv.innerHTML = content;
//document.body.innerHTML ="";
tag.appendChild(oDiv);
oDiv.appendChild(oDocDiv);

// create canvas
var c = document.createElement("canvas");
c.setAttribute("width",iWidth);
c.setAttribute("height",iHeight);
c.setAttribute("id","cl");
oDiv.appendChild(c);
var ctx = c.getContext("2d");

// create the gradient
var gradient= ctx.createLinearGradient(0,0,0,iHeight)
gradient.addColorStop(0, startColor)
gradient.addColorStop(1, endColor);
ctx.fillStyle = gradient;
ctx.fillRect(0, 0,iWidth,iHeight);

}
} catch(e){
//alert(e);
}
}

