//jQuery sitewide form field manipulations
jQuery(document).ready(function(){
	jQuery("#pageForms input:not(.button), textarea, select").focus(function() {
	    jQuery(this).parent().prev().addClass("curFormField");
	});
	jQuery("#pageForms input:not(.button), textarea, select").blur(function() {
	    jQuery(this).parent().prev().removeClass("curFormField");
	});

	jQuery("input:not(.button), textarea, select").focus(function() {
	    jQuery(this).addClass("curFocus");
	});
	jQuery("input:not(.button), textarea, select").blur(function() {
		jQuery(this).removeClass("curFocus");
	});

	jQuery('input.button').hover(function() {
		jQuery(this).addClass('buttonHighlight');
	}, function() {
		jQuery(this).removeClass('buttonHighlight');
	});

});

jQuery(document).ready(function(){

	jQuery(function() {
		jQuery("#siteTabs").tabs({ fx: { opacity: 'toggle' } });
	});
	
});

jQuery(document).ready(function(){

	jQuery('.sidebar li.widget').hover(function() {
		jQuery(this).addClass('widgetHover');
	}, function() {
		jQuery(this).removeClass('widgetHover');
	});

});

jQuery(document).ready(function(){
	var sortedList = "#sortable-sidebar";

	jQuery(sortedList).sortable({
		axis: 'y',
		item: 'li',
		handle: 'h2',
		cursor: 'move',
		distance: 4,
		opacity: 0.6,
		placeholder: 'ui-state-highlight',
		sort: function(event, ui) {
			jQuery('.widgettitle').children('span').remove();
		}
	});
	
	jQuery('.widgettitle').hover(function() {
		jQuery(this).append('<span>&nbsp;(drag me)</span>');
	}, function() {
		jQuery(this).children('span').remove();
	});
});



// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

// email


function checkEmail (strng) {

var error="";
if (strng == "") {
	if(document.getElementById && document.createTextNode)
	{
		if(document.getElementById('contactForm_email'))
		{
			document.getElementById('contactForm_email').className='formError';
			error = "yes";
		}
	}
}
    var emailFilter=/^.+@.+\..{2,10}$/;
    if (!(emailFilter.test(strng))) { 
			if(document.getElementById && document.createTextNode)
			{
				if(document.getElementById('contactForm_email'))
				{
					document.getElementById('contactForm_email').className='formError';
					error = "yes";
				}
			}
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
			if(document.getElementById && document.createTextNode)
			{
				if(document.getElementById('contactForm_email'))
				{
					document.getElementById('contactForm_email').className='formError';
					error = "yes";
				}
			}
       }
    }
return error;    
}

// non-empty textboxes
// Name on contact; author on comments
function isEmptyName(strng) {
var error = "";
  if (strng.length == 0) {
    if(document.getElementById && document.createTextNode)
		{
		  if(document.getElementById('contactForm_name'))
		  {
		    document.getElementById('contactForm_name').className='formError';
			error = "yes";
		  }
		}
  }
return error;	  
}
// Subject on Contact
function isEmptySubject(strng) {
var error = "";
  if (strng.length == 0) {
    if(document.getElementById && document.createTextNode)
		{
		  if(document.getElementById('contactForm_subject'))
		  {
		    document.getElementById('contactForm_subject').className='formError';
			error = "yes";
		  }
		}
  }
return error;	  
}

// Message on contact
function isEmptyMessage(strng) {
var error = "";
  if (strng.length == 0) {
    if(document.getElementById && document.createTextNode)
		{
		  if(document.getElementById('contactForm_message'))
		  {
		    document.getElementById('contactForm_message').className='formError';
			error = "yes";
		  }
		}
  }
return error;	  
}

// Comment on comment
function isEmptyComment(strng) {
var error = "";
  if (strng.length == 0) {
    if(document.getElementById && document.createTextNode)
		{
		  if(document.getElementById('contactForm_comment'))
		  {
		    document.getElementById('contactForm_comment').className='formError';
			error = "yes";
		  }
		}
  }
return error;	  
}

function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Your name is required.\n"
  }
return error;	  
}

// was textbox altered

function isDifferent(strng) {
var error = ""; 
  if (strng != "Can\'t touch this!") {
     error = "You altered the inviolate text area.\n";
  }
return error;
}

// exactly one radio button is chosen

function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n";
    }
return error;
}

// valid selector from dropdown list

function checkDropdown(choice) {
var error = "";
    if (choice == 0) {
    error = "You didn't choose an option from the drop-down list.\n";
    }    
return error;
}

// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng) {
var error = "";
if (strng == "") {
   error = "Your phone number is required.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters.";
  
    }
    if (!(stripped.length == 10)) {
	error = "Your phone number does not appear to be correct. Please make sure to include the area code.\n";
    } 
return error;
}


// password - between 6-8 chars, uppercase, lowercase, and numeral

function checkPassword (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a password.\n";
}

    var illegalChars = /[\W_]/; // allow only letters and numbers
    
    if ((strng.length < 6) || (strng.length > 8)) {
       error = "The password is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The password contains illegal characters.\n";
    } 
    else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
       error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";
    }  
return error;    
}    


// username - 4-10 chars, uc, lc, and underscore only.

function checkUsername (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a username.\n";
}


    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 10)) {
       error = "The username is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The username contains illegal characters.\n";
    } 
return error;
}       
































































