/*-----------------------------------------------------------------
*******************************************************************
File: stulife.js
Designed for: MU Dept. of Student Life
Author: Ravi Dhobale
Email: ravidhoble@yahoo.com
Created on: 10/13/2005
******************************************************************
----------------------------------------------------------------*/

function clickPrint() { 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
  var content_vlue = document.getElementById("print_content").innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>MU Dept. of Student Life</title>'); 
   docprint.document.write('<meta name="author" content="Petar Datsov, daosvp@missouri.edu />'); 
   docprint.document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><meta name="keywords"  content="Student Life, MU, Missouri, Mizzou" /><meta name="description" content="Hello, and welcome to the Department of Student Life. Our mission is to provide social, cultural and educational opportunities that promote student involvement outside of the classroom. Your overall success at MU will be based on your academic achievement in the classroom AND the combined impact of all experiences you have outside of the classroom. Student Life sponsors more than 200 social, education and cultural events a year. You could be involved by attending some of these events, but you could also get involved by becoming part of the student planning team for these events." /> <meta name="author" content="Ravi Dhobale, ravidhoble@yahoo.com, www.Dhobale.com" /> ');
   
   docprint.document.write('</head><body><left>');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</left><p align="center"><a href="javascript:window.print()">Print this page</a><br /><a href="javascript:window.close();">Close Window</a></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
} 

//following function is to validate the Legislative Issues Survey form
function checkFeedback() {

	 if (document.feedback.comments.value == "") {
		alert("You must enter your comments.");
		return false;
	}
	
	if (document.feedback.randomno.value == "") {
		alert("You must enter the code.");
		return false;
	}
	
	 if (! isValidEmail(document.feedback.email.value)) {
        alert("Please enter a valid email address");
        return false;
	 }
	 // above loop calls the email validator function i.e. located in this file

return true;
}
//-------End checkFeedback



//-----Following code is for the email validator script above function will be calling for. 
// You should call this function inside another functions you would write to validate some forms

function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    }
	
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "_abcdefghijklmnopqrstuvwxyz0123456789@.-";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}
//end of email validator. 

// pop up window
function windowOpener(url, name, args) {
if (typeof(popupWin) != "object"){
popupWin = window.open(url,name,args);
} else {
if (!popupWin.closed){ 
popupWin.location.href = url;
} else {
popupWin = window.open(url, name,args);
}
}
popupWin.focus();
}
// end


// random images

var stuLife = new Array() 

stuLife[0] = 'menu_picture1.jpg'
stuLife[1] = 'menu_picture2.jpg'
stuLife[2] = 'menu_picture3.jpg'
stuLife[3] = 'menu_picture4.jpg'
stuLife[4] = 'menu_picture5.jpg'
stuLife[5] = 'menu_picture6.jpg'
stuLife[6] = 'menu_picture7.jpg'
stuLife[7] = 'menu_picture8.jpg'
stuLife[8] = 'menu_picture9.jpg'
stuLife[9] = 'menu_picture10.jpg'

var j = 0
var p = stuLife.length;
var SL = new Array()
for (i = 0; i < p; i++){
   SL[i] = new Image()
   SL[i].src = stuLife[i]
}
var pictNumber = Math.round(Math.random()*(p-1));
//function showImage(){
//document.write('<img src="images/'+stuLife[pictNumber]+'" alt="Student Life Picture" width="130">');
//}

function showImage(){
document.write('<p style="background-image:url(images/'+stuLife[pictNumber]+'); background-position:bottom; background-repeat:no-repeat; "></p>');
}
//end random images

// jump menu

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
// Pre-load menu images

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_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_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];}
}


// This is for MUPA Grant
function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}

