/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var offsetfrommouse=[15,115]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 70;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").style
else if (document.all)
return document.all.trailimagid.style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("trailimageid")
else if (document.all)
return document.all.trailimagid
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtrail(imagename,title,created,description,showthumb,height){
	


	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") != -1 ) {

		//alert("code ended here");
	return false;
	} 
	
	
	if (height > 0){
		currentimageheight = height;
	}

	document.onmousemove=followmouse;

	cameraHTML = '' + created;

	newHTML = '<div style="padding: 5px; background-color: #000080; border: 1px solid #888; text-align:left;"><div style="padding: 20px; background-color: #FFF;">';

	newHTML = newHTML + '<div align="center"><img src="images/above_and_beyond_logo.gif"></div><br />';

	if (title > ''){
		newHTML = newHTML + '<h2>' + title + '</h2>';
	}

	if (showthumb > 0){
		newHTML = newHTML + '<div style="float:right" style="padding: 8px 2px 2px 2px;"><img src="' + imagename + '" border="0"></div>';
	}

	//newHTML = newHTML + cameraHTML + '<br/>';
	newHTML = newHTML + description + '<br/>';


	newHTML = newHTML + '</div></div>';

	gettrailobjnostyle().innerHTML = newHTML;

	gettrailobj().visibility="visible";

}


function showtrail2(imagename,title,created,description,showthumb,height){
	


	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") != -1 ) {

		//alert("code ended here");
	return false;
	} 
	
	
	if (height > 0){
		currentimageheight = height;
	}

	document.onmousemove=followmouse;

	cameraHTML = '' + created;

	newHTML = '<div style="padding: 5px; background-color: #000080; border: 1px solid #27a197; text-align:left;"><div style="padding: 20px; background-color: #FFF;">';

	newHTML = newHTML + '<div align="center"><img src="images/aab_careappeal_logo.gif"></div><br />';

	if (title > ''){
		newHTML = newHTML + '<h2>' + title + '</h2>';
	}

	if (showthumb > 0){
		newHTML = newHTML + '<div style="float:right" style="padding: 8px 2px 2px 2px;"><img src="' + imagename + '" border="0"></div>';
	}

	//newHTML = newHTML + cameraHTML + '<br/>';
	newHTML = newHTML + description + '<br/>';


	newHTML = newHTML + '</div></div>';

	gettrailobjnostyle().innerHTML = newHTML;

	gettrailobj().visibility="visible";

}


function showtrail3(imagename,title,created,description,showthumb,height){
	


	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") != -1 ) {

		//alert("code ended here");
	return false;
	} 
	
	
	if (height > 0){
		currentimageheight = height;
	}

	document.onmousemove=followmouse;

	cameraHTML = '' + created;

	newHTML = '<div style="padding: 5px; background-color: #000080; border: 1px solid #27a197; text-align:left;"><div style="padding: 20px; background-color: #FFF;">';

	newHTML = newHTML + '<div align="center"><img src="images/cupcake_recipe.jpg"></div><br />';

	if (title > ''){
		newHTML = newHTML + '<h2>' + title + '</h2>';
	}

	if (showthumb > 0){
		newHTML = newHTML + '<div style="float:right" style="padding: 8px 2px 2px 2px;"><img src="' + imagename + '" border="0"></div>';
	}

	//newHTML = newHTML + cameraHTML + '<br/>';
	newHTML = newHTML + description + '<br/>';


	newHTML = newHTML + '</div></div>';

	gettrailobjnostyle().innerHTML = newHTML;

	gettrailobj().visibility="visible";

}



function hidetrail(){
	gettrailobj().visibility="hidden"
	document.onmousemove=""
	gettrailobj().left="-500px"

}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	//if (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}
	// Change 420 if your window width isn't 400

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 420){
			xcoord = e.pageX - xcoord - 400; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 110)){
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 420){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 400; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}




var targBox = "scroller";

function init()
{
	if (document.getElementById) {
		var atags = document.getElementsByTagName("A");
		for (var i=0;i<atags.length;i++) {
			var ca = atags[i];
			if (ca.href.indexOf("#") > -1) {
				ca.onclick = function() {
					scrollDivToAnchor(this.href.split("#")[1]);
				}
			}
		}
	}
}

function scrollDivToAnchor(a) {
	var b = document.getElementById(targBox);
	b.scrollTop = document.getElementById(a).offsetTop - b.offsetTop;
}



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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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_setAltText(objName,x,newText) { //v3.0
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (navigator.appName=='Netscape') {alt = unescape(newText);}
    else alt = unescape(newText);
}

function MM_setTextOfLayer(objName,x,newText) { //v3.0
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (navigator.appName=='Netscape') {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function popupwin()
{
	var popupvars = popupwin.arguments;
	var url = popupvars[0];

	winpopup3 = window.open(url,'popup3','height=500,width=480,left=50,top=50,margin=0,scrollbars=yes,sizeable=yes');	// !resizeable
	setTimeout('if (winpopup3 && !winpopup3.closed) winpopup3.focus()', 230);	// Give focus soon
	
	return false;
}


function miniescape(what)
{
	return (what.replace(/\\/g, "\\\\"));	// Replace slash with double slash
}

// .  Any character (literal period if escaped)
// []  A list of characters in square brackets (called a character class) matches any one of the characters in the list. A caret (^) at the beginning of the list causes it to match only characters that are not in the list. Most characters loose their meta-ness inside square brackets. 
// \d  A digit (same as [0-9])
// \D  A non-digit (same as [^0-9])
// \w  A word (alphanumeric) character (same as [a-zA-Z_0-9]) 
// \W  A non-word character (same as [^a-zA-Z_0-9]) 
// \s  A whitespace character (same as [ \t\v\n\r\f])
// \S  A non-whitespace character (same as [^ \t\v\n\r\f])
// Quantifiers: eg. (word){4}
// {m,n}  Must occur at least m times, but not more than n times.
// {n,}  Must occur at least n times
// {n}  Must occur exactly n times.
// *  Must occur 0 or more times (same as {0,}).
// +  Must occur 1 or more times (same as {1,}). 
// ?  Must occur 0 or 1 time (same as {0,1}).

function validateemail(theform)
{
	// Ensures only _.- and alphanumeric on left. Alphanumeric and - on right.
	// Right must be at least one alphanumeric sequence of 2+ chars separated
	// with a period. 2nd char onwards can be a dash. Final alphanumeric sequence
	// can be 2-6 chars (.store, .museum)

	var emailReg = "^[_\\.0-9A-Za-z\\+-]+@([0-9A-Za-z][0-9A-Za-z-]+\\.)+[A-Za-z]{2,6}$"; 
	var regex;
	var valid = true;

	if (window.RegExp)
	{
		regex = new RegExp(emailReg);

		if (!regex.test(theform.email.value))
		{
			alert("Please enter a valid email address");
			valid = false;
		}
		else if (theform.email.value.toUpperCase().indexOf("@HOTMAIL.")>0)
		{
			//alert("Sorry, we don't accept Hotmail addresses");
			//valid = false;
		}
		else if (theform.email.value.toUpperCase().indexOf("@YAHOO.")>0)
		{
			//alert("Sorry, we don't accept Yahoo addresses");
			//valid = false;
		}
	}

	return valid;
}


function validate(theform)
{
	var valid = true;

	/*
	Submit Once form validation- 
	© Dynamic Drive (www.dynamicdrive.com)
	For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
	*/

	if (document.all||document.getElementById)	// IE 4+ or NS 6+
	{
		for (i=0;i<theform.length;i++)	//  Locate "submit" and "reset" elements in the form
		{
			var tempobj=theform.elements[i]
			if(tempobj.type.toLowerCase()=="submit")	//||tempobj.type.toLowerCase()=="reset")
			tempobj.disabled=true
		}
	}

	return valid;
}


/* Zap default textarea contents on first click */

function checkbox()
{
	var valid = true;

	if (document.form1.comments.value == "Type your enquiry here")
	{
		document.form1.comments.value = "";
	}

	return valid;
}

function checkbox2()
{
	var valid = true;

	if (document.form1.comments.value == "Type the message your friend will receive here")
	{
		document.form1.comments.value = "";
	}

	return valid;
}

if (navigator.userAgent.indexOf("Safari") > -1) {
	window.onload = init;
}