//Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com
var okToScroll = 1
function submitForms()
{
if (isFname() && isLname()) {
		return true;
	}	
	else {
		return false;
	}
}

function isFname()
{
	if (document.forms[0].elements[2].value == "")	{	
		alert ("\n The First Name field is blank. \n\n Please enter your first name.")
		document.forms[0].elements[2].focus();
		return false;
	}
	return true;
}

function isLname()
{
	if (document.forms[0].elements[3].value == "") {
		alert ("\n The Last Name field is blank. \n\nPlease enter your last name.")
		document.forms[0].elements[3].focus();
		return false;
	}
	return true;
}

var highlightcolor="#FFFFFF"
var highlighttext="#0066CC"
var highlightbutton="#003399"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
	if (which.style&&intended.test(which.tagName)) {
		if (ns6&&eventobj.nodeType==3)
			eventobj=eventobj.parentNode.parentNode
		return true
	}
	else
		return false
}

//Function to highlight form element
function highlight(e){
	eventobj=ns6? e.target : event.srcElement
	if (previous!=''){
		if (checkel(previous)) {
			previous.style.backgroundColor=''
			previous.style.color=''
		}
		previous=eventobj
		if (checkel(eventobj)) {
			if (eventobj.type == "submit" || eventobj.type == "reset" || eventobj.type == "button") {
				eventobj.style.backgroundColor=highlightbutton
			}
			else {
				eventobj.style.backgroundColor=highlightcolor
				eventobj.style.color=highlighttext
			}
		}
	}
	else {
		if (checkel(eventobj)) {
			if (eventobj.type == "submit" || eventobj.type == "reset" || eventobj.type == "button") {
				eventobj.style.backgroundColor=highlightbutton
			}
			else {
				eventobj.style.backgroundColor=highlightcolor
				eventobj.style.color=highlighttext
			}
		}
		previous=eventobj
	}
}

function addFavorite()
{
	burl="http://www.jasonbayle.com"
	btitle="Jason Bayle Website - singer & songwriter"
	if (document.all)
		window.external.AddFavorite(burl,btitle)
}

// WILL CHANGE ALT TAG FOR THE LARGE_PIC ALT ON THE PICTURES PAGE //
function changeAlt(altText) {
    document.large_pic.alt=altText	
}

// FUNCTIONS TO SCROLL THE TEXT ON THE SONGS AND BIO/RESUME PAGE //
// I WROTE THE 2 FUNCTIONS - resetTop() AND recheckHeight() //
function resetTop() {
if (iens6)
	crossobj.style.top=0
else if (ns4)
	crossobj.top=0
}

function recheckHeight() {
if (!okToScroll) return false
if (iens6){
	crossobj=document.getElementById? document.getElementById("content") : document.all.content
	contentheight=crossobj.offsetHeight
}
else if (ns4){
	crossobj=document.nscontainer.document.nscontent
	contentheight=crossobj.clip.height
}
resetTop()
}

function movedown(){
movedownvar=setTimeout("movedown()",20)
if (!okToScroll) return
if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
	crossobj.style.top=parseInt(crossobj.style.top)-speed
else if (crossobj.top>=(contentheight*(-1)+100))
	crossobj.top-=speed
}

function moveup(){
moveupvar=setTimeout("moveup()",20)
if (!okToScroll) return
if (iens6&&parseInt(crossobj.style.top)<=0)
	crossobj.style.top=parseInt(crossobj.style.top)+speed
else if (ns4&&crossobj.top<=0)
	crossobj.top+=speed
}

function getcontent_height(){
if (iens6)
	contentheight=crossobj.offsetHeight
else if (ns4)
	document.nscontainer.document.nscontent.visibility="show"
}

// USED TO DYNAMICALLY ALTER A TOOLTIP //
function showtip(current,e,text){
	if (document.all||document.getElementById){
		thetitle=text.split('<br>')
	if (thetitle.length>1){
		thetitles=''
	for (i=0;i<thetitle.length;i++)
		thetitles+=thetitle[i]
	current.title=thetitles
}
else
	current.title=text
}

else if (document.layers){
	document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+text+'</layer>')
	document.tooltip.document.close()
	document.tooltip.left=e.pageX+5
	document.tooltip.top=e.pageY+5
	document.tooltip.visibility="show"
	}
}

function hidetip(){
	if (document.layers)
		document.tooltip.visibility="hidden"
}

// WRITES THE DATE THE PAGE WAS LAST MODIFIED AT THE BOTTOM OF EACH PAGE //
function writeUpdateDate() {	
    document.write(lastMod())
}

function lastMod()
{
	var x = new Date (document.lastModified);
	Modif = new Date(x.toGMTString());
	Year = takeYear(Modif);
	Month = Modif.getMonth();
	Day = Modif.getDate();
	Mod = (Date.UTC(Year,Month,Day,0,0,0))/86400000;
	x = new Date();
	today = new Date(x.toGMTString());
	Year2 = takeYear(today);
	Month2 = today.getMonth();
	Day2 = today.getDate();
	now = (Date.UTC(Year2,Month2,Day2,0,0,0))/86400000;
	daysago = now - Mod;
	if (daysago < 0) return '';
	unit = 'days';
	if (daysago > 730)
	{
		daysago = Math.floor(daysago/365);
		unit = 'years';
	}
	else if (daysago > 60)
	{
		daysago = Math.floor(daysago/30);
		unit = 'months';
	}
	else if (daysago > 14)
	{
		daysago = Math.floor(daysago/7);
		unit = 'weeks'
	}
	var towrite = 'Page last changed ';
	if (daysago == 0) towrite += 'today';
	else if (daysago == 1) towrite += 'yesterday';
	else towrite += daysago + ' ' + unit + ' ago';
	return towrite;
}


function takeYear(theDate)
{
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}

// DYNAMICALLY SETS THE FORM ON THE TELL A FRIEND POPUP PAGE //
function setFields() {
	var strSearch = window.location.href;
    strSearch = strSearch.substring(1);
    var arrNameValues = strSearch.split("?");
	document.eMailer.email.value = unescape(arrNameValues[1]);
	document.eMailer.thename.value = unescape(arrNameValues[2]);
}

// DYNAMICALLY SETS THE IMAGE ON THE PHOTOPOPUP PAGE AND CHANGES THE ALT TAG TO THE TEXT PASSED IN //
function setImage()
{
	var strSearch = window.location.href;
    strSearch = strSearch.substring(1);
    var arrNameValues = strSearch.split("?");
	document.images[0].src = arrNameValues[1];
	document.images[0].alt = unescape(arrNameValues[2]);
}

// USED WHEN DYNAMICALLY ALTERING TEXT IN DIVISIONS (SUCH AS IN THE PICTURES SECTION) //
function regenerate(){
	window.location.reload()
}
function regenerate2(){
	if (document.layers)
	setTimeout("window.onresize=regenerate",450)
}

function changetext(whichcontent){
okToScroll = 1
if (document.all||document.getElementById){
cross_el=document.getElementById? document.getElementById("descriptions"):document.all.descriptions
cross_el.innerHTML='<font face="Verdana"><small>'+whichcontent+'<font></small>'
}
else if (document.layers){
document.d1.document.d2.document.write('<font face="Verdana"><small>'+whichcontent+'</small></font>')
document.d1.document.d2.document.close()
}		
}

// MACROMEDIA GENERATED FUNCTIONS FOR NAVIGATION ROLLOVERS //
function MM_displayStatusMsg(msgStr)  { //v3.0
	status=msgStr; document.MM_returnValue = true;
}
function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
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];}
}
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 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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}