/*
Scripts for creating all sorts of standard boxes with rounded corners.

	(Not anymore: -- ATTENTION: var template must be given a value in the calling HTML file)

*/

/***************
Round-cornered textbox With Title

optBG -  path to an optional image for left side of box.
if optBG is provided, provide the height of the image in height

*/

function text_flexible_titled(width,title,text,height) // use even number for width to avoid gap with IE :: removed last argument: ,optBG
{
	shift=8;
	
	// height: if height is speficied, overflow stuff will be cut 
	overflow='visible';
	if(typeof height=='undefined')
	{
		height='auto';
		overflow='hidden';//
	}
		
	// MAIN container
	document.write('<div style="width:'+(width)+'px; position:relative;">');	// container 1px #526184 solid;
		
		// TOP container
		document.write('<div style="position:relative; top:0px; right:0px;">');
		
			
			// top title
			document.write('<div class="text roundTight darkBG" style="position:relative; top:0px; right:0px; text-align:center; width:'+(width)+'px; overflow:'+overflow+'">'+title+'&nbsp;</div>'); // this div is relative so that it gives the outer div a height. pos:Absolute divs don't have height.
			
		document.write('<\/div>');
		// end TOP container
		
		// start Middle container
		
		document.write('<div style="position:relative; width:'+width+'px;height:'+(height-shift)+'px; overflow:hidden; z-index=1; " class="midBG">');
				document.write('<div style="padding:5px; padding-bottom:10px; text-align:right;" class="midBG">'+text+'<\/div>');
				
			// background Image
			/*
			if(typeof optBG!='undefined')
			{
				bgimage_left(optBG)
			}
			*/
			
			document.write('<\/div>');
		
			
		// add corners
		just_corners();
		
	document.write('<\/div>'); // close container

}


function randomBox(width,title,text,height,id,optBG) // use even number for width to avoid gap with IE
{
	shift=8;
	
	// height
	if(typeof height=='undefined')
	{
		height='auto';
	}
	
	width = 10;

	// MAIN container
	document.write('<div style="width:'+(width)+'px; position:relative;">');	// container 1px #526184 solid;
		
		// TOP container
		document.write('<div style="position:relative; top:0px; right:0px;">');
		
			
			// top title
			document.write('<div class="text roundTight darkBG" style="position:relative; top:0px; right:0px; text-align:center; width:'+(width)+'px;">'+title+'&nbsp;</div>'); // this div is relative so that it gives the outer div a height. pos:Absolute divs don't have height.
			
		document.write('<\/div>');
		// end TOP container
		
		// start Middle container
		document.write('<div style="position:relative; width:'+width+'px;height:'+(height-shift)+'px; z-index=1; " class="midBG">');
			if(typeof optBG=='undefined') // don't limit left margin
				document.write('<div style="padding:5px; padding-bottom:10px; text-align: right; " class="midBG"><a href="article.php?id='+$id+'">'+text+'</a><\/div>');
			else	// create a 145px margin left of text for side image
				document.write('<div style="padding:5px; padding-bottom:10px; text-align: right; margin-left: 145px;" class="midBG"><a href="article.php?article='+id+'">'+text+'</a><\/div>');
				
			// background/side Image
			if(typeof optBG!='undefined')
			{
				//bgimage_left(optBG);
				document.write('<div style="position:absolute;top:0px; left:0px; z-index:0; cursor:pointer;"><img style="position:absolute; top:0px; left:0px;" src="'+optBG+'" onclick="window.location=\'article.php?article='+id+'\';" />&nbsp;<\/div>');
			}
			
			document.write('<\/div>');
		
			
		// add corners
		just_corners();
		
	document.write('<\/div>'); // close container

}



/***************
Round-cornered Image Box Without title


*/

function image_flexible(width,image) // use even number fir width to avoid gap with IE
{
	shift=8;

	// MAIN container
	document.write('<div style="width:'+(width)+'px; position:relative; padding: 0px;">');	// container 1px #526184 solid;
		
		// image 
		document.write('<img src="'+image+'" alt="." class="roundTight" style="position:relative; width:'+width+'px; margin:0px 0px -1px 0px; padding:0px; text-align: right;" />'); // bottom -1px margin: correct for Mozilla positioning bug

		// add corners
		just_corners();
		
	document.write('<\/div>'); // close container

}



/***************
Round-cornered Image Box With Title


*/

function image_flexible_titled(width,title,image) // use even number fir width to avoid gap with IE
{
	shift=8;

	// MAIN container
	document.write('<div style="width:'+(width)+'px; position:relative; padding: 0px;">');	// container 1px #526184 solid;
		

		// top title
		document.write('<div class="text roundTight darkBG" style="position:relative; top:0px; right:0px; text-align:center; width:'+(width)+'px;">'+title+'&nbsp;</div>'); // this div is relative so that it gives the outer div a height. pos:Absolute divs don't have height.
		// end TOP container
		
		// image 
		document.write('<img src="'+image+'" alt="'+title+'" class="roundTight" style="position:relative; width:'+width+'px; margin:0px 0px -1px 0px; padding:0px; text-align: right;" />'); // bottom -1px margin: correct for Mozilla positioning bug

		// add corners
		just_corners();
		
	document.write('<\/div>'); // close container

}


/***************
Simple Round-cornered Text box without title


*/
function text_flexible(width,text) // use even number fir width to avoid gap with IE  !!! DOES NOT WORK IN IE
{
	shift=8;

	// MAIN container
	document.write('<div style="width:'+(width)+'px; position:relative;">');	// container 1px #526184 solid;
		
			//text
			document.write('<div style="padding:5px; padding-bottom:10px; text-align: right;" class="midBG">'+text+'<\/div>');

			// add corners
			just_corners();
			
	document.write('<\/div>'); // close container

}






/***************
Put rounded corners on div
Must be called from within a Div

the bottom margin is -1 due to a bug in IE

*/
function just_corners() // use even number fir width to avoid gap with IE  !!! DOES NOT WORK IN IE
{
	var shift=8;
	
	// fix positioning bug in Mozilla
	var bot=-1
	var agt=navigator.userAgent.toLowerCase();
	if(agt.indexOf('gecko')!=-1)
		bot="0"; 

			
			// top rounds
			document.write('<div style="position:absolute; top:0px; right:0px; z-index:9;"><img style="position: absolute; top:0px; right:0px;" src="templates/images/corner-topright.gif" />&nbsp;<\/div>');
			document.write('<div style="position:absolute; top:0px; left:0px; z-index:9;"><img src="templates/images/corner-topleft.gif" style="position:absolute; top:0px; left:0px;"/><\/div>');
		
		
			// bottom rounds
			document.write('<div style="position:absolute;bottom:'+bot+'px; right:0px; z-index:9;"><img style="position:absolute; bottom:'+bot+'px; right:0px;" src="templates/images/corner-bottomright.gif" />&nbsp;<\/div>');
			document.write('<div style="position:absolute; bottom:'+bot+'px; left:0px; z-index:9;"><img src="templates/images/corner-bottomleft.gif" style="position:absolute; bottom:'+bot+'px; left:0px;"/><\/div>');

}

function just_bottom_corners() // use even number fir width to avoid gap with IE  !!! DOES NOT WORK IN IE
{
	var shift=8;
	
	// fix positioning bug in Mozilla
	var bot=-1
	var agt=navigator.userAgent.toLowerCase();
	if(agt.indexOf('gecko')!=-1)
		bot="0"; 
		
			// bottom rounds
			document.write('<div style="position:absolute;bottom:'+bot+'px; right:0px; z-index:9;"><img style="position:absolute; bottom:'+bot+'px; right:0px;" src="templates/images/corner-bottomright.gif" />&nbsp;<\/div>');
			document.write('<div style="position:absolute; bottom:'+bot+'px; left:0px; z-index:9;"><img src="templates/images/corner-bottomleft.gif" style="position:absolute; bottom:'+bot+'px; left:0px;"/><\/div>');

}


/***************
Put image at the background, left side of a dive
Must be called from within a Div

*/
function bgimage_left(img,margintop,marginleft) // use even number fir width to avoid gap with IE  !!! DOES NOT WORK IN IE
{
	if(typeof margintop=='undefined')
		margintop=0;
	if(typeof marginleft=='undefined')
		marginleft=0;
		
	document.write('<div style="position:absolute;top:'+margintop+'px; left:'+marginleft+'px; z-index:0;"><img style="position:absolute; top:0px; left:0px;" src="'+img+'" />&nbsp;<\/div>');
}




