// JavaScript Document

// Background image
randimg = new Array();

randimg[0]="bgimage1.jpg";
randimg[1]="bgimage2.jpg";
randimg[2]="bgimage3.jpg";
randimg[3]="bgimage4.jpg";
randimg[4]="bgimage5.jpg";
randimg[5]="bgimage6.jpg";

function background(){
	var i=(Math.round(5*Math.random()));
	document.write('<style type="text/css">.body_table{background:#000000 url(/themes/jtwebsite/images/'+randimg[i]+') top center fixed no-repeat;}</style>');
	//document.getElementById('background').innerHTML='<style type="text/css">.body_table{background:#000000 url(/themes/jtwebsite/images/'+randimg[i]+') top center fixed no-repeat;}</style>';
}

// Welcome image
randwelcome = new Array();

randwelcome[0]="welcome_admit.png";
randwelcome[1]="welcome_connect.png";
randwelcome[2]="welcome_grow.png";
randwelcome[3]="welcome_reach.png";
randwelcome[4]="welcome_retain.png";

randalt = new Array();

randalt[0]='Admit Best-Fit Candidates';
randalt[1]='Connect & Build Relationships';
randalt[2]='Grow Enrollment Numbers';
randalt[3]='Reach More Students';
randalt[4]='Retain Current Students';

function welcomeImage(){
	var n=(Math.round(4*Math.random()));
	document.write('<img src="images/'+randwelcome[n]+'" height="85" alt="'+randalt[n]+'" border="0" />');
}

// Homepage tabs
function toggleTabs(clickedLink, toggleId)
{
$(".selected_content").slideUp();
$(".selected_content").removeClass("selected_content");
$(".selected_tab").removeClass("selected_tab");
$("#"+toggleId).slideDown();
$("#"+toggleId).addClass("selected_content");
$(clickedLink).addClass("selected_tab");
}

// Homepage tabs
function toggleExpand(clickedLink, toggleId)
{
$("#generic_content").addClass("hide");
$("#custom_content").removeClass("hide");
$("#custom_content").addClass("show");
$("#custom_content").addClass("trans_bk");
$(".selected").slideUp();
$(".selected").removeClass("selected");
$("#"+toggleId).slideDown();
$("#"+toggleId).addClass("selected");
}

function closeTab(clickedLink, toggleId)
{
$(".selected").slideUp();
$(".selected").removeClass("selected");
$("#custom_content").removeClass("show");
$("#custom_content").addClass("hide");
$("#generic_content").removeClass("hide");
}

// Interior tabs
function toggleIntTabs(clickedLink, toggleId)
{
$(".selected_content").slideUp();
$(".selected_content").removeClass("selected_content");
$("#"+toggleId).slideDown();
$("#"+toggleId).addClass("selected_content");
}

// PNG fix functions fox IE
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 var imgAttribs = img.attributes;
		 for (var j=0; j<imgAttribs.length; j++)
			{
			var imgAttrib = imgAttribs[j];
			if (imgAttrib.nodeName == "align")
			   {		  
			   if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle
			   if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle
			   break
			   }
            }
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 strNewHTML += "(src='" + img.src + "', sizingMethod='scale');\""
		 strNewHTML += " onmouseover=\"PNGswap('" + img.id + "');\" onmouseout=\"PNGswap('" + img.id +"');\""
		 strNewHTML += "></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
function PNGswap(myID)
{
   var strOver  = "_on"
   var strOff = "_off"
   var oSpan = document.getElementById(myID)
   if(oSpan)
   {
	   var currentAlphaImg = oSpan.filters(0).src
	   if (currentAlphaImg.indexOf(strOver) != -1)
	      oSpan.filters(0).src = currentAlphaImg.replace(strOver,strOff)
	   else
	      oSpan.filters(0).src = currentAlphaImg.replace(strOff,strOver)
   }
}
function fixPNG(){
	window.attachEvent("onload", correctPNG);
}

// Contact Us form
function validateContact(objForm){
	var strReqMsg = "";
	var strValidationMsg = "";			
				
	if(objForm.name.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Name\n"; }
					
	if(objForm.organization.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Organization\n"; }
					
	if(objForm.email.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Email\n"; }
		
	if(objForm.email.value.length && ! isEmail(objForm.email.value))
	{ strValidationMsg += "    - Email must be a well-formed email address\n"; }
									
	// Assemble all of the error messates together to display to the user
	if(strReqMsg.length || strValidationMsg.length)
	{
		var strDisplay = "";
		if(strReqMsg.length)
		{ strDisplay += "The following fields are required to be completed:\n\n" + strReqMsg + "\n"; }

		if(strValidationMsg.length)
		{ strDisplay += "The following fields are not filled in correctly:\n\n" + strValidationMsg; }

		alert(strDisplay);
		return false;
	}
	else
	{
		return true;
	}
}

// Calculator form
function validateCalc(objForm){
	var strReqMsg = "";
	var strValidationMsg = "";			
				
	if(objForm.calcname.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Name\n"; }
					
	if(objForm.calcinst.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Institution\n"; }
													
	// Assemble all of the error messates together to display to the user
	if(strReqMsg.length || strValidationMsg.length)
	{
		var strDisplay = "";
		if(strReqMsg.length)
		{ strDisplay += "The following fields are required to be completed:\n\n" + strReqMsg + "\n"; }

		if(strValidationMsg.length)
		{ strDisplay += "The following fields are not filled in correctly:\n\n" + strValidationMsg; }

		alert(strDisplay);
		return false;
	}
	else
	{
		return true;
	}
}


// News form
function validateNews(objForm){
	var strReqMsg = "";
	var strValidationMsg = "";			
				
	if(objForm.fname.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - First Name\n"; }
	
	if(objForm.lname.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Last Name\n"; }
					
	if(objForm.college.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - College/University\n"; }
					
	if(objForm.email.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Email\n"; }
		
	if(objForm.email.value.length && ! isEmail(objForm.email.value))
	{ strValidationMsg += "    - Email must be a well-formed email address\n"; }
									
	// Assemble all of the error messates together to display to the user
	if(strReqMsg.length || strValidationMsg.length)
	{
		var strDisplay = "";
		if(strReqMsg.length)
		{ strDisplay += "The following fields are required to be completed:\n\n" + strReqMsg + "\n"; }

		if(strValidationMsg.length)
		{ strDisplay += "The following fields are not filled in correctly:\n\n" + strValidationMsg; }

		alert(strDisplay);
		return false;
	}
	else
	{
		return true;
	}
}

// Webinar forms
function validateAGWebinar(objForm){
	var strReqMsg = "";
	var strValidationMsg = "";			
				
	if(objForm.agname.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Name\n"; }
					
	if(objForm.agcollege.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - College/University\n"; }
					
	if(objForm.agemail.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Email\n"; }
		
	if(objForm.agemail.value.length && ! isEmail(objForm.agemail.value))
	{ strValidationMsg += "    - Email must be a well-formed email address\n"; }
									
	// Assemble all of the error messates together to display to the user
	if(strReqMsg.length || strValidationMsg.length)
	{
		var strDisplay = "";
		if(strReqMsg.length)
		{ strDisplay += "The following fields are required to be completed:\n\n" + strReqMsg + "\n"; }

		if(strValidationMsg.length)
		{ strDisplay += "The following fields are not filled in correctly:\n\n" + strValidationMsg; }

		alert(strDisplay);
		return false;
	}
	else
	{
		return true;
	}
}

function validateEmailWebinar(objForm){
	var strReqMsg = "";
	var strValidationMsg = "";			
				
	if(objForm.ename.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Name\n"; }
					
	if(objForm.ecollege.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - College/University\n"; }
					
	if(objForm.eemail.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Email\n"; }
		
	if(objForm.eemail.value.length && ! isEmail(objForm.eemail.value))
	{ strValidationMsg += "    - Email must be a well-formed email address\n"; }
									
	// Assemble all of the error messates together to display to the user
	if(strReqMsg.length || strValidationMsg.length)
	{
		var strDisplay = "";
		if(strReqMsg.length)
		{ strDisplay += "The following fields are required to be completed:\n\n" + strReqMsg + "\n"; }

		if(strValidationMsg.length)
		{ strDisplay += "The following fields are not filled in correctly:\n\n" + strValidationMsg; }

		alert(strDisplay);
		return false;
	}
	else
	{
		return true;
	}
}

function validateAltWebinar(objForm){
	var strReqMsg = "";
	var strValidationMsg = "";			
				
	if(objForm.altname.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Name\n"; }
					
	if(objForm.altinstitution.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Institution\n"; }
					
	if(objForm.altemail.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Email\n"; }
		
	if(objForm.altemail.value.length && ! isEmail(objForm.altemail.value))
	{ strValidationMsg += "    - Email must be a well-formed email address\n"; }
									
	// Assemble all of the error messates together to display to the user
	if(strReqMsg.length || strValidationMsg.length)
	{
		var strDisplay = "";
		if(strReqMsg.length)
		{ strDisplay += "The following fields are required to be completed:\n\n" + strReqMsg + "\n"; }

		if(strValidationMsg.length)
		{ strDisplay += "The following fields are not filled in correctly:\n\n" + strValidationMsg; }

		alert(strDisplay);
		return false;
	}
	else
	{
		return true;
	}
}

function validateConsultation(objForm){
	var strReqMsg = "";
	var strValidationMsg = "";			
				
	if(objForm.timename.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Name\n"; }
					
	if(objForm.timeinstitution.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Institution\n"; }
					
	if(objForm.timeemail.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Email\n"; }
		
	if(objForm.timeemail.value.length && ! isEmail(objForm.timeemail.value))
	{ strValidationMsg += "    - Email must be a well-formed email address\n"; }
					
	if(objForm.timephone.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Phone\n"; }
					
	if(objForm.slotchoice1.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - First Date/Time Choice\n"; }
					
	if(objForm.slotchoice2.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Second Date/Time Choice\n"; }
							
	// Assemble all of the error messates together to display to the user
	if(strReqMsg.length || strValidationMsg.length)
	{
		var strDisplay = "";
		if(strReqMsg.length)
		{ strDisplay += "The following fields are required to be completed:\n\n" + strReqMsg + "\n"; }

		if(strValidationMsg.length)
		{ strDisplay += "The following fields are not filled in correctly:\n\n" + strValidationMsg; }

		alert(strDisplay);
		return false;
	}
	else
	{
		return true;
	}
}

// Partner form
function validatePartner(objForm){
	var strReqMsg = "";
	var strValidationMsg = "";			
				
	if(objForm.pname.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Name\n"; }
	
	if(objForm.porg.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Organization\n"; }
					
	if(objForm.pemail.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Email\n"; }
		
	if(objForm.pemail.value.length && ! isEmail(objForm.pemail.value))
	{ strValidationMsg += "    - Email must be a well-formed email address\n"; }

	if(objForm.pdetails.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - How we can work together\n"; }

	// Assemble all of the error messates together to display to the user
	if(strReqMsg.length || strValidationMsg.length)
	{
		var strDisplay = "";
		if(strReqMsg.length)
		{ strDisplay += "The following fields are required to be completed:\n\n" + strReqMsg + "\n"; }

		if(strValidationMsg.length)
		{ strDisplay += "The following fields are not filled in correctly:\n\n" + strValidationMsg; }

		alert(strDisplay);
		return false;
	}
	else
	{
		return true;
	}
}

function isEmail(strValue)
{
	// get location of @
		intAtSign = strValue.indexOf("@");
	// if no @ found or it is the first char, return false
	if(intAtSign < 1)
	{
		return false;
	}
	
	// else get the string of chars following the @
	else
	{
		strAfterAtSign = strValue.substring(intAtSign + 1);
	}
	
	// if there are less than 4 chars after the @, return false
	if(strAfterAtSign.length < 4)
	{
		return false;
	}
	
	// if there is no '.' after the @, return false
	else if(strAfterAtSign.indexOf(".") == -1)
	{
		return false;
	}
	// if the last char is '.', return false
	else if(strAfterAtSign.charAt(strAfterAtSign.length - 1) == ".")
	{
		return false;
	}
	
	// everything's good so return true
	else
	{
		return true;
	}
}

//XMLHTTPrequest
function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
	return request_type;
}

var http;

//show php response
function insertReply(theDiv) {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById(theDiv).innerHTML = response;
	}
}

function formContactSubmit(theDiv) {
	http = createObject();
	var nocache = 0;
	var name= document.getElementById('name').value;
	var organization= document.getElementById('organization').value;
	var email= document.getElementById('email').value;
	var phone= document.getElementById('phone').value;
	var reason=''
	var len = document.contactForm.reason.length;
	for (i = 0; i <len; i++) {
		if (document.contactForm.reason[i].checked)
			reason=document.contactForm.reason[i].value
	}
	nocache = Math.random();
	http.open('get', '/themes/jtwebsite/sendform.php?nocache='+nocache+'&name='+name+'&organization='+organization+'&email='+email+'&phone='+phone+'&reason='+reason);
	http.onreadystatechange = function() { insertReply(theDiv); }
	http.send(null);
}

// Caluclator download form submit
function formCalcSubmit(theDiv) {
	http = createObject();
	var nocache = 0;
	var name= document.getElementById('calcname').value;
	var institution= document.getElementById('calcinst').value;
	var email= document.getElementById('calcemail').value;
	var phone= document.getElementById('calcphone').value;
	var request=''
	var len = document.calcform.request.length;
	for (i = 0; i <len; i++) {
		if (document.calcform.request[i].checked)
			request=document.calcform.request[i].value
	}
	nocache = Math.random();
	http.open('get', '/themes/jtwebsite/sendCalculator.php?nocache='+nocache+'&name='+name+'&institution='+institution+'&email='+email+'&phone='+phone+'&request='+request);
	http.onreadystatechange = function() { insertReply(theDiv); }
	http.send(null);
}

// News form submits to Blue Ox
function formNewsSubmit(theDiv) {
	http = createObject();
	var fname= document.getElementById('fname').value;
	var lname= document.getElementById('lname').value;
	var college= document.getElementById('college').value;
	var email= document.getElementById('email').value;
	var phone= document.getElementById('phone').value;
	var questions= document.getElementById('questions').value;
	var submitaction=document.getElementById('submitaction').value;
	var mlid=document.getElementById('mlid').value;
	var siteid=document.getElementById('siteid').value;
	var tagtype=document.getElementById('tagtype').value;
	var demographics=document.getElementById('demographics').value;
	var welcome=document.getElementById('welcome').value;
	var double_optin=document.getElementById('double_optin').value;
	var append=document.getElementById('append').value;
	var update=document.getElementById('update').value;
	var activity=document.getElementById('activity').value;
	var mmm=document.getElementById('mmm').value;
	nocache = Math.random();
	http.open('get', '/themes/jtwebsite/transport.php?action=http://email.blueoxmailbox.com/functions/mailing_list.html&method=POST&val_1='+fname+'&val_2='+lname+'&val_99617='+college+'&email='+email+'&val_9='+phone+'&val_101871='+questions+'&submitaction='+submitaction+'&mlid='+mlid+'&siteid='+siteid+'&tagtype='+tagtype+'&demographics='+demographics+'&welcome='+welcome+'&double_optin='+double_optin+'&append='+append+'&update='+update+'&activity='+activity+'&val_102196='+mmm, true );
	http.onreadystatechange = function() { insertReply(theDiv); }
	http.send(null);
}


function formAGWebinarSubmit(theDiv) {
	http = createObject();
	var nocache = 0;
	var name= document.getElementById('agname').value;
	var college= document.getElementById('agcollege').value;
	var email= document.getElementById('agemail').value;
	var phone= document.getElementById('agphone').value;
 	var date='';
	var len = document.webinarform1.agdate.length;
	for (i = 0; i <len; i++) {
		if (document.webinarform1.agdate[i].checked)
			date=document.webinarform1.agdate[i].value
	}
	nocache = Math.random();
	http.open('get', '/themes/jtwebsite/sendAGwebinar.php?nocache='+nocache+'&name='+name+'&college='+college+'&email='+email+'&phone='+phone+'&date='+date);
	http.onreadystatechange = function() { insertReply(theDiv); }
	http.send(null);
}

function formEmailWebinarSubmit(theDiv) {
	http = createObject();
	var nocache = 0;
	var name= document.getElementById('ename').value;
	var college= document.getElementById('ecollege').value;
	var email= document.getElementById('eemail').value;
	var phone= document.getElementById('ephone').value;
 	var date='';
	var len = document.webinarform2.edate.length;
	for (i = 0; i <len; i++) {
		if (document.webinarform2.edate[i].checked)
			date=document.webinarform2.edate[i].value
	}
	nocache = Math.random();
	http.open('get', '/themes/jtwebsite/sendEmailwebinar.php?nocache='+nocache+'&name='+name+'&college='+college+'&email='+email+'&phone='+phone+'&date='+date);
	http.onreadystatechange = function() { insertReply(theDiv); }
	http.send(null);
}

function formAltWebinarSubmit(theDiv) {
	http = createObject();
	var nocache = 0;
	var name= document.getElementById('altname').value;
	var institution= document.getElementById('altinstitution').value;
	var email= document.getElementById('altemail').value;
 	var date='';
	var len = document.webinarformalt.altdate.length;
	for (i = 0; i <len; i++) {
		if (document.webinarformalt.altdate[i].checked)
			date=document.webinarformalt.altdate[i].value
	}
	nocache = Math.random();
	http.open('get', '/themes/jtwebsite/sendAltwebinar.php?nocache='+nocache+'&name='+name+'&institution='+institution+'&email='+email+'&date='+date);
	http.onreadystatechange = function() { insertReply(theDiv); }
	http.send(null);
}

function formConsultationSubmit(theDiv) {
	http = createObject();
	var nocache = 0;
	var name= document.getElementById('timename').value;
	var institution= document.getElementById('timeinstitution').value;
	var email= document.getElementById('timeemail').value;
	var phone= document.getElementById('timephone').value;
	var slotchoice1= document.getElementById('slotchoice1').value;
	var slotchoice2= document.getElementById('slotchoice2').value;
	var topics= document.getElementById('timetopics').value;
	nocache = Math.random();
	http.open('get', '/themes/jtwebsite/sendConsultation.php?nocache='+nocache+'&name='+name+'&institution='+institution+'&email='+email+'&phone='+phone+'&slotchoice1='+slotchoice1+'&slotchoice2='+slotchoice2+'&topics='+topics);
	http.onreadystatechange = function() { insertReply(theDiv); }
	http.send(null);
}

function formPartnerSubmit(theDiv) {
	http = createObject();
	var nocache = 0;
	var name= document.getElementById('pname').value;
	var organization= document.getElementById('porg').value;
	var email= document.getElementById('pemail').value;
	var phone= document.getElementById('pphone').value;
 	var details=document.getElementById('pdetails').value;
	nocache = Math.random();
	http.open('get', '/themes/jtwebsite/sendPartner.php?nocache='+nocache+'&name='+name+'&organization='+organization+'&email='+email+'&phone='+phone+'&details='+details);
	http.onreadystatechange = function() { insertReply(theDiv); }
	http.send(null);
}

//*********************************//
// Modals //

// News form submits to Blue Ox
function modalNewsSubmit(theDiv) {
	http = createObject();
	var fname= document.getElementById('mdl_fname').value;
	var lname= document.getElementById('mdl_lname').value;
	var college= document.getElementById('mdl_college').value;
	var email= document.getElementById('mdl_email').value;
	var phone= document.getElementById('mdl_phone').value;
	var questions= document.getElementById('mdl_questions').value;
	var submitaction=document.getElementById('submitaction').value;
	var mlid=document.getElementById('mlid').value;
	var siteid=document.getElementById('siteid').value;
	var tagtype=document.getElementById('tagtype').value;
	var demographics=document.getElementById('demographics').value;
	var welcome=document.getElementById('welcome').value;
	var double_optin=document.getElementById('double_optin').value;
	var append=document.getElementById('append').value;
	var update=document.getElementById('update').value;
	var activity=document.getElementById('activity').value;
	var mmm=document.getElementById('mmm').value;
	nocache = Math.random();
	http.open('get', '/themes/jtwebsite/transport.php?action=http://email.blueoxmailbox.com/functions/mailing_list.html&method=POST&val_1='+fname+'&val_2='+lname+'&val_99617='+college+'&email='+email+'&val_9='+phone+'&val_101871='+questions+'&submitaction='+submitaction+'&mlid='+mlid+'&siteid='+siteid+'&tagtype='+tagtype+'&demographics='+demographics+'&welcome='+welcome+'&double_optin='+double_optin+'&append='+append+'&update='+update+'&activity='+activity+'&val_102196='+mmm, true );
	http.onreadystatechange = function() { insertReply(theDiv); }
	http.send(null);
}

function modalAGWebinarSubmit(theDiv) {
	http = createObject();
	var nocache = 0;
	var name= document.getElementById('mdl_agname').value;
	var college= document.getElementById('mdl_agcollege').value;
	var email= document.getElementById('mdl_agemail').value;
	var phone= document.getElementById('mdl_agphone').value;
 	var agdate='';
	var len = document.demoModalForm.mdl_agdate.length;
	for (i = 0; i <len; i++) {
		if (document.demoModalForm.mdl_agdate[i].checked)
			agdate=document.demoModalForm.mdl_agdate[i].value
	}
 	var emdate='';
	var len = document.demoModalForm.mdl_emdate.length;
	for (i = 0; i <len; i++) {
		if (document.demoModalForm.mdl_emdate[i].checked)
			emdate=document.demoModalForm.mdl_emdate[i].value
	}
	nocache = Math.random();
	http.open('get', '/themes/jtwebsite/sendModalWebinar.php?nocache='+nocache+'&name='+name+'&college='+college+'&email='+email+'&phone='+phone+'&agdate='+agdate+'&emdate='+emdate);
	http.onreadystatechange = function() { insertReply(theDiv); }
	http.send(null);
}

// modal validation scripts
// News form
function validateModalNews(objForm){
	var strReqMsg = "";
	var strValidationMsg = "";			
				
	if(objForm.val_1.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - First Name\n"; }

	if(objForm.val_2.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Last Name\n"; }

	if(objForm.val_99617.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - College/University\n"; }
					
	if(objForm.mdl_email.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Email\n"; }
		
	if(objForm.email.value.length && ! isEmail(objForm.email.value))
	{ strValidationMsg += "    - Email must be a well-formed email address\n"; }
									
	// Assemble all of the error messates together to display to the user
	if(strReqMsg.length || strValidationMsg.length)
	{
		var strDisplay = "";
		if(strReqMsg.length)
		{ strDisplay += "The following fields are required to be completed:\n\n" + strReqMsg + "\n"; }

		if(strValidationMsg.length)
		{ strDisplay += "The following fields are not filled in correctly:\n\n" + strValidationMsg; }

		alert(strDisplay);
		return false;
	}
	else
	{
		return true;
	}
}

// Webinar form
function validateModalAGWebinar(objForm){
	var strReqMsg = "";
	var strValidationMsg = "";			
				
	if(objForm.mdl_agname.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Name\n"; }
					
	if(objForm.mdl_agcollege.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - College/University\n"; }
					
	if(objForm.mdl_agemail.value.replace(/\s+/g, "") == "")
	{ strReqMsg += "    - Email\n"; }
		
	if(objForm.mdl_agemail.value.length && ! isEmail(objForm.mdl_agemail.value))
	{ strValidationMsg += "    - Email must be a well-formed email address\n"; }
									
	// Assemble all of the error messates together to display to the user
	if(strReqMsg.length || strValidationMsg.length)
	{
		var strDisplay = "";
		if(strReqMsg.length)
		{ strDisplay += "The following fields are required to be completed:\n\n" + strReqMsg + "\n"; }

		if(strValidationMsg.length)
		{ strDisplay += "The following fields are not filled in correctly:\n\n" + strValidationMsg; }

		alert(strDisplay);
		return false;
	}
	else
	{
		return true;
	}
}

//simple modal calls
$(document).ready(function () {
	$('a.btn1').click(function (e) {
		e.preventDefault();
		$('#demoModal').modal();
	});
	$('a.btn2').click(function (e) {
		e.preventDefault();
		$('#newsModal').modal();
	});
	$('a.btn3').click(function (e) {
		e.preventDefault();
		$('#papersModal').modal();
	});
});

// Load tabs from URL
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
}

// Preload a tab from a URL variable for the Email page
function loadEmailTab(){
	var theTab=getQueryVariable("tab");
	if(theTab){
		if(theTab=='benefits')
			setTimeout("toggleTabs(document.getElementById('tab3_link'), 'int_tab3_content')",800);
	}
}

// Preload a tab from a URL variable for the Research page
function loadWhitepapersTab(){
	var theTab=getQueryVariable("tab");
	if(theTab){
		if(theTab=='whitepapers')
			setTimeout("toggleTabs(document.getElementById('tab2_link'), 'int_tab2_content')",800);
	}
}

// Preload a tab from a URL variable for the News page
function loadNewsTab(){
	var theTab=getQueryVariable("tab");
	if(theTab){
		if(theTab=='AG')
			setTimeout("toggleIntTabs(document.getElementById('tab2_link'), 'tab2')",800);
		else if(theTab=='email')
			setTimeout("toggleIntTabs(document.getElementById('tab3_link'), 'tab3')",800);
	}
}

// Preload a tab from a URL variable for the Portfolio page
function loadPortfolioTab(){
	var theTab=getQueryVariable("tab");
	if(theTab){
		if(theTab=='email')
			setTimeout("toggleTabs(document.getElementById('tab4_link'), 'int_tab4_content')",800);
		else if(theTab=='print')
			setTimeout("toggleTabs(document.getElementById('tab5_link'), 'int_tab5_content')",800);
		else if(theTab=='search')
			setTimeout("toggleTabs(document.getElementById('tab6_link'), 'int_tab6_content')",800);
	}
}

// Popup functions
function popitup(url) {
	newwindow=window.open(url,'popup','height=600,width=800,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}
function popup_plain(url,width,height) {
	plainnewwindow=window.open(url,'plainpop','height='+height+',width='+width+',resizable=yes,scrollbars=yes');
	if (window.focus) {plainnewwindow.focus()}
	return false;
}