﻿var remoteWin = null;
var photos=new Array()
var journals=new Array()
var which=0


photos[0]="cape rock.jpg"
photos[1]="mt san michel.jpg"
photos[2]="rovaniemi snow and ice construction2.jpg"
photos[3]="rovaniemi snowmen.jpg"
photos[4]="vorarlberg-funkensontag.jpg"

journals[0]="Aachen, Germany has a large university student population"
journals[1]="Strolling the streets of old Hasselt, Belgium"
journals[2]="Satakunta Polytechnic's studio art building in Kankaanpaa, Finland"
journals[3]="Relaxing in the square, Rennes, France"
journals[4]="Santa Claus resides in Rovaniemi, Finland year round"


var preloadedimages=new Array()
for (i=0;i<photos.length;i++){
preloadedimages[i]=new Image()
preloadedimages[i].src=photos[i]
}

function applyeffect(){
if (document.all && photoslider.filters){
photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*23)
photoslider.filters.revealTrans.stop()
photoslider.filters.revealTrans.apply()
}
}

function playeffect(){
if(document.all && photoslider.filters)
photoslider.filters.revealTrans.play()
}

function keeptrack(){
window.status="Image "+(which+1)+" of "+photos.length
}

function backward(){
if (which>0){
which--
applyeffect()
document.images.photoslider.src=photos[which]
document.getElementById("journals").innerHTML=journals[which]
playeffect()
keeptrack()
}
}

function forward(){
if (which<photos.length-1){
which++
applyeffect()
document.images.photoslider.src=photos[which]
document.getElementById("journals").innerHTML=journals[which]
playeffect()
keeptrack()
}
}

function first()
{
window.location.reload()
}


//
// Generic open window function
//
function openWindow(pURL, pWindowName, pWidth, pHeight, pMenubar, pSetFocus, pScrollbars, pResizable, pPositionStyle) 
{

	browserName = navigator.appName;
	browserVer = parseInt(navigator.appVersion);

	if (pPositionStyle == "A")
	{
		left_position = screen.availWidth - pWidth - 10;
		top_position = 0;
	}
	else
	{
		left_position = (screen.availWidth / 2) - (pWidth / 2);
		top_position = 50;
	}
				
	if (((browserName == "Netscape") && (browserVer < 3)) || ((browserName == "Microsoft Internet Explorer") && (browserVer < 2))) 
	{
		alert("\n Sorry, but this feature is only available for Navigator 3.x, Explorer 4.x, and above. \n");			
	} 
	else 
	{
		remoteWin = window.open(pURL,pWindowName,'toolbar=1,location=0,directories=0,status=0,left=' + left_position + ',top=' + top_position + ',menubar=' + pMenubar + ',scrollbars=' + pScrollbars + ',resizable=' + pResizable + ',width=' + pWidth + ',height=' + pHeight);

		if (remoteWin != null) 
		{
			self.name = "helpWindow";
		}
	}
			
	if (pSetFocus == true) 
	{
		if (((browserName == "Netscape") && (browserVer >= 3)) || ((browserName == "Microsoft Internet Explorer") && (browserVer >= 4)))
			remoteWin.focus();
	}	
}
//
// Opens an application work window (centered)
//
function openAppWorkWindow(pstrURL, pintWidth, pintHeight) 
{
	openWindow(pstrURL, 'AppWork', pintWidth, pintHeight, 0, 1, 1, 1, 'B');	
}

//
// Opens a help viewer window
//
function openHelpWindow(pstrURL, pintWidth, pintHeight) 
{
	openWindow(pstrURL, 'AppHelp', pintWidth, pintHeight, 1, 1, 1, 1, 'A');	
}

//
// Opens a data viewer window
//
function openDataWindow(pstrURL, pintWidth, pintHeight) 
{
	openWindow(pstrURL, 'AppData', pintWidth, pintHeight, 1, 1, 1, 1, 'A');	
}

//
// Request that the user confirms a delete action
//
function confirmDelete(itemType)
{
	if (itemType.length == 0)
		itemType = "record";
	
	if (window.confirm("You are requesting to delete the current " + itemType + ".\nOnce an item has been deleted, it can not be undone.\n\nAre you sure you want to delete this " + itemType + "?") == true)
	    {
		return true;
		}
	else
	    {
		return false;
		}
}

//
// Request that the user confirms a delete action
//
function confirmDeleteList(itemType)
{
	if (itemType.length == 0)
		itemType = "records";
	
	if (window.confirm("You are requesting to delete the selected " + itemType + ".\nOnce an item has been deleted, it can not be undone.\n\nAre you sure you want to delete the selected " + itemType + "?") == true)
	    {
		return true;
		}
	else
	    {
		return false;
		}
}

//
// Redirect browser to requested URL
//
function redirect(url, allowPostback)
{
	document.location.href = url;
	
	if (allowPostback == true)
	    {
	    return true;
	    }
    else	    
	    {
	    return false;
	    }
}

//
// Initialize focus on a certain control
//
function SetFocus(control, select) 
{
	control.focus();
	if (select == "Y")
	{
		control.select();
	}
}

//
// Sets the checked property on a series of check boxes
//
function setCheckboxList(parent, control, value) 
{
	var endSearch = false
	var i = 0

	// Search for check box controls
	if (setCheckboxList_MaxKey != null)
	{
		while(!endSearch)
		{
			// Find item
			var item = document.getElementById(parent + "__ctl" + i + "_" + control);
			if (item != null)
			{
				item.checked = value;
				if (item.name == setCheckboxList_MaxKey)
					endSearch = true;
			}
			i++;
		}
	}
}

//
// Opens an application work window (centered)
//
function openModalDialog(pstrURL, pintWidth, pintHeight) 
{
	var szFeatures;

	left_position = (screen.availWidth / 2) - (pintWidth / 2);
	top_position = 50;

	szFeatures = 'dialogWidth:' + pintWidth + 'px; dialogHeight:' + pintHeight + 'px; dialogTop:50px; center:1; status:0; help:0';

	szName = window.showModalDialog(pstrURL, 'AppWorkModal', szFeatures)

}


//============================================================================
//  %FUNCTION:		RemoveItems
//  %DESCRIPTION:	Moves items from the selected options list to the 
//                  available options list
//  %INPUTS:        form        Form object
//                  removeAll   Boolean
//  %OUTPUTS:		None
//  %RETURN:		None
//============================================================================    
function RemoveItems(lstAvailableItems, lstSelectedItems, lstSync, removeAll)
{
    var item_key;
    var option_name;
    var newOption;
    var move;
    var keys;

    //Process list members            
	for (var i = lstSelectedItems.length - 1; i >= 0; i--)
	{
		move = false;
		
		//Adding all members
		if (removeAll == true)
		{
			move = true;
		}
		else
		{
    		//Adding selected members
			if (lstSelectedItems.options[i].selected)
		    {
    			move = true;
		    }
		}

		//If moving member
		if (move == true)
		{
			//Get id and name
			item_key = lstSelectedItems.options[i].value
			option_name = lstSelectedItems.options[i].text
			keys = item_key.split("|")
			
			//If option being removed should be added back to available list
			newOption = new Option(option_name, keys[1]);
			lstAvailableItems.options[lstAvailableItems.length] = newOption;

			//Add option to sync list
			newOption = new Option(option_name, GetTimestamp() + "|" + item_key + "||R~~");
			newOption.selected = true;
			lstSync.options[lstSync.length] = newOption;

			//Remove option from available list
			lstSelectedItems.options[i] = null;
		}
	}
}

//============================================================================
//  %FUNCTION:		GetTimestamp
//  %DESCRIPTION:	Get a timestamp value
//  %INPUTS:        None
//  %OUTPUTS:		None
//  %RETURN:		String
//============================================================================    
function GetTimestamp()
{
    var timestamp = new Date();
    return timestamp.getTime();
}

	function AddItems(lstAvailableItems, lstSelectedItems, lstSync, addAll)
            {
                var item_key;
                var option_name;
                var newOption;
                var move;

                //debugger;
                //Process list members            
	            for (var i = lstAvailableItems.length - 1; i >= 0; i--)
	            {
		            move = false;
            		
		            //Adding all members
		            if (addAll == true)
		            {
			            move = true;
		            }
		            else
		            {
    		            //Adding selected members
			            if (lstAvailableItems.options[i].selected)
		                {
    			            move = true;
		                }
		            }

		            //If moving member
		            if (move == true)
		            {
			            //Get id and name
			            item_key = lstAvailableItems.options[i].value
			            option_name = lstAvailableItems.options[i].text
            			
			            //Add option to selected list
			            newOption = new Option(option_name, item_key);
			            lstSelectedItems.options[lstSelectedItems.length] = newOption;

			            //Add option to sync list
			            newOption = new Option(option_name, GetTimestamp() + "|" + item_key + "|" + option_name + "|A~");
			            newOption.selected = true;
			            lstSync.options[lstSync.length] = newOption;

			            //Remove option from available list
			            lstAvailableItems.options[i] = null;
		            }
	            }
            }
