var roundedCornersPanelScriptsFolder = '../../js/loading';

var roundCornerstyle = {};

function renderpanel(a,b,c,d,e,f,g){
if($get(a)==null){
	alert('Rounded Corners with ID "'+a+'" does not exist');
	return false
	}
	
if($get(a).rel=='roundCornerstyle'){return false}

$stylesheet(
	roundedCornersPanelScriptsFolder+'/roundCornerstyle/roundCorners.css','roundCornersBaseStyleSheet');
	var h=$get(a).innerHTML;
	var i=$get(a).offsetHeight;
	if(window.attachEvent){var j=$get(a).currentStyle.backgroundColor;
		var k=$get(a).parentNode.currentStyle.backgroundColor}
		else{
		var l=window.getComputedStyle;
		var m=window.getComputedStyle($get(a).parentNode,'');
		var j=l($get(a),'').getPropertyValue('background-color');
		var k=m.getPropertyValue('background-color')}
		
	$get(a).className+=' roundedCornersPanel';
	$get(a).rel='roundCornerstyle';
	$get(a).style.background=k;$get(a).innerHTML='';
	if(b=='large'){$get(a).innerHTML=['<div style="position: relative;" id="'+a+'_TopPanel">'+'<div class="roundedCornerElement" style="border-left: solid 2px '+c+'; border-right: solid 2px '+c+'; margin-left: 3px; margin-right: 3px; background: '+j+'; width: auto;">&nbsp;</div>'+'<div class="roundedCornerElement" style="border-left: solid 1px '+c+'; margin-left: 2px; border-right: solid 1px '+c+'; margin-right: 2px; background: '+j+'; width: auto;">&nbsp;</div>'+'<div class="roundedCornerElement" style="border-left: solid 1px '+c+'; margin-left: 1px; border-right: solid 1px '+c+'; margin-right: 1px; background: '+j+'; width: auto;">&nbsp;</div>'+'<div class="roundedCornerElement" style="border-left: solid 1px '+c+'; margin-left: 0px; border-right: solid 1px '+c+'; margin-right: 0px; background: '+j+'; width: auto; height: 2px;">&nbsp;</div>'+'<div class="SkipCorner" style="background: '+j+'; width: 5px; height: 5px; top: 0; left: 0;" id="'+a+'_HidePanelTopLeftCorner">&nbsp;</div>'+'<div class="SkipCorner" style="background: '+j+'; width: 5px; height: 5px; top: 0; right: 0;" id="'+a+'_HidePanelTopRightCorner">&nbsp;</div>'+'</div>'+'<div class="roundedCornersPanelContent" id="'+a+'_content" style="background: '+j+'; padding-left: 5px; padding-right: 5px;">'+h+'</div>'+'<div style="position: relative;" id="'+a+'_BottomPanel">'+'<div class="roundedCornerElement" style="border-left: solid 1px '+c+'; margin-left: 0px; border-right: solid 1px '+c+'; margin-right: 0px; background: #c6c3de; background: '+j+'; width: auto; height: 2px;">&nbsp;</div>'+'<div class="roundedCornerElement" style="border-left: solid 1px '+c+'; margin-left: 1px; border-right: solid 1px '+c+'; margin-right: 1px; background: '+j+'; auto;">&nbsp;</div>'+'<div class="roundedCornerElement" style="border-left: solid 1px '+c+'; margin-left: 2px; border-right: solid 1px '+c+'; margin-right: 2px; background: '+j+'; auto;">&nbsp;</div>'+'<div class="roundedCornerElement" style="border-left: solid 2px '+c+'; border-right: solid 2px '+c+'; margin-left: 3px; margin-right: 3px; background: '+j+'; auto;">&nbsp;</div>'+'<div class="SkipCorner" style="background: '+j+'; width: 5px; height: 5px; bottom: 0; right: 0;" id="'+a+'_HidePanelBottomRightCorner">&nbsp;</div>'+'<div class="SkipCorner" style="background: '+j+'; width: 5px; height: 5px; bottom: 0; left: 0;" id="'+a+'_HidePanelBottomLeftCorner">&nbsp;</div>'+'</div>']}
	if(b=='large'){$get(a+'_content').style.height=i-parseInt('10')+'px'}
	
	if(!d){$get(a+'_HidePanelTopLeftCorner').style.display='block'}
	if(!e){$get(a+'_HidePanelTopRightCorner').style.display='block'}
	if(!f){$get(a+'_HidePanelBottomRightCorner').style.display='block'}
	if(!g){$get(a+'_HidePanelBottomLeftCorner').style.display='block'}}
	

roundCornerstyle.pageload = function(elementid, cornerstyle, dithercolor, topleftcorner, toprightcorner, bottomrightcorner, bottomleftcorner)
{
	if (window.addEventListener){
		window.addEventListener('load', function(e){ renderpanel(elementid, cornerstyle, dithercolor, topleftcorner, toprightcorner, bottomrightcorner, bottomleftcorner); }, false);
	}
	if (window.ActiveXObject){
		window.attachEvent('onload', function(e){ renderpanel(elementid, cornerstyle, dithercolor, topleftcorner, toprightcorner, bottomrightcorner, bottomleftcorner); });
	}
}

roundCornerstyle.demand = function(elementid, cornerstyle, dithercolor, topleftcorner, toprightcorner, bottomrightcorner, bottomleftcorner)
{
	renderpanel(elementid, cornerstyle, dithercolor, topleftcorner, toprightcorner, bottomrightcorner, bottomleftcorner);
}

function $stylesheet(file, id)
{
	var stylesheet = document.createElement('link');
	stylesheet.setAttribute('type', 'text/css');
	stylesheet.setAttribute('rel', 'stylesheet');
	stylesheet.setAttribute('href', file);
	stylesheet.setAttribute('id', id);
	
	if($get(id) == null){
		document.getElementsByTagName('head')[0].appendChild(stylesheet);
	}
}

function $get(stringId){
	return document.getElementById(stringId);
}