/*-----------------------------------------------------------------
*******************************************************************
File: xhp_sls.js
Designed for: http://students.missouri.edu/~sls
Author: Ravi Dhobale
Email: ravidhoble@yahoo.com
Web: www.Dhobale.com
Created on: 11/09/2006
******************************************************************
----------------------------------------------------------------*/
// printer friendly

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>Student Legal Services</title>'); 
   docprint.document.write('<meta name="author" content="Ravi Dhobale, ravidhoble@yahoo.com, www.Dhobale.com" />'); 
   docprint.document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />');
   
   docprint.document.write('</head><body><left>');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</left><p align="center"><div style="border:1px solid #000000; padding: 3px; background-color: #cccccc; width:150px; text-align: center; margin-left:40%; margin-right: 40%;"><a href="javascript:window.close();">Close Window</a></div></p></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
} 




//following function is to validate the Group Sign Up form
function checkRequest() {

	if (document.info.groupname.value == "") {
		alert("Please enter your group's name.");
		return false;
	}
	
	if (document.info.contactname.value == "") {
		alert("Please enter your name.");
		return false;
	}
	
	 if (! isValidEmail(document.forms[0].email.value)) {
        alert("Please enter a valid email address");
        return false;
	 }

return true;
}
//-------End checkRequest

//following function is to validate the Newsletter Sign Up form
function checkNews() {

	if (document.info.fname.value == "") {
		alert("Please enter your first name.");
		return false;
	}
	
	if (document.info.lname.value == "") {
		alert("Please enter your last name.");
		return false;
	}
	
	 if (! isValidEmail(document.forms[0].email.value)) {
        alert("Please enter a valid email address");
        return false;
	 }

return true;
}
//-------End checkNews


//-----Following code is for the email validator script above function will be calling for. 
// You should call this function inside another function you will write to validate some form

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. 


// random images

var ventureOut = new Array() 

ventureOut[0] = '1.jpg'
ventureOut[1] = '2.jpg'
ventureOut[2] = '3.jpg'
ventureOut[3] = '4.jpg'
ventureOut[4] = '5.jpg'
ventureOut[5] = '6.jpg'
ventureOut[6] = '7.jpg'
ventureOut[7] = '8.jpg'
ventureOut[8] = '9.jpg'
ventureOut[9] = '10.jpg'


var j = 0
var p = ventureOut.length;
var VO = new Array()
for (i = 0; i < p; i++){
   VO[i] = new Image()
   VO[i].src = ventureOut[i]
}
var pictNumber = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="./images/'+ventureOut[pictNumber]+'" alt="Venture Out Picture">');
}
//end random images


// following code modified on 09/21/2005 at 11:40 am . Please update this from the template if you do any changes inside the template

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];}
}
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];}}
}

