function addStyle(styleType){
//style options
	var objStyle=""
	var buttonW=" width: 100px;"
	var defaultBorder=" border: 2px solid #003366; border-top: 2px solid #ddeeff; border-left: 2px solid #ddeeff;"; 
	var buttonBg="background-color: #006699; ";
	var body=""
	if(styleType=="divStyle"){
		objStyle=buttonW+defaultBorder+buttonBg
	}
	else if(styleType=="mOver"){
		objStyle=' onmouseover="this.style.backgroundColor=\'#005588\'; this.style.borderColor=\'#dddddd #ffffff #ffffff #dddddd\'"'
	}
	else if(styleType=="mOut"){
		objStyle=' onmouseout="this.style.backgroundColor=\'#006699\'; this.style.borderColor=\'#ddeeff #003366 #003366 #ddeeff\'"'
	}
	else if(styleType=="page"){
		objStyle='body {';
		objStyle+=' margin: 0px; ';
		objStyle+=' font-family: sans-serif; ';
		objStyle+=' font-weight: bold; ';
		objStyle+=' page: landscape; ';
		objStyle+=' background-color: #dddddd; ';
		objStyle+=' text-align: center; ';
		objStyle+=' overflow: hidden; ';
		objStyle+='} ';
		objStyle+='a {';
		objStyle+=' text-decoration: none; ';
		objStyle+=' color: #ffffff; ';
		objStyle+=' font-size: 11px; ';
		objStyle+='} ';
		objStyle+='a:hover {color: #999999} ';
		objStyle+='.captionDiv { ';
		objStyle+=' text-align: left; ';
		objStyle+=' border-bottom: 1px solid #003366; '; 
		objStyle+=' border-top: 1px solid #003366; ';
		objStyle+=' padding: 5px; ';
		objStyle+=' margin-top: 5px; ';
		objStyle+=' background-color: #ffffff; ';
		objStyle+=' font-weight: normal; ';
		objStyle+=' font-size: 12px; ';
		objStyle+='} ';
		objStyle+='@media print {.noprint{display: none}}';
	}
	else {
		return;
	}
	return objStyle;
}

function useResizeScript() {
var resizeScript='';
	resizeScript+='function getCurrentSize(sizeType){';
	resizeScript+='	if (parseInt(navigator.appVersion)>3) {';
	resizeScript+='	if (navigator.appName=="Netscape") {';
	resizeScript+='	winH = (window.innerHeight);';
	resizeScript+='	winW = (window.innerWidth);';
	resizeScript+='	}';
	resizeScript+='	if (navigator.appName.indexOf("Microsoft")!=-1) {';
	resizeScript+='		winH = (document.body.offsetHeight);';
	resizeScript+='		winW = (document.body.offsetWidth);';
	resizeScript+='		}';
	resizeScript+='	}';
	resizeScript+='	if (sizeType=="w") {return winH} else {return winW}';
	resizeScript+='}';
	resizeScript+='function findDiffVal(diffType){';
	resizeScript+='		var diffVal=0;';
	resizeScript+='		if (diffType==1){diffVal=200-getCurrentSize("w")} else {diffVal=200-getCurrentSize("h")}';
	resizeScript+='		return diffVal';
	resizeScript+='}';
	resizeScript+='function adjustWidth(currentWidth){';
	resizeScript+='/* if there is a caption but the window is small (less than 300px) force window width to be 300 */';
	resizeScript+='	if(caption !="" && currentWidth < 300) {return 300} else {return currentWidth}';
	resizeScript+='}';
	
	return resizeScript;
}

function formatWindow(windowType){
	//create window properties
	var wProps=""
	
	if(windowType=="image") {
		wProps=" top=10,left=10,width=200,height=200,status=1,menubar=1,resizable=1,scrollbar=0,toolbar=0 ";
	}
	else if(windowType=="doc") {
		wProps="top=10,left=10,width=800,height=500,directories=1,location=1,menubar=1,";
		wProps+="scrollbars=1,status=1,toolbar=1,resizable=1 ";	
	}
	else if(windowType=="media") {
		wProps=" top=10,left=10,width=200,height=200,status=0,menubar=0,resizable=1,scrollbar=0,toolbar=0 ";
	}
	else {
		return;
	}
	
	return wProps;
}

function pop_open(thisItem){
	itm = document.all ? document.all[thisItem].style : document.getElementById(thisItem).style;
	itm.display=="inline" ? itm.display="none" : itm.display="inline";
}

function show_picture(link){
var caption='';
var wOffset=70;
var hOffset=70;
window_name='view';
var poppedWindow;

var is_a_picture=link.substring(link.length-3)=='jpg' || link.substring(link.length-3)=='gif';
	if(top.consoleRef){top.consoleRef.close()}

if(is_a_picture){
	if(link.indexOf(';') > -1){
		caption=link.split(';');
		caption[0]="<div class='captionDiv'>"+caption[0]+"</div>";
		link=caption[1];
		caption=caption[0];
		hOffset=130;
	}
	windowProps=formatWindow("image");
	
	top.consoleRef=window.open('',window_name,windowProps);

	consoleContent='';
	consoleContent+='<html><head>';
	consoleContent+='<style>'+addStyle("page")+'</style>';
	consoleContent+='<scr';
	consoleContent+='ipt language="javascript" type="text/javascript">';
	consoleContent+='var caption="'+caption+'";';
	consoleContent+=useResizeScript();
	consoleContent+='top.resizeTo(200,200);';
	consoleContent+='</scr';
	consoleContent+='ipt>';
	consoleContent+='</head><body onload="self.focus()"><center>';
	consoleContent+='<scr';
	consoleContent+='ipt language="javascript" type="text/javascript">';
	consoleContent+='var newSizeW=findDiffVal(1);';
	consoleContent+='var newSizeH=findDiffVal(0);';
	consoleContent+='</scr';
	consoleContent+='ipt>';
	consoleContent+='<img src="'+link+'" border="0" ';
	consoleContent+='onLoad="if(this.height > 460){this.height=460}; if(this.width < 250){this.width=250}';		
	consoleContent+='top.resizeTo(this.width+newSizeH+'+wOffset+',this.height+newSizeW+'+hOffset+');" ';
	consoleContent+='onerror=this.style.visibility="hidden" style="border: 2px solid #666666; margin-top: 5px"><br>';
	consoleContent+= caption;
	consoleContent+='<br><div style="'+addStyle("divStyle")+'"'+addStyle("mOver")+addStyle("mOut")+' class="noprint">';
	consoleContent+='<a href="javascript: void window.close()">Close Window</a></div>&nbsp;';
	consoleContent+='</center></body></html>';

	 setTimeout("top.consoleRef.document.writeln(consoleContent)",400);
	 //top.consoleRef.document.writeln(consoleContent)
	 top.consoleRef.document.close();
	}

	else {
		window_name='Doc_View';
		poppedWindow=window.open(link,window_name,formatWindow('doc'));
		poppedWindow.focus()		
	}
}

/*
	fileName: include filename in path, if you want a caption then this format 'filename;caption'
	autoStartValue: set this to 0 for audio 1 for video
	mediaHeight: height of the media, if you have an especially long caption then this format mediaHeight;extra height in pixels
	mediaWidth: width of the media
*/
function mediaPop(fileName,autoStartValue,mediaHeight,mediaWidth){
var caption='';
var wOffset=70;
var hOffset=200;
var title='';

//FOR OPTIONAL MEDIA HEIGHT
//	if(mediaHeight.indexOf(';') > -1){
//		mediaHeight=mediaHeight.split(';');
//		mediaHeight=mediaHeight[0];
//		hOffset+=mediaHeight[1];
//	}		

	if(fileName.indexOf(';') > -1){
		caption=fileName.split(';');
		title=caption[0];
		caption[0]="<br><div class='captionDiv'>"+caption[0]+"</div>";
		fileName=caption[1];
		caption=caption[0];
		hOffset=250;
	}

	
	windowProps=formatWindow("media");
	window_name='ADC_Audio';
	top.consoleRef=window.open('',window_name,windowProps);

	consoleContent='';
	consoleContent+='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
	consoleContent+='<html><head>';
	consoleContent+='<title>'+title+'</title>';
	consoleContent+='<style>'+addStyle("page")+'</style>';
	consoleContent+='<scr';
	consoleContent+='ipt language="javascript" type="text/javascript">';
	consoleContent+=useResizeScript();
	consoleContent+='top.resizeTo(200,200);';
	consoleContent+='</scr';
	consoleContent+='ipt>';
	consoleContent+='</head><body onload="self.focus()"><center>';
	consoleContent+='<scr';
	consoleContent+='ipt language="javascript" type="text/javascript">';
	consoleContent+='var newSizeW=findDiffVal(1)+'+(mediaWidth+wOffset)+';';
	consoleContent+='var newSizeH=findDiffVal(0)+'+(mediaHeight+hOffset)+';';
	consoleContent+='top.resizeTo(newSizeW,newSizeH); ';
	consoleContent+='</scr';
	consoleContent+='ipt>';
	consoleContent+=caption;
	consoleContent+='<br><p style="width: '+mediaWidth+'px; height: '+mediaHeight+'px; ';
	consoleContent+='background-color: #000000; border: 1px solid #000000;">';
	consoleContent+='<object id="MediaPlayer" height="'+mediaHeight+'" width="'+mediaWidth+'" style="position:relative; z-index:5" ';
	consoleContent+='classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" ';
	consoleContent+='standby="Loading Windows Media Player components..." ';
	consoleContent+='type="application/x-oleobject" ';
	consoleContent+='codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"> ';
	consoleContent+='<param name="filename" value="'+fileName+'">';
	consoleContent+='<param name="Showcontrols" value="True"><param name="autoStart" value="False">';
	consoleContent+='<embed type="application/x-mplayer2" src="'+fileName+'" name="MediaPlayer" ';
	consoleContent+='autostart="'+autoStartValue+'" width="'+mediaWidth+'" height="'+mediaHeight+'" style="position:relative; z-index:5"></embed>';
	consoleContent+='</object></p>';
	consoleContent+='<div style="'+addStyle("divStyle")+'"'+addStyle("mOver")+addStyle("mOut")+' class="noprint">';
	consoleContent+='<a href="javascript: void window.close()">Close Window</a></div>&nbsp;';
	consoleContent+='</body></html></center>';

	 setTimeout("top.consoleRef.document.writeln(consoleContent)",400);

	//top.consoleRef.document.writeln(consoleContent)
	top.consoleRef.document.close();

}
