//comp 2900 - mjexternal.js

//Author - Minu Jacob

function stopError() 
{
		return true;
}


//Author:Minu Jacob
//Date: 25, June 2004
//Function: Display Current Date on every Page
// display Current Date on every Page - Link this js file from every web page

function displayToday()
{
	var days=new Array(8);
	days[1]="Sunday";
	days[2]="Monday";
	days[3]="Tuesday";
	days[4]="Wednesday";
	days[5]="Thursday";
	days[6]="Friday";
	days[7]="Saturday";

	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 today=new Date();
	var lday=days[today.getDay()+ 1];
	var lmonth=months[today.getMonth() + 1];
	var date=today.getDate();
	var year=today.getFullYear();
	
	
	var currentDate=lday + ", " + lmonth + " " + date + ", " + year; 
	return currentDate;

}

//End of display Current Date function



//Author:Minu Jacob
//Date: 25, June 2004
//Function: Display Web Page's last modified Date/Time on every Web Page.



//start of display lastModified date 


function displayLastUpdated()
{

	var dayShort=new Array(8);
	dayShort[1]="Sun";
	dayShort[2]="Mon";
	dayShort[3]="Tue";
	dayShort[4]="Wed";
	dayShort[5]="Thur";
	dayShort[6]="Fri";
	dayShort[7]="Sat";

	var month=new Array(13);
	month[1]="January";
	month[2]="February";
	month[3]="March";
	month[4]="April";
	month[5]="May";
	month[6]="June";
	month[7]="July";
	month[8]="August";
	month[9]="September";
	month[10]="October";
	month[11]="November";
	month[12]="December";

	var targetDate=new Date(document.lastModified);

	alert(targetDate);

	var targetDay=dayShort[targetDate.getDay()+1];
	var targetMonth=month[targetDate.getMonth()+ 1];
	var targetYear=targetDate.getYear();
	var date=targetDate.getDate();
	var hours=targetDate.getHours();
	var minutes=targetDate.getMinutes();
	var seconds=targetDate.getSeconds();

	if (minutes <= 9) minutes = "0" + minutes;
			if (seconds <= 9) seconds = "0" + seconds;


	var lastModifiedDate=targetDay+ ", " + targetMonth + " " + date + ", "  + " " +	 targetYear + ", "  + hours + ":" + minutes + ":" + seconds;
	return lastModifiedDate;		


	}

//end of display lastModified date 

//start of openVersion window function 
//Author:Minu Jacob
//Date: 29, June 2004
//Function: Display Client's Browser Version and Browser support for Javascript Version
function openVersion(theUrl,windowname)
{
	window.open(theUrl, windowname,"width=500,height=300,scrollbars=yes,resizable=yes,status=yes");

}
//end of openVersion window function 



//start of Autumn Leaf function 
//Modified By:Minu Jacob
//Date: 30, June 2004
//Function: Display Autumn Leaves
// Modified by Minu to add the feature with the check box

//Autumn leaves- by Kurt Grigg (kurt.grigg@virgin.net)
//Modified by Dynamic Drive for NS6 functionality
//visit http://www.dynamicdrive.com for this script

//Pre-load your image below!
grphcs=new Array(6)
Image0=new Image();
Image0.src=grphcs[0]="al.gif";
Image1=new Image();
Image1.src=grphcs[1]="bl.gif"
Image2=new Image();
Image2.src=grphcs[2]="cl.gif"
Image3=new Image();
Image3.src=grphcs[3]="dl.gif"
Image4=new Image();
Image4.src=grphcs[4]="el.gif"
Image5=new Image();
Image5.src=grphcs[5]="fl.gif" 

Amount=8; //Smoothness depends on image file size, the smaller the size the more you can use!
Ypos=new Array();
Xpos=new Array();
Speed=new Array();
Step=new Array();
Cstep=new Array();
ns=(document.layers)?1:0;
ns6=(document.getElementById&&!document.all)?1:0;

if (ns){
for (i = 0; i < Amount; i++){
var P=Math.floor(Math.random()*grphcs.length);
rndPic=grphcs[P];
document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+rndPic+"></LAYER>");
}
}
else{
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i = 0; i < Amount; i++){
var P=Math.floor(Math.random()*grphcs.length);
rndPic=grphcs[P];
// Added by Minu Jacob, June 30, 2004:'visibility:value:hidden'
document.write('<img id="si'+i+'" src="'+rndPic+'" style="position:absolute;top:0px;left:0px;visibility:hidden">');
}
document.write('</div></div>');
}
WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight;
WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth;
for (i=0; i < Amount; i++){                                                                
 Ypos[i] = Math.round(Math.random()*WinHeight);
 Xpos[i] = Math.round(Math.random()*WinWidth);
 Speed[i]= Math.random()*5+3;
 Cstep[i]=0;
 Step[i]=Math.random()*0.1+0.05;
}
function fall(){
var WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight;
var WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth;
var hscrll=(ns||ns6)?window.pageYOffset:document.body.scrollTop;
var wscrll=(ns||ns6)?window.pageXOffset:document.body.scrollLeft;
for (i=0; i < Amount; i++){
sy = Speed[i]*Math.sin(90*Math.PI/180);
sx = Speed[i]*Math.cos(Cstep[i]);
Ypos[i]+=sy;
Xpos[i]+=sx; 
if (Ypos[i] > WinHeight){
Ypos[i]=-60;
Xpos[i]=Math.round(Math.random()*WinWidth);
Speed[i]=Math.random()*5+3;
}
if (ns){
document.layers['sn'+i].left=Xpos[i];
document.layers['sn'+i].top=Ypos[i]+hscrll;
}
else if (ns6){
document.getElementById("si"+i).style.left=Math.min(WinWidth,Xpos[i]);
document.getElementById("si"+i).style.top=Ypos[i]+hscrll;
}
else{
eval("document.all.si"+i).style.left=Xpos[i];
eval("document.all.si"+i).style.top=Ypos[i]+hscrll;
} 
Cstep[i]+=Step[i];
}
setTimeout("fall()",20);
}

	// function checkAutumnLeaf 
	// Author: Minu Jacob
	// Date: June 30 2004
	// Checks the toggle value of Autumn Leaf checkbox for checked or unchecked and assigns either a hidden or visible
	// style attribute based on user preference

	function checkAutumnLeaf(checkObject) { 

		if (document.getElementById(checkObject).checked == true) 
		{	
			for (i=0; i < Amount; i++)
			{
				document.getElementById("si"+i).style.visibility='visible';
			}
		
		}

		if (document.getElementById(checkObject).checked == false)
		{
			for (i=0; i < Amount; i++)
			{
				document.getElementById("si"+i).style.visibility='hidden';
		
			}
		}
	
	}

//start of text Animation function 
//Author:Minu Jacob
//Date: 03, July 2004
//Function: Display Client's Browser Version

var displayText= "Welcome to BCIT COMP 1921:Javascript Course Web Site";
var timerId;
var xPos;
var yPos;
var step=5;
var xMax;
var yMax;
var contentWidth;
var contentHeight;


document.write('<div id="banner" style="position:absolute;left:0px;top:0px;visibility:hidden;font-family:arial;font-size:12pt;font-weight:bold;color:#a52a2a"><nobr>' + displayText + '</nobr></div>');

function initPara()
{
	xPos= 0;
	yPos= 100;
	xMax = document.body.clientWidth;
	yMax = document.body.clientHeight;
	contentWidth=banner.offsetWidth;
	//alert(xMax);
	//alert(contentWidth);
	contentHeight=banner.offsetHeight;
	//document.getElementById("banner").style.left = xPos;
	//document.getElementById("banner").style.top = yPos;
	timerId= setInterval("movePara()",20);
}

function movePara()
{
	
	//alert(xPos);
	document.getElementById("banner").style.left = xPos + document.body.scrollLeft;
	document.getElementById("banner").style.top = yPos + document.body.scrollTop;

	if (xPos > xMax- contentWidth - step)
	{
		xPos=0;
		//clearTimeout(timerId);
	}
	else
	xPos = xPos + step;
}


function checkTxtAnimate(checkObject)
{
	if (document.getElementById(checkObject).checked == true)
	{
		document.getElementById("banner").style.visibility='visible';
		initPara();
	}

	if (document.getElementById(checkObject).checked == false)
	{
		document.getElementById("banner").style.visibility='hidden';
		clearTimeout(timerId);
	}
}

// end of text Animation function

//start of display Browser Version function using Browser Detection and Object Detection
//Author:Minu Jacob
//Date: 29, June 2004
//Function: Display Client's Browser Version

/*
function displayBrowserVersion()
{
var v3 = false; 
var op = false; 
var ie4  = false; 
var ie5 = false; 
var ie55 = false;
var ie6 = false;
var nn4 = false; 
var nn6 = false; 
var isMac = false; 
var aol = false;

var agent=navigator.userAgent.toLowerCase();

if(document.images)
{
		if(navigator.userAgent.indexOf("Opera") != -1)
		{
        op = true;
		} 
		else 
		{
			if(navigator.userAgent.indexOf("AOL") != -1)
			{
				aol = true;
			} 
			else 
			{
				ie4 = (document.all && !document.getElementById);
				nn4 = (document.layers);
				ie5 = ((document.all && document.getElementById) && (agent.indexOf("msie5.0") != -1));
				ie55 = ((document.all && document.getElementById) && (agent.indexOf("msie5.5") != -1));
				nn6 = (document.addEventListener);
				ie6	= ((document.all && document.getElementById) && (agent.indexOf("msie6.0") != -1));
			}
		}
} 
else 
{
    v3 = true;	
}

if(navigator.userAgent.indexOf("Mac") != -1)
{
    isMac = true;
}


if(op)
{ // do this
    alert("You are using Opera");
} 
if(ie4)
{ // do this
    alert("You are using Internet Explorer 4");
} 
if(ie5)
{ // do this
    alert("You are using Internet Explorer 5");
} 
if(ie55)
{ // do this
    alert("You are using Internet Explorer 5.5");
}
if(ie6)
{ // do this
    alert("You are using Internet Explorer 6");
} 
if(nn4)
{ // do this
    alert("You are using Netscape 4");
} 
if(nn6)
{ // do this
    alert("You are using Netscape 6 or higher");
} 
if(aol)
{ // do this
    alert("You are using an AOL browser");
}
if(v3)
{ // do this
    alert("You are using a pre version 4 browser");
}

}
//end of display Browser Version - link this js file from each web page
*/




/*
//start of openBrowserVersion window function 
//Author:Minu Jacob
//Date: 29, June 2004
//Function: Display Client's Browser support of Javascript Version

function openJsVersion(theUrl)
{
	window.open(theUrl, "jsversionwindow","width=500,height=300,scrollbars=yes,resizable=yes,status=yes");

}
*/

//end of openJavaScriptVersion window function 

/***********************************************
* Sticky Note script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
* Go to http://www.dynamicdrive.com/ for full source code
***********************************************/

//Specify display mode. 3 possible values are:
//1) "always"- This makes the fade-in box load each time the page is displayed
//2) "oncepersession"- This uses cookies to display the fade-in box only once per browser session
//3) integer (ie: 5)- Finally, you can specify an integer to display the box randomly via a frequency of 1/integer...
// For example, 2 would display the box about (1/2) 50% of the time the page loads.
/*
var displaymode="always"

var enablefade="yes" //("yes" to enable fade in effect, "no" to disable)
var autohidebox=["yes", 5] //Automatically hide box after x seconds? [yes/no, if_yes_hide_after_seconds]
var showonscroll="yes" //Should box remain visible even when user scrolls page? ("yes"/"no)
var IEfadelength=1 //fade in duration for IE, in seconds
var Mozfadedegree=0.05 //fade in degree for NS6+ (number between 0 and 1. Recommended max: 0.2)

////////No need to edit beyond here///////////

if (parseInt(displaymode)!=NaN)
var random_num=Math.floor(Math.random()*displaymode)

function displayfadeinbox(){
var ie=document.all && !window.opera
var dom=document.getElementById
iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
objref=(dom)? document.getElementById("fadeinbox") : document.all.fadeinbox
var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
var docwidth=(ie)? iebody.clientWidth : window.innerWidth
docheight=(ie)? iebody.clientHeight: window.innerHeight
var objwidth=objref.offsetWidth
objheight=objref.offsetHeight
objref.style.left=docwidth/2-objwidth/2+"px"
objref.style.top=scroll_top+docheight/2-objheight/2+"px"

if (showonscroll=="yes")
showonscrollvar=setInterval("staticfadebox()", 50)

if (enablefade=="yes" && objref.filters){
objref.filters[0].duration=IEfadelength
objref.filters[0].Apply()
objref.filters[0].Play()
}
objref.style.visibility="visible"
if (objref.style.MozOpacity){
if (enablefade=="yes")
mozfadevar=setInterval("mozfadefx()", 90)
else{
objref.style.MozOpacity=1
controlledhidebox()
}
}
else
controlledhidebox()
}

function mozfadefx(){
if (parseFloat(objref.style.MozOpacity)<1)
objref.style.MozOpacity=parseFloat(objref.style.MozOpacity)+Mozfadedegree
else{
clearInterval(mozfadevar)
controlledhidebox()
}
}

function staticfadebox(){
var ie=document.all && !window.opera
var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
objref.style.top=scroll_top+docheight/2-objheight/2+"px"
}

function hidefadebox(){
objref.style.visibility="hidden"
if (typeof showonscrollvar!="undefined")
clearInterval(showonscrollvar)
}

function controlledhidebox(){
if (autohidebox[0]=="yes"){
var delayvar=(enablefade=="yes" && objref.filters)? (autohidebox[1]+objref.filters[0].duration)*1000 : autohidebox[1]*1000
setTimeout("hidefadebox()", delayvar)
}
}

function initfunction(){
setTimeout("displayfadeinbox()", 100)
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}


if (displaymode=="oncepersession" && get_cookie("fadedin")=="" || displaymode=="always" || parseInt(displaymode)!=NaN && random_num==0){
if (window.addEventListener)
window.addEventListener("load", initfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", initfunction)
else if (document.getElementById)
window.onload=initfunction
document.cookie="fadedin=yes"
}

// end of the sticky note function
*/

