// var timerID = null;
// var timerRunning = false;

// time
function getdate() {
	var months=new Array(13);
	months[1]="Jan";
	months[2]="Feb";
	months[3]="Mar";
	months[4]="Apr";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="Aug";
	months[9]="Sept";
	months[10]="Oct";
	months[11]="Nov";
	months[12]="Dec";
	time=new Date();
	lmonth=months[time.getMonth() + 1];
	date=time.getDate();
	year=time.getYear();
	hours = time.getHours();
	if (year < 2000)  {   
	   year = year + 1900; 
	}
	return (date + " " +  lmonth + " " + year);
}

function gethours() {
	time=new Date();
	 hours = time.getHours();
	// alert (hours);
	
	if (hours > 17) {
		return ("&#161;Buenas noches!");
	}
	else if (hours > 11) {
	 	return ("&#161;Buenas tardes!");
	 }
	 else { // < 12
	 	return ("&#161;Buenos d&iacute;as!")
	 }
}


// ebe 2002-10-11: not used
function stopclock (){
	if(timerRunning)
	clearTimeout(timerID);
	timerRunning = false;
}

function showtime () {
	var now = new Date();
	var month = now.get
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds()
	var timeValue = "" + ((hours >12) ? hours -12 :hours)
	if (timeValue == "0") timeValue = 12;
	timeValue += ((minutes < 10) ? ":0" : ":") + minutes
	timeValue += ((seconds < 10) ? ":0" : ":") + seconds
	timeValue += (hours >= 12) ? " P.M." : " A.M."
	document.clock.face.value = timeValue;
	timerID = setTimeout("showtime()",1000);
	timerRunning = true;
}

function startclock() {
	getdate();
	stopclock();
	showtime();
}


// mm
function MM_openBrWindow(theURL,winName,features) { //v2.0
  features += ",resizable";
  win2 = window.open(theURL,winName,features);
  win2.focus();
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// layers
function togtxt (what) {
	r = what;
	// alert (r);
	
	// 'related' layers
	rvid = document.getElementById("vid");
	rvoc = document.getElementById("voc");
	rphr = document.getElementById("phr");
	rgra = document.getElementById("gra");

	if (r == "i") {
		rvid.style.visibility = "visible";
		rvoc.style.visibility = "hidden";
		rphr.style.visibility = "hidden";
		rgra.style.visibility = "hidden";
	}
	else if (r == "v") {
		rvid.style.visibility = "hidden";
		rvoc.style.visibility = "visible";
		rphr.style.visibility = "hidden";
		rgra.style.visibility = "hidden";
	}
	else if (r == "p") {
		rvid.style.visibility = "hidden";
		rvoc.style.visibility = "hidden";
		rphr.style.visibility = "visible";
		rgra.style.visibility = "hidden";

	}
	else { // (what == "g")
		rvid.style.visibility = "hidden";
		rvoc.style.visibility = "hidden";
		rphr.style.visibility = "hidden";
		rgra.style.visibility = "visible";
	}
	MM_swapImgRestore();
}

function togtxtvid (what) {
	MM_swapImgRestore();
	
	t = what;
	// single letter icons: S E N
	icos = document.getElementById("s");
	icoe = document.getElementById("e");
	icon = document.getElementById("n");
	
	tspn = document.getElementById("spn");
	teng = document.getElementById("eng");
	
	if (t == "s") {
		icos.style.visibility = "visible";
		icoe.style.visibility = "hidden";
		icon.style.visibility = "hidden";
		
		tspn.style.visibility = "visible";
		teng.style.visibility = "hidden";
	}
	else if (t == "e") {
		icos.style.visibility = "hidden";
		icoe.style.visibility = "visible";
		icon.style.visibility = "hidden";
		
		tspn.style.visibility = "hidden";
		teng.style.visibility = "visible";
	}
	else { // (t == "n")
		icos.style.visibility = "hidden";
		icoe.style.visibility = "hidden";
		icon.style.visibility = "visible";
		
		tspn.style.visibility = "hidden";
		teng.style.visibility = "hidden";
	}
	MM_swapImgRestore();
}

/*
function foot() {
	 return '<DIV id="foo"><table cellpadding=0 cellspacing=0 border=0><tr><td align=left valign=middle><a href="index.html" title=Spanish Proficiency Exercises"><img src="images/star40.gif" width=40 height=40 border=0 alt="Texas star"></a></td><td><img src="images/transdot.gif" width=5 height=1></td><td align=left valign=middle class="sh3"><a href="index.html" title="Spanish for Texas web site" class="fo">Spanish for Texas</a><br><a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#119;&#119;&#119;&#64;&#109;&#97;&#105;&#108;&#46;&#108;&#97;&#105;&#116;&#115;&#46;&#117;&#116;&#101;&#120;&#97;&#115;&#46;&#101;&#100;&#117;&#63;&#115;&#117;&#98;&#106;&#101;&#99;&#116;&#61;&#83;&#112;&#97;&#110;&#105;&#115;&#104;&#32;&#102;&#111;&#114;&#32;&#84;&#101;&#120;&#97;&#115;" class="fo" title="Comments or questions">&#119;&#119;&#119;&#64;&#109;&#97;&#105;&#108;&#46;&#108;&#97;&#105;&#116;&#115;&#46;&#117;&#116;&#101;&#120;&#97;&#115;&#46;&#101;&#100;&#117;</a><br><a href="http://www.laits.utexas.edu/" title="Liberal Arts ITS" class="fo">Liberal Arts ITS</a>, <a href="http://www.utexas.edu/" title="University of Texas at Austin" class="fo">University of Texas at Austin</a></td></tr></table><p class="reg">&nbsp;</p></DIV>';
}
*/

function foot() {
	 return '<DIV id="foo"><table cellpadding=0 cellspacing=0 border=0><tr><td align=left valign=middle><a href="http://utopia.utexas.edu/" target="offsite" title="Jump to UTopia website"><img src="images/utopia_40.gif" width=58 height=40 border=0 alt="UTopia"></a></td><td><img src="images/transdot.gif" width=7 height=1></td><td align=left valign=middle class="sh3"><a href="index.html" title="Spanish Proficiency web site" class="fo">Spanish for Texas</a><br><a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#119;&#119;&#119;&#64;&#109;&#97;&#105;&#108;&#46;&#108;&#97;&#105;&#116;&#115;&#46;&#117;&#116;&#101;&#120;&#97;&#115;&#46;&#101;&#100;&#117;&#63;&#115;&#117;&#98;&#106;&#101;&#99;&#116;&#61;&#83;&#112;&#97;&#110;&#105;&#115;&#104;&#32;&#102;&#111;&#114;&#32;&#84;&#101;&#120;&#97;&#115;" class="fo" title="Comments or questions">&#119;&#119;&#119;&#64;&#109;&#97;&#105;&#108;&#46;&#108;&#97;&#105;&#116;&#115;&#46;&#117;&#116;&#101;&#120;&#97;&#115;&#46;&#101;&#100;&#117;</a><br><a href="http://www.laits.utexas.edu/" target="offsite" title="Liberal Arts ITS" class="fo">Liberal Arts ITS</a>, <a href="http://www.utexas.edu/" target="offsite" title="University of Texas at Austin" class="fo">University of Texas at Austin</a></td></tr></table><p class="reg">&nbsp;</p></DIV>';
}


// searchargs, added =ebe, 2006-05-05
function get_param(name) {
  var start=location.search.indexOf("?"+name+"=");
  if (start<0) start=location.search.indexOf("&"+name+"=");
  if (start<0) return '';
  start += name.length+2;
  var end=location.search.indexOf("&",start)-1;
  if (end<0)end=location.search.length;
  var result=location.search.substring(start,end);
  var result='';
  for(var i=start;i<=end;i++) {
    var c=location.search.charAt(i);
    result=result+(c=='+'?' ':c);
  }
return unescape(result);
}


// get_os, added =ebe, 2006-05-11
function get_os() {
	var detect = navigator.userAgent.toLowerCase();
	var os;

	if (detect.indexOf('linux')+1){
		os = "other";
	}
	else if (detect.indexOf('unix')+1){
		os = "other";
	}
	else if (detect.indexOf('mac')+1){
		os = "mac";
	}
	else if (detect.indexOf('win')+1){
		os = "win";
	}
	else{
		os = "other";
	}
	return os;
}


// get_object, added =ebe, 2006-05-11
function get_object(name) {
   var ns4 = (document.layers) ? true : false;
   var w3c = (document.getElementById) ? true : false;
   var ie4 = (document.all) ? true : false;

   if (ns4) return eval('document.' + name);
   if (w3c) return document.getElementById(name);
   if (ie4) return eval('document.all.' + name);
   return false;
}

