window.onload = sfHover;


function loadTwitter() {
	$.ajax({
    	type: "GET",
        url: "_actions/twitter.php?limit=1&random="+Math.random(),
        dataType: "xml",
        	success: function(xml) {
				var ulHolder = document.createElement('ul');
				ulHolder.id = 'ulTwitter';
            	$(xml).find('feed').each(function(){
                	var feedTitle = $(this).find('title').text();
					var feedLink = $(this).find('link').text();
					var liRow = document.createElement('li');
					liRow.innerHTML = '<a href = "'+feedLink+'">'+feedTitle+'</a>';
					ulHolder.appendChild(liRow);					
                }); //close each(
				
				$('#twitterFeed').html('');
				$('#twitterFeed').append(ulHolder);
				$('#ulTwitter').innerfade({ 
					speed: 'slow', 
					timeout: 6000, type: 'sequence'
				});				
            }
    }); //close $.ajax(	
}



Shadowbox.init({
    language: 'en',
    players:  ['img', 'html', 'iframe', 'qt', 'wmp', 'swf', 'flv']
});

//this function enables the nav bar to work in IE6
function sfHover() {
   var sfEls = document.getElementById("navbar").getElementsByTagName("li");
   for (var i=0; i<sfEls.length; i++) {
      sfEls[i].onmouseover=function() {
         this.className+=" hover";
      }
      sfEls[i].onmouseout=function() {
         this.className=this.className.replace(new RegExp(" hover\\b"), "");
      }
   } 	
}



$().ready(function() {
      		 $('#coda-slider-5').codaSlider({
           dynamicArrows: false,
		   autoHeight:0,
           
       });
   });
   
   
   
   
   /*************************************/
	
	// Place ID's of all required fields here.
	required = ["name", "email", "message"];
	// If using an ID other than #email or #error then replace it here
	email = $("#email");
	errornotice = $("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Please fill out this field.";
	emailerror = "Please enter a valid e-mail.";

	$("#theform").submit(function(){	
		//Validate required fields
		for (i=0;i<required.length;i++) {
			var input = $('#'+required[i]);
			if ((input.val() == "") || (input.val() == emptyerror)) {
				input.addClass("needsfilled");
				input.val(emptyerror);
				errornotice.fadeIn(750);
			} else {
				input.removeClass("needsfilled");
			}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val(emailerror);
		}

		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});
	
	// Clears any fields in the form when the user clicks on them
	$(":input").focus(function(){		
	   if ($(this).hasClass("needsfilled") ) {
			$(this).val("");
			$(this).removeClass("needsfilled");
	   }
	});
