
// Ultimate Fade-In Slideshow (v1.51): © Dynamic Drive (http://www.dynamicdrive.com)
// This notice MUST stay intact for legal use
// Visit http://www.dynamicdrive.com/ for this script and 100s more.
// ---------------------------------------------------------------
 
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["img/slide01.jpg", "", ""]
fadeimages[1]=["img/slide02.jpg", "", ""]
fadeimages[2]=["img/slide03.jpg", "", ""]
fadeimages[3]=["img/slide04.jpg", "", ""]
fadeimages[4]=["img/slide05.jpg", "", ""]
fadeimages[5]=["img/slide06.jpg", "", ""]
fadeimages[6]=["img/slide07.jpg", "", ""]
fadeimages[7]=["img/slide08.jpg", "", ""]
 
//var fadeimages2=new Array() //2nd array set example. Remove or add more sets as needed.
//SET IMAGE PATHS. Extend or contract array as needed
//fadeimages2[0]=["gif_logojsb.gif", "", ""] //plain image syntax
//fadeimages2[1]=["logojs.gif", "http://www.javascriptbank.com", ""] //image with link syntax
//fadeimages2[2]=["gif_logojsb2.gif", "http://www.javascriptbank.com", "_new"] //image with link and target syntax
 
var fadebgcolor="white"
 
// NO need to edit beyond here
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
	this.pausecheck=pause
	this.mouseovercheck=0
	this.delay=delay
	this.degree=5 //initial opacity degree (5%)
	this.curimageindex=0
	this.nextimageindex=1
	fadearray[fadearray.length]=this
	this.slideshowid=fadearray.length-1
	this.canvasbase="canvas"+this.slideshowid
	this.curcanvas=this.canvasbase+"_0"

	if (typeof displayorder!="undefined")
		theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)

	this.theimages=theimages
	this.imageborder=parseInt(borderwidth)
	this.postimages=new Array() //preload images

	for (p=0;p<theimages.length;p++){
		this.postimages[p]=new Image()
		this.postimages[p].src=theimages[p][0]
	}
	 
	var fadewidth=fadewidth+this.imageborder*2
	var fadeheight=fadeheight+this.imageborder*2
	 
	if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
		document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div></div>')
	else
		document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
	 
	if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
		this.startit()
	else{
		this.curimageindex++
		setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
	}
}

function fadepic(obj){
	if (obj.degree<150){
		obj.degree+=5
		if (obj.tempobj.filters&&obj.tempobj.filters[0]){
			if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
				obj.tempobj.filters[0].opacity=obj.degree
			else //else if IE5.5-
				obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
			}
		else if (obj.tempobj.style.MozOpacity)
			obj.tempobj.style.MozOpacity=obj.degree/151
		else if (obj.tempobj.style.KhtmlOpacity)
			obj.tempobj.style.KhtmlOpacity=obj.degree/150
		else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
			obj.tempobj.style.opacity=obj.degree/151
		}
	else{
		clearInterval(fadeclear[obj.slideshowid])
		obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
		obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
		obj.populateslide(obj.tempobj, obj.nextimageindex)
		obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
		setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
	}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
	var slideHTML=""
	if (this.theimages[picindex][1]!="") //if associated link exists for image
		slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
	slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
	if (this.theimages[picindex][1]!="") //if associated link exists for image
		slideHTML+='</a>'
	picobj.innerHTML=slideHTML
}

fadeshow.prototype.rotateimage=function(){
	if (this.pausecheck==1) //if pause onMouseover enabled, cache object
		var cacheobj=this
	if (this.mouseovercheck==1)
		setTimeout(function(){cacheobj.rotateimage()}, 100)
	else if (iebrowser&&dom||dom){
		this.resetit()
		var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
		crossobj.style.zIndex++
		fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
		this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
	}
	else{
		var ns4imgobj=document.images['defaultslide'+this.slideshowid]
		ns4imgobj.src=this.postimages[this.curimageindex].src
	}
	this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
	this.degree=5
	var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
	if (crossobj.filters&&crossobj.filters[0]){
		if (typeof crossobj.filters[0].opacity=="number") //if IE6+
			crossobj.filters(0).opacity=this.degree
		else //else if IE5.5-
			crossobj.style.filter="alpha(opacity="+this.degree+")"
		}
	else if (crossobj.style.MozOpacity)
		crossobj.style.MozOpacity=this.degree/151
	else if (crossobj.style.KhtmlOpacity)
		crossobj.style.KhtmlOpacity=this.degree/150
	else if (crossobj.style.opacity&&!crossobj.filters)
		crossobj.style.opacity=this.degree/151
}
 
fadeshow.prototype.startit=function(){
	var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
	this.populateslide(crossobj, this.curimageindex)
	if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
		var cacheobj=this
		var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
		crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
		crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
	}
	this.rotateimage()
}
// ---------------------------------------------------------------


// Checks whether all required fields are correctly filled in.
// ---------------------------------------------------------------
function FormCheck() {

	if (document.Registration.FirstName.value=="") {
		alert('A first name is required.');
		return false;
	}

	if (document.Registration.LastName.value=="") {
		alert('A last name is required.');
		return false;
	}

	if (document.Registration.Address1.value=="") {
		alert('An address is required.');
		return false;
	}

	if (document.Registration.Phone1.value=="") {
		alert('At least one valid phone number is required.');
		return false;
	}

	if (document.Registration.City.value=="") {
		alert('A city is required.');
		return false;
	}

	if (document.Registration.Zip.value=="") {
		alert('A zip code is required.');
		return false;
	}

	switch(document.Registration.HowList.value){
		case "":
			alert('"How did you hear about us?" is required.');
			return false;
			break;
		case "Referred by a friend":
			if (document.Registration.HowDidYou.value=="") {
				alert('Please enter the name of the referrer, so that we can give due credit.');
				return false;
			}
			break;
		case "From a poster":
			if (document.Registration.HowDidYou.value=="") {
				alert('"How did you hear about us?" source specification is required.');
				return false;
			}
			break;
		case "Through another event":
			if (document.Registration.HowDidYou.value=="") {
				alert('Please tell us which event.');
				return false;
			}
			break;
		case "Received a postcard":
			if (document.Registration.HowDidYou.value=="") {
				alert('"How did you hear about us?" source specification is required.');
				return false;
			}
			break;
		case "Through an announcement":
			if (document.Registration.HowDidYou.value=="") {
				alert('"How did you hear about us?" source specification is required.');
				return false;
			}
			break;
		case "Through a web site":
			if (document.Registration.HowDidYou.value=="") {
				alert('"How did you hear about us?" source specification is required.');
				return false;
			}
			break;
		case "Newspaper ad":
			if (document.Registration.HowDidYou.value=="") {
				alert('"How did you hear about us?" source specification is required.');
				return false;
			}
			break;
		case "Other":
			if (document.Registration.HowDidYou.value=="") {
				alert('"How did you hear about us?" source specification is required.');
				return false;
			}
			break;
	}

	emailCheck(document.Registration.Email.value);

	return true;

}

// Limits characters in text field to: [0-9], -, (), ext, period and space.
//----------------------------------------------------------------
function CheckPhone(e) {
	var NotAllowed = "";
	var Allowed = "|32|40|41|45|46|101|116|120|";
	var KeyValue;
	if (window.event) { // IE
		KeyValue = e.keyCode;
	} else if (e.which) { // Netscape/Firefox/Opera
		KeyValue = e.which;
	}
	if (KeyValue == 8) return true; //Allow backspace
	if (NotAllowed.indexOf("|"+KeyValue+"|") > -1) {
		return false;
	} else if (Allowed.indexOf("|"+KeyValue+"|") > -1) {
		return true;
	} else if (KeyValue < 48 || KeyValue > 57) {
		return false;
	}
}

//Checks an email address for proper format. [Global]
//----------------------------------------------------------------
function emailCheck(emailStr) {

	if (emailStr == "") {
		alert("A valid email address is required.");
		return false;
	}

	/* The following variable tells the rest of the function whether or not
	to verify that the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */
	var checkTLD=1;

	/* The following is the list of known TLDs that an e-mail address must end with. */
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */
	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address.
	These characters include ( ) < > @ , ; : \ " . [ ] */
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a
	username or domainname.  It really states which chars aren't allowed.*/
	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */
	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */
	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {

		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */
		alert("Email address seems incorrect (check @ and .'s)");
		return false;
	}

	var user=matchArray[1];
	var domain=matchArray[2];

	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			alert("Username in email address contains invalid characters.");
			return false;
		}
	}

	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			alert("Domain in email address contains invalid characters.");
			return false;
		}
	}

	// See if "user" is valid
	if (user.match(userPat)==null) {
		// user is not valid
		alert("The username in the email address doesn't seem to be valid.");
		return false;
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {

			// this is an IP address
			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					alert("Destination IP address is invalid.");
					return false;
				}
			}
		return true;
	}

	// Domain is symbolic name.  Check if it's valid.
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			alert("The domain name does not seem to be valid.");
			return false;
		}
	}

	/* domain name seems valid, but now make sure that it ends in a
	known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding
	the domain or country. */
	if (checkTLD && domArr[domArr.length-1].length!=2 &&
	domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("Email address must end in a well-known domain or two letter country.");
		return false;
	}

	// Make sure there's a host name preceding the domain.
	if (len<2) {
		alert("Email address is missing a hostname.");
		return false;
	}

	// If we've gotten this far, everything's valid!
	return true;
}
//----------------------------------------------------------------

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	} else {
		countfield.value = maxlimit - field.value.length;
	}
}

function flipTab(tabName) {

	switch(tabName){
		case "location":
			document.getElementById('details').className='Hide';
			document.getElementById('location').className='Show';
			document.getElementById('gallerytab').className='Hide';
			document.getElementById('testimonials').className='Hide';
			document.getElementById('pricing').className='Hide';
			break;
		case "gallerytab":
			document.getElementById('details').className='Hide';
			document.getElementById('location').className='Hide';
			document.getElementById('gallerytab').className='Show';
			document.getElementById('testimonials').className='Hide';
			document.getElementById('pricing').className='Hide';
			break;
		case "testimonials":
			document.getElementById('details').className='Hide';
			document.getElementById('location').className='Hide';
			document.getElementById('gallerytab').className='Hide';
			document.getElementById('testimonials').className='Show';
			document.getElementById('pricing').className='Hide';
			break;
		case "pricing":
			document.getElementById('details').className='Hide';
			document.getElementById('location').className='Hide';
			document.getElementById('gallerytab').className='Hide';
			document.getElementById('testimonials').className='Hide';
			document.getElementById('pricing').className='Show';
			break;
		default:
			document.getElementById('details').className='Show';
			document.getElementById('location').className='Hide';
			document.getElementById('gallerytab').className='Hide';
			document.getElementById('testimonials').className='Hide';
			document.getElementById('pricing').className='Hide';
	}
}