
// ------------------------------------------------------------------------------------------------------------------

// NAV ON-STATE

var curLoc;
curLoc = document.location.toString();

var navList = new Array;

	navList[0] = new Object; navList[0].id = "mnAbout"; navList[0].path = "/about/";
	navList[1] = new Object; navList[1].id = "mnNews"; navList[1].path = "/news/";
	navList[2] = new Object; navList[2].id = "mnPortfolio"; navList[2].path = "/portfolio/";
	navList[3] = new Object; navList[3].id = "mnWriting"; navList[3].path = "/whitepapers/";
	navList[4] = new Object; navList[4].id = "mnResume"; navList[4].path = "/resume/";
	navList[5] = new Object; navList[5].id = "mnGallery"; navList[5].path = "/gallery/";
	navList[6] = new Object; navList[6].id = "mnSurf"; navList[6].path = "/surf/";
	navList[7] = new Object; navList[7].id = "mnMusic"; navList[7].path = "/music/";
	navList[8] = new Object; navList[8].id = "mnContact"; navList[8].path = "/contact/";
	navList[9] = new Object; navList[9].id = ""; navList[9].path = ""; //catch misc files

var setNavState = function() {
	if (!document.getElementById) return false;
	var id;
	for (i=0; i<=navList.length; i++) {
		if (curLoc.indexOf(navList[i].path) > -1) {
			id = navList[i].id;
			break;
		}
	}
	if (document.getElementById(id)) {
		var o = document.getElementById(id);
		o.className = "mnOn";
	}
}

// ------------------------------------------------------------------------------------------------------------------

// CURRENT DATE

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 time = new Date();
	var lmonth = months[time.getMonth() + 1];
	var date = time.getDate();
	var year = time.getYear();
	if (year < 2000)    
	year = year + 1900;

// ------------------------------------------------------------------------------------------------------------------

// POP-UP WINDOWS

function makePOPwindow(url,height,width){newWindow = window.open(url,"","height=" + height + ",width=" + width + ",toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no")}
function makeNEWwindow(url,height,width){newWindow = window.open(url,"","height=" + height + ",width=" + width + ",toolbar=no,location=yes,directories=no,status=yes,menubar=yes,scrollbars=auto,resizable=yes")}

// ------------------------------------------------------------------------------------------------------------------

// GALLERY DROP-DOWN

var gallerySwitchEN = function(theform) {
	num= theform.URLSelect.selectedIndex;
	if (num==3)  {site = "/gallery/indo.php";}
	if (num==4)  {site = "/gallery/thailand.php";}
	if (num==5)  {site = "/gallery/bajaSur.php";}
	if (num==6)  {site = "/gallery/costaRica.php";}
	if (num==7)  {site = "/gallery/chihuahua.php";}
	if (num==8)  {site = "/gallery/kalifornia.php";}
	if (num==9)  {site = "/gallery/france.php";}
	if (num==10) {site = "/gallery/china.php";}
	if (num==11) {site = "/gallery/hawaii.php";}
	if (num==12) {site = "/gallery/bullrun.php";}
	if (num==13) {site = "/gallery/england.php";}
	this.location.href=site;
}

// ------------------------------------------------------------------------------------------------------------------

// TEXT SIZE SWITCHER

var fontSize = 14;

var setTextSize = function() {
	domTextSize(document.getElementById("mainText"));
	saveTextSize();
}

var increaseTextSize = function() {
	fontSize = fontSize+2;
	if (fontSize > 24) {fontSize = 24;}
	setTextSize()
}

var decreaseTextSize = function() {
	fontSize = fontSize-2
	if (fontSize < 9) fontSize = 9;
	setTextSize();
}

var saveTextSize = function() {
	var expire = new Date ();
   	expire.setTime (expire.getTime() + (6000 * 24 * 3600000));
   	expire = expire.toGMTString();
	document.cookie="fontSize="+fontSize+"; path=/; expires="+expire;
}

var loadFontSize = function() {
	if (!document.getElementById) return false;
	var main = document.getElementById("mainText");
	if (!main) return false;
	tempArray = document.cookie.split(";");		
	for (tA = 0; tA < tempArray.length; tA++) {
		if (tempArray[tA].indexOf('fontSize') > -1) {
			fontValue = tempArray[tA].split("=")
			fontSize = parseInt(fontValue[1]);
		}
	}
	domTextSize(main);
	return fontSize;
}

var domTextSize = function(obj) {obj.style.fontSize = fontSize + 'px';}
window.onload = loadFontSize;

// ------------------------------------------------------------------------------------------------------------------

// FORM VALIDATION

var validate_form = function() {
  validity = true;
  if (!check_empty(document.contact.realname.value))
        { validity = false; alert('Please enter your name!'); }
  if (!check_email(document.contact.email.value))
        { validity = false; alert('E-mail address is invalid!'); }

  return validity;
}

var check_empty = function(text) {
  return (text.length > 0);
}

var check_email = function(address) {
  if ((address == "")
    || (address.indexOf ('@') == -1)
    || (address.indexOf ('.') == -1))
      return false;
  return true;
}

// ------------------------------------------------------------------------------------------------------------------