//get the domain name
var JsDomain = window.location.href.match(/:\/\/(.[^/]+)/)[1];
JsDomain = JsDomain.split(".");
JsDomain = JsDomain[2];

var JsTimeZone = "";
/*
var JsTimeZone = "EST";
if (JsDomain=="ca")
{
	JsTimeZone = "PT";
}
*/

function  LoadCalendar(id1,id2,id3)
{
	  Calendar.setup(
    {
      inputField  : id1,         // ID of the input field
      ifFormat    : id2,    // the date format
      button      : id3 // ID of the button
    }
  );

}



function trim(str)
	    {
		  s = str.replace(/^(\s)*/, '');
		  s = s.replace(/(\s)*$/, '');
	      return s;
		}



function OpenSchPopupWindow(url, SchId, HourValue, MinuteValue)
{
	scr=window.open(url+'?id='+SchId+'&hour='+HourValue+'&minute='+MinuteValue,'Schedule Details','width=500, height=450, resizable=0, status=no, menubar=no, scrollbars=1');
	scr.moveTo(screen.width/2-250,screen.height/2-275);
	//scr.moveTo(1,1);
	//scr.resizeTo(screen.width,screen.height);
	scr.focus();	
}

function ViewDayDetailsSmall(url,yearID,monthID,dayID)
{
	window.location.href="../ShowEventsCalendar.php?CalendarType=day&yearID="+yearID+"&monthID="+monthID+"&dayID="+dayID; 

}

function OpenNewWindow(url, name, width,height)
{
	scr=window.open(url,name,'width='+width+', height='+height+', resizable=1, status=no, menubar=no, scrollbars=1');
	scr.moveTo(screen.width/2-250,screen.height/2-275);
	//scr.moveTo(1,1);
	//scr.resizeTo(screen.width,screen.height);
	scr.focus();	
	return scr;
}


function ClearDateInput (id)
{
	if (document.getElementById(id))	
		document.getElementById(id).value="";	
}

function getCookieValue(nme)
{
   var cck=document.cookie;	
   var nameEQ = nme + "=";
   var ckie=cck.split(";")
   for(var i=0;i<ckie.length;++i) 
   {
     	//var splitValues=ckie[i].split("=");
      	var splitValues=ckie[i];
	while (splitValues.charAt(0)==' ') splitValues = splitValues.substring(1,splitValues.length);
	if (splitValues.indexOf(nameEQ) == 0) return splitValues.substring(nameEQ.length,splitValues.length);
   }
   return null;
}

function ConfirmDelete(url,id)
{	
	if(confirm('Are you sure you want to delete registration with Id #'+id+' ?'))
			location.href=url;
}

//redirect with javascript
function JsRedirectLocation(url)
{
	window.location.href= url;
}


function AjaxError(req)
{
	alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
	OpenNewWindow("AjaxError.html","ERROR",500,500);	
}



 function processUser()
  {
    var parameters = location.search.substring(1).split("&");

    var temp = parameters[0].split("=");
    l = unescape(temp[1]);
    temp = parameters[1].split("=");
    p = unescape(temp[1]);
    document.getElementById("log").innerHTML = l;
    document.getElementById("pass").innerHTML = p;
  }





//select manipulation
function moveSelectedOptions(from,to) {
	//moveSelectedOptions(this.form['SchoolsToSelect'],this.form['SelectedSchools'],true,this.form['movepattern1'].value)
	// Unselect matching options, if required
	if (arguments.length>3) {
		var regex = arguments[3];
		if (regex != "") {
			unSelectMatchingOptions(from,regex);
			}
		}
	// Move them over
	if (!hasOptions(from)) { return; }
	for (var i=0; i<from.options.length; i++) {
		var o = from.options[i];
		if (o.selected) {
			if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
			to.options[index] = new Option( o.text, o.value, false, false);
			}
		}
	// Delete them from original
	for (var i=(from.options.length-1); i>=0; i--) {
		var o = from.options[i];
		if (o.selected) {
			from.options[i] = null;
			}
		}
	if ((arguments.length<3) || (arguments[2]==true)) {
		sortSelect(from);
		sortSelect(to);
		}
	from.selectedIndex = -1;
	to.selectedIndex = -1;
	}

	
// -------------------------------------------------------------------
// moveAllOptions(select_object,select_object[,autosort(true/false)[,regex]])
//  Move all options from one select box to another.
// -------------------------------------------------------------------
function moveAllOptions(from,to) {
	selectAllOptions(from);
	if (arguments.length==2) {
		moveSelectedOptions(from,to);
		}
	else if (arguments.length==3) {
		moveSelectedOptions(from,to,arguments[2]);
		}
	else if (arguments.length==4) {
		moveSelectedOptions(from,to,arguments[2],arguments[3]);
		}
	}

// -------------------------------------------------------------------
// copyAllOptions(select_object,select_object[,autosort(true/false)])
//  Copy all options from one select box to another, instead of
//  removing items. Duplicates in the target list are not allowed.
// -------------------------------------------------------------------
function copyAllOptions(from,to) {
	selectAllOptions(from);
	if (arguments.length==2) {
		copySelectedOptions(from,to);
		}
	else if (arguments.length==3) {
		copySelectedOptions(from,to,arguments[2]);
		}
	}

// -------------------------------------------------------------------
// swapOptions(select_object,option1,option2)
//  Swap positions of two options in a select list
// -------------------------------------------------------------------
function swapOptions(obj,i,j) {
	var o = obj.options;
	var i_selected = o[i].selected;
	var j_selected = o[j].selected;
	var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
	var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
	o[i] = temp2;
	o[j] = temp;
	o[i].selected = j_selected;
	o[j].selected = i_selected;
	}
	
// -------------------------------------------------------------------
// moveOptionUp(select_object)
//  Move selected option in a select list up one
// -------------------------------------------------------------------
function moveOptionUp(obj) {
	if (!hasOptions(obj)) { return; }
	for (i=0; i<obj.options.length; i++) {
		if (obj.options[i].selected) {
			if (i != 0 && !obj.options[i-1].selected) {
				swapOptions(obj,i,i-1);
				obj.options[i-1].selected = true;
				}
			}
		}
	}

// -------------------------------------------------------------------
// moveOptionDown(select_object)
//  Move selected option in a select list down one
// -------------------------------------------------------------------
function moveOptionDown(obj) {
	if (!hasOptions(obj)) { return; }
	for (i=obj.options.length-1; i>=0; i--) {
		if (obj.options[i].selected) {
			if (i != (obj.options.length-1) && ! obj.options[i+1].selected) {
				swapOptions(obj,i,i+1);
				obj.options[i+1].selected = true;
				}
			}
		}
	}

// -------------------------------------------------------------------
// removeSelectedOptions(select_object)
//  Remove all selected options from a list
//  (Thanks to Gene Ninestein)
// -------------------------------------------------------------------
function removeSelectedOptions(from) { 
	if (!hasOptions(from)) { return; }
	if (from.type=="select-one") {
		from.options[from.selectedIndex] = null;
		}
	else {
		for (var i=(from.options.length-1); i>=0; i--) { 
			var o=from.options[i]; 
			if (o.selected) { 
				from.options[i] = null; 
				} 
			}
		}
	from.selectedIndex = -1; 
	} 

// -------------------------------------------------------------------
// removeAllOptions(select_object)
//  Remove all options from a list
// -------------------------------------------------------------------
function removeAllOptions(from) { 
	if (!hasOptions(from)) { return; }
	for (var i=(from.options.length-1); i>=0; i--) { 
		from.options[i] = null; 
		} 
	from.selectedIndex = -1; 
	} 

// -------------------------------------------------------------------
// addOption(select_object,display_text,value,selected)
//  Add an option to a list
// -------------------------------------------------------------------
function addOption(obj,text,value,selected) {
	if (obj!=null && obj.options!=null) {
		obj.options[obj.options.length] = new Option(text, value, false, selected);
		}
	}


// -------------------------------------------------------------------
// sortSelect(select_object)
//   Pass this function a SELECT object and the options will be sorted
//   by their text (display) values
// -------------------------------------------------------------------
function sortSelect(obj) {
	var o = new Array();
	if (!hasOptions(obj)) { return; }
	for (var i=0; i<obj.options.length; i++) {
		o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
		}
	if (o.length==0) { return; }
	o = o.sort( 
		function(a,b) { 
			if ((a.text+"") < (b.text+"")) { return -1; }
			if ((a.text+"") > (b.text+"")) { return 1; }
			return 0;
			} 
		);

	for (var i=0; i<o.length; i++) {
		obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
		}
	}

// -------------------------------------------------------------------
// selectAllOptions(select_object)
//  This function takes a select box and selects all options (in a 
//  multiple select object). This is used when passing values between
//  two select boxes. Select all options in the right box before 
//  submitting the form so the values will be sent to the server.
// -------------------------------------------------------------------
function selectAllOptions(obj) {
	if (!hasOptions(obj)) { return; }
	for (var i=0; i<obj.options.length; i++) {
		obj.options[i].selected = true;
		}
	}

// -------------------------------------------------------------------
// hasOptions(obj)
//  Utility function to determine if a select object has an options array
// -------------------------------------------------------------------
function hasOptions(obj) {
	if (obj!=null && obj.options!=null) { return true; }
	return false;
	}
	
	
 /*
		  function check_form(){
  	obj=document.f['oem_comp_products[]'];
  	for(i=0;i<obj.options.length;i++)
  		obj.options[i].selected=true;
  	return true;
  }
		 */	
 
 function CheckSelectSchool(SchoolId)
{
	var Selects=document.getElementById(SchoolId);
	
	
	for (var i=0; i<Selects.options.length; i++) {
		Selects.options[i].selected = true;
		}


	if (Selects.selectedIndex < 0 || Selects.options[0].value=="0")
		{
		alert("You must add at least one university before continue");
		return false;
		}
	else
	{
		return true;	
	}	
}

function returnSelectedValueFromSelect(id)
{
	var Selects=document.getElementById(id);

	alert(Selects.value);
}


//check if any checkbox is checked from
function checkBoxesChecked(frm) 
{
for (i=0;i<frm.length;i++)
    {
    e =	frm.elements[i]; 	
	if (e.type == "checkbox" && e.checked == true) return true;
 	}
    return false;
}

/*
for(i=0;i<frm.length;i++){
			e	=	frm.elements[i];
			if(e.name.substring(0,14)=='aaa'){

			}
		}
*/


function new_freecap()
{
	// loads new freeCap image
	if(document.getElementById("captcha"))
	{
		// extract image name from image source (i.e. cut off ?randomness)
		thesrc = document.getElementById("captcha").src;
		thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
		// add ?(random) to prevent browser/isp caching
		document.getElementById("captcha").src = "captcha.php";

	} else {
		alert("Sorry, cannot autoreload captcha.\nRefresh the page and a new Captcha will be loaded");
	}
}


function slideShow(sno) {
	var obj = document.getElementById("photo").getElementsByTagName("ul")[0];
	var no = parseInt(document.getElementById("indexDashboard").value);
	document.getElementById("indexDashboard").value = no-1;
	
	if (sno)
	{
		no = parseInt(no)+1;
		document.getElementById("indexDashboard").value = no;
	}	
		
	if(obj.style.marginLeft != 0) {var x = parseInt(obj.style.marginLeft.replace(/px/g, "")); x = -x;}
	else {var x = obj.style.marginLeft;}
	--no;
	var newx = no*850;
	
	
	slideIt(x, newx);
}

function slideIt(x, newx) { //inspired by Jeremy Keith - www.adactio.com
	if (newx > x) {x += Math.ceil((newx-x)/2);}
	else if (newx < x) {x += Math.floor((newx-x)/2);}
	else if (newx == x) {return true;}
	var obj = document.getElementById("photo").getElementsByTagName("ul")[0].style.marginLeft = -x + 'px';
	var time = setTimeout('slideIt('+x+', '+newx+')', 200);
}



function getXPos(h){
	var xPos = h.offsetLeft;
	var tempEl = h.offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	return xPos;
}
function getYPos(h){
	var yPos = h.offsetTop;
	tempEl = h.offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
	return yPos;
}


var seHideTimeout;
function se_ovr(h,idn){
	var yPos = getYPos(h);
	var xPos = getXPos(h);
	var seDiv = document.getElementById('ViewContent_'+idn);
	
	for (i=0;i<100;i++)
	{
		if (document.getElementById('ViewContent_announcement'+i))
		{
			document.getElementById('ViewContent_announcement'+i).style.display = 'none';
	
		}
		
		if (document.getElementById('ViewContent_tip'+i))
		{
			document.getElementById('ViewContent_tip'+i).style.display = 'none';
	
		}
		
		if (document.getElementById('ViewContent_resource'+i))
		{
			document.getElementById('ViewContent_resource'+i).style.display = 'none';
	
		}
	}
	
	
	seDiv.style.position = 'absolute';
	seDiv.style.display = 'block';

	seDiv.style.left = xPos-250+"px"; //-250 
	//if (yPos <= 400){
	seDiv.style.top = yPos-200+"px"; //-200
	//} else {
		//seDiv.style.top = yPos - 385;
	//}
	clearTimeout(seHideTimeout);
}



function se_ovrD(h,idn){
	for (i=0;i<100;i++)
	{
		if (document.getElementById('ViewContent_announcement'+i))
		{
			document.getElementById('ViewContent_announcement'+i).style.display = 'none';
	
		}
	}
	seHideTimeout = setTimeout('se_ovr(\''+h+'\',\''+idn+'\')', 200);	
}

function se_out(idn){
	//seHideTimeout = setTimeout(se_hide, 300);
	seHideTimeout = setTimeout('se_hide(\''+idn+'\')', 200);
}



function se_hide(idn){
	var seDiv = document.getElementById('ViewContent_'+idn);
	seDiv.style.display = 'none';
}

//show calendar details
function se_ovrCalendar(h,idn){
	var yPos = getYPos(h);
	var xPos = getXPos(h);
	var seDiv = document.getElementById('ViewContent_'+idn);
	
	seDiv.style.position = 'absolute';
	seDiv.style.display = 'block';
		
	
/*	var agent = navigator.userAgent.toLowerCase(); 
	if (agent.indexOf("msie") != -1) //IE
	{
		
		xPos = xPos-508;
		yPos = yPos-284;
	}
	*/
	
	//seDiv.style.left = xPos;
	//seDiv.style.top = yPos;
	clearTimeout(seHideTimeout);
}

function se_ovrCalendarDay(h,idn){
	var yPos = getYPos(h);
	var xPos = getXPos(h);
	var seDiv = document.getElementById('ViewContent_'+idn);
	
	seDiv.style.position = 'absolute';
	seDiv.style.display = 'block';

	seDiv.style.left = xPos-75+"px";
	seDiv.style.top = yPos-121+"px";
	clearTimeout(seHideTimeout);
}


function ColorchkLabel(id1,id2)
{
	if (document.getElementById(id1) && document.getElementById(id2))
	{
		if (document.getElementById(id1).checked==true)
		{
			document.getElementById(id2).className="ColorckLabel";
		}
		else
		{
			document.getElementById(id2).className="";
		}
		
	}
}




/***********************************************
* Start Building clock
***********************************************/
var oneMinute=60 //minute unit in seconds
var oneHour=60*60 //hour unit in seconds
var oneDay=60*60*24 //day unit in seconds
var divClockContainer;
var mycountainer;
var timeIntervalArray = new Array();

/**
* Build Videoconference Timer
**/
function ShowClock (ApplId)
{
	var mycountainer=document.getElementById("cpcontainer"+ApplId);
	var mycountainerCurrDate = document.getElementById("cpcontainerCur"+ApplId);
	var divClockContainer = document.getElementById("divClockContainer"+ApplId);
	
	if (mycountainer && mycountainerCurrDate && ApplId)
	{
		var endDate = mycountainer.innerHTML;
		var currDate = mycountainerCurrDate.innerHTML;
		if (timeIntervalArray[ApplId])
		{
			clearInterval(timeIntervalArray[ApplId]);
		}

		JsUpdateClockTime(endDate,currDate,ApplId);
	}
}

function JsUpdateClockTime (startingdate, enddate,ApplId)
{
	var divClockContainer = document.getElementById("divClockContainer"+ApplId);
	var mycountainer=document.getElementById("cpcontainer"+ApplId);
	var divClockContainer = document.getElementById("divClockContainer"+ApplId);
	
	//alert(startingdate+"-"+enddate);
	var CurrentDigital = new Date(enddate);
	var CurrentHours = CurrentDigital.getHours();
	var CurrentMinutes = CurrentDigital.getMinutes();
	var CurrentSeconds = CurrentDigital.getSeconds();
	var dn = "AM";
	if ((CurrentHours >= 12) && (CurrentMinutes >= 1) || (CurrentHours >= 13)) {
	dn = "PM";
	CurrentHours = CurrentHours-12;
	}
	if (CurrentHours == 0)
	CurrentHours = 12;
	if (CurrentHours<10)
	CurrentHours = "0"+CurrentHours;
	if (CurrentMinutes<10)
	CurrentMinutes = "0"+CurrentMinutes;
	if (CurrentSeconds<10)
	CurrentSeconds = "0"+CurrentSeconds;
	
	var months=new Array(13);
		months[1]="January";
		months[2]="February";
		months[3]="March";
		months[4]="April";
		months[5]="May";
		months[6]="June";
		months[7]="July";
		months[8]="August";
		months[9]="September";
		months[10]="October";
		months[11]="November";
		months[12]="December";
		var CurrentMonth=months[CurrentDigital.getMonth()+1];
		var CurrentDay=CurrentDigital.getDate();
		var CurrentYear=CurrentDigital.getYear();
		if (CurrentYear < 2000)    
		CurrentYear = CurrentYear + 1900; 
	
	

	var currentTime=new Date(enddate)
     var startingdate=new Date(startingdate)
	currentTime.setSeconds(currentTime.getSeconds()+1)
	var timediff=(startingdate-currentTime)/1000 //difference btw target date and current date, in seconds
	var timeNegative = 0;
	if (timediff<0)
	{
		var timediff=(currentTime-startingdate)/1000
		timeNegative = 1;
	}
	
	var dayfield=Math.floor(timediff/oneDay)
	var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
	var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
	var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
	
	var result={days: dayfield, hours:hourfield, minutes:minutefield, seconds:secondfield, timeNegativeField:timeNegative, timediffField:timediff}
	
	var spanClockContainer = document.getElementById("spanClockContainer"+ApplId);
	var spanCurrentTimeContainer  = document.getElementById("spanCurrentTimeContainer"+ApplId);
	
	if (result['timeNegativeField'])
	{
		if (spanClockContainer)
		{
			spanClockContainer.innerHTML = result['days']+" <sup>days</sup> "+result['hours']+" <sup>hours</sup> "+result['minutes']+" <sup>minutes</sup> "+result['seconds']+" <sup>seconds</sup>";
			spanCurrentTimeContainer.innerHTML = CurrentMonth+" "+CurrentDay+", "+CurrentYear+" "+CurrentHours+":"+CurrentMinutes+":"+CurrentSeconds+" "+dn+" "+JsTimeZone;
		}
		else
		{
			divClockContainer.innerHTML = '<img src="../images/clock.png" hspace="5" border="0" align="left" style="padding-left:1px"> <b>Current Time:</b> <span id="spanCurrentTimeContainer'+ApplId+'" style="color: #990000;font-weight:bold;">'+CurrentMonth+' '+CurrentDay+', '+CurrentYear+' '+CurrentHours+':'+CurrentMinutes+':'+CurrentSeconds+' '+dn+' '+JsTimeZone+'</span><br /><b>Time elapsed:</b> <span id="spanClockContainer'+ApplId+'" style="color: #990000;font-weight:bold;">'+result['days']+' <sup>days</sup> '+result['hours']+' <sup>hours</sup> '+result['minutes']+' <sup>minutes</sup> '+result['seconds']+' <sup>seconds</sup></span>';
		}
		
		if (document.getElementById("JoinToVideoConference"+ApplId))
		{
			document.getElementById("JoinToVideoConference"+ApplId).disabled=false;
		}
	}
	else
	{
		if (result['timediffField']<=300)
		{
			if (document.getElementById("JoinToVideoConference"+ApplId))
			{
				document.getElementById("JoinToVideoConference"+ApplId).disabled=false;
			}
		}

		if (spanClockContainer)
		{
			spanClockContainer.innerHTML = result['days']+" <sup>days</sup> "+result['hours']+" <sup>hours</sup> "+result['minutes']+" <sup>minutes</sup> "+result['seconds']+" <sup>seconds</sup>";
			spanCurrentTimeContainer.innerHTML = CurrentMonth+" "+CurrentDay+", "+CurrentYear+" "+CurrentHours+":"+CurrentMinutes+":"+CurrentSeconds+" "+dn+" "+JsTimeZone;
		}
		else
		{
			divClockContainer.innerHTML = '<img src="../images/clock.png" hspace="5" border="0" align="left" style="padding-left:1px"> <b>Current Time:</b> <span id="spanCurrentTimeContainer'+ApplId+'" style="color: #990000;font-weight:bold;">'+CurrentMonth+' '+CurrentDay+', '+CurrentYear+' '+CurrentHours+':'+CurrentMinutes+':'+CurrentSeconds+' '+dn+' '+JsTimeZone+'</span><br /><b>Time remaining:</b> <span id="spanClockContainer'+ApplId+'" style="color: #990000;font-weight:bold;">'+result['days']+' <sup>days</sup> '+result['hours']+' <sup>hours</sup> '+result['minutes']+' <sup>minutes</sup> '+result['seconds']+' <sup>seconds</sup></span>';
		}

	}
			
	timeIntervalArray[ApplId] =  setTimeout(function(){JsUpdateClockTime(startingdate, currentTime,ApplId)}, 1000) //update results every second
}

/**
* BUILD Webcast Timer
**/
function ShowWebcastClock (WebcastId, SecondsSinceWebcastEnd)
{
	mycountainer=document.getElementById("cpcontainer"+WebcastId);
	var mycountainerCurrDate = document.getElementById("cpcontainerCur"+WebcastId);
	
	if (mycountainer && mycountainerCurrDate && WebcastId)
	{
		var endDate = mycountainer.innerHTML;
		var currDate = mycountainerCurrDate.innerHTML;

		mycountainer.style.display="block";
		JsUpdateWebcastClockTime(endDate,currDate,SecondsSinceWebcastEnd);
	}
}


function JsUpdateWebcastClockTime (startingdate, enddate,SecondsSinceWebcastEnd)
{
	var currentTime=new Date(enddate)
     var startingdate=new Date(startingdate)
	currentTime.setSeconds(currentTime.getSeconds()+1)
	var timediff=(startingdate-currentTime)/1000 //difference btw target date and current date, in seconds
	var timeNegative = 0;
	if (timediff<0)
	{
		var timediff=(currentTime-startingdate)/1000
		timeNegative = 1;
	}
	
	var dayfield=Math.floor(timediff/oneDay)
	var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
	var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
	var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
	
	var result={days: dayfield, hours:hourfield, minutes:minutefield, seconds:secondfield, timeNegativeField:timeNegative, timediffField:timediff}
	
	if (result['timeNegativeField'])
	{
		mycountainer.innerHTML ="<img src=\"../images/clock.png\" border=\"0\" align=\"absmiddle\" hspace=\"5\" vspace=\"5\"> <span style=\"color: #990000;font-weight:bold;\"> <b>Time elapsed:</b> <span class='dcountstyle'>"+result['days']+" <sup>days</sup> "+result['hours']+" <sup>hours</sup> "+result['minutes']+" <sup>minutes</sup> "+result['seconds']+" <sup>seconds</sup></span></b> ago</span>";
		
		
		//five hours after the conference career counselor can't join
		//if (result['timediffField']>15000)
		if (SecondsSinceWebcastEnd>0 || result['timediffField']>86400)
		{
			if (document.getElementById("buttJoinWebcast"))
			{
				document.getElementById("buttJoinWebcast").disabled=true;
			}
			
			if (document.getElementById("divApplicantsInWebcastWindow"))
			{
				document.getElementById("divApplicantsInWebcastWindow").style.display="none";
			}
			
		}
		else
		{
			if (document.getElementById("buttJoinWebcast"))
			{
				document.getElementById("buttJoinWebcast").disabled=false;
			}
			
			if (document.getElementById("divApplicantsInWebcastWindow"))
			{
				document.getElementById("divApplicantsInWebcastWindow").style.display="block";
			}
		}
	}
	else
	{
		if (result['timediffField']<=300) //five minutes before te conference the career counselor can join
		{
			if (document.getElementById("buttJoinWebcast"))
			{
				document.getElementById("buttJoinWebcast").disabled=false;
			}
			
			if (document.getElementById("divApplicantsInWebcastWindow"))
			{
				document.getElementById("divApplicantsInWebcastWindow").style.display="block";
			}
		}

		mycountainer.innerHTML ="<img src=\"../images/clock.png\" border=\"0\" align=\"absmiddle\" hspace=\"5\" vspace=\"5\"> <b>Time remaining:</b> <span class='dcountstyle'>"+result['days']+" <sup>days</sup> "+result['hours']+" <sup>hours</sup> "+result['minutes']+" <sup>minutes</sup> "+result['seconds']+" <sup>seconds</sup></span>";
	}

	
			
	setTimeout(function(){JsUpdateWebcastClockTime(startingdate, currentTime,SecondsSinceWebcastEnd)}, 1000) //update results every second
}


//save as favorites
function ShowFavBox(h,idn){
	var yPos = getYPos(h);
	var xPos = getXPos(h);
	var seDiv = document.getElementById('ViewContent_'+idn);

	seDiv.style.position = 'absolute';
	seDiv.style.display = 'block';

	seDiv.style.left = xPos-100+"px"; 
	seDiv.style.top = yPos-70+"px";

	clearTimeout(seHideTimeout);
}

function SaveJobFavorite(id,act,obj)
{
	if (obj!='')
	{
		ShowFavBox(obj, id);
		document.getElementById('ViewContent_'+id).style.display = "block";
	}
	
	if (document.getElementById('textareaPostNote_'+id))
	{
		var NoteValue = document.getElementById('textareaPostNote_'+id).value;	
	}
	
	AjaxRequest.post
	(
	
	  	{
	  	'parameters':{'id':id,'act':act,'NoteMessage':NoteValue}
   	           ,'url':'LoadExternContent/SaveJob.php'
	          ,'onLoading':function()
		  { 
			document.getElementById('ViewContent_'+id).innerHTML = "<b>Saving Post ...</b>";	
		  }
	    ,'onSuccess':function(req)
	    	{
			document.getElementById('ViewContent_'+id).innerHTML = req.responseText;	
			document.getElementById('SaveJob_'+id).innerHTML = '<small>&raquo;<a href="SavedPosts.php">View Favorites</a></small>';
	    	}
	    ,'onError':function(req)
	    	{ 
	    		AjaxError(req);
	    	}
	  	}
	);	

}


//load modal windows videos or content
function jsDetailContent(pageTitle,pageType)
{
	var pagePadding = 'padding:5px 20px;';
	var heightWindow = 529;
	if (pageType=="videoStudentHome" 
		|| pageType=='videoEmployerHome'
		|| pageType=='video_resumeModule'
		|| pageType=='video_resumeGPSModule'
			|| pageType=='video_letterModule'
				|| pageType=='video_portfolioModule'
					|| pageType=='video_interviewModule'
						|| pageType=='video_skillsModule'
							|| pageType=='video_videoresumeModule'
								|| pageType=='video_websiteModule'
								 ||  pageType=='video_myHomePage'
									 ||  pageType=='loadWebinars'
		)
	{
		pagePadding = "";
	}
	
	if (pageType=='loadWebinars')
	{
		heightWindow = 529;
	}
	
	$("body").append('<div id="previewDocWindow" style="width:642px;'+pagePadding+'background:url(/images/or20/or20_ajax-loader.gif) no-repeat 50% 40%;"></div>');
	var topBarContent = '<h3 class="or20_TopModalTitle or20_modalTopIcon"><span style="text-transform: capitalize;">'+pageTitle+'</span></h3>';
	
	var diag = $("#previewDocWindow");
	//$("#previewDocWindow").html('<div style="padding-left:280px;padding-top:200px;"><img src="images/or20/or20_ajax-loader.gif" border="0" /> Loading...<div id="divTemporaryVideo" style="display:none;"></div></div>');
	
	 $.post(
			 "homeContent.php?page="+pageType,
			 	  {    
			 	   async: false
			 	  }, 
			     function(msg) { 
			 		  	$("#previewDocWindow").css("background", "none");
			 			$("#previewDocWindow").html(msg);
			 }); 
	
	 diag.dialog({
				modal:true,
				title: topBarContent,
				close: function() {diag.remove();},
				width: 642,
				height: heightWindow
			}); 
}

//load gps video in the same modal window
function jsLoadGpsVideo()
{
	$("#previewDocWindow").remove();
	
	jsDetailContent('ResumeGPS','video_resumeGPSModule');
}
	

function sleepVideo(numberMillis){
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true){
	now = new Date();
	if (now.getTime() > exitTime) return;
	}
};
	
//load O-NET 
function jsShowONET()
{
	$("body").append('<div id="previewDocWindow" style="width:930px;background:#ffffff url(/images/or20/or20_ajax-loader.gif) no-repeat 50% 40%;"></div>');
	var topBarContent = '<h3 class="or20_TopModalTitle or20_modalTopIcon"><span style="text-transform: capitalize;">O*NET Database</span></h3>';
	
	var diag = $("#previewDocWindow");
	//$("#previewDocWindow").html('<img src="images/or20/or20_ajax-loader.gif" border="0" /> Loading...');
	diag.load('/modules/onet/index.php',
			function(msg)
			{
				$("#previewDocWindow").css("background", "none");
				diag.html(msg);
			}
	);
	
	 diag.dialog({
				modal:true,
				title: topBarContent,
				close: function() {diag.remove();},
				width: 940,
				height: 550
			}); 
	 jsCloseMenuToolbar('Resources');
}
	
