//--------- UPDATED 12/5/07 ---------------

	function makeCorners(node){
	
		  if (node.hasChildNodes) {
				var iteration;
				for (iteration=0;iteration<node.childNodes.length;iteration++) {
					makeCorners(node.childNodes[iteration]);
				}
		  }
		  
  // format for ATTRIBUTE: corners="round,[radius (0 if none)],[color (0 if background or none)],[shadowOffset (0 if none)],[shadowOpacity (0-1)]"
  // ex: corners=round,10,#000FFF,10,0.50"
		  
		  if (node.getAttribute&&(sty=node.getAttribute('corners'))){
		   
			var arrSty=sty.split(',');
			sty=arrSty[0];
			cornerRadius=parseInt(arrSty[1]);
			shadowOffset=parseInt(arrSty[3]);
			shadowOpacity=arrSty[4];
			
			var n=node;
			
			if (arrSty[2]!=0) {
				borderColor=arrSty[2];
			} else {
				borderColor=n.style.backgroundColor;
			}
						
			if (parseInt(n.offsetWidth)!=0){  

				elWidth=n.offsetWidth;
				elHeight=n.offsetHeight;
				
			} else {  //ROUTINE TO DETERMINE SIZE OF display:none ELEMENTS
			
				var elTemp=document.createElement('div');
				elTemp.style.position='absolute';
				elTemp.style.visibility='hidden';
				document.body.insertBefore(elTemp,document.body.firstChild);
				nodeTemp=n.cloneNode(true);
				elTemp.appendChild(nodeTemp);
				elWidth=nodeTemp.offsetWidth;
				elHeight=nodeTemp.offsetHeight;
				elTemp.parentNode.removeChild(elTemp);
			
			}
			
			if (sty=='round'){
			
				var newDiv=document.createElement('div');
				newDiv.style.width=elWidth+(!document.all?0:0)+'px';
				newDiv.style.styleFloat=n.style.styleFloat;
				newDiv.style.cssFloat=n.style.cssFloat;
				newDiv.style.marginLeft=n.style.marginLeft;
				newDiv.style.marginRight=n.style.marginRight;
				newDiv.style.marginTop=n.style.marginTop;
				newDiv.style.marginBottom=n.style.marginBottom;
				newDiv.style.position=n.style.position==''?'relative':n.style.position;
				newDiv.style.top=n.style.top;
				newDiv.style.left=n.style.left;
				newDiv.style.zIndex=n.style.zIndex;
				
				for (i=cornerRadius;i>=0;i--){
					var newLine=document.createElement('div');
					newLine.style.height='1px';
					newLine.style.overflow='hidden';
					newLine.style.position='relative';
					newLine.style.zIndex='10';
					var mrgn=cornerRadius-Math.cos(Math.asin(i/cornerRadius))*cornerRadius;
					newLine.style.margin='0px ' + mrgn + 'px';
					newLine.style.backgroundColor=borderColor;
					newDiv.appendChild(newLine);	
				}
				
				var orig=n.cloneNode(true);
				orig.style.position='relative';
				orig.style.top='0px';
				orig.style.left='0px';
				orig.style.marginLeft='0px';
				orig.style.marginRight='0px';
				orig.style.marginTop='0px';
				orig.style.marginBottom='0px';
				orig.style.cssFloat='';
				orig.style.styleFloat='';
				newDiv.appendChild(orig);
				
				for (i=1;i<=cornerRadius;i++){
					var newLine=document.createElement('div');
					newLine.style.height='1px';
					newLine.style.overflow='hidden';
					newLine.style.position='relative';
					var mrgn=cornerRadius-Math.cos(Math.asin(i/cornerRadius))*cornerRadius;
					newLine.style.margin='0px ' + mrgn + 'px';
					newLine.style.backgroundColor=borderColor;
					newDiv.appendChild(newLine);	
				}

				n.parentNode.replaceChild(newDiv,n);
				
				if (shadowOffset!=0){
				
					if (document.all && !window.opera){
						var shad=newDiv.cloneNode(true);
						shad.style.position='absolute';
						shad.style.marginLeft='0px';
						shad.style.marginRight='0px';
						shad.style.marginTop='0px';
						shad.style.marginBottom='0px';
						shad.style.top=-shadowOffset/2+'px';
						shad.style.left=-shadowOffset/2+'px';
						shad.style.filter='progid:DXImageTransform.Microsoft.Blur(PixelRadius="'+shadowOffset+'", MakeShadow="true", ShadowOpacity="'+shadowOpacity+'")';
						newDiv.insertBefore(shad,newDiv.firstChild);
					} else {
						var shad=newDiv.cloneNode(true);
						shad.style.marginLeft='0px';
						shad.style.marginRight='0px';
						shad.style.marginTop='0px';
						shad.style.marginBottom='0px';
						var allDivs=shad.getElementsByTagName('div');
						for (i=0;i<allDivs.length;i++){
						allDivs[i].style.backgroundColor='#000000';
						allDivs[i].style.borderColor='#000000';
						}
						shad.style.position='absolute';
						shadowOffset+=5;
						for (x=1;x<=shadowOffset;x++){
							var shad2=shad.cloneNode(true);
							shad2.style.top=x+'px';
							shad2.style.left=x+'px';
							shad2.style.zIndex=0;
							shad2.style.opacity=shadowOpacity/(1*x);
							newDiv.insertBefore(shad2,newDiv.firstChild);
						}
					}
				}
				
			}

		  }
		  
	}
/*------------------------------ZOOM OVERLAY SCRIPT -------------------------*/

var pdfAdder=0; 

function getZoom(url,action){
	pdfAdder=url.indexOf('.pdf')==-1?0:30;
	var size=openOverlay();
	var ifr=document.createElement('iframe');
	ifr.frameBorder='0';
	ifr.style.width=size[0]+'px';
	ifr.style.height=size[1]+'px';
	ifr.id='newFrame';
	ifr.name='newFrame';
	//if (url.indexOf('http://')==-1&&url.indexOf('_returnDetails.cfm?id=')==-1) url='http://'+url;
	ifr.src=url;
	document.getElementById('rolodex').insertBefore(ifr,document.getElementById('rolodex').firstChild);
	document.getElementById('rolodex').setAttribute('corners','round,0,#CCCCFF,8,0.90');
	document.getElementById('rolodex').style.zIndex='20';
	//makeCorners(document.getElementById('rolodex'));
	
	//alert(url);
	document.getElementById('newFrame').src=url;
	//document.getElementById('newFrame').src='module-lounge.cfm';
	
	var closer=document.createElement('div');
	
	var button=document.createElement('input');
	button.type='button';
	button.value='X';
	button.style.border='2px outset white';
	button.style.backgroundColor='#990000';
	button.style.color='white';
	button.style.fontWeight='bold';
	button.style.height='20px';
	button.style.fontSize='8pt';
	button.style.padding='0px 2px';
	button.id='histCloser';
	button.style.position='absolute';
	button.style.left=(size[0]-20)+'px';
	button.style.top='-23px';
	button.onclick=function(){showLess(this.parentNode.parentNode)};

	var button2=document.createElement('input');
	button2.type='button';
	button2.value='Print';
	button2.id='histPrinter';
	button2.style.styleFloat='left';
	button2.style.cssFloat='left';
	button2.style.display='none';
	button2.onclick=function(){printHist()};

	var button3=document.createElement('input');
	button3.type='button';
	button3.value='Create PDF';
	button3.id='makePDF';
	button3.style.styleFloat='left';
	button3.style.cssFloat='left';
	button3.style.display='none';
	button3.onclick=function(){createPDF()};

	var button5=document.createElement('input');
	button5.type='button';
	button5.value='Go to Lounge';
	button5.style.width='90px';
	button5.style.marginRight='10px';
	button5.id='last';
	button5.style.display='none';
	button5.onclick=function(){window.newFrame.document.location.href='module-lounge.cfm'};

	var button6=document.createElement('input');
	button6.type='image';
	button6.src='images/button-forward.gif';
	button6.value='Forward';
	button6.id='next';
	button6.style.display='none';
	button6.onclick=function(){window.newFrame.history.forward()};


	if (url.indexOf('.pdf')==-1){
		closer.style.position='relative';
	} else {
		closer.style.position='relative';
	}
	
	closer.style.top='0px';
	closer.id='closerHolder';
	closer.style.left='0px';
	closer.style.backgroundColor='transparent';
	closer.style.border='none';
	closer.style.padding='0px';
	closer.style.textAlign='left';
	closer.style.position='relative';
	
	closer.appendChild(button5);
	closer.appendChild(button6);
	closer.appendChild(button);
	closer.appendChild(button3);
	closer.appendChild(button2);

	//if (action!='register') {button5.style.display='inline';}
	//if (action=='makePDF'||action=='makeCalendar') button3.style.display='inline';
	//if (action=='makeCalendar') button4.style.display='inline';

	document.getElementById('rolodex').insertBefore(closer,document.getElementById('rolodex').firstChild);

}

			function openOverlay(){
					if (window.pageYOffset) prevScroll=window.pageYOffset;
			
					document.documentElement.style.overflow='hidden';
					window.scrollBy(0,1);
					if (document.documentElement.scrollTop==0){
						document.body.style.overflow='hidden';
					}
			
					var w=document.documentElement.clientWidth;
					var h=document.documentElement.clientHeight;
					if (h==0) h=document.body.clientHeight;
					if (w==0) w=document.body.clientWidth;
			
					var card=document.createElement('div');
					card.id='rolodex';
					with (card.style){
						overflow='visible';
						backgroundColor='white';
						border='1px #CCCCFF solid';
						borderWidth='25px 5px 5px 5px';
						position= 'absolute';
						zIndex=10;
						width = Math.max((w-250),750) + 'px';
						height=(h<600?h-50:h-150) + pdfAdder + 'px';
						top=(window.pageYOffset ? (window.pageYOffset) : (document.documentElement.scrollTop!=0?document.documentElement.scrollTop:document.body.scrollTop))+(h/2-((parseInt(height)+30)/2))+'px';
						left=Math.max((w/2-(parseInt(width)+20)/2),0)+'px';
					}
					var size=new Array()
					size[0]=card.style.width.replace(/px/,'');
					size[1]=card.style.height.replace(/px/,'');
					
					var screener=document.createElement('div');
					screener.id='screen2';
					with (screener.style){
						position='absolute';
						top=(window.pageYOffset ? (window.pageYOffset) : (document.documentElement.scrollTop!=0?document.documentElement.scrollTop:document.body.scrollTop))+'px'
						left='0px';
						width=w+30+'px';
						height=h+10+'px';;
						filter='alpha(opacity=60)';
						opacity='0.60';
						backgroundColor='#000000';
						display='block';
						zIndex=9;
					}
					
					document.body.insertBefore(card,document.body.firstChild);
			
					document.body.insertBefore(screener,document.getElementById('rolodex'));
					setTimeout('setResize()',1000);
					return size;
			}
			
			function setResize(){
				var url=document.getElementById('newFrame').src;
				window.onresize=function(){showLess(document.body.firstChild.nextSibling,url)};	
			}
			
			function showLess(obj,url){
					window.onresize=null;
					if (window.newFrame.document.getElementById('mediaplayer1')){
						window.newFrame.document.getElementById('mediaplayer1').style.display='none';
					}
					document.body.removeChild(obj);
					if (document.getElementById('screen2')) document.body.removeChild(document.getElementById('screen2'))
					document.documentElement.style.overflow='auto';
					window.scrollBy(0,1);
					if (document.documentElement.scrollTop==0){
						document.body.style.overflow='auto';
					}
					
					if (typeof prevScroll!='undefined' && prevScroll!=0) window.scrollTo(0,prevScroll);
					if (typeof(url)!='undefined') getZoom(url);
			}

function printHist(){
	window.top.frames[0].focus();
	window.top.frames[0].print();
}
function createPDF(){
	window.top.frames[0].document.workOrder.submit();
}
function showButtons(){
	window.top.document.getElementById('showCalendar').style.display='inline';
}

/*-------------------------------------- START IT ALL ---------------------*/

window.onload=function(){makeCorners(document)}

