// JS functions for bradvertrees.com
// created by Susan Vertrees 1/26/08

// Copyright 2001, Aaron Boodman
// This code is public domain. Please use it for good, not evil.
// from http://youngpup.net/projects/sleight/ woot!

if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
	window.attachEvent("onload", fnLoadPngs);
}

function fnLoadPngs() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

	for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
		if (itsAllGood && img.src.match(/\.png$/i) != null) {
			var src = img.src;
			var div = document.createElement("DIV");
			div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizing='scale')"
			div.style.width = img.width + "px";
			div.style.height = img.height + "px";
			img.replaceNode(div);
		}
		img.style.visibility = "visible";
	}
}
//end slight.js code

// writes out list of 3 featured writing samples in samples section
function writeSamples() {
	var arrTitle = new Array();
		arrTitle[0] = 'Susan Vertrees Web Design Portfolio';
		arrTitle[1] = 'Brad\'s Reader Blog';
		arrTitle[2] = 'Historic Banning House &amp; Pub Lunch Tour';
		arrTitle[3] = 'New Asthma Resource Directory for Consumers...';
		arrTitle[4] = 'Behind the Receiving Gates';
		arrTitle[5] = 'The Season for Giving';
		arrTitle[6] = 'Famous Donuts New at College';
		arrTitle[7] = 'Sales Letter for Insurance Company';
		arrTitle[8] = 'Freelance Web Design Solicitation Email';
	
	var arrLink = new Array();
		arrLink[0] = '/samples/susan_portfolio.htm';
		arrLink[1] = '/samples/brads_reader.htm'
		arrLink[2] = '/samples/banning_house.htm';
		arrLink[3] = '/samples/asthma_resource.htm';
		arrLink[4] = '/samples/behind_gates.htm';
		arrLink[5] = '/samples/season_giving.htm';
		arrLink[6] = '/samples/famous_donuts.htm';
		arrLink[7] = '/samples/sales_insurance.htm';
		arrLink[8] = '/samples/design_email.htm';
	
	var arrDesc = new Array();
		arrDesc[0] = 'Descriptive content written for a freelance web designer\'s online portfolio. August 2007.';
		arrDesc[1] = 'My blog about all things literature and writing. An ongoing project.';
		arrDesc[2] = 'A press release announcing an upcoming trip to the Banning House in Wilmington, CA. August 2001.';
		arrDesc[3] = 'A press release for the American Lung Association announcing a new asthma care directory. December 2002.';
		arrDesc[4] = 'Article published in the College of DuPage <em>Courier</em> describing the college\'s onsite receiving warehouse. October 2003.';
		arrDesc[5] =  'An article about the Share the Sprit Holiday Gift Drive for the College of DuPage <em>Courier</em>. December 2003.';
		arrDesc[6] = 'Written for the College of DuPage <em>Courier</em> announcing the sale of Krispy Kreme donuts on campus. April 2004.';
		arrDesc[7] = 'A sample sales letter written for an insurance company touting their new services.';
		arrDesc[8] = 'A prospecting email written for a web designer to send to possible clients. December 2007';
		
		var ranNum1 = Math.floor(Math.random() * 8); // get random numbers for which post to display
		var ranNum2 = Math.floor(Math.random() * 8);
		var ranNum3 = Math.floor(Math.random() * 8);
		while (ranNum1 == ranNum2){
			ranNum2 = Math.floor(Math.random() * 8);
		}
		while (ranNum1 == ranNum3 || ranNum2 == ranNum3){ // make sure no two random numbers are the same
			ranNum3 = Math.floor(Math.random() * 8);
		}
		document.write('<ul class="featured">'); // write out list items
		document.write('<li><a href="' + arrLink[ranNum1] + '">' + arrTitle[ranNum1] + '</a> - ' + arrDesc[ranNum1] + '</li>');
		document.write('<li><a href="' + arrLink[ranNum2] + '">' + arrTitle[ranNum2] + '</a> - ' + arrDesc[ranNum2] + '</li>');
		document.write('<li class="last"><a href="' + arrLink[ranNum3] + '">' + arrTitle[ranNum3] + '</a> - ' + arrDesc[ranNum3] + '</li>');
		document.write('</u>');
}

//validates the contact me form
function validateForm(form) { 
	if (form.name.value == "") { 
	   alert("Please enter your name."); 
	   form.name.focus( ); 
	   return false;
	} else if (form.email.value == "") { 
	   alert("Please enter your email address."); 
	   form.email.focus( ); 
	   return false;
	} else if (form.comments.value == ""){
		alert("Please enter your comments.");
		form.comments.focus();
		return false;
	}	else {
		document.frmContact.submit();
		return true;
	}
}

// clears the contact me form
function resetForm(form){
	form.name.value = "";
	form.email.value = "";
	form.subject.value = "";
	form.comments.value = "";
}

function writeEmail(){
	document.write('<p><a href="m&#97;i&#108;t&#111;:&#98;&#114;&#97;&#100;&#118;&#49;&#64;&#98;&#114;&#97;&#100;&#118;&#101;&#114;&#116;&#114;&#101;&#101;&#115;&#46;&#99;&#111;&#109;">&#98;&#114;&#97;&#100;&#118;&#49;&#64;&#98;&#114;&#97;&#100;&#118;&#101;&#114;&#116;&#114;&#101;&#101;&#115;&#46;&#99;&#111;&#109;<\/a><\/p>');
	
}