//domCorners by Alessandro Fulciniti on http://web-graphics.com/mtarchive/001660.php

function DomCheck(){
return(document.createElement && document.getElementById);
}

function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1)
      return false;
   else
      return true;
}

function pausecomp(millis){
	var date = new Date();
	var curDate = null;

	do { curDate = new Date(); }
	while(curDate-date < millis);
} 

function DomCorners(id,bk,h,ipath,tries){
var el;

for(var i=0;i<50;i++){
	if(el=document.getElementById(id)){
		break;
	}
	pausecomp(50);
}
if(!el){
	return;
}
var c=new Array(4);
var ls=new Array(4);//labels
var rd=new Array(4);//radii

if(4==bk.length){
	ls=bk; //tl tr bl br
	rd=h;	
}else{
	ls[0]=ls[1]=ls[2]=ls[3]=bk;
	rd[0]=rd[1]=rd[2]=rd[3]=h;
}
		


for(var i=0;i<4;i++){
    c[i]=document.createElement("b");
    c[i].style.display="block";
    c[i].style.fontSize="1px";

	//alert(rd[i]);
	if(0==rd[i]){
		continue;
	}

	switch(i){
		case 0:			
			c[i].style.background="url("+ipath+"/"+ls[0]+"/tl.png) no-repeat";
		    c[i].style.height=rd[0]+"px";
			break;
		case 1:
			c[i].style.background="url("+ipath+"/"+ls[1]+"/tr.png) no-repeat 100%";
		    c[i].style.height=rd[1]+"px";
			break;
		case 2:
			c[i].style.background="url("+ipath+"/"+ls[2]+"/bl.png) no-repeat";
		    c[i].style.height=rd[2]+"px";
			break;
		case 3:
			c[i].style.background="url("+ipath+"/"+ls[3]+"/br.png) no-repeat 100%";
		    c[i].style.height=rd[3]+"px";
			break;
	}	
}
c[0].appendChild(c[1]);
c[2].appendChild(c[3]);
el.style.padding="0";
el.insertBefore(c[0],el.firstChild);
el.appendChild(c[2]);
}