

/* emg.js.php */
/*
12:25 PM 1/6/2011 - added tokenInit() and toggleClassArray()
3:38 PM 12/13/2010
2:04 PM 10/14/2010
3:52 PM 10/12/2010
/*
Copyright © 2008 Eckx Media Group, LLC. All rights reserved.
Eckx Media Group respects the intellectual property of others, and we ask our users to do the same.
*/
/*<script>*/

var emgInit = function(){
			BrowserDetect.init();				initValForm();			ie6Check();
	//emg link
	$('#emg-link').hide();
	
	if(window.siteInit){
		siteInit();
	}
	
	markupInit();
}; 

$(document).ready(emgInit);

//function to run initial function that changes markup
function markupInit(){
	var bodyElement = $('body')[0]; // cant use document.body because error in IE7, no .select
	confirmInit(bodyElement);
	externalLinks(bodyElement);
	autoCompleteOff(bodyElement);
	defaultClear(bodyElement);
	
	ieSelectExpand();
}

//Event.observe(window, 'load', emgInit);
//document.observe('dom:loaded', emgInit);

// Show / Hide object
function toggle(obj) {
	alert('Deprecated - use toggleClass with css');
	return;
	
	var el = $(obj);
	el.style.display = (el.style.display != 'block' ? 'block' : 'none' );
	el.blur();
}
function toggle2(obj) {
	alert('Deprecated - use toggleClass with css');
	return;
	
	var el = $(obj);
	el.style.display = (el.style.display != 'block' ? 'block' : 'none' );
	el.blur();
}

function toggleClass(id, className) {
	$('#' + id).toggleClass(className);
	/*
	var el = $(id);
	if (el.hasClassName(className)) {
		el.removeClassName(className);
	}
	else {
		el.addClassName(className);
	}*/
}

function toggleClassArray(ids, className){
	for(var i = 0; i < ids.length; i++){
		toggleClass(ids[i], className);	
	}
}

// Reset form fields
function clearForm(id, skipids) {
	if(!skipids){
		skipids = new Array();
	}
	var form = byId(id);
	for (var i = 0; i < form.length; i++) {
		if(inArray(form[i].id, skipids) || form[i].type == 'submit' || form[i].type == 'button' ){
			continue;
		}
		if(form[i].type == 'checkbox' || form[i].type == 'radio') {
			form[i].checked = false;	
		}
		if(form[i].options){ // drop downs
			form[i].selectedIndex = 0;
		}
		else {
			form[i].value = '';
		}
		
	}
}

// Reset form fieldset fields
function clearFieldset(id) {
	var fieldset = $('#' + id + ' input[type="text"], ' + '#' + id + ' input[type="password"], ' + '#' + id + ' input[type="file"], ' + '#' + id + ' select, ' + '#' + id + ' textarea');
	
	for (var i = 0; i < fieldset.length; i++) {
		clearField(fieldset[i]);
	}
}
// Clear individual field
function clearField (field) {
	if(field.type == 'checkbox' || field.type == 'radio') {
		field.checked = false;	
	}
	else {
		field.value = '';
	}
}

function popUpA(URL) { //allow all features
	day = new Date();
	id = "aboutUS";
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=900,height=400,left = 240,top = 212');");
}

function popUpB(URL) { // disable all features
	day = new Date();
	id = "aboutUS";
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=300,left = 240,top = 212');");
}

function isset(obj){
	if(typeof obj == 'undefined'){
		return false;
	}
	else{
		return true;	
	}
}


function getMousePos(e) {
	var IE = document.all?true:false
	var scrollXY = getScrollXY();
	var mousePos = new Array();
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = e.x;
		tempY = e.y;
	} 
	else {  // grab the x-y pos.s if browser is NS
		tempX = e.clientX;
		tempY = e.clientY;
	}
	// catch possible negative values in NS4
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}  
	mousePos['x'] = tempX + scrollXY[0];
	mousePos['y'] = tempY + scrollXY[1];
	return mousePos;
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getPageDim(){
	/*if(document.all?true:false){ // IE
		if(document.body.clientHeight > document.body.scrollHeight){
			var height = document.body.clientHeight;
			var width = document.body.clientWidth;
		}
		else{
			var height = document.body.scrollHeight;
			var width = document.body.scrollWidth;
		}
	}
	else{
		var height = document.height;
		var width = document.weidth;
	}
	var viewPortHeight = document.viewport.height();
	if(height < viewPortHeight){
		height = viewPortHeight;
	}*/
	return [ $(document).width(), $(document).height() ];
}

function getVisibleDim(){ alert('function getVisibleDim() decremented, use prototype viewport');
	if(!$('getTopLeft-fake-body')){ //generate fake div to get screen size
		var fakeDiv = document.createElement('div');
		fakeDiv.id = 'getTopLeft-fake-body';
		fakeDiv.style.visibility = 'hidden';
		fakeDiv.style.margin = '0';
		fakeDiv.style.padding = '0';
		fakeDiv.style.position = 'absolute';
		fakeDiv.style.top = '0';
		fakeDiv.style.bottom = '0';
		fakeDiv.style.left = '0';
		fakeDiv.style.right = '0';
		fakeDiv.style.width = '100%';
		fakeDiv.style.height = '100%';
		fakeDiv.style.zIndex = '-1';
		document.body.appendChild(fakeDiv);
	}
	
	var fakeDiv = $('getTopLeft-fake-body');
	var width = fakeDiv.getWidth();
	var height = fakeDiv.height();
	return [ width, height ];
}


function alert2(text, dim, alertTime, className){ 
	//check if alert 2 already exist
	
	var i = 0;
	while(byId('alert2_' + i)){
		i++;
	}
	
	var alert2 = document.createElement('div');
	
	alert2.id = 'alert2_' + i;
	alert2.style.visibility = 'hidden';
	document.body.appendChild(alert2);
	
	alert2 = byId('alert2_' + i);
	if (className === undefined) {
		$(alert2).addClass('alert2');
	}
	else {
		$(alert2).addClass(className);	
	}
	
	alert2.innerHTML = text;
	
	if (dim) {
		width = dim[0];
		height = dim[1];
		alert2.style.width = width + 'px';
		alert2.style.height = height + 'px';
	}
	else {
		width = $(alert2).width();
		height = $(alert2).height();
	}
	
	if(isNaN(width) || isNaN(height)){
		alert('Alert2() error, width or height isNaN');	
	}
	
	var xy = getScrollXY();
	var topLeft = getTopLeft(width, height);
	alert2.style.top = topLeft[0]+'%';
	alert2.style.left = topLeft[1]+'%';
	alert2.style.visibility = 'visible';
	if (!alertTime) {
		alertTime = 2000;	
	}
	setTimeout("document.body.removeChild(document.getElementById('alert2_" + i + "'))", alertTime);
}


//return the top left percentage for an absolute centered layer, req 100% body height
function getTopLeft(width, height){
	var windowWidth = $(window).width();
	var windowHeight = $(window).height();
	var ie = getIEVerNum();
	
	//compensate for scroll
	var xy = getScrollXY();
	
	//get %
	var top = (windowHeight/2 + xy[1] - (height/2)) / windowHeight;
	var left = (windowWidth/2 + xy[0] - (width/2)) / windowWidth;

	if(top < 0){
		top = 0;	
	}
	if(left <0){
		left = 0;	
	}
	
	//compensate for ie 6 usage of %, the entire document not just what u see is 100%
	if(ie == 6){ // ie 6
		var pxHeight = windowHeight * top; //get pixel height
		top = pxHeight/document.body.clientHeight; // get decimal height
	}
	
	top  = Math.round(top * 100); 
	left  = Math.round(left * 100);
			
	return [ top, left ];
}

function money(num){
	var formated = Math.round(num*1000)/1000; //use 1000 for partial cents
	formated = formated.toString();
	if(formated.indexOf('.') == -1){
		formated += '.00';
	}
	else{
		var parts = formated.split('.');
		if(parts[1].length == 1){
			formated += '0';	
		}
	}
	return formated;
}

function urlencode(str) { alert('use encodeURIComponent()');
	str = escape(str);
	str = str.replace('+', '%2B');
	str = str.replace('%20', '+');
	str = str.replace('*', '%2A');
	str = str.replace('/', '%2F');
	str = str.replace('@', '%40');
	return str;
}

function urldecode(str) {
	str = str.replace('+', ' ');
	str = unescape(str);
	return str;
}

function htmlentities(html) {
	html = html.replace('<','&lt;');
	html = html.replace('>','&gt;');
	html = html.replace('"','&quot;');
	return html;
} 

function getJs(url){
	if(!inString(url, '?')){
		url += '?';	
	}
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url+'&klioe='+Math.random()*10000;
	document.body.appendChild(jsel);
}

//Get IE Version Number
function getIEVerNum() {
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    
    if (MSIEOffset == -1) {
        return 0;
    } else {
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
}

function confirm2(e, title, yesEval, noEval){
	var delConfirm = document.createElement('div');
	delConfirm.id = 'confirm2';
	document.body.appendChild(delConfirm);
	modal.load();
	modal.content('<p><strong>'+title+'</strong></p><ul class="tools confirm"><li class="yes"><span><a href="#" id="confirm2-yes">Yes</a></span></li><li class="no"><span><a href="#" id="confirm2-no">No</a></span></li></ul>');
	//delConfirm = $('confirm2');
	//delConfirm.addClassName('confirm2');
	//delConfirm.innerHTML = '<div>'+title+'</div><input type="button" id="confirm2_yes" value="Yes"/><br/><input type="button" id="confirm2_no" value="No" />';
	
	//var mousePos = getMousePos(e);
	//delConfirm.style.left=mousePos['x']+'px';
	//delConfirm.style.top=mousePos['y']+'px';
	$('#confirm2-yes')[0].onclick= function(){ 
		//document.body.removeChild($('confirm2'));
		eval(yesEval);
		modal.close();
		return false;
	}
	$('#confirm2-no')[0].onclick= function(){ 
		//document.body.removeChild($('confirm2'));
		eval(noEval); 
		modal.close();
		return false;
	}
}

function checkAll(name, trueFalse){
	var checkBoxes = document.getElementsByName(name);
	var len = checkBoxes.length;
	for(var i=0; i<len; i++){
		checkBoxes[i].checked = trueFalse;
	}
}

function confirmInit(container){
	var anchors = $('a[rel~="confirm"]', container);
	for(var i = 0; i < anchors.length; i++){
		anchors[i].href  = 'javascript:confirm2(null, \'' + anchors[i].title + '\', \'window.location=\\\'' + anchors[i].href + '\\\'\', \'\')';
	}
}

function externalLinks(container) {
	var anchors = $('a[rel~="external"]', container);
	
	for (var i=0; i<anchors.length; i++) {
		anchors[i].target = "_blank";
	}
}

function autoCompleteOff(container){
	var inputs = $('input[class~="autocomplete-off"]', container);
	for (var i=0; i<inputs.length; i++) {
		inputs[i].setAttribute("autocomplete", "off");
	}
}

function defaultClear(container){	
	var inputs = $('[class~="default-clear"]', container);
	
	var defaultClassName = 'default';
	
	
	inputs.focus(function() {
		if(this.value == this.defaultValue){
			this.value = '';
			$(this).removeClass(defaultClassName);
		}
	}).blur(function() {
		if(this.value == ''){
			this.value = this.defaultValue;
			$(this).addClass(defaultClassName);
		}
	});
}

function bookMark(url, title){
	if(document.all?true:false){ // IE
		window.external.AddFavorite(url, title);
	}
	else{
		window.sidebar.addPanel(title, url, '')
	}
}

function ajaxFill(url, containerid, callback){
	alert('depercated, please use EmgAjax.call()');
	return;
	var container = $(containerid);
	if(!container){
		alert('ajaxFill(): '+containerid+' id dosnt exist');
		return;
	}
	container.innerHTML = '<div style="text-align:center"><img src="'+window.CR+'/images/library/loading.gif" /></div>';
	new Ajax.Request(url, { method: 'get', onSuccess: function(ajaxReturn) {
		if(ajaxReturn.responseText == 'died'){
			window.location = window.CR + '/died';
			return;
		}
		container.innerHTML = ajaxReturn.responseText;
		curtain.initLinks(container); //curtain reference
		eval(callback);
	}}); 
}

function ie6Check() {
	if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version < 7) {
		var ie6Notice = document.createElement('div');
		ie6Notice.id = 'ie6-notice';
		ie6Notice.innerHTML = '<p class="title">It seems like you are using Internet Explorer 6 or lower.</p><p>IE6 is an outdated web browser that cannot provide the rich web experience that a modern web browser is able to.  This site may not display and function correctly as a result.</p><p>You may want to upgrade to one of these newer web browsers:</p><ul class="browsers"><li><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx" title="Download Internet Explorer 9">Download Internet Explorer 9</a></li><li><a href="http://www.mozilla.com/en-US/firefox/" title="Download Mozilla Firefox">Download Mozilla Firefox</a></li><li><a href="http://www.google.com/chrome" title="Download Google Chrome">Download Google Chrome</a></li></ul><p class="hide-notice"><a href="#" onclick="document.getElementById(\'ie6-notice\').style.display = \'none\'; return false;" title="Hide this notice" rel="external">Hide this notice</a></p>';
		document.body.appendChild(ie6Notice);
	}
}

// verify the captcha
function verifyCaptcha(captchaFieldid){
	var url = window.CR + '/ajax/verify-captcha?area=' + captchaFieldid + '&captcha=' + $('#' + captchaFieldid)[0].value;
	var valFormIndex = getValFormIndex(captchaFieldid);
	valForms[valFormIndex].ajaxRunning[captchaFieldid] = true;

	$.ajax({
		   url: url
		   , type: 'get'
		   , dataType: 'text'
		   , cache: false
		   , complete: function(ajaxReturn) {
			   				var response = ajaxReturn.responseText;
							var error = response == '0' ? ' is incorrect.' : false;
							
							valForms[valFormIndex].errorHandler($('#' + captchaFieldid)[0], error);
							valForms[valFormIndex].ajaxRunning[captchaFieldid] = false;
						}
			});
	
}

function refreshCaptcha(formid) {
	var textInput = byId(formid + '-captcha');
	textInput.value = '';
	byId(formid + '-captcha-img').src = '/ajax/show-captcha?area=' + formid + '-captcha&amp;k=' + Math.random();
	textInput.focus();
}

function refreshImg(id){
	var img = byId(id);
	if(inString(img.src, '?')){
		img.src = img.src + '&k='+Math.random();
	}
	else{
		img.src = img.src + '?k='+Math.random();
	}
}

function showFlash(src, w, h, container, parameters, variables){
	alert('decremented, use swfobject.embedSWF(window.CR + \'/swf/player.swf\', containerid, w, h, \'9.0.0\', \'expressInstall.swf\', variables, parameters);'); return;
	var s1 = new SWFObject(src, 'mediaplayer', w, h,'7');
	if(parameters){
		parameters = parameters.split('&');
		for(var i = 0; i < parameters.length; i++){
			var parts = parameters[i].split('=');
			s1.addParam(parts[0], parts[1]);
		}
	}
	if(variables){
		s1.addParam('flashvars', variables);
	} 
	if(!s1.write(container)){
		$(container).innerHTML = '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Click here to get the flash player.</a>';
	}
}

//controlbar: over, under
function showPlayer(flv, w, h, containerid, preview, skin, controlbar){
	var parameters = {};
	parameters.allowfullscreen = true;
	parameters.allowscriptaccess = 'always';
	parameters.wmode = 'opaque';
	
	var variables = {file: flv};
	if(preview){
		variables.image = preview;
	}
	if(skin){
		variables.skin = skin;
	}
	if(controlbar){
		variables.controlbar = controlbar;
	}
	swfobject.embedSWF(window.CR + '/swf/player.swf', containerid, w, h, '9.0.0', 'expressInstall.swf', variables, parameters);
}

// skin: (default) | bekle
// controlbar: bottom (default) | top | over | none
// autostart: false (default) | true
// stretching: uniform (default) | fill | exactfit | none
// volume: (integer)
// mute: false (default) | true
function showVideo(flv, w, h, containerid, image, skin, controlbar, autostart, stretching, volume, mute) {
	var parameters = {};
	// Standard parameters
	parameters.allowfullscreen = true;
	parameters.allowscriptaccess = 'always';
	parameters.wmode = 'opaque';
	
	// Flash variables
	var variables = {file: flv};
	if (image !== undefined){
		variables.image = window.CR + '/images/video-previews/' + image;
	}
	if (skin !== undefined){
		variables.skin = window.CR + '/swf/skins/' + skin + '/overlay.swf';
	}
	variables.controlbar = controlbar === undefined ? 'bottom' : controlbar;
	variables.autostart = autostart === undefined ? 'false' : autostart;
	variables.stretching = stretching === undefined ? 'uniform' : stretching;
	variables.volume = volume === undefined ? 100 : volume;
	variables.mute = mute === undefined ? 'false' : mute;
	
	swfobject.embedSWF(window.CR + '/swf/player.swf', containerid, w, h, '9.0.0', 'expressInstall.swf', variables, parameters);
}


function textAreaExp(id){
	var label = $('label[for="' + id + '"]');
	var header = '';
	if(label){
		header = '<h3>' + label[0].innerHTML + '</h3>';
	}

	var html = '<div class="emg-form">' + header + '<textarea rows="25" cols="100" id="' + id + '-expanded" class="fluid">' + $('#' + id)[0].value + '</textarea><br /><button onclick="$(\'#' + id + '\')[0].value = $(\'#' + id + '-expanded\')[0].value; modal.close();">Finish</button></div>';
	modal.load();
	modal.content(html);
}

//use to show all the properties of an object;
function alerto(obj, hideValues){
	var output = '';
	for (var prop in obj ) {
		output += 'object.' + prop;
		if(hideValues != true){
			output += ' = ' + obj[prop] 
		}
		output += "\n";
	}
	alert(output);
}


function checkedToStr(inputName){
	var checkboxes = document.getElementsByName(inputName);
	var values = new Array();
	for(var i=0; i<checkboxes.length; i++){
		if(checkboxes[i].checked){
			values[values.length] = checkboxes[i].value;
		}
	}
	return values.join('-');
}

function moneyFormat(value, nosymbol, cents) {
	if (isNaN(value)) {
		var formatted = '0.00';
	}
	else {
		//var formatted = Math.round(value*100)/100;
		var formatted = Math.round(value*1000)/1000; //use 1000 for partial cents
		formatted = formatted.toString();
		
		if (formatted.indexOf('.') == -1) {
			formatted += '.00';
		}
		else {
			var parts = formatted.split('.');
			if (parts[1].length == 1) {
				formatted += '0';
			}
		}
		// Thousands commas
		if (formatted.length >= 7) {
			var parts = formatted.split('.');
			var integer = parts[0];
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(integer)) {
				integer = integer.replace(rgx, '$1' + ',' + '$2');
			}
			formatted = integer + '.' + parts[1];
		}
	}
	if(!nosymbol && !cents){
		formatted = '$' + formatted;
	}
	// Cent symbol
	else if (cents && formatted < 1) {
		return formatted * 100 + '\u00a2';
	}
	return formatted;
}

function emailInUse(emailFieldid){
	checkExist('email', emailFieldid, false);
}

function emailNotExist(emailFieldid){
	checkExist('email', emailFieldid, true);
}

function zipExist(zipFieldid){
	checkExist('zip', zipFieldid, true);
}

function checkExist(field, fieldid, valExists){
	var url = window.CR + '/ajax/check-exist/' + field + '?check-value=' + $('#' + fieldid)[0].value;
	var valFormIndex = getValFormIndex(fieldid);
	valForms[valFormIndex].ajaxRunning[fieldid] = true;
	$.ajax({
		   url: url
		   , type: 'get'
		   , dataType: 'text'
		   , cache: false
		   , complete: function(ajaxReturn) {
						   	if (ajaxReturn.status == '404') { // page not found
								window.location = window.CR + '/error';
								return;
							}
							
			   				var response = ajaxReturn.responseText;
							
							if(valExists){  // for reset password form
								var error = response == '0' ? ' does not exist.' : false;
							}
							else{
								var error = response == '1' ? ' already in use.' : false;
							}
							
							valForms[valFormIndex].errorHandler($('#' + fieldid)[0], error);
							valForms[valFormIndex].ajaxRunning[fieldid] = false;
						}
		   });
}

// Scrolls to hash instead of instant jump
// Also doesn't append hash to current url
// Requires jquery
// Usage: enableHashScroll('a');
// Usage: enableHashScroll(['a', '.nav a]], 1, 16);
function enableHashScroll(anchorSelectors, duration, offset) {
	// Set default duration to 1 second
	duration = isNaN(duration) ? 1000 : duration * 1000;
	offset = isNaN(offset) ? 0 : offset;
	if (!isArray(anchorSelectors)) {
		anchorSelectors = [anchorSelectors];
	}
	
	// For each group of anchor selectors
	$(anchorSelectors).each(function() {
		anchorSelector = $(this).get();
		anchorSelector = anchorSelector === undefined ? 'a' : anchorSelector;
		
		// Anchor events
		$(anchorSelector + '[href^="#"]:not([href="#"]').click(function() {
			this.blur();
			var target = $(this.hash);
			if (target[0]) {
				$('html, body').animate({scrollTop: target.offset().top - offset}, duration);
			}
			return false;
		});
	});
}

// Get hash value from url
function getHash(href) {
	return href.split(/#/)[1];
}

// Get document height, or viewport if body height is less
function getDocHeight() {
	return Math.max(
		Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
		Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
		Math.max(document.body.clientHeight, document.documentElement.clientHeight)
	);
}

// IE select expand
// Usage: ieSelectExpand('select.ie-expand')
function ieSelectExpand(selectSelector) {
	if (selectSelector === undefined) {
		selectSelector = 'select.ie-expand';
	}
	if ($.browser.msie) {
		$(selectSelector).bind('mouseover focus', function() {
			$(this).addClass('expanded').removeClass('clicked');
		}).bind('click', function() {
			$(this).toggleClass('clicked');
		}).bind('mouseout', function() {
			if (!$(this).hasClass('clicked')) {
				$(this).removeClass('expanded');
			}
		}).bind('blur', function() {
			$(this).removeClass('expanded clicked');
		});
	}
}

// Set/append return false
function setOnclickFalse(el, replaceOnclick) {
	if (replaceOnclick == true) {
		el.setAttribute('onclick', 'return false;');
	}
	else {
		var originalOnclick = el.onclick;
		el.onclick = (function(e) {
			if (originalOnclick) {
				originalOnclick();
			}
			return false;
		});
	}
}

// Trim
if (typeof(String.prototype.trim) === "undefined") {
	String.prototype.trim = function() {
		return String(this).replace(/^\s+|\s+$/g, '');
	};
}

//use to concat token to action requests
//function is useful when using ajax to login
//currently being used in checkout.js
function tokenInit(){
	var url = window.CR + '/ajax/account/token';
	var callBackComplete = function(ajaxReturn) {				
		if(!inString(ajaxReturn.responseText, 'lv2-token=')){ //token not available, something could be wrong
			window.TOKEN = '';
			return;
		}
		
		window.TOKEN = ajaxReturn.responseText;
		
		//handle forms
		var forms = $('form');
		for(var i = 0; i < forms.length; i++){
			if(inString(forms[i].action, 'lv2-token=')){ //already has token, potential bugs with user logging in n out with differnt accounts
				continue;	
			}
			if(inString(forms[i].action, window.CR + '/action')){ //if request is an action page
				if(inString(forms[i].action, '?')){
					forms[i].action += '&' + ajaxReturn.responseText;
				}
				else{
					forms[i].action += '?' + ajaxReturn.responseText;
				}
			}
		}
		
		//handle anchors
		var anchors = $('a');
		for(var i = 0; i < anchors.length; i++){
			if(inString(anchors[i].href, 'lv2-token=')){ //already has token, potential bugs with user logging in n out with differnt accounts
				continue;	
			}
			if(inString(anchors[i].href, window.CR + '/action')){ //if request is an action page
				if(inString(anchors[i].href, '?')){
					anchors[i].href += '&' + ajaxReturn.responseText;
				}
				else{
					anchors[i].href += '?' + ajaxReturn.responseText;
				}
			}
		}
	};
	//use ajax to grab token
	$.ajax({url: url, complete: callBackComplete});
	
}

function isArray(o) {
	return Object.prototype.toString.call(o) === '[object Array]';
}

function inString(haystack, needle){
	if(isArray(haystack)){
		alert('use inArray() for ' + needle);
		return false;
	}
	var index = haystack.indexOf(needle);
	
	if (index != -1) {
		return true;	
	}
	
	return false;	
}

function inArray(needle, haystack){
	var index = $.inArray(needle, haystack);
	
	if (index != -1) {
		return true;	
	}
	
	return false;
}

function byId(id){
	return document.getElementById(id);
}

// The .bind method from Prototype.js 
if (!Function.prototype.bind) { // check if native implementation available
  Function.prototype.bind = function(){ 
    var fn = this, args = Array.prototype.slice.call(arguments),
        object = args.shift(); 
    return function(){ 
      return fn.apply(object, 
        args.concat(Array.prototype.slice.call(arguments))); 
    }; 
  };
}

// Scrollbar Width
function getScrollBarWidth() {  
	var inner = document.createElement('p');
	inner.style.width = "100%";
	inner.style.height = "200px";
	
	var outer = document.createElement('div');
	outer.style.position = "absolute";
	outer.style.top = "0px";
	outer.style.left = "0px";
	outer.style.visibility = "hidden";
	outer.style.width = "200px";
	outer.style.height = "150px";
	outer.style.overflow = "hidden";
	outer.appendChild (inner);
	
	document.body.appendChild (outer);
	var w1 = inner.offsetWidth;
	outer.style.overflow = 'scroll';
	var w2 = inner.offsetWidth;
	if (w1 == w2) w2 = outer.clientWidth;
	
	document.body.removeChild (outer);
	
	return (w1 - w2);
};

function youtubeEmbed(selector, url, w, h, autoplay){
	//get video id
	var parts = url.split('?');
	var variables = parts[1].split('&');
	for(var i = 0; i < variables.length; i++){
		var variableParts = variables[i].split('=');
		if(variableParts[0] == 'v'){
			var id = variableParts[1];
		}
	}
	
	if(id == null){
		return;	
	}
	
	if(autoplay == null || !autoplay){
		autoplay = '0';
	}
	else if(autoplay){
		autoplay = '1';	
	}
	
	var html = '<object width="' + w + '" height="' + h + '">';
	html += '<param name="movie" value="http://www.youtube.com/v/' + id + '?fs=1&amp;hl=en_US&autoplay=' + autoplay + '"></param>';
	html += '<param name="allowFullScreen" value="true"></param>';
	html += '<param name="allowscriptaccess" value="always"></param>';
	html += '<param name="wmode" value="opaque"></param>';
	html += '<embed src="http://www.youtube.com/v/' + id + '?fs=1&amp;hl=en_US&autoplay=' + autoplay + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="' + w + '" height="' + h + '"></embed>';
	html += '</object>';

	$(selector)[0].innerHTML = html;
}

/* AC_RunActiveContent.js.php */
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


/* browser-detect.js.php */
/*<script>*/
// Browser name:	BrowserDetect.browser
// Browser version:	BrowserDetect.version
// OS name:			BrowserDetect.OS
/* July 16 09 */ 
/*
Copyright Â© 2008 Eckx Media Group, LLC. All rights reserved.
Eckx Media Group respects the intellectual property of others, and we ask our users to do the same.
*/

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.userAgent,
			subString: "iPhone",
			identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

/* functions.js.php */
/*<script>*/
function siteInit() {
	// Page scroll on anchor links
	enableHashScroll('ul.class-groups a, p.top a, ul.calendar ul.nav a', 0.5);
	
	var slideshow = new Slideshow({navClass: '#slideshow ul.nav'
									, slidesClass: '#slideshow ul.slides'
									, autoplay: true
									, slideDuration: 5
									, transition: 'fade'
									, transitionDuration: 0.5
									});	
	// Append submit button symbol
	buttonGt();
	
	// Resource external links
	$('a[href$=".pdf"], a[href$=".xls"]').click(function() {
		$(this).attr('target', '_blank');
	});
	
	// Fancybox	
	$('a[href$=".jpg"], a[href$=".gif"], a[href$=".png"]').fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	500, 
		'speedOut'		:	250,
		'overlayColor'	:	'#000',
		'overlayOpacity':	'0.8',
		'titlePosition'	:	'inside'
	});
	
	// ^Mc headings (Dorms)
	$('h3').filter(function() {
        return $(this).html().match(/^Mc/);
    })
	.css('textTransform', 'none')
	.html(function(index, oldhtml) {
		return 'Mc' + oldhtml.replace(/^Mc(.*)/, '$1').toUpperCase();
	});
	
	// Footer contact form
	$('#request-information-form').submit(function(event) {
		//alert(1);
		//return false;
	});
}

// Append submit button symbol
function buttonGt() {
	$('p.go > a').append(' &rsaquo;');
	$('.emg-form input[type="submit"], #footer-map input[type="submit"]').val(function(i, val) {
		return val + ' \u203A';
	});
}


/* jquery.easing-1.3.pack.js.php */
/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'1a\']=h.i[\'z\'];h.O(h.i,{y:\'D\',z:9(x,t,b,c,d){6 h.i[h.i.y](x,t,b,c,d)},17:9(x,t,b,c,d){6 c*(t/=d)*t+b},D:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},X:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},U:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},R:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},N:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},M:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},L:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},K:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},I:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t*t+b;6 c/2*((t-=2)*t*t*t*t+2)+b},G:9(x,t,b,c,d){6-c*8.C(t/d*(8.g/2))+c+b},15:9(x,t,b,c,d){6 c*8.n(t/d*(8.g/2))+b},12:9(x,t,b,c,d){6-c/2*(8.C(8.g*t/d)-1)+b},Z:9(x,t,b,c,d){6(t==0)?b:c*8.j(2,10*(t/d-1))+b},Y:9(x,t,b,c,d){6(t==d)?b+c:c*(-8.j(2,-10*t/d)+1)+b},W:9(x,t,b,c,d){e(t==0)6 b;e(t==d)6 b+c;e((t/=d/2)<1)6 c/2*8.j(2,10*(t-1))+b;6 c/2*(-8.j(2,-10*--t)+2)+b},V:9(x,t,b,c,d){6-c*(8.o(1-(t/=d)*t)-1)+b},S:9(x,t,b,c,d){6 c*8.o(1-(t=t/d-1)*t)+b},Q:9(x,t,b,c,d){e((t/=d/2)<1)6-c/2*(8.o(1-t*t)-1)+b;6 c/2*(8.o(1-(t-=2)*t)+1)+b},P:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6-(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b},H:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},F:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},E:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},16:9(x,t,b,c,d,s){e(s==u)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.B))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.B))+1)*t+s)+2)+b},A:9(x,t,b,c,d){6 c-h.i.v(x,d-t,0,c,d)+b},v:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.q*t*t)+b}m e(t<(2/2.k)){6 c*(7.q*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.q*(t-=(2.14/2.k))*t+.11)+b}m{6 c*(7.q*(t-=(2.18/2.k))*t+.19)+b}},1b:9(x,t,b,c,d){e(t<d/2)6 h.i.A(x,t*2,0,c,d)*.5+b;6 h.i.v(x,t*2-d,0,c,d)*.5+c*.5+b}});',62,74,'||||||return||Math|function|||||if|var|PI|jQuery|easing|pow|75|70158|else|sin|sqrt||5625|asin|||undefined|easeOutBounce|abs||def|swing|easeInBounce|525|cos|easeOutQuad|easeOutBack|easeInBack|easeInSine|easeOutElastic|easeInOutQuint|easeOutQuint|easeInQuint|easeInOutQuart|easeOutQuart|easeInQuart|extend|easeInElastic|easeInOutCirc|easeInOutCubic|easeOutCirc|easeInOutElastic|easeOutCubic|easeInCirc|easeInOutExpo|easeInCubic|easeOutExpo|easeInExpo||9375|easeInOutSine|easeInOutQuad|25|easeOutSine|easeInOutBack|easeInQuad|625|984375|jswing|easeInOutBounce'.split('|'),0,{}))

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */


/* jquery.fancybox-1.3.4.pack.js.php */
/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 * 
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
 * 
 * Version: 1.3.4 (11/11/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("<div/>")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)||
c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=
false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel",
function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+
'"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win==
"function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('<div style="width:'+a+";height:"+c+
";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor,
opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length?
d.titlePosition=="float"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding});
y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height==
i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents());
f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode==
37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto");
s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').appendTo(j);
f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c);
j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type==
"image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"),
10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)};
b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k=
0,C=a.length;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+
1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h=
true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1;
b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5-
d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()});
b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D)}}};
b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",
easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery);

/* jquery.mousewheel-3.0.4.pack.js.php */
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.4
*
* Requires: 1.2.2+
*/

(function(d){function g(a){var b=a||window.event,i=[].slice.call(arguments,1),c=0,h=0,e=0;a=d.event.fix(b);a.type="mousewheel";if(a.wheelDelta)c=a.wheelDelta/120;if(a.detail)c=-a.detail/3;e=c;if(b.axis!==undefined&&b.axis===b.HORIZONTAL_AXIS){e=0;h=-1*c}if(b.wheelDeltaY!==undefined)e=b.wheelDeltaY/120;if(b.wheelDeltaX!==undefined)h=-1*b.wheelDeltaX/120;i.unshift(a,c,h,e);return d.event.handle.apply(this,i)}var f=["DOMMouseScroll","mousewheel"];d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=
f.length;a;)this.addEventListener(f[--a],g,false);else this.onmousewheel=g},teardown:function(){if(this.removeEventListener)for(var a=f.length;a;)this.removeEventListener(f[--a],g,false);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);

/* slideshow-v4.js.php */
/*<script>*/
// Requires jquery
// Usage:
/* var slideshow = new Slideshow({previousNextNavClass: '#slideshow ul.previous-next-nav'
								, navClass: '#slideshow ul.nav'
								, slidesClass: '#slideshow ul.slides'
								, autoplay: true
								, slideDuration: 5
								, transition: 'scroll'
								, transitionDuration: 0.5
								//, replaceOnlick = false
								});
*/
function Slideshow(args) {
	// Constructor
	this.construct = function(args) {
		// Required Parameters
		this.previousNextNavClass = args.previousNextNavClass;
		this.navClass = args.navClass;
		this.slidesClass = args.slidesClass;
		// Optional parameters (set default values in 'else' condition)
		this.autoplay = args.autoplay == true ? true : false;
		this.slideDuration = args.slideDuration > 0 ? args.slideDuration : 4;
		this.transition = args.transition;
		this.transitionDuration = args.transitionDuration > 0 ? args.transitionDuration : 1;
		
		// Navs & Slides
		this.previousNextNavs = $(this.previousNextNavClass + ' > li');
		this.navs = $(this.navClass + ' > li');
		this.slides = $(this.slidesClass + ' > li');
		this.count = this.slides.length;
		// Need slides container for 'scroll'
		this.slidesContainer = $(this.slidesClass)[0];
		
		this.scrollAmount = $(this.slidesClass + ' > li:first-child').width();
		
		this.current = 1;
		this.currentClass = 'current';
		this.currentPreviousClass = 'current-previous';
		this.previousClass = 'previous';
		this.nextClass = 'next';
		
		// Tabbed class for classname handling
		this.tabbed = false;
		
		// Return if elements don't exist
		if (this.slides.length < 1 || (this.navs.length + this.previousNextNavs.length < 1)) {
			return;
		}
		// Create Tabbed instance
		else {
			this.tabbed = new Tabbed({navClass: this.navClass});
		}
		
		// Set slides container width for scroll transition
		if (this.transition == 'scroll') {
			$(this.slidesContainer).width($(this.slides[0]).width() * $(this.slides).length);
		}
		
		this.setEvents();
		
		setTimeout((function() {
			this.play();
		}).bind(this), this.slideDuration * 1000);
	}
	
	// Event handlers
	this.setEvents = function() {
		// Stop autoplay if list item is clicked on
		this.slides.click((function() {
			this.stop();
		}).bind(this));
		
		// Swap events
		$(this.navClass + ' > li > a').each((function(i, el) {
			// Click event
			$(el).click((function() {
				this.swap(el.hash);
				return false;
			}).bind(this, el))
		}).bind(this));
		
		// Previous / Next links
		$(this.previousNextNavClass + ' > li > a').each((function(i, el) {
			$(el).click((function() {
				if ($(el).parent().hasClass(this.previousClass)) {
					this.previous(false);
				}
				else if ($(el).parent().hasClass(this.nextClass)) {
					this.next(false);
				}
				return false;
			}).bind(this, el))
		}).bind(this));
	}
	
	// Autoplay
	this.play = function() {
		if (!this.autoplay) {
			return;
		}
		
		// Go to next slide
		this.next(true);
		
		// Continue autoplay
		setTimeout((function() {
			this.play();
		}).bind(this), (this.slideDuration + this.transitionDuration) * 1000);
	}
	
	// Swap target slide with current
	this.swap = function(target, autoplay) {
		if (!autoplay) {
			this.stop();
		}
		
		// Target slide <li> element
		var targetSlide = $(target);
		var currentSlide = $(this.slides[this.current - 1]);
		
		// Do nothing if swap target is current
		var newCurrent = $(this.slides).index(targetSlide) + 1;
		if (this.current ==  newCurrent) {
			return;
		}
		
		// Fade
		if (this.transition == 'fade') {
			// Fade out
			// Add currentPreviousClass so we can fade out from the current slide			
			$(currentSlide).addClass(this.currentPreviousClass);
			$(currentSlide).fadeOut(this.transitionDuration * 1000);
			
			// Fade in			
			$(targetSlide).hide();
			$(targetSlide).fadeIn(this.transitionDuration * 1000, (function() {
				$(this.slides).removeClass(this.currentPreviousClass);
			}).bind(this));
		}
		// Scroll
		else if (this.transition == 'scroll') {
			var displacement = -(this.scrollAmount) * (newCurrent - 1);
			$(this.slidesContainer).animate({marginLeft: displacement}, this.transitionDuration * 1000, 'swing');
		}
		
		// Set new current
		this.current = newCurrent;
	}
	
	// Go to previous slide
	this.previous = function(autoplay) {
		this.traverse(false, autoplay);
	}
	// Go to next slide
	this.next = function(autoplay) {
		this.traverse(true, autoplay);
	}
	
	// Traverse (Previous/Next) slides
	// previous: direction = 0
	// next: direction = 1
	this.traverse = function(direction, autoplay) {
		// Default autoplay is false
		autoplay = autoplay == true ? true : false;
		
		// Default direction is true (next)
		var targetAnchorIndex = 0;
		if (direction == false) {
			targetAnchorIndex = (this.current == 1) ? this.count - 1 : this.current - 2;
		}
		else {
			targetAnchorIndex = (this.current == this.count) ? 0 : this.current;
		}
		// Swap
		var targetAnchor = $(this.navClass + ' > li > a')[targetAnchorIndex];
		
		this.tabbed.setCurrents(targetAnchor);
		this.swap(targetAnchor.hash, autoplay);
	}
	
	// Stop autoplay
	this.stop = function() {
		if (this.autoplay) {
			this.autoplay = false;
		}
	}
	
	this.construct(args);
}


/* tabbed-v2.js.php */
/*<script>*/
// Requires jquery
// Usage:
/* var tabbed = new Tabbed({navClass: '.tabbed-content ul.nav'
							, currentItem: 1
							//, currentClass: 'current'
							//, tabbedClass: 'tabbed'
							//, toggle: true // for to
							});
*/
function Tabbed(args) {
	// Constructor
	this.construct = function(args) {
		// Required Parameters
		this.navClass = args.navClass;
		// Optional Parameters
		this.toggle = args.toggle == true ? true : false;
		this.currentItem = args.currentItem > 0 ? args.currentItem : (this.toggle ? 0 : 1);
		this.currentClass = args.currentClass !== undefined ? args.currentClass : 'current';
		this.tabbedClass = args.tabbedClass !== undefined ? args.tabbedClass : 'tabbed';
	
		this.currentNav = false;
		this.currentContent = false;
		
		// Use parent <li>s when applicable
		this.navs = $(this.navClass + ' > li');
		// Don't force anchors to be within <li>
		this.navAnchors = $(this.navClass + ' a[href*="#"]:not([href$="#"])');
		this.contents = [];
		
		// Get content containers based on anchor hashes
		var contentIds = [];
		$(this.navAnchors).each(function() {
			if (this.hash) {
				contentIds.push(this.hash);
			}
		});
		this.contents = $(contentIds.join(', '));
		
		// Return if contents don't exist
		if (this.contents.length < 1) {
			return;
		}
		
		// Append tabbed class to hide
		$([this.navs, this.navAnchors, this.contents]).each((function(i, el) {
			$(el).addClass(this.tabbedClass);
		}).bind(this));
		
		// Set current class to currentItem's nav & content
		$(this.navAnchors).each((function(i, el) {
			if (i + 1 == this.currentItem) {
				this.setCurrents(el);
			}
		}).bind(this));
		
		this.setEvents();
	}
	
	// Set click events on anchors
	this.setEvents = function() {
		var thisClass = this;
		$(this.navAnchors).click(function() {
			this.blur();
				
			// Clear 'current' class from navs and contents
			// Set current nav and content
			// Apply 'current' class
			thisClass.setCurrents(this);
			return false;
		});
	};
	
	// Remove 'current' class name from navs and contents
	this.clearCurrents = function() {
		$([this.navs, this.navAnchors, this.contents]).each((function(i, el) {
			$(el).removeClass(this.currentClass);
		}).bind(this));
	};
	
	// Add 'current' class name on current nav and content
	this.setCurrents = function(targetAnchor) {
		var target = targetAnchor.hash;
		if (!this.toggle) {
			this.clearCurrents();
		}
		
		// Set current on <li> (parent) nav, <a>, and content
		this.currentNav = $(targetAnchor).parent();
		this.currentContent = $(target);
		$([this.currentNav, targetAnchor, this.currentContent]).each((function(i, el) {
			if (!this.toggle) {
				$(el).addClass(this.currentClass);
			}
			else {
				$(el).toggleClass(this.currentClass);
			}
		}).bind(this));
	}
	
	this.construct(args);
}


/* valform-v2.js.php */
/* 
3:44 PM 5/19/2011 - added error msg to use default value, did not thourghly tested.
3:29 PM 3/10/2011 - added this.inputs = $('input:enabled,select:enabled,textarea:enabled', this.form);

 */
/*
Copyright Â© 2008 Eckx Media Group, LLC. All rights reserved.
Eckx Media Group respects the intellectual property of others, and we ask our users to do the same.
*/
/*<script>*/
/*
PACK:
	replace JS Variables: formClasses submitBtns waitFlag errorStr locate errorField labelFor focusThisFlag validNodes args colonPos
	after pack, need to replace $Vxxxxxx with $w or $A
*/
/*key words

class names
val-form
alert-errors
hide-errors
dont-disable
auto-focus-on

validators
==========
val_req
val_checked (int)(checkboxes only)
val_checked_min (int) (checkboxes only)
val_checked_max (int) (checkboxes only)
val_min(int)
val_max(int)
val_maxNum(int)
val_minNum(int)
val_alpha
val_alpha_num
val_alpha_space
val_alpha_num_space
val_num
val_int
val_email
val_len
val_same(input id)
val_notSame(input id); // id of input(hidden) containing ids of fields to check
val_url
val_ajax(function)
val_func(function)
val_date
val_datetime
val_phone
val_ceil
val_exist
val_not_exist
key words
=========
val_combo(input id): combine multiple elements to a single output error base on input id, elements should have a single name to allow access to lable name
	usage: label for should match with first input id, val_comboe (id of last input)
	ie:
		<label for="register-birthdate-month">Birthdate:</label>
		<select id="register-birthdate-month" name="dob[]" class="month val_req val_combo register-birthdate-year"></select>
		<select id="register-birthdate-day" name="dob[]" class="day val_req val_combo register-birthdate-year"></select>
		<select id="register-birthdate-year" name="dob[]" class="year val_req val_combo register-birthdate-year"></select>
		
val_money: turn into money format
val_errorAfter(element id): errors would be displayed after a html element
val_skipifis(input id): ignore validations if the value is the same as the provided input 
*/

/* bugs
	- error appears then disappears, try placing val_ajax check at the end.


*/
var valForms = new Array(); //global scope
function initValForm(container){
	//getting new forms to initialize valform
	if(container){
		var forms = $('form[class~="val-form"]', container[0]);
	}
	else{
		var forms = $('form[class~="val-form"]');
	};
	
	//adding the valform object to a global list
	for(var i = forms.length; i > 0; i--){
		//check if formid already exist
		var existFlag = false;
		for(var j = 0; j < valForms.length; j++){
			if(valForms[j].form.id == forms[i - 1].id){
				//form id already exist, need to reset event observation and stuff
				valForms[j].reset();
				valForms[j].init(forms[i - 1]);
				existFlag = true;
			}
		}
		if(!existFlag){
			var nextIndex = valForms.length;
			valForms[nextIndex] = new Valform();
			valForms[nextIndex].init(forms[i - 1]);
		}
	}
}

function valFormsResetSubmit(){
	for(var i = 0; i < valForms.length; i++){
		valForms[i].resetSubmit();
	}	
}

function getValFormIndex(nodeid){ // gets valform index based of form id or an input id
	for(var valFormIndex = 0; valFormIndex < valForms.length; valFormIndex++){
		if(valForms[valFormIndex].form.id == nodeid){
			return valFormIndex;
		}
		
		for(var i = 0; i < valForms[valFormIndex].inputs.length; i++){
			if(valForms[valFormIndex].inputs[i].id == nodeid){
				return valFormIndex;
			}
		}
	}
	alert('valform index not found');
}

function Valform() { 
	//config
	this.errorClass = 'val-error';
	this.errorContainerTag = 'div';
	this.errorContainerClass = 'val_error';
	//!config
	
	//all validator and key words
	this.classList = new Array('val_req', 'val_min', 'val_max', 'val_maxNum', 'val_minNum', 'val_alpha', 'val_alpha_num', 'val_alpha_num_sym', 'val_alpha_space', 'val_alpha_num_space', 'val_num', 'val_int', 'val_email', 'val_len', 'val_same', 'val_notSame', 'val_url', 'val_ajax', 'val_money', 'val_func',  'val_checked', 'val_checked_min', 'val_checked_max', 'val_date', 'val_datetime', 'val_phone', 'val_ceil', 'val_exist', 'val_not_exist', 'val_decimal');
	//key words that are dependent on next class
	this.dependents = new Array('val_len', 'val_min', 'val_max', 'val_maxNum', 'val_minNum', 'val_same', 'val_notSame', 'val_ajax', 'val_func', 'val_checked', 'val_checked_min', 'val_checked_max', 'val_ceil', 'val_exist', 'val_not_exist', 'val_decimal');
	this.ajaxClasses = new Array('val_ajax', 'val_exist', 'val_not_exist');
	this.failed = true; // flag for submitting
	this.form = null;	// form obj
	this.formObsFunc = null; //holds event observer function to stop observing
	
	this.submitBtn = null; //button object for submitting form
	this.submitBtnDefaultVal = null; //to toggle between please wait...
	this.ajaxRunning = new Object(); //flag to signal if ajax check is running
	this.alertErrorsFlag = false; //flag to alert errors when submitting
	this.containerErrorsFlag = false; //flag to show errors in a container when submitting
	this.hideErrorsFlag = false; // flag to not display errors next to field
	this.errors = new Object();
	this.errorFocusedFlag = false; //flag to focus on first error field only when submitting
	this.inputs = new Array(); //holds all the form inputs that will be validated
	
	this.originalSubmit = null; //the onsubmit of the form before its overwritten, will run before valform submits
	//arg[0]: form id, arg[1]: options
	//options: ae - alert errors on submit, he = dont display errors next to field
	this.init = function(form){
		
		if(!form){
			alert('Valform.init(), form object dosnt exist');
			return false;
		}
		
		this.form = form;
		
		//handle options
		if($(form).hasClass('alert-errors')){
			this.alertErrorsFlag = true;
		}
		if($(form).hasClass('container-errors')){
			this.containerErrorsFlag = true;
		}
		if($(form).hasClass('hide-errors')){
			this.hideErrorsFlag = true;
		}
		
		//get submit btn
		var submitBtns = $('input[type="submit"]', this.form);
		
		if(submitBtns.length == 0){
			alert('valForm init error: no submit button');	
		}
		else{
			this.submitBtn = submitBtns[0];
			this.submitBtnDefaultVal = this.submitBtn.defaultValue;
			this.resetSubmit();
		}
		
		//get inputs from form elements
		var validNodes = new Array('INPUT', 'TEXTAREA', 'SELECT');
		
		this.inputs = $('input:enabled,select:enabled,textarea:enabled', this.form);

		/* bug in ie when input name = length
		
		for(var i = 0; i < formLength; i++){
			/* does not work in ie

			if(this.form.elements[i].disabled || !inArray(this.form.elements[i].nodeName, validNodes)){ //no point of checking if disabled or if not valid tag;
				continue;	
			}
			this.inputs[this.inputs.length] = this.form.elements[i];
		}*/
		
		//set event for inputs
		var focusThisFlag = true;
		if($(form).hasClass('auto-focus-on')){
			focusThisFlag = false;
		}
		for(var i = 0; i < this.inputs.length; i++){
			var inputType = this.inputs[i].type.toLowerCase();
			//determine which field to focus first
			if(!focusThisFlag && this.inputs[i].name && inputType != 'hidden'){
				focusThisFlag = true;
				if(inputType != 'radio' && inputType != 'checkbox'){ //radio & checkbox causes blur event to occurw when selecting options
					this.inputs[i].focus();
				}
			}
			
			//setting up events
			$(this.inputs[i]).bind('blur', {parent:this}, this.fieldCheck);
			
			//get all ajax check and initialize the running flag
			for (var j = 0; j < this.ajaxClasses.length; j++) {
				if ($(this.inputs[i]).hasClass(this.ajaxClasses[j])) {
					this.ajaxRunning[this.inputs[i].id] = false;
				}
			}
		}
		
		//set submit event
		this.originalSubmit = this.form.onsubmit; //save original onsubmit function
		this.form.onsubmit = null; // remove it
		this.formObsFunc = 1;
		$(this.form).bind('submit', {parent:this}, this.submitCheck);
	};
	
	this.reset = function(){
		//reset member variables
		this.failed = true;
		this.ajaxRunning = new Object();
		
		if(this.inputs){ // unset event observation
			for(var i = 0; i < this.inputs.length; i++){
				$(this.inputs[i]).unbind('blur', {parent:this}, this.fieldCheck); //stop input obs
			}
		}
		this.inputs = new Array();
		
		if(this.formObsFunc){
			$(this.form).unbind('submit', {parent:this}, this.submitCheck); //stop submit obs
		}
	};

	this.submitCheck = function(event){
		var parent = event.data.parent; //because out of scope because function is called on event
		
		parent.errorFocusedFlag = false; //not focused on any errors yet
		if(!$(parent.form).hasClass('dont-disable')){
			parent.submitBtn.disabled = true; //prevent double click
		}
		parent.submitBtn.value = 'Please wait...';
		parent.errors = new Object(); // clean error list
		
		parent.failed = false;
		for(var fieldID in this.ajaxRunning){
			this.ajaxRunning[fieldID] = true;	
		}
		
		for(var i = 0; i < parent.inputs.length; i++){
			parent.fieldCheckSubmit(parent.inputs[i]);
			if(parent.errors[parent.inputs[i].id] && !parent.errorFocusedFlag){ // focusing on error input
				parent.inputs[i].focus();
				parent.errorFocusedFlag = true;
			}
		}
		
		parent.submitAjaxChk();
		//setTimeout('parent.submitAjaxChk()', 1); //causing error in ie, not sure why the setTimeout is needed.
		
		event.preventDefault();
		event.stopPropagation();
		return false;
	};
	

	//make sure ajax function is complete
	this.submitAjaxChk = function(){ 
	
		var waitFlag = false;
		for(var fieldID in this.ajaxRunning){
			if(this.ajaxRunning[fieldID]){
				waitFlag = true;
			}
			else{
				if(this.errors[fieldID] && !this.errorFocusedFlag){ // focusing on error fields
					$('#' + fieldID)[0].focus();
					this.errorFocusedFlag = true;
				}
			}
		}
		if(waitFlag){
			var valFormIndex = getValFormIndex(this.form.id);
			setTimeout('valForms[' + valFormIndex + '].submitAjaxChk()', 100);
		}
		else if(!this.failed){
			var tosubmit = true;  //alert(this.originalSubmit);
			if(this.originalSubmit){
				tosubmit = this.originalSubmit.call(this.form);
			}
			if(tosubmit == 'dont reset'){ //special case where originalSubmit is submitting the form
				//nothing
			}
			else if(tosubmit){
				this.form.submit();
			}
			else{ //may cause problems but need it for curtain
				this.resetSubmit();
			}
		}
		else { //failed
			if (this.alertErrorsFlag) {
				var errorStr = '';
				for (var fieldID in this.errors) {
					errorStr += this.errors[fieldID] + "\n";
				}
				
				alert(errorStr);
			}
			
			if (this.containerErrorsFlag && byId(this.form.id + '-errors-cont') != null) {
				var errorStr = '<ul class="' + this.errorContainerClass + '">';
				for (var fieldID in this.errors) {
					errorStr += '<li>' + this.errors[fieldID] + '</li>';
				}
				
				errorStr += '</ul>';
				
				byId(this.form.id + '-errors-cont').innerHTML = errorStr;
			}
			
			this.resetSubmit();
		}
	};
	
	this.resetSubmit = function(){
		this.submitBtn.disabled = false; //make sure the button is enabled
		this.submitBtn.value = this.submitBtnDefaultVal;
	};
	
	this.fieldCheck= function(event){ //check event
		var parent = event.data.parent; //out of scope because function is called on event
		
		var classes = this.className.split(' ');
		//handle combo
		/* does not work in ie
		var index = classes.indexOf('val_combo');
		*/
		var index = $.inArray('val_combo', classes);
		if(index != -1){ // found key word
			if(index + 1 == classes.length){ // dosnt have combo id
				alert('val_combo id required');
				return;
			}
			var comboID = classes[index + 1];
			
			if($('#' + parent.comboID + '_error')){ //clear combo error
				$('#' + parent.comboID + '_error').remove();
			}
			if(parent.errors[comboID]){ //clear combo error
				parent.errors[comboID] = false;
			}
			var comboFields = $('.' + comboID, parent.form); //get all fields with combo id in class
			
			for(var i = 0; i < comboFields.length; i++){
				parent.validate(comboFields[i], comboID);
				if(parent.errors[comboID]){
					return;	
				}
			}
			return;
		}
		
		parent.validate(this);
		return;
	};
	
	this.fieldCheckSubmit= function(field){ //check event
		var classes = field.className.split(' '); //make sure to get the latest class name sice it may have changed
		//handle combo
		/* does not work in ie
		var index = classes.indexOf('val_combo');
		*/
		var index = $.inArray('val_combo', classes);
		if(index != -1){ // found key word
			if(index + 1 == classes.length){ // dosnt have combo id
				alert('val_combo id required');
				return;
			}
			var comboID = classes[index + 1];
			
			if($('#' + this.comboID + '_error')){ //clear combo error
				$('#' + this.comboID + '_error').remove();
			}
			if(this.errors[comboID]){ //clear combo error
				this.errors[comboID] = false;
			}
			
			var comboFields = $('.' + comboID, this.form); //get all fields with combo id in class
			
			for(var i = 0; i < comboFields.length; i++){
				this.validate(comboFields[i], comboID);
				if(this.errors[comboID]){
					return;	
				}
			}
			return;
		}
		
		this.validate(field);
		return;
	};
	
	this.validate= function(field, comboID){ // validate function
		
		if(field.value && field.type.toLowerCase() != 'file'){ //security error for file inputs
			field.value = $.trim(field.value); //auto strip whitespaces
		}
		var classes = field.className.split(' ');
		//check for val_skipifis
		/* does not work in ie
		var locate = classes.indexOf('val_skipifis');
		*/
		
		var locate = $.inArray('val_skipifis', classes);
		if(locate != -1 && locate != (classes.length - 1)){ // exist and not the last class name
			var ifisInput = $('#' + classes[locate + 1])[0];
			if(ifisInput.value != '' && field.value == ifisInput.value){
				/* does not work in ie
				if(classes.indexOf('val_ajax') != -1 ){ // top ajax running, because of submit check
				*/
				for (var j = 0; j < this.ajaxClasses.length; j++) {
					if (inArray(this.ajaxClasses[j], classes)) { // top ajax running, because of submit check
						this.ajaxRunning[field.id] = false;
					}
				}
				this.errorHandler(field, false);
				return;	
			}
		}
		
		for(var i = 0; i < classes.length; i++){
			/*
			does not work in ie
			if(this.classList.indexOf(classes[i]) == -1){ //not a keyword
			*/
			if(!inArray(classes[i], this.classList)){ //not a keyword
				continue;
			}
			/*
			does not work in ie
			if(this.dependents.indexOf(classes[i]) == -1){ //not a dependant
			*/
			if(!inArray(classes[i], this.dependents)){ //not a dependant
				var run = 'var error = this.' + classes[i] + '(field);';
			}
			else{ //dependent on next class
				if(i + 1 == classes.length){
					alert('valForm dependent required');
					return false;
				}
				var run = 'var error = this.' + classes[i] + '(field, "' + classes[i + 1] + '");';
			}
			eval(run); //alert(run);
			
			//if(classes[i] == 'val_ajax'){
			if(inArray(classes[i], this.ajaxClasses)){
				continue;	
			}
			var errorField = field;
			if(comboID){ // display error for combo 
				errorField = $('#' + comboID)[0];
			}
			if(this.errorHandler(errorField, error)){
				break;	
			}
		}
	};
	
	this.errorHandler= function(field, error){ // function to display error	
		var fieldType = field.type.toLowerCase();
		if(fieldType == 'checkbox' && field.name.indexOf('[') != -1 ){ //for checkboxes, name is an array, get label base on first index id 
			var labelFor = $('[name="' + field.name + '"]', this.form)[0].id;
		}
		else{
			var labelFor = field.id;
		}
		
		var label = $('label[for=' + labelFor  + ']', this.form)[0];
		
		if($('#' + field.id + '_error')[0]){
			$('#' + field.id + '_error').remove();
		}
		
		if(label != ''){
			$([label, field]).removeClass(this.errorClass);
		}
		
		if (!error) { // no error
			return false;	
		}
		this.failed = true;
		
		 //when submiting, ajax running are set, but there is an error, so ajax function will not start, therefore ajax running will never be unset
		if (this.ajaxRunning[field.id]) {
			this.ajaxRunning[field.id] = false;
		}
		
		/* comment out because some forms may use default value as the label
		if (!label) {
			alert(field.id + ' label is missing, check label id');
			return;
		}*/
		//remove html between label tags or remove a colon and after
		if(label != ''){ //msg comes from label
			var errorMsg = label.innerHTML;
		}
		else{ //msg comes from default value
			var errorMsg = $('#' + labelFor)[0].defaultValue;
		}
		
		// Remove <em>*</em>, tooltip
		errorMsg = errorMsg.replace(/<em>\*<\/em>|<span class="hint">.+<\/span>|<span class="tip">.+<\/span>/gi, '');
		
		// Strip tags
		errorMsg = $('<tag>' + errorMsg + '</tag>').text(); // .text() will only work when string starts with html tag
		
		// Trim whitespace and ending colon
		errorMsg = $.trim(errorMsg);
		errorMsg = errorMsg.replace(/:$/gi, '') + ' ' + error;
		
		if(!this.hideErrorsFlag){
			//check to place error after a diferent element
			var classNames = field.className.split(' ');
			/* does not work in ie
			var findKeyword = classNames.indexOf('val_errorAfter');
			*/
			var findKeyword = $.inArray('val_errorAfter', classNames);
			if (findKeyword != -1){
				if (findKeyword == (classNames.length - 1)) { //missing id for error element
					alert('val_form: val_errorAfter is missing an id');
				}
				else {
					var errorMsgHtml = '<' + this.errorContainerTag + ' id="' + field.id + '_error" class="' + this.errorContainerClass + '">' + errorMsg + '</' + this.errorContainerTag + '>';
					$(errorMsgHtml).insertAfter($('#' + classNames[findKeyword + 1]));
				}
			}
			else { //place error after field element
				var errorMsgHtml = '<' + this.errorContainerTag + ' id="' + field.id + '_error" class="' + this.errorContainerClass + '">' + errorMsg + '</' + this.errorContainerTag + '>';
				$(errorMsgHtml).insertAfter(field);
			}
		}
		
		if(label != ''){
			$([label, field]).addClass(this.errorClass);
		}
		
		this.errors[field.id] = errorMsg;
		
		return true;
	};
	
	
	//-------------- VALIDATORS
	
	this.val_num = function(field) {
		if(field.value.match(/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/) || field.value == '') {
			return false;
		} 
		else {
			return 'needs to be a number.';
		}
	};
	
	this.val_req = function(field) {
		//handle default value cases when label is missing
		var label = $('label[for=' + field.id  + ']', this.form)[0];
		if(label == ''){
			if(field.value == field.defaultValue){
				return 'is required.';	
			}
		}
		var fieldType = field.type.toLowerCase();
		if(fieldType == 'checkbox' || fieldType == 'radio'){
			var values = $('[name="' + field.name + '"]', this.form);
			for(var i = 0; i < values.length; i++){
				if(values[i].checked){
					return false;	
				}
			}
		}  
		else if(field.value.length != 0) {
			return false;
		} 
		
		return 'is required.';
	};
	
	this.val_min = function(field, minLen) {
		if(field.value.length < parseFloat(minLen) && field.value != ''){
			return 'must be at least ' + minLen + ' characters long.';
		}
		else{
			return false;	
		}
	};
	
	this.val_max = function(field, maxLen) {
		if(field.value.length > parseFloat(maxLen) && field.value != ''){
			return 'must be at most ' + maxLen + ' characters long.';
		}
		else{
			return false;	
		}
	};
	
	this.val_maxNum = function(field, maxNum){
		if(!isNaN(field.value) && field.value > parseFloat(maxNum)){ 
			return 'must be ' + maxNum + ' or less.';
		}
		else{
			return false;	
		}
	};
	
	this.val_minNum = function(field, minNum){
		if(!isNaN(field.value) && (field.value < parseFloat(minNum)) && field.value != ''){
			return 'must be ' + minNum + ' or greater.';
		}
		else{
			return false;	
		}
	};
	
	this.val_len = function(field, len) {
		if(field.value.length != parseFloat(len) && field.value != ''){
			return 'must be ' + len + ' characters long.';
		}
		else{
			return false;	
		}
	};
	
	this.val_same = function(field, field2){
		var field2Obj = $('#' + field2)[0];
		if(!field2Obj){
			alert('val_same: ' + field2 + ' is not defined');
			return true;
		}
		if(field.value != field2Obj.value && field2Obj.value != ''){
			var field2Label = $('label[for=' + field2Obj.id + ']', this.form)[0].innerHTML;
			field2Label = field2Label.replace(/^<em>\*<\/em>|<span class="tip">.+<\/span>/gi, '');
			field2Label = $.trim($('<tag>' + field2Label + '</tag>').text()); // .text() will only work when string starts with html tag
			field2Label = field2Label.replace(/:$/gi, ''); // remove ending colon
			return 'does not match ' + field2Label + '.';
		}
		return false;
	};
	
	this.val_notSame = function(field, field2){
		var field2Obj = $('#' + field2)[0];
		if(!field2Obj){
			alert('val_notSame: ' + field2 + ' is not defined');
			return 'error';
		}
		if(field.value.length == 0){ //blank
			return false;	
		}
		if(field.value == field2Obj.value){
			var field2Label = $('label[for=' + field2Obj.id + ']', this.form)[0].innerHTML;
			field2Label = field2Label.replace(/^<em>\*<\/em>|<span class="tip">.+<\/span>/gi, '');
			field2Label = $.trim($('<tag>' + field2Label + '</tag>').text()); // .text() will only work when string starts with html tag
			field2Label = field2Label.replace(/:$/gi, ''); // remove ending colon
			return ' must not match ' + field2Label;	
		}
		return false;
	};
	
	this.val_email = function(field){
		if(field.value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/) || field.value == '') {
			return false;
		} 
		else {
			return 'is not a valid email address.';
		}
	};
	
	this.val_alpha = function(field) {
		if(field.value.match(/^[a-zA-Z]+$/) || field.value == '') {
			return false;
		} 
		else {
			return 'should contain only letters.';
		}
	};
	
	this.val_alpha_space = function(field) {
		if(field.value.match(/^[a-zA-Z\s]*$/) || field.value == '') {
			return false;
		} 
		else {
			return 'should contain only letters and spaces.';
		}
	};
	
	this.val_alpha_num = function(field) {
		if(field.value.match(/^[a-zA-Z0-9]*$/) || field.value == '') {
			return false;
		} 
		else {
			return 'should contain only letters and numbers.';
		}
	};
	
	this.val_alpha_num_space = function(field) {
		if(field.value.match(/^[a-zA-Z0-9\s]*$/) || field.value == '') {
			return false;
		} 
		else {
			return 'value should contain only letters, numbers, and spaces.';
		}
	};
	
	this.val_alpha_num_sym = function(field) {
		if(field.value.match(/^[a-zA-Z0-9_\-.]*$/) || field.value == '') {
			return false;
		} 
		else {
			return 'should contain only letters, numbers, and "-", "_", or ".".';
		}
	};
	
	this.val_int = function(field) {
		if(field.value.match(/(^-?\d\d*$)/) || field.value == '') {
			return false;
		} 
		else {
			return 'needs to be a whole number.';
		}
	};
	
	this.val_url = function(field) {
		if(field.value.match(/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i) || field.value == '') {
			return false;
		} 
		else {
			return 'needs to be a valid url.';
		}


	};
	
	this.val_checked = function(field, len){
		var checked = 0;
		var values = $('[name="' + field.name + '"]', this.form);
		for(var i = 0; i < values.length; i++){
			if(values[i].checked){
				checked++;
			}
		}
		if(checked != len){
			return 'requires ' + len + ' selections.';
		}
		return false;
	};
	
	this.val_checked_min = function(field, len){
		var checked = 0;
		var values = $('[name="' + field.name + '"]', this.form);
		for(var i = 0; i < values.length; i++){
			if(values[i].checked){
				checked++;
			}
		}
		if(checked < len){
			return 'requires at least ' + len + ' selections.';
		}
		return false;
	};

	this.val_checked_max = function(field, len){
		var checked = 0;
		var values = $('[name="' + field.name + '"]', this.form);
		for(var i = 0; i < values.length; i++){
			if(values[i].checked){
				checked++;
			}
		}
		if(checked > len){
			return 'requires at most ' + len + ' selections.';
		}
		return false;
	};

	this.val_ajax = function(field, func){
		eval(func + "('" + field.id + "')");
		return true;
	};
	
	this.val_func = function(field, func){
		eval('var valForm_error = ' + func + "('" + field.id + "')");
		if(valForm_error){
			return valForm_error;
		}
		else{
			return false;
		}
	};
	
	this.val_exist = function(field, fieldToCheck){
		eval("checkExist('" + fieldToCheck + "', '" + field.id + "', true)");
		return true;
	};
	
	this.val_not_exist = function(field, fieldToCheck){
		eval("checkExist('" + fieldToCheck + "', '" + field.id + "', false)");
		return true;
	};
	
	//action key words	
	this.val_money = function(field){
		field.value = field.value.replace(/[^0-9\-\.]/g, '');
		if(field.value == ''){
			return;	
		}
		if(isNaN(field.value)){
			formated = '0.00';
		}
		else{
			var formated = Math.round(field.value * 1000) / 1000; //1000 for partial cents
			formated = formated.toString();
			if(formated.indexOf('.') == -1){
				formated += '.00';
			}
			else{
				var parts = formated.split('.');
				if(parts[1].length == 1){
					formated += '0';	
				}
			}
		}
		field.value = formated;
	};
	
	this.val_decimal = function(field, precision){
		field.value = field.value.replace(/[^0-9\-\.]/g, '');
		if(field.value == ''){
			return;	
		}
		if(isNaN(field.value)){
			formated = '0.00';
		}
		else{
			var formated = Math.round(field.value * Math.pow(10, precision)) / Math.pow(10, precision);
			formated = formated.toString();
			if(formated.indexOf('.') == -1){
				formated += '.00';
			}
			else{
				var parts = formated.split('.');
				if(parts[1].length == 1){
					formated += '0';	
				}
			}
		}
		field.value = formated;
	};
	
	this.val_date = function(field) {
		if(field.value == ''){
			return false;	
		}
		else if(field.value.match(/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/)) {
			//make sure date is valid
			var dateParts = field.value.split('/');
			var day = dateParts[1];
			var month = dateParts[0];
			var year = dateParts[2];
			var dteDate = new Date(year, month - 1, day);
			if(day == dteDate.getDate() && (month == dteDate.getMonth() + 1) && year == dteDate.getFullYear()){
				return false;
			}
			return 'is an invalid date.';
		} 
		else {
			return 'needs to be mm/dd/yyyy.';
		}
	};
	
	this.val_datetime = function(field) {
		if(field.value.match(/^[0-9]{2}\/[0-9]{2}\/[0-9]{4} [0-9]{2}:[0-9]{2}(:[0-9]{2})? (am|pm|AM|PM)$/) || field.value == '') {
			return false;
		} 
		else {
			return 'needs to be mm/dd/yyyy hh:mm:ss am/pm.';
		}
	};
	
	this.val_phone = function(field) {
		if(field.value == ''){
			return false;	
		}
		var numbers = field.value.replace(/[^0-9]/g, ''); //remove all non numerics
		if(numbers.length < 10){
			return 'needs to be 10 digits.';	
		}
		field.value = numbers.substr(0, 3) + '-' + numbers.substr(3, 3) + '-' + numbers.substr(6, 4);
		// handle extensions
		if(numbers.length > 10){
			field.value += ' x ' + numbers.substr(10);
		}
		return false;
	};
	
	this.val_ceil = function(field, multiple) {
		if(field.value == ''){
			return false;	
		}
		var factor = Math.floor(field.value / multiple);
		var remainder = field.value % multiple;
		if(remainder > 0){
			factor++;	
		}
		field.value = factor * multiple;
	};
}

//Event.observe(window, 'load', this.init);
