/*
'===========================================================================
'|
'|			  J A V A S C R I P T   D O C U M E N T
'|			(c) 2004 East Aurora High School Web Page - All Rights Reserved	
'|
'===========================================================================
'| Code Info ---------------------------------------------------------------
'|		Purpose:	Common Javascript Variables and Functions
'|		Requires:	
'|		Author:		Salvador Bayron Pablo M. Alvarez
'|		Workfile:	common.js
'===========================================================================
*/
/*
'===========================================================================
'| constants and global variables
'===========================================================================
*/

/*
'===========================================================================
'| functions
'===========================================================================
*/

//testing:

//alert('getting the js file');

function showForms(){

	for (var i=0; i<document.forms.length; i++) {
		alert(i + ') form name = ' + document.forms[i].name);
		
		//for (var j=0; j<document.forms[i].elements.length; j++) {
		for (var j=0; j<1; j++) {
			alert(document.forms[i].elements[j].name);
		}		
	}
}

//end testing

/*
'===========================================================================
'| name:		MM_preloadImages()
'| parameters:	image list
'| purpose:		macromedia function for preloading images
'===========================================================================
*/

//preload function
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];
				}
	}
}

/*
'===========================================================================
'| name:		highlightCell()
'| parameters:	object, color
'| purpose:		mouseover effect for left navigation
'===========================================================================
*/

function highlightCell(object,color) {
	object.style.background=color;	
}

/*
'===========================================================================
'| name:		dataChanged()
'| parameters:	
'| purpose:		check if user has changed data in an input
'===========================================================================
*/

var changed = false;
		
function dataChanged() {
	changed = true;	
}

var onloadfunctions = "";

function doOnloadFunctions() {
	var arr=onloadfunctions.split(",");
	for (var k=0;k<arr.length;k++) {
		if (arr[k].length>0) {
			eval(arr[k]+"();");
		}
	}
}

/*
'===========================================================================
'| name:		hyperlink()
'| parameters:	url
'| purpose:		create link with javascript
'===========================================================================
*/

function hyperlink(url) {
	window.document.location.href = url;	
}

/*
'===========================================================================
'| name:		openWindow()
'| parameters:	url, type
'| purpose:		open child window
'===========================================================================
*/

function openWindow(url,type) {				
	if (type == 'full') {
		var popW = 700;
		var popH = 500;
		var menubar = "yes";
		var toolbar = "yes";
		var location = "yes";
		var status = "yes";
		var scrollbars = "yes";
		var resizable = "yes";
	}
	else if (type == 'basic') {
		var popW = 400;
		var popH = 300;
		var menubar = "no";
		var toolbar = "no";
		var location = "no";
		var status = "no";
		var scrollbars = "no";
		var resizable = "no";
	}
	else if (type == 'full_basic') {
		var popW = 700;
		var popH = 500;
		var menubar = "yes";
		var toolbar = "no";
		var location = "no";
		var status = "yes";
		var scrollbars = "yes";
		var resizable = "no";
	}
	else if (type == 'cpp') {
		var popW = 700;
		var popH = 500;
		var menubar = "no";
		var toolbar = "no";
		var location = "no";
		var status = "yes";
		var scrollbars = "yes";
		var resizable = "no";
	}
							
	//Check screen size	
	if (screen) {	
		
		//alert ('width = ' + screen.availWidth);
		//alert ('height = ' + screen.availHeight);
		
		x = (screen.availWidth - popW)/2;
		
		if (type == 'full' || type == 'full_basic') {
			y = ((screen.availHeight - popH)/6);
		}
		else {
			y = ((screen.availHeight - popH)/2);
		}
		
		//alert('x = ' + x);
		//alert('y = ' + y);
	}
	
	//Open popup Window						
	window.open(url,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +menubar+ ',toolbar=' +toolbar+ ',location=' +location+ ',status=' +status+ ',scrollbars=' +scrollbars+ ',resizable=' +resizable);
}

//Function to preload images
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 to find images
function MM_findObj(n, d) 
{ //v3.0
	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); 
	
	return x;
}



//Function to restore images (mouse-outs)
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 to swap images (mouse-overs)
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];
	}
}

//Get date and time
function getDateTime(str)
{				
	//Variable declarations
	var dteObj = new Date();
	var dteToday = dteObj.toLocaleDateString();
	var dteTime = dteObj.toLocaleTimeString();
								
	//Check str
	if (str == 'date')
	{
		//Display current date
		document.write (dteToday);
	}
	else if (str == 'time')
	{
		//Display current time
		//document.write (dteTime);
	}
}


//Function to show pop-ups
function openWindow(strURL)
{
	//Variable declerations
	var strYes = "yes";
	var strNo = "no";
	
	if (screen.availWidth < 801)
	{
		var popW = 600;
		var popH = 400;	
	}
	else if (screen.availWidth > 800)
	{
		var popW = 600;
		var popH = 550;
	}
	
	//Check screen size
	if (screen)
	{		
		x = (screen.availWidth - popW)/2;
		y = (screen.availHeight - popH)/2;
	}
	//Open popup Window
	window.open(strURL,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +strNo+ ',toolbar=' +strNo+ ',location=' +strNo+ ',status=' +strNo+ ',scrollbars=' +strYes+ ',resizable=' +strYes);
}

//Function to show pop-ups with menubar
function openWindowMenu(strURL)
{
	//Variable declarations
	var strYes = "yes";
	var strNo = "no";
	
	if (screen.availWidth < 801)
	{
		var popW = 600;
		var popH = 325;	
	}
	else if (screen.availWidth > 800)
	{
		var popW = 600;
		var popH = 475;
	}
	
	//Check screen size
	if (screen)
	{		
		x = (screen.availWidth - popW)/2;
		y = (screen.availHeight - popH)/2;
	}
	//Open popup Window
	window.open(strURL,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +strYes+ ',toolbar=' +strNo+ ',location=' +strNo+ ',status=' +strNo+ ',scrollbars=' +strYes+ ',resizable=' +strYes);
}

//Function to show pop-ups with menubar
function openWindowTool(strURL)
{
	//Variable declarations
	var strYes = "yes";
	var strNo = "no";
	
	if (screen.availWidth < 801)
	{
		var popW = 600;
		var popH = 325;	
	}
	else if (screen.availWidth > 800)
	{
		var popW = 600;
		var popH = 475;
	}
	
	//Check screen size
	if (screen)
	{		
		x = (screen.availWidth - popW)/2;
		y = (screen.availHeight - popH)/2;
	}
	//Open popup Window
	window.open(strURL,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +strNo+ ',toolbar=' +strYes+ ',location=' +strNo+ ',status=' +strNo+ ',scrollbars=' +strYes+ ',resizable=' +strYes);
}

//Function to show pop-ups with menubar
function openWindowMenuTool(strURL)
{
	//Variable declarations
	var strYes = "yes";
	var strNo = "no";
	
	if (screen.availWidth < 801)
	{
		var popW = 700;
		var popH = 350;	
	}
	else if (screen.availWidth > 800)
	{
		var popW = 900;
		var popH = 500;
	}
	
	//Check screen size
	if (screen)
	{		
		x = (screen.availWidth - popW)/2;
		y = 20 //(screen.availHeight - popH)/2;
	}
	//Open popup Window
	window.open(strURL,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +strYes+ ',toolbar=' +strYes+ ',location=' +strNo+ ',status=' +strNo+ ',scrollbars=' +strYes+ ',resizable=' +strYes);
}

//Function to show pop-ups with menubar
function openWindowFull(strURL)
{
	//Variable declarations
	var strYes = "yes";
	var strNo = "no";
	
	if (screen.availWidth < 801)
	{
		var popW = 700;
		var popH = 350;	
	}
	else if (screen.availWidth > 800)
	{
		var popW = 900;
		var popH = 500;
	}
	
	//Check screen size
	if (screen)
	{		
		x = 60 //(screen.availWidth - popW)/2;
		y = 20 //(screen.availHeight - popH)/2;
	}
	//Open popup Window
	window.open(strURL,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +strYes+ ',toolbar=' +strYes+ ',location=' +strYes+ ',status=' +strYes+ ',scrollbars=' +strYes+ ',resizable=' +strYes);
}

//Function to show pop-ups with menubar
function openWindowNoMenu(strURL)
{
	//Variable declarations
	var strYes = "yes";
	var strNo = "no";
	
	if (screen.availWidth < 801)
	{
		var popW = 700;
		var popH = 350;	
	}
	else if (screen.availWidth > 800)
	{
		var popW = 900;
		var popH = 500;
	}
		
	//Check screen size
	if (screen)
	{		
		x = 60 //(screen.availWidth - popW)/2;
		y = 20 //(screen.availHeight - popH)/2;
	}
	//Open popup Window
	window.open(strURL,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +strYes+ ',toolbar=' +strYes+ ',location=' +strNo+ ',status=' +strNo+ ',scrollbars=' +strYes+ ',resizable=' +strYes);
}

//Function to show pop-ups with menubar
function openWindowGallery(strURL)
{
	//Variable declarations
	var strYes = "yes";
	var strNo = "no";
	
	if (screen.availWidth < 801)
	{
		var popW = 600;
		var popH = 325;	
	}
	else if (screen.availWidth > 800)
	{
		var popW = 600;
		var popH = 475;
	}
	
	//Check screen size
	if (screen)
	{		
		x = (screen.availWidth - popW)/2;
		y = (screen.availHeight - popH)/2;
	}
	//Open popup Window
	window.open(strURL,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +strNo+ ',toolbar=' +strNo+ ',location=' +strNo+ ',status=' +strNo+ ',scrollbars=' +strYes+ ',resizable=' +strYes);
}

function openWindowMural(strURL)
{
	//Variable declarations
	var strYes = "yes";
	var strNo = "no";
	
	if (screen.availWidth < 801)
	{
		var popW = 600;
		var popH = 425;	
	}
	else if (screen.availWidth > 800)
	{
		var popW = 600;
		var popH = 525;
	}
	
	//Check screen size
	if (screen)
	{		
		x = (screen.availWidth - popW)/2;
		y = (screen.availHeight - popH)/2;
	}
	//Open popup Window
	window.open(strURL,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +strNo+ ',toolbar=' +strNo+ ',location=' +strNo+ ',status=' +strNo+ ',scrollbars=' +strYes+ ',resizable=' +strYes);
}

function openWindowMural2(strURL)
{
	//Variable declarations
	var strYes = "yes";
	var strNo = "no";
	
	if (screen.availWidth < 801)
	{
		var popW = 600;
		var popH = 375;	
	}
	else if (screen.availWidth > 800)
	{
		var popW = 600;
		var popH = 375;
	}
	
	//Check screen size
	if (screen)
	{		
		x = (screen.availWidth - popW)/2;
		y = (screen.availHeight - popH)/2;
	}
	//Open popup Window
	window.open(strURL,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +strNo+ ',toolbar=' +strNo+ ',location=' +strNo+ ',status=' +strNo+ ',scrollbars=' +strYes+ ',resizable=' +strYes);
}


//Function to show pop-ups with menubar
function openSmWindow(strURL)
{
	//Variable declarations
	var strYes = "yes";
	var strNo = "no";
	
	if (screen.availWidth < 801)
	{
		var popW = 465;
		var popH = 460;	
	}
	else if (screen.availWidth > 800)
	{
		var popW = 475;
		var popH = 460;
	}
	
	//Check screen size
	if (screen)
	{		
		x = (screen.availWidth - popW)/2;
		y = (screen.availHeight - popH)/2;
	}
	//Open popup Window
	window.open(strURL,'','width=' +popW+ ',height=' +popH+ ',screenX=' +x+ ',screenY=' +y+ ',top=' +y+',left='+x+ ',menubar=' +strNo+ ',toolbar=' +strNo+ ',location=' +strNo+ ',status=' +strNo+ ',scrollbars=' +strYes+ ',resizable=' +strYes);
}



function SmallWindow1(wintype) 
{ SmallWin=window.open(wintype,"SmallWin","toolbar=no,directories=no,status=no,scrollbars=no,menubar=no,width=365,height=360"); SmallWin.window.focus() } 

