#!/oracle/app/oracle/product/7.3.3/bin/oraperl

##### set Oracle's variables #####
$ENV{'ORACLE_HOME'}='/oracle/app/oracle/product/7.3.3';
$ENV{'ORACLE_SID'}='rabbit';
$orauser="vod";
$orapass="vod";

#### set web server address ####
$WSA = "http://clarissa.npac.syr.edu/vod";
$PROJDIR="/project/K136/VOD";


print ("Content-type: TEXT/HTML\n\n");
print <<"EndOfHTML"; 
<html>
<head>
<TITLE>Video News Database - Select an Archive </TITLE>
<script>
document.bgColor=top.menu.document.bgColor
function setCookie(name, value, expire) {
	document.cookie = name + "=" + escape(value)
	+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}
function getCookie(Name) {
	var search = Name + "="
	if(document.cookie.length > 0){
		var offset = document.cookie.indexOf(search)
		if (offset != -1) {
			offset += search.length
			var end = document.cookie.indexOf(";", offset)
			if (end == -1)
				end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		}
	}
}
function setArchive(value) {
	var today = new Date()
	var expires = today
	expires.setTime(today.getTime() + 3600*24*7)
	setCookie("CurrentArchive", value, expires)
}
</script>
</head>
<body>
<script>
var aid = -1
if (getCookie("CurrentArchive")) {aid = getCookie("CurrentArchive")}
</script>
<H1>Select Archive</H1>
<HR>
<FONT Size="3"> 
<FORM NAME="selColl" >
<SELECT NAME="archiveid" SIZE="10">
<script>
  document.writeln("<OPTION VALUE='0' > ALL ARCHIVES <BR>")
</script>
EndOfHTML
##### oracle login #####
$lda = &ora_login('', $orauser, $orapass);

$csr = &ora_open($lda, 
                 "select distinct archiveid, aname, adesc from archivetable 
		  order by aname");

while ( ($archid, $aname, $adesc ) = &ora_fetch($csr))
{
    print ("<OPTION VALUE=\"$archid\"> $aname : $adesc  \n");

}

&ora_close($csr);
##### oracle logoff ##### 
&ora_logoff($lda);

print <<"EndOfHTML"; 
</SELECT><P>
<INPUT TYPE="text" NAME="text1" SIZE="63" VALUE="Select an archive!"><p>
<INPUT TYPE="button" VALUE=" SELECT " NAME="button1"
OnClick="var sid = document.selColl.archiveid.selectedIndex;
         var aid = document.selColl.archiveid.options[sid].value;
         setArchive(aid); 
	 document.selColl.button1.value = 'SELECTED';
document.selColl.text1.value = 'All operations will be performed on clips belonging to selected archive';
 	 ">
<script>
for (var i = 0; i < document.selColl.archiveid.options.length; i++) {
  if (document.selColl.archiveid.options[i].value == aid) {
    document.selColl.archiveid.selectedIndex = i
  }
}
</script>
</FORM>
<HR>
</BODY>
</HTML>
EndOfHTML


