/* function or opening a popup window */

function createWindow(cUrl,cName,cFeatures) {
	var xWin = window.open(cUrl,cName,cFeatures);
	xWin.focus();
}

function shutwin() {
	var xWin = window.close();
}

function pageSwap() {
    if ( document.clients.clientlist.options[document.clients.clientlist.selectedIndex].value != "") {
        var url = document.clients.clientlist.options[document.clients.clientlist.selectedIndex].value;
        window.location.href = url;
    }
}

function resize(windowWidth,windowHeight,targetWidth,targetHeight,widthMod,heightMod,fullScreen) {
	if (fullScreen) {
		targetWidth = screen.availWidth;
		targetHeight = screen.availHeight;
	 }
	if (windowWidth < targetWidth) 
		windowWidth += widthMod;
	if (windowHeight < targetHeight) 
		windowHeight += heightMod;
	windowLeft = (screen.availWidth / 2) - (windowWidth / 2);
	windowTop = (screen.availHeight / 2) - (windowHeight / 2);
	top.window.resizeTo(windowWidth,windowHeight);
	top.window.moveTo(windowLeft,windowTop);
	if (windowWidth < targetWidth || windowHeight < targetHeight)		
		setTimeout('resize(' + windowWidth + ', ' + windowHeight + ', ' + targetWidth + ', ' + targetHeight + ', ' + widthMod + ', ' + heightMod + ', ' + fullScreen + ');',10);
 }

function noSpam(user,domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function preloadImages() {
	document.preload = new Array();
	if (document.images) {
		for (var i = 0; i < preloadImages.arguments.length; i++) {
			document.preload[i] = new Image();
			document.preload[i].src = preloadImages.arguments[i];
		}
	}
}

function loadImages() {
		var i;
		var temp;

		for (i = 0; i < arguments.length; i++) {
				temp = makeId(arguments[i]);
				eval(temp +"= new Image()");
				eval(temp+".src ='"+ arguments[i] +"'");
		}
}
function makeId(path) {
		return path.substring( path.lastIndexOf("/")+1, path.lastIndexOf("."));
}

function checkContactForm(){
	var frm = document.contact;
	var err_msg = '';
	if(frm.first_name.value == ''){
		err_msg += "\n   - " +  'Please include your first name.\n';	
 }
	if(frm.last_name.value == ''){
		err_msg += "\n   - " +  'Please include your last name.\n';	
 }
	if(frm.email.value == ''){
		err_msg += "\n   - " +  'Please include your email address.\n';	
 }
	if(err_msg == ''){
		frm.submit();
	} else {
		msg =  "______________________________________________________\n\n"; 
		msg += "The form was not submitted because of the following error(s).\n"; 
		msg += "Please correct these error(s) and resubmit.\n"; 
		msg += "______________________________________________________\n\n"; 
		msg += err_msg+ "\n";       
		alert(msg);
	}
}

//hey this is easy - just populate this array with
//the pictures and captions you want in this slide show.

var cnnPix = new Array("images/where/bolivia/pict01.gif","images/where/bolivia/pict02.gif","images/where/bolivia/pict03.gif","images/where/bolivia/pict04.gif");
/* above is the array that holds our images, it is indexed from 0 to 
   (number of elements - 1) */

var thisPic = 0;  //the counter for the image array
var lastPic = 3;  //the last cell in our array = (number of pictures - 1)

function processPrevious() {
	if (document.images) {
		if (thisPic==0) { //if at the very beginning of array
			thisPic=lastPic; //goto the last cell in the array
		} else {
			thisPic--; //else simply decrement the counter                    
		}
		document.myPicture.src=cnnPix[thisPic];
	}
}

function processNext() {
	if (document.images) {
		if (thisPic==lastPic) { //if at the very end of the array		
			thisPic=0; //goto the first cell of the array
		} else {
			thisPic++; //else simply increment the counter
		}
		document.myPicture.src=cnnPix[thisPic];
	}
}