
/* emg.js.php */
/* 2:56 PM 7/15/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>*/

function emgInit(){
	externalLinks();
	autoCompleteOff();
	defaultClear();
			BrowserDetect.init();				EmgAjax.init($$('body').first());				loginTimer.init();				initValForm();				modal.init();				slideshow.init("slideshow", true, 5, "scroll", 1);				ImageHover.init();			ie6Check();
	
	//flash
	if($('flash-div')){
		showFlash(window.CR+'/flash/header.swf?CR='+window.CR+'&xmlPath='+window.CR+'/xml/slideshow.php?CR='+window.CR, 785, 152, 'logo');	
	}
	if($('emg-link')){
		$('emg-link').style.display = 'none';
	}
	
	if(window.siteInit){
		siteInit();
	}
}

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

// Show / Hide object
function toggle(obj) {
	var el = $(obj);
	el.style.display = (el.style.display != 'block' ? 'block' : 'none' );
	el.blur();
}
function toggle2(obj) {
	var el = $(obj);
	el.style.display = (el.style.display != 'block' ? 'block' : 'none' );
	el.blur();
}

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

// Reset form fields
function clearForm(id, skipids) {
	if(!skipids){
		skipids = new Array();
	}
	var form = document.getElementById(id);
	for (var i = 0; i < form.length; i++) {
		if(skipids.indexOf(form[i].id) != -1 || 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.getHeight();
	if(height < viewPortHeight){
		height = viewPortHeight;
	}
	return [ width, 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.getHeight();
	return [ width, height ];
}


function alert2(text, dim, alertTime, className){ 
	//check if alert 2 already exist
	var i=0;
	while($('alert2_'+i)){
		i++;
	}
	var alert2 = document.createElement('div');
	alert2.id = 'alert2_'+i;
	alert2.style.visibility = 'hidden';
	document.body.appendChild(alert2);
	
	alert2 = $('alert2_'+i);
	if (className === undefined) {
		alert2.addClassName('alert2');
	}
	else {
		alert2.addClassName(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.getWidth();
		height = alert2.getHeight();
	}
	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 visibleDim = getVisibleDim();
	//var windowWidth = visibleDim[0];
	//var windowHeight = visibleDim[1];
	document.viewport.getWidth()
	var windowWidth = document.viewport.getWidth();
	var windowHeight = document.viewport.getHeight();
	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*100)/100;
	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) {
	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(url.indexOf('?')==-1) {
		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"><a href="#" id="confirm2-yes">Yes</a></li><li class="no"><a href="#" id="confirm2-no">No</a></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').onclick= function(){ 
		//document.body.removeChild($('confirm2'));
		eval(yesEval);
		modal.close();
		return false;
	}
	$('confirm2-no').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 externalLinks(container) {
	if(container){
		var anchors = container.select('a[rel*="external"]');
	}
	else{
		var anchors = $$('a[rel*="external"]');
	}
	for (var i=0; i<anchors.length; i++) {
		anchors[i].target = "_blank";
	}
}

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

function defaultClear(){
	var inputs = $$('input.default-clear');
	for (var i=0; i<inputs.length; i++) {
		inputs[i].onfocus = function(){
			if(this.value == this.defaultValue){
				this.value = ''; 
			}
		}
		inputs[i].onblur = function(){
			if(this.value == ''){
				this.value = this.defaultValue;
			}
		}
	}
}

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+'/action/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 8">Download Internet Explorer 8</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 + "/action/verify-captcha?area=" + captchaFieldid + "&captcha=" + $(captchaFieldid).value + "&k=" + Math.round(100000*Math.random());
	var valFormIndex = getValFormIndex(captchaFieldid);
	valForms[valFormIndex].ajaxRunning[captchaFieldid] = true;
	new Ajax.Request(url, { method: 'get',  onSuccess: function(verifyCaptcha2) {
			if(verifyCaptcha2.responseText == '0'){
				var error = ' is incorrect.'; //error
			}
			else{
				 var error = false; // no errror
			}
			valForms[valFormIndex].errorHandler($(captchaFieldid), error);
			valForms[valFormIndex].ajaxRunning[captchaFieldid] = false;
		}
	});
}

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

function showFlash(src, w, h, container, parameters, variables){
	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>';
	}
}

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).value+'</textarea><br /><button onclick="$(\''+id+'\').value = $(\''+id+'-expanded\').value; modal.close();">Finish</button></div>';
	modal.load();
	modal.content(html);
}

//use to show all the properties of an object;
function objProperties(obj, objName){
	var output = '';
	for (var prop in obj ) {
		output += objName + "." + prop + " = " + obj[prop] + "\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) {
	if (isNaN(value)) {
		var formatted = '0.00';
	}
	else {
		var formatted = Math.round(value*100)/100;
		formatted = formatted.toString();
		if (formatted.indexOf('.') == -1) {
			formatted += '.00';
		}
		else {
			var parts = formatted.split('.');
			if (parts[1].length == 1) {
				formatted += '0';
			}
		}
	}
	if(!nosymbol){
		formatted = '$' + formatted;
	}
	return formatted;
}

function emailInUse(emailFieldid){
	emailAjaxCheck(emailFieldid, 'in use');
}

function emailNotExist(emailFieldid){
	emailAjaxCheck(emailFieldid, 'not exist');
}

function emailAjaxCheck(emailFieldid, useToggle){
	var url = window.CR + "/action/check-exist?check-field=login&check-value=" + $(emailFieldid).value + "&k=" + Math.round(100000*Math.random());
	var valFormIndex = getValFormIndex(emailFieldid);
	valForms[valFormIndex].ajaxRunning[emailFieldid] = true;
		new Ajax.Request(url, { method: 'get',  onSuccess: function(emailExist2) {
			
			if(useToggle == 'not exist'){  // for reset password form
				var error = emailExist2.responseText == '0' ? ' does not exist.' : false;
			}
			else{
				var error = emailExist2.responseText == '1' ? ' already in use.' : false;
			}
			
			valForms[valFormIndex].errorHandler($(emailFieldid), error);
			valForms[valFormIndex].ajaxRunning[emailFieldid] = false;
		}
	}); 
}
/* 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"
		}
	]

};
/* checkout.js.php */
/*<script>*/
//10:10 AM 7/27/2010
function checkoutInitForm(containerid){ //need this function because cant use '.' for call back function in class markup
	checkout.initForm(containerid);
}
var checkout = {
	status: 0,
	statuses: new Array('login', 'shipping', 'billing', 'confirmation'),
	
	init: function(status){
		//set css class for steps
		for(var i = 0; i < this.statuses.length; i++){
			$(this.statuses[i] + '-step').addClassName('visited');
			if(status == this.statuses[i]){
				$(this.statuses[i] + '-step').addClassName('current');
				break;	
			}
		}
	},
	
	open: function(status){ //alert(status);
		this.close(this.currentOpen());
		$(status + '-container-close').addClassName('hide');
		$(status + '-container-open').removeClassName('hide');
		$(status + '-step').addClassName('visited');
		$(status + '-step').addClassName('current');
		EmgAjax.refresh(status + '-container-open');
	},
	
	close: function(status){
		$(status + '-container-close').removeClassName('hide');
		$(status + '-container-open').addClassName('hide');
		$(status + '-step').removeClassName('current');
		EmgAjax.refresh(status + '-container-close');
	},
	
	currentOpen: function(){
		//close current open status
		for(var i = 0; i < this.statuses.length; i++){
			if(!$(this.statuses[i] + '-container-open').hasClassName('hide')){
				return this.statuses[i];
			}
		}
	},
	
	closeAll: function(except){
		for(var i = 0; i < this.statuses.length; i++){
			if(this.statuses[i] == except){
				continue;
			}
			this.close(this.statuses[i]);	
		}
	},
	
	//need to make form run our script (ajax) when submitting
	initForm: function(containerid){ //alert(containerid);
		var forms = $(containerid).select('form');
		if(forms.length > 0){
			//need to find the correct valform and set the onsubmit to run checkout.submit instead of submitting the form
			for(var i = 0; i < valForms.length; i++){ //alert(valForms[i].form.id + '==' + forms[0].id);
				if(valForms[i].form.id == forms[0].id){
					valForms[i].originalSubmit = function(){
						checkout.submit(this);
						return 'dont reset';
					};
					return;
				}
			}
			//if no valform
			forms[0].onsubmit = function(){
				checkout.submit(this);
				return false;
			};
		}
	},
	
	editCancel: function(){
		new Ajax.Request(window.CR + '/ajax/checkout/status', { method: 'get', onFailure: checkout.submitFailed, onSuccess: function(ajaxReturn) { //alert(ajaxReturn.responseText);
			if(ajaxReturn.responseText == 'died'){
				window.location = window.CR+'/action/died';
				return;
			}
			checkout.open(ajaxReturn.responseText);
		}}); 	
	
	},
	
	submit: function(form){
		var validate = this.validate();
		if(!validate){
			return false;	
		}
		form.request({onComplete: checkout.submitDone, onFailure: checkout.submitFailed}); 
	},
	
	validate: function(){
		switch(this.currentOpen()){
			case 'login':
				//validate
				if($('login').value == '' && $('email').value == ''){
					alert('Please sign in if you are an existing customer or enter your email address for guest checkout.');
					$('login').focus();
					valFormsResetSubmit();
					return false;
				}
			break;
		}
		return true;
	},
	

	submitDone: function(ajaxReturn){  //alert(ajaxReturn.responseText);
		if(ajaxReturn.responseText == 'died'){
			window.location = window.CR+'/action/died';
			return;
		}
		valFormsResetSubmit();
		switch(ajaxReturn.responseText){
				case 'Bad Login':
					alert('Your email address or the password was invalid.');
					$('login').focus();
					return;
				case 'You cannot use an administrator portal login.':
					alert('You cannot use an administrator portal login.');
					$('login').focus();
					return;
				case 'Bad Email':
					alert('The email address is already in use.');
					$('email').focus();
					return;
				case 'Bad Shipping Address':
					alert('The shipping address is invalid.');
					return;
				case 'billing':
					if(checkout.currentOpen() == 'login'){ //user logged in and status skipped to billing
						//show shipping/billing that was auto filled
						checkout.close('shipping');
					}
					break;
				case 'confirmation':
					if(checkout.currentOpen() == 'login'){ //user logged in and status skipped to confirmation
						//show shipping/billing that was auto filled
						checkout.close('shipping');
						checkout.close('billing');
					}
		}
		if(checkout.statuses.indexOf(ajaxReturn.responseText) == -1){
			alert('Connection failed, please wait while we reload the page.');
			location.reload(1);
		}
		checkoutCartUpdate();
		checkout.open(ajaxReturn.responseText);
	},
	
	submitFailed: function(){
		alert('Connection failed, please wait while we reload the page.');
		location.reload(1);
	},
	
	copyShipping: function(){
		new Ajax.Request(window.CR + '/action/checkout/copy-shipping', { method: 'get', onFailure: checkout.submitFailed, onSuccess: function(ajaxReturn) { //alert(ajaxReturn.responseText);
			if(ajaxReturn.responseText == 'died'){
				window.location = window.CR+'/action/died';
				return;
			}
			checkout.open('billing');
		}}); 	
	},
	
	submitOrder: function(){
		modal.load();
		modal.content('<div style="text-align:center">Please wait while we process your order. <br/ ><img src="'+window.CR+'/images/library/loading.gif" /></div>');
		new Ajax.Request(window.CR + '/action/checkout/submit', { method: 'get', onFailure: checkout.submitFailed, onComplete: function(ajaxReturn) {
			if(ajaxReturn.responseText == 'died'){
				window.location = window.CR+'/action/died';
				return;
			}
			modal.close();
			if(ajaxReturn.responseText == 'died'){
				window.location = window.CR+'/action/died';
				return;
			}
			switch(ajaxReturn.responseText){
				case 'Checkout Complete':
					window.location = window.CR + '/invoice-receipt';
				return;
				case 'Bad Credit Card':
					alert('We were unable to process your credit card, please verify your information.');
					checkout.open('billing');
				return;
				case 'Paypal':
					//alert('We have submitted your order; however, you still need to make payment via PayPal, please wait while we redirect you.  If any problems occur, please give us a call.');
					window.location = window.CR + '/redirect-to-paypal';
				return;
				case 'Google Checkout':
					//alert('We have submitted your order; however, you still need to make payment via Google Checkout, please wait while we redirect you.  If any problems occur, please give us a call.');
					window.location = window.CR + '/redirect-to-google';
				return;
				case 'Amazon Checkout':
				//	alert('We have submitted your order; however, you still need to make payment via Amazon Checkout, please wait while we redirect you.  If any problems occur, please give us a call.');
					window.location = window.CR + '/redirect-to-amazon';
				return;
				default:
					alert(ajaxReturn.responseText + ': Connection failed, please wait while we reload the page.');
					location.reload(1);
			}
		}});	
	},
	
	promo: function(){
		var promo = $('promo');
		if(promo.value.length == 0){
			alert('Please enter a promo code.');
			promo.focus();
			return;
		}
		new Ajax.Request(window.CR + '/action/checkout/promo?code='+promo.value, { method: 'get', onFailure: checkout.submitFailed, onSuccess: function(ajaxReturn) {
			if(ajaxReturn.responseText == 'died'){
				window.location = window.CR+'/action/died';
				return;
			}
			if(ajaxReturn.responseText == 'Good Promo'){
				EmgAjax.call('/checkout/totals/', 'ajax container totals-container');
				promo.value = '';
			}
			else{
				alert(ajaxReturn.responseText);	
			}
		}});
		return false;
	}
}
/* ecommerce.js.php */
/* 
3:56 PM 6/30/2010
*/ 
/*<script>*/
function updateCartCount(){
	var url = window.CR + '/ajax/cart-details';
	new Ajax.Request(url, { method: 'get',  onSuccess: function(updateCartCount2) {
			var containers = $$('.cart-item-count');
			for(var i = 0; i < containers.length; i++){
				containers[i].innerHTML = updateCartCount2.responseText;
			}
		}
	}); 	
}

function changeCountry(country, pre){
	if(country == 'US'){
		$(pre + 'province-container').addClassName('hide');
		$(pre + 'state-container').removeClassName('hide');
		$(pre + 'state').addClassName('val_req');
		$(pre + 'province').removeClassName('val_req');
		$(pre + 'province').value = '';
		$(pre + 'zip').addClassName('val_req');
	}
	else{
		$(pre + 'province').addClassName('val_req');
		$(pre + 'province-container').removeClassName('hide');
		$(pre + 'state-container').addClassName('hide');
		$(pre + 'state').removeClassName('val_req');
		$(pre + 'state').value = '';
		$(pre + 'zip').removeClassName('val_req');
	}
}

function valCC(){
	if($('cctype').value == ''){// no cc type, let cc type req validation take over
		return false;
	}
	var ccNumField = $('ccnumber');
	if(ccNumField.value.length == 0){ // no cc, let req validation take over
		return false;
	}
	if(checkCreditCard(ccNumField.value, $('cctype').value)){ //valid cc
		return false;
	}
	else{ // invalid cc
		return " is invalid.";
	}
	
}

function setBillingInfoReq(req){
	var reqFields = new Array('b-fname', 'b-lname', 'b-address1', 'b-city', 'b-country', 'b-zip', 'cctype', 'ccnumber', 'cccode', 'ccexp0', 'ccexp1');
	if($('country').value == 'US'){
		reqFields[reqFields.length] = 'b-state';
	}
	else{
		reqFields[reqFields.length] = 'b-province';
	}

	for(var  i=0; i < reqFields.length; i++){
		if(req){
			$(reqFields[i]).addClassName('val_req');
		}
		else{
			$(reqFields[i]).removeClassName('val_req');
		}
	}
	//changeCountry($('country').value); would set state/zip back to required, plust dont even think this is needed
}

function changePaymentMethod(){
	if($('payment-method-credit_card').checked){
		$('ccfields').removeClassName('hide'); //hide cc fields
		setBillingInfoReq(true);
	}
	else{
		$('ccfields').addClassName('hide'); //hide cc fields
		setBillingInfoReq(false);
	}
}

//function used to update price when an option is selected in items details
function optionChange(){
	var addToCartForm = $('add-to-cart-form');
	var oldAction = addToCartForm.action;
	addToCartForm.action = window.CR + '/ajax/price-quantity-check'; //need to reset form aciton so it has ajax in it
	var callBackSuccess =  function(ajaxReturn) { //alert(ajaxReturn.responseText);
			if(ajaxReturn.responseText == 'died'){ //in case something died in ajax
				window.location = window.CR+'/action/died';
				return;
			}
			var parts = ajaxReturn.responseText.split(' ');
			var price = parts[0];
			var inStock = parts[1];
			
			$('item-current-price').innerHTML = price;
			if(inStock == '0'){
				$('add-to-cart-fieldset').addClassName('out-of-stock');
			}
			else{
				$('add-to-cart-fieldset').removeClassName('out-of-stock');
			}
			addToCartForm.action = oldAction;
		};
	
	var callBackFailed = function(){
		addToCartForm.action = oldAction;
		alert2('Failed to update price, please try again.');
	};
	
	addToCartForm.request({onSuccess: callBackSuccess, onFailure: callBackFailed});
	
}


function processPayment(){
	setTimeout('window.location = \''+window.CR+'/action/process-payment\'', 5000);
	/*
	var url = window.CR+"/action/process-payment/?k="+ Math.round(100000*Math.random());	
	new Ajax.Request(url, { method: 'get',  onSuccess: function(processPayment2) {
			if(processPayment2.responseText == 'died'){
				window.location = window.CR+'/action/died'; return;
			}
			if(processPayment2.responseText == 'good'){
				window.location = window.CR+'/account/orders/';
			}
			else{
				alert(processPayment2.responseText);
				window.location = window.CR+'/account/shipping-billing-info/?r=checkout';
			}
		}
	});*/ 
}

//need to verify 

function starSelect(containerid, inputidPrefix, value){
	var startContainer = $(containerid);
	var starSelectidPrefix = 'selected-';
	//remove existing class that dictates the amount of stars
	var classNames = startContainer.className.split(' ');
	for(var i = 0; i<classNames.length; i++){
		if(classNames[i].include(starSelectidPrefix)){
			startContainer.removeClassName(classNames[i]);
		}
	}
	
	startContainer.addClassName(starSelectidPrefix+value);
	$(inputidPrefix+value).checked = true;
}

function swapMainItemImg(psml, pmed, pbig, position){
	var mainImg = $('image-main-img');
	var mainLink = $('image-main-link');
	var smlImg = $('item-img-'+position);
	var smlLink = $('item-img-link-'+position);
	var mainImgName = mainImg.src.replace(document.location.protocol+'//'+document.domain+pmed, '');
	var smlImgName = smlImg.src.replace(document.location.protocol+'//'+document.domain+psml, '');
	mainImg.src = pmed+smlImgName;
	mainLink.href = pbig+smlImgName;
	//smlImg.src = psml+mainImgName;
	//smlLink.href = pbig+mainImgName;
}

function checkoutCartUpdate(){
	updateCartCount();
	if($('empty-cart-checkout')){
		window.location	= window.CR + '/checkout';
	}
	else{
		EmgAjax.refresh('totals-container');
	}
}

function updateCheckoutPage(){
	EmgAjax.refresh('cart-container', 'checkoutCartUpdate()');
}
/* emg-ajax-v1.js.php */
/*
4:07 PM 7/27/2010
*/
/*
Copyright Â© 2010 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 EmgAjax = { 
 urls: new Array(), flags: new Array(), forms: new Object(), init: function(container){
 if(!container){ alert('EmgAjax.init(): container is null'); }
 var anchors = container.select('a[rel~="ajax"]');
for(var i = 0; i < anchors.length; i++){ anchors[i].href = 'javascript:EmgAjax.call(\'' + EmgAjax.normalizeUrl(anchors[i].href) + '\', \'' + anchors[i].readAttribute('rel') + '\')';
} 
 var forms = container.select('form[class~="ajax"]'); for(var i = 0; i < forms.length; i++){ forms[i].onsubmit = function(){
 EmgAjax.call(EmgAjax.normalizeUrl(this.action), this.readAttribute('class'), this); return false };
} 
 var containers = container.select('[class~="ajax-autofill"]'); for(var i = 0; i < containers.length; i++){
 if(containers[i].id.length == 0){ alert('ajax-container missing id'); } var url = EmgAjax.normalizeUrl(containers[i].select('a')[0].href);
if(url.indexOf('?') == -1){ url += '?'; } EmgAjax.call(url + '&ajax-container=' + containers[i].id, 'ajax container ' + containers[i].id + ' ' + containers[i].readAttribute('class'));
} }, 
 normalizeUrl: function (url){ url = url.replace('%27', '\\%27'); url = url.replace(document.location.protocol+'//'+document.domain, ''); 
 return url; }, 
 getFlags : function(flagstr){ var flags = { modal : false, samemodal: false, callback:false, modalCloseCallback: false, skipRewrite: false, container: false, containerid: false }; 
 var flagstrs = flagstr.split(' '); flags.modal = flagstrs.include('modal'); flags.samemodal = flagstrs.include('same');
flags.skipRewrite = flagstrs.include('skip-rewrite'); flags.container = flagstrs.indexOf('container');
if(flags.container != -1){ flags.containerid = flagstrs[flags.container + 1]; if($(flags.containerid)){ 
 flags.container = true; flags.modal = false; } else{ flags.container = false; flags.containerid = false;
} } else{ flags.container = false; flags.containerid = false; } flags.callback = flagstrs.indexOf('callback');
if(flags.callback != -1){ flags.callback = flagstrs[flags.callback + 1];
 if(flags.containerid){
 flags.callback += '(\'' + flags.containerid + '\')'; } else{ flags.callback += '()'; } } else{ flags.callback = false; 
 } flags.modalCloseCallback = flagstrs.indexOf('modal-close-callback'); if(flags.modalCloseCallback != -1){
 flags.modalCloseCallback = flagstrs[flags.modalCloseCallback + 1]; if(flags.containerid){ flags.modalCloseCallback += '(\'' + flags.containerid + '\')';
} else{ flags.modalCloseCallback += '()'; } } else{ flags.modalCloseCallback = false; } return flags;
}, refresh: function(refreshid, callback){ if(!this.urls[refreshid]){ alert('refreshid:' + refreshid + ' does not exist'); 
 return; } if(!callback){ var callback = false; } this.call(this.urls[refreshid], this.flags[refreshid], this.forms[refreshid], false, callback);
}, refreshModal: function(prev){ if(prev){ var thisIndex = modal.index - 2; } else{ var thisIndex = modal.index;
} var refreshid = 'modal-' + thisIndex; this.flags[refreshid] += ' same'; this.refresh(refreshid); 
 }, 
 call : function(url, flagstr, form, post, callback){ if(!form){ form = false; } if(!post){
 post = false; } var flags = this.getFlags(flagstr);
 if(flags.containerid){ var container = $(flags.containerid);
var containerHeight = container.getHeight();
 var loading = document.createElement('div');
 loading.style.textAlign = 'center';
loading.style.position = 'relative'; loading.style.top = '-' + (containerHeight / 2) + 'px'; loading.innerHTML = '<img src="'+window.CR+'/images/library/loading.gif" />';
container.appendChild(loading); var refreshid = flags.containerid; } else{ if(!flags.samemodal){ modal.load(); 
 } var refreshid = 'modal-' + modal.index; } 
 this.urls[refreshid] = url; this.flags[refreshid] = flagstr;
this.forms[refreshid] = form;
 if(!flags.skipRewrite){
 if(window.CR.length > 0){ var urlParts = url.split(window.CR);
url = urlParts[0]+ window.CR + '/ajax' + urlParts[1]; } else{ url = '/ajax' + url; } } var rand = Math.round(100000*Math.random()); 
 if(!url.include('?')){ url += '?'; } url += '&k='+rand; if(flags.containerid){ url += '&ajax-container=' + flags.containerid;
} else{ url += '&ajax-modal=true'; } 
 
 var callBackComplete = function(ajaxReturn) { if(ajaxReturn.responseText == 'died'){ 
 window.location = window.CR+'/action/died'; return; } if(flags.modal){ var classStr = modal.urlToClassStr(url);
modal.content(ajaxReturn.responseText, classStr, flags.samemodal, false, false, false, flags.modalCloseCallback);
var container = $('modal-contentLayer' + modal.index); } else{ var container = $(flags.containerid);
if(!container){ alert('EmgAjax.call(): error, `' + flags.containerid + '` container id dosnt exist'); 
 } container.innerHTML = ajaxReturn.responseText; container.setStyle({height : null}); } EmgAjax.init(container);
externalLinks(container); if(window.initValForm){ initValForm($(container)); } 
 if(callback){
 eval(callback); }
 if(flags.callback){ eval(flags.callback); } }; var callBackFailed = function(ajaxReturn){ 
 alert('callBackFailed() ' + url); }; if(form){ form.action = url; form.request({onComplete: callBackComplete, onFailure: callBackFailed}); 
 } else{ var method = post ? 'post' : 'get'; var postBody = post ? post : ''; new Ajax.Request(url, { method: method, postBody: postBody, onComplete: callBackComplete, onFailure: callBackFailed}); 
 } } }
/* functions.js.php */
/*<script>*/
function toggleUl(parentUlId, ulId, duration) {
	// Collapse other open subnavs
	var submenus = $$('ul#' + parentUlId + ' > li > div');
	submenus.each(function(ul) {
		if (ul.id != ulId && ul.style.display != 'none') {
			Effect.SlideUp(ul.id, { duration: duration/*, queue: 'end'*/ });
		}
	});
	
	// Expand / collapse this subnav
	var submenu = $(ulId);
	if (submenu.style.display == 'none') {
		Effect.SlideDown(ulId, { duration: duration/*, queue: 'end'*/ });
	}
	else {
		Effect.SlideUp(ulId, { duration: duration/*, queue: 'end'*/ });
	}
}

var filterShow = false;
function toggleFilters() {
	if (!filterShow) {
		$('browse-by-row-2').style.display = 'block';
		filterShow = true;
		$('view-all-filters-link').innerHTML = '&larr; View Less Filters';
	}
	else {
		$('browse-by-row-2').style.display = 'none';
		filterShow = false;
		$('view-all-filters-link').innerHTML = 'View All Filters &rarr;';
	}
}

function siteInit(){
	updateCartCount();	
}

/* image-hover.js.php */
/*
4:48 PM 8/18/2010
*/
/*
Copyright Â© 2010 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>*/
//need anchor to bigger image, set rel = image-hover
var ImageHover = {
	spacing: 4, //px between source and zoom
	staticImageDim: new Array(500, 500), //help with slow pre loading, set to false for auto
	init: function(){
		var anchors = document.body.select('a[rel~="image-hover"]');
		var images = new Array();
		for(var i = 0; i < anchors.length; i++){
			//preload image
			images[i] = new Image();
			images[i].src = anchors[i].href;
				
			anchors[i].onmouseover = function (){	
				var hoverContainer = document.createElement('div');
				hoverContainer.id = 'image-hover-container';
				
				//need to append then get element again for ie 7
				document.body.appendChild(hoverContainer);
				hoverContainer = $('image-hover-container');
				
				//append image to container
				var image = new Image();
				image.src = this.href;
				hoverContainer.appendChild(image);
				
				//static image dim
				if(ImageHover.staticImageDim[0]){
					image.width = ImageHover.staticImageDim[0];
					image.height = ImageHover.staticImageDim[1];
				}
				
				//position is off based on scroll, so need to adjust it accordingly
				var adjustments = new Array(0, 0);
				adjustments[0] = document.documentElement.scrollLeft;
        		adjustments[1] = document.documentElement.scrollTop;
				
				//set top offset relative to anchor, try to get hover image vertically centered in the viewport
				var topOffset =  (this.viewportOffset()[1] * -1) + adjustments[1]; //top of viewport
				var vcenterOffset = (document.viewport.getHeight() - image.height) / 2;
				topOffset += vcenterOffset;
				
				//clone position base on anchor with offset and adjustments
				//hoverContainer.clonePosition(this, {offsetLeft: this.getWidth() + ImageHover.spacing + adjustments[0], offsetTop: adjustments[1]});
				hoverContainer.clonePosition(this, {offsetLeft: this.getWidth() + ImageHover.spacing + adjustments[0], offsetTop: topOffset});
				
				//absolute to make it hover, w/h for the borders
				hoverContainer.setStyle({position: 'absolute', width: image.width + 'px', height: image.height + 'px'});
			}
			
			//disable anchor
			anchors[i].onclick = function (){
				return false;
			}
			
			anchors[i].onmouseout = function (){
				var container = $('image-hover-container');
				if(container){
					document.body.removeChild(container);
				}
			}
		}
	}
}
/* jqzoo.js.php */
/* lightbox.js.php */
/* login-timer.js.php */
/*3/29/2010 1:41*/
/*
Copyright Â© 2009 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 loginTimer = {
	init: function(){
		loginTimer.extendTimeout(0, false);
	},
	setExtendTimeout: function setExtendTimeout(){
		var url = ($('keep-logged-in').checked) ? window.CR + "/action/set-extend-timeout?extend=1&k=" + Math.round(100000*Math.random()) : window.CR + "/action/set-extend-timeout?extend=0&k=" + Math.round(100000*Math.random());
		
		new Ajax.Request(url, { method: 'get',  onSuccess: function(setExtendTimeout2) {
				location.reload(true);
			}
		}); 
	},
	extendTimeout: function (showAlert, extendOneTime){
		var loginInterval, promptInterval, timeRemaining, numIdleSeconds, numIdleMinutes, loginInterval;
		loginInterval 		= 0;
		promptInterval 		= timeRemaining = numIdleSeconds = numIdleMinutes = loginInterval;
					return false;
					if(showAlert) {
			var time 		= new Date();
			var curHour 	= (time.getHours() > 12) ? time.getHours() - 12 : time.getHours();
			var curTime 	= curHour + " : " + time.getMinutes() + " : " + time.getSeconds();
			var seconds 	= time.getSeconds();
			seconds 		+= timeRemaining;
			time.setSeconds(seconds);
			var logoutHour 	= (time.getHours() > 12) ? time.getHours() - 12 : time.getHours();
			//var idleStr 	= (numIdleMinutes < 1) ? numIdleSeconds + ' seconds' : numIdleMinutes + ' minutes';
			var idleStr 	= numIdleMinutes + ' minutes';
			//== SHOW CURTAIN
			timeRemaining 	= timeRemaining - 5; // 5 second padding
			
			var html 		= '<p>You have been idle for ' + idleStr + '.</p><p>You will be logged out in: <span id="time-remaining"></span></p><p><a href="javascript:loginTimer.extendTimeout(1, true);">Keep Me Logged In</a></p>';
							if(extendOneTime == true){
					
					curtain.close();
					var url = window.CR + "/ajax/extend-timeout?k=" + Math.round(100000*Math.random());
					new Ajax.Request(url, { method: 'get',  onSuccess: function(extendTimeout2) {
							setTimeout ("loginTimer.extendTimeout(1, false)", promptInterval);
						}
					});
				}
				else{
					
					var url = window.CR + "/ajax/check-last-active?k=" + Math.round(100000*Math.random());
					new Ajax.Request(url, { method: 'get',  onSuccess: function(extendTimeout2) {
							if(parseInt(extendTimeout2.responseText) < numIdleSeconds){
								setTimeout ("loginTimer.extendTimeout(1, false)", promptInterval);
							}
							else{
								curtain.load();
								curtain.content(html);
								window.focus();
								var minRemaining = (timeRemaining > 60) ? timeRemaining / 60 : 0;
								minRemaining	 = parseInt(minRemaining);
								var secRemaining = (timeRemaining > 60) ? timeRemaining % 60 : timeRemaining;
								loginTimer.countdown(secRemaining, minRemaining, promptInterval);
							}
						}
					});
				}
						} // end if
	},
	
	countdown:	function(seconds, minutes, promptTime){
		if(seconds == 0 && minutes == 0){
			window.location = window.CR + '/action/logout?k=' + Math.round(100000*Math.random());
		}
		else{
			if (seconds <= 0){
				seconds =  59;
				minutes -= 1;
			}
			if (minutes <= -1){
				seconds =  0;
				minutes += 1;
			}
			else{
				seconds -= 1;
			}
			
			secondsRemaining = seconds + (minutes * 60);
			
			if($('time-remaining') != null){
				var url = window.CR + "/ajax/check-last-active?k=" + Math.round(100000*Math.random());
				new Ajax.Request(url, { method: 'get',  onSuccess: function(countdown2) {
						if(parseInt(countdown2.responseText) <= 2){
							curtain.close();
							setTimeout ("loginTimer.extendTimeout(1, false)", promptTime);
						}
						else{
							$('time-remaining').innerHTML = minutes + ":" + seconds;
							setTimeout("loginTimer.countdown(" + seconds + ", " + minutes + ", " + promptTime + ")", 1000);
						}
					}
				});
			}
		}
	}
	
};
/* modal-v1.js.php */
 /*
12:22 PM 7/27/2010- updated handle javascript
*/
/*
Copyright © 2010 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 modal = { index: -1, expandLink: false, expandView: false, hideSelects: new Array(),
 closeCallBacks: new Array(), 
 init: function(){ modal.index = -1; var blinds = document.createElement('div');

		blinds.id = 'modal-blinds'; document.body.appendChild(blinds); }, urlToClassStr: function (url) {
		var cr = window.CR;
		
		var classStr = url;
		if (cr.length > 0) {
			classStr = classStr.split(cr)[1];
		}
		classStr = classStr.split('?')[0].replace('ajax/', '').replace('action/', '').replace(/\//g, ' ').strip();
		
		return classStr;
	}, 
	
	
	
	load: function(){ this.openBlinds(); var loadPop = document.createElement('div'); loadPop.id = 'modal-load';
document.body.appendChild(loadPop); loadPop = $('modal-load'); loadPop.addClassName('modal-load'); 
 topLeft = getTopLeft(loadPop.getWidth(), loadPop.getHeight()); loadPop.style.top = topLeft[0] + '%';
loadPop.style.left = topLeft[1] + '%'; loadPop.style.zIndex = this.index + 1; loadPop.innerHTML = '<img src="' + window.CR + '/images/library/loading.gif" />';
}, content: function(html, classStr, sameLayer, width, height, noPadding, closeCallBack){ if(closeCallBack){
 this.closeCallBacks[this.index] = closeCallBack; } if(sameLayer == true){ if(!$('modal-popUp' + this.index)){
 alert('modal error: samelayer is set, but theres no modal layer yet'); } document.body.removeChild($('modal-popUp' + this.index));
this.content(html, '', false, width, height, noPadding); return; } if($('modal-load')){ document.body.removeChild($('modal-load')); 
 } 
 var popUp = document.createElement('div'); var closeLayer = document.createElement('div'); 
 var contentLayer = document.createElement('div'); var bodyLayer = document.createElement('div'); 
 popUp.id = 'modal-popUp' + this.index; closeLayer.id = 'modal-closeLayer' + this.index; contentLayer.id = 'modal-contentLayer' + this.index;
bodyLayer.id = 'modal-bodyLayer' + this.index; 
 popUp.appendChild(closeLayer); popUp.appendChild(contentLayer);
contentLayer.appendChild(bodyLayer); document.body.appendChild(popUp); 
 popUp = $('modal-popUp' + this.index);
closeLayer = $('modal-closeLayer' + this.index); contentLayer = $('modal-contentLayer' + this.index);
bodyLayer = $('modal-bodyLayer' + this.index); popUp.style.visibility = 'hidden'; popUp.addClassName('modal-popUp' + (classStr ? ' ' + classStr : ''));
closeLayer.addClassName('modal-close'); bodyLayer.addClassName('modal-body'); if (noPadding) { contentLayer.addClassName('no-padding'); 
 } 
 if (this.expandLink) { closeLayerHtml = '<a href="javascript:modal.expand()" id="modal_expand' + this.index + '" class="expand" title="Expand / Contract"></a>';
closeLayerHtml += '<a href="javascript:modal.close()" class="close" title="Close"></a>'; } else { closeLayerHtml = '<a href="javascript:modal.close()" class="close" title="Close"></a>';
} closeLayer.innerHTML = closeLayerHtml; bodyLayer.innerHTML = html; 
 var scripts = html.match(/<script.*>([\s\S]*)<\/script>/gi);
if(scripts != null){ var headTag = document.getElementsByTagName("head")[0]; for(var i = 0; i < scripts.length; i++){
 var newScript = document.createElement("script"); newScript.type = 'text/javascript'; headTag.appendChild(newScript);
newScript.text = scripts[i].replace(/<script.*>/i, '').replace(/<\/script>/i, ''); } } contentLayer.addClassName('modal-content');
 if(this.expandView){ this.expand(); } else if(parseFloat(width) != width || parseFloat(height) != height){ 
 this.autoSize(); } else{ this.resizeContent(width, height); } popUp.style.zIndex = this.index + 1;
popUp.style.visibility = 'visible'; }, autoSize: function(){ 
 var popUp = $('modal-popUp' + this.index);
var contentLayer = $('modal-contentLayer' + this.index); var contentInner = contentLayer.firstDescendant();
var closeLayer = $('modal-closeLayer' + this.index); width = contentInner.getWidth(); height = contentInner.getHeight(); 
 maxW = document.viewport.getWidth(); maxH = document.viewport.getHeight(); if(height >= (maxH - 25)){
 height = maxH - 50; } if(width >= (maxW - 25)){ width = maxW - 25; } contentLayer.style.height = height + 'px';
height += closeLayer.getHeight(); width += 18; var topLeft = getTopLeft(width, height); popUp.style.width = width + 'px';
popUp.style.height = height + 'px'; popUp.style.top = topLeft[0] + '%'; popUp.style.left = topLeft[1] + '%';
}, resizeContent: function(width, height){ var popUp = $('modal-popUp' + this.index); var contentLayer = $('modal-contentLayer' + this.index);
var closeLayer = $('modal-closeLayer' + this.index); var topLeft = getTopLeft(width, height); popUp.style.width = width + 'px';
popUp.style.height = height + 'px'; popUp.style.top = topLeft[0] + '%'; popUp.style.left = topLeft[1] + '%';
contentLayer.style.height = (height - closeLayer.getHeight()) + 'px'; }, close: function(){
 if(this.closeCallBacks[this.index]){
 eval(this.closeCallBacks[this.index]); } document.body.removeChild($('modal-popUp' + this.index));
this.closeBlinds(); }, resize: function(){ var modal_blinds = $('modal-blinds'); var pageDim = getPageDim();
modal_blinds.style.width = pageDim[0] + 'px'; modal_blinds.style.height = pageDim[1] + 'px'; }, expand: function(){
 this.expandView = true; var width = document.viewport.getWidth() - 25; var height = document.viewport.getHeight() - 50;
this.resizeContent(width, height); $('modal-expand' + this.index).href = 'javascript:modal.shrink()';
 }, shrink: function(){ this.expandView = false; $('modal-expand' + this.index).href = 'javascript:modal.expand()';
this.autoSize(); }, openBlinds: function(){ if( getIEVerNum() == 6){ this.hideSelects(); } var modal_blinds = $('modal-blinds');
this.index +=2; modal_blinds.style.zIndex = this.index; modal_blinds.style.display='block'; var pageDim = getPageDim();
modal_blinds.style.width = pageDim[0] + 'px'; modal_blinds.style.height = pageDim[1] + 'px'; Event.observe(window, 'resize', this.resize); 
 }, closeBlinds: function(){ var modal_blinds = $('modal-blinds'); this.index -= 2; modal_blinds.style.zIndex = this.index;
if(this.index == -1){ modal_blinds.style.display='none'; Event.stopObserving(window, 'resize', this.resize); 
 } if( getIEVerNum() == 6){ this.showSelects(); } }, hideSelects: function(){ this.hideSelects[this.index] = new Array(); 
 if(this.index != -1){ var allSel = $('modal-popUp' + this.index).select('select'); } else{ var allSel = $$('select');
} for(var i=0; i < allSel.length; i++){ if(allSel[i].style.visibility != 'hidden'){ allSel[i].style.visibility = 'hidden';
this.hideSelects[this.index][i] = allSel[i]; } } }, showSelects: function(){ var selects = this.hideSelects[this.index];
for(var i=0; i < selects.length; i++){ selects[i].style.visibility = 'visible'; } } }; 
/* select.js.php */
//07/17/2009
/*<script>*/
function sel(url, sameLayer){
	
	if(!sameLayer){
		modal.load();	
	}
	
	new Ajax.Request(url, { method: 'get',  onSuccess: function(sel2) {
			if(sel2.responseText == 'died'){ //in case something died in ajax
				window.location = window.CLIENTROOT+'/action/died';
				return;
			}
			if(sameLayer == true){
				modal.content(sel2.responseText, true);
			}
			else{
				modal.content(sel2.responseText);
			}
			rewritePgl("sel('%url%', true)");
			//customTitle.init('modal_contentLayer'+modal.index);
		} 
	}); 	
}

function sel2(name, fieldid, formid2Submit){
	var field = $(fieldid);
	field.value = name;
	if(field.type.toLowerCase() !=  'hidden'){
		field.focus(); //fake as if a user entered the value
		field.blur();
	}
	//customTitle.hide();
	modal.close();
	if(formid2Submit){
		$(formid2Submit).submit();	
	}
}
/* slideshow.js.php */
/*<script>*/
// CUSTOM, DO NOT REPLACE

var slideshow = {
	
	interval: 4, // seconds
	
	slideshowid: 'slideshow', // slideshow container
	slidesClass: 'slides', // ul of slides within slideshow container
	navClass: 'nav', // ul of links within slideshow container
	slidesWidth: 0,
	slideWidth: 0,
	
	slidesList: false,
	navsList: false,
	
	transition: 'fade', // fade, scroll
	transitions: ['fade', 'scroll'],
	transitionInterval: 1, // seconds
	
	slidePrefix: 'slide-',
	linkPrefix: 'slide-link-',
	
	curclass: 'current',
	curPrevclass: 'current-previous', //allow fading out of current
	
	//private
	current: 1, //current slide #
	autoplayFlag: true,
	cnt: 0,
	loaded: false,
	
	init: function(slideshowid, autoplay, interval, transition, transitionInterval){
		this.slideshowid = slideshowid;
		if (!$(this.slideshowid)) {
			return;
		}
		this.autoplayFlag = autoplay;
		this.interval = interval;
		this.transition = transition;
		this.transitionInterval = transitionInterval;
		
		this.slidesList = $$('#' + this.slideshowid + ' ul.' + this.slidesClass)[0];
		this.navsList = $$('#' + this.slideshowid + ' ul.' + this.navClass)[0];
		
		this.cnt = this.slidesList.childElements().length;
		
		if (this.cnt < 1) {
			return;
		}
		
		this.slidesWidth = this.slidesList.getDimensions().width;
		this.slideWidth = this.slidesWidth / this.cnt;
		
		this.loaded = true;
		setTimeout('slideshow.autoplay()', this.interval * 1000);
	},
	
	autoplay: function(){
		if(!this.autoplayFlag){
			return;
		}
		var next = this.current + 1;
		if(next > (this.cnt - 1)){
			next = 1;
		}
		this.swap(next, true);
		setTimeout('slideshow.autoplay()', this.interval * 1000);
	},
	
	swap: function(number, autoplay){
		if(!this.loaded){
			return ;	
		}
		
		if(!autoplay){
			this.autoplayFlag = false;	
		}
        else{
        	this.autoplayFlag = true;	
        }
		
		// Clear classes
		this.slidesList.childElements().each(function(el) {
			el.removeClassName(this.curclass);
			el.removeClassName(this.curPrevclass);
		}, this);
		this.navsList.childElements().each(function(el) {
			el.removeClassName(this.curclass);
		}, this);
		
		// Set new current
		var targetSlide = $(this.slidePrefix + number);
		targetSlide.addClassName(this.curclass);
		
		// Fade
		if (this.transition == 'fade') {
			$(this.slidePrefix + this.current).addClassName(this.curPrevclass); //so we can fade out from it
			targetSlide.setStyle({ opacity:0 }); // for fade in
			targetSlide.fade({ duration: this.transitionInterval, from: 0, to: 1 }); //fade in
		}
		else if (this.transition = 'scroll') {
			var displacement = -(this.slideWidth) * (number - this.current);
			new Effect.MoveBy(this.slidesList, 0, displacement, 
				{
					duration: this.transitionInterval,  
					transition: Effect.Transitions.sinoidal,
					queue: 'end'
				});
		}
		
		var targetLink = $(this.linkPrefix + number)
		if(targetLink != null){
			targetLink.addClassName(this.curclass);
		}
		
		this.current = number;
	},
	
	next: function(){
		var next = this.current + 1;
		if(next > (this.cnt - 1)){
			next = 1;
		}
		this.swap(next, false);
	},
	
	prev: function(){
		var prev = this.current - 1;
		if(prev < 1){
			prev = this.cnt - 1;
		}
		this.swap(prev, false);
	}
}
/* val-cc.js.php */
/*<script>*/
//11:15 AM 7/21/2009
/*============================================================================*/

/*

This routine checks the credit card number. The following checks are made:

1. A number has been provided
2. The number is a right length for the card
3. The number has an appropriate prefix for the card
4. The number has a valid modulus 10 number check digit if required

If the validation fails an error is reported.

The structure of credit card formats was gleaned from a variety of sources on 
the web, although the best is probably on Wikepedia ("Credit card number"):

  http://en.wikipedia.org/wiki/Credit_card_number

Parameters:
            cardnumber           number on the card
            cardname             name of card as defined in the card list below

Author:     John Gardner
Date:       1st November 2003
Updated:    26th Feb. 2005      Additional cards added by request
Updated:    27th Nov. 2006      Additional cards added from Wikipedia

*/

/*
   If a credit card number is invalid, an error reason is loaded into the 
   global ccErrorNo variable. This can be be used to index into the global error  
   string array to report the reason to the user if required:
   
   e.g. if (!checkCreditCard (number, name) alert (ccErrors(ccErrorNo);
*/

var ccErrorNo = 0;
var ccErrors = new Array ()

ccErrors [0] = "Unknown card type";
ccErrors [1] = "No card number provided";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";

function checkCreditCard (cardnumber, cardname) {
     
  // Array to hold the permitted card characteristics
  var cards = new Array();

  // Define the cards we support. You may add addtional card types.
  
  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit
  
  cards [0] = {name: "Visa", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};
  cards [1] = {name: "MasterCard", 
               length: "16", 
               prefixes: "51,52,53,54,55",
               checkdigit: true};
  cards [2] = {name: "Diners Club", 
               length: "14,16", 
               prefixes: "300,301,302,303,304,305,36,38,55",
               checkdigit: true};
  cards [3] = {name: "Carte Blanche", 
               length: "14", 
               prefixes: "300,301,302,303,304,305,36,38",
               checkdigit: true};
  cards [4] = {name: "American Express", 
               length: "15", 
               prefixes: "34,37",
               checkdigit: true};
  cards [5] = {name: "Discover", 
               length: "16", 
               prefixes: "6011,650",
               checkdigit: true};
  cards [6] = {name: "JCB", 
               length: "15,16", 
               prefixes: "3,1800,2131",
               checkdigit: true};
  cards [7] = {name: "Enroute", 
               length: "15", 
               prefixes: "2014,2149",
               checkdigit: true};
  cards [8] = {name: "Solo", 
               length: "16,18,19", 
               prefixes: "6334, 6767",
               checkdigit: true};
  cards [9] = {name: "Switch", 
               length: "16,18,19", 
               prefixes: "4903,4905,4911,4936,564182,633110,6333,6759",
               checkdigit: true};
  cards [10] = {name: "Maestro", 
               length: "16", 
               prefixes: "5020,6",
               checkdigit: true};
  cards [11] = {name: "VisaElectron", 
               length: "16", 
               prefixes: "417500,4917,4913",
               checkdigit: true};
               
  // Establish card type
  var cardType = -1;
  for (var i=0; i<cards.length; i++) {

    // See if it is this card (ignoring the case of the string)
    if (cardname.toLowerCase () == cards[i].name.toLowerCase()) {
      cardType = i;
      break;
    }
  }
  
  // If card type not found, report an error
  if (cardType == -1) {
     ccErrorNo = 0;
     return false; 
  }
   
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
     return false; 
  }
    
  // Now remove any spaces from the credit card number
  cardnumber = cardnumber.replace (/\s/g, "");
  
  // Check that the number is numeric
  var cardNo = cardnumber
  var cardexp = /^[0-9]{13,19}$/;
  if (!cardexp.exec(cardNo))  {
     ccErrorNo = 2;
     return false; 
  }
       
  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
    var checksum = 0;                                  // running checksum total
    var mychar = "";                                   // next char to process
    var j = 1;                                         // takes value of 1 or 2
  
    // Process each digit one by one starting at the right
    var calc;
    for (i = cardNo.length - 1; i >= 0; i--) {
    
      // Extract the next digit and multiply by 1 or 2 on alternative digits.
      calc = Number(cardNo.charAt(i)) * j;
    
      // If the result is in two digits add 1 to the checksum total
      if (calc > 9) {
        checksum = checksum + 1;
        calc = calc - 10;
      }
    
      // Add the units element to the checksum total
      checksum = checksum + calc;
    
      // Switch the value of j
      if (j ==1) {j = 2} else {j = 1};
    } 
  
    // All done - if checksum is divisible by 10, it is a valid modulus 10.
    // If not, report an error.
    if (checksum % 10 != 0)  {
     ccErrorNo = 3;
     return false; 
    }
  }  

  // The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false; 
  var undefined; 

  // We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();
    
  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");
      
  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
    var exp = new RegExp ("^" + prefix[i]);
    if (exp.test (cardNo)) PrefixValid = true;
  }
      
  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
     ccErrorNo = 3;
     return false; 
  }
    
  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
    if (cardNo.length == lengths[j]) LengthValid = true;
  }
  
  // See if all is OK by seeing if the length was valid. We only check the 
  // length if all else was hunky dory.
  if (!LengthValid) {
     ccErrorNo = 4;
     return false; 
  };   
  
  // The credit card is in the required format.
  return true;
}

/*============================================================================*/
/* valform-v2.js.php */
/* 11:56 AM 5/27/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 valForms = new Array(); function initValForm(container){
 if(container){ var forms = container.select('form[class*="val-form"]');
} else{ var forms = $$('form[class*="val-form"]'); }; 
 for(var i = forms.length; i > 0; i--){
 
 var existFlag = false; for(var j = 0; j < valForms.length; j++){ if(valForms[j].form.id == forms[i-1].id){
 
 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){ 
 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() { 
 this.errorTag = 'div';
this.errorClass = 'val_error';
 
 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');
 
 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');
this.failed = true; this.form = null; this.formObsFunc = null; this.submitBtn = null; this.submitBtnDefaultVal = null; 
 this.ajaxRunning = new Object(); this.alertErrorsFlag = false; this.hideErrorsFlag = false; this.errors = new Object();
this.errorFocusedFlag = false; this.inputs = new Array(); this.inputObsFuncs = new Array(); this.originalSubmit = null; 
 this.init = function(form, flagstr){ if(!form){ alert('Valform.init(), form object dosnt exist');
return false; } this.form = form; if(flagstr){ if(flagstr.include('ae')){ this.alertErrorsFlag = true;
} if(flagstr.include('he')){ this.hideErrorsFlag = true; } } 
 var submitBtns = this.form.select('input[type="submit"]');
if(submitBtns.length == 0){ alert('valForm init error: no submit button'); } else{ this.submitBtn = submitBtns[0];
this.submitBtnDefaultVal = this.submitBtn.defaultValue; this.resetSubmit(); } 
 var validNodes = new Array('INPUT', 'TEXTAREA', 'SELECT');
for(var i = 0; i < this.form.elements.length; i++){ if(this.form.elements[i].disabled || validNodes.indexOf(this.form.elements[i].nodeName) == -1){ 
 continue; } this.inputs[this.inputs.length] = this.form.elements[i]; } 
 var focusThisFlag = false;
for(var i=0; i < this.inputs.length; i++){ var inputType = this.inputs[i].type.toLowerCase();
 if(!focusThisFlag && this.inputs[i].name && inputType != 'hidden'){
 focusThisFlag = true; if( inputType != 'radio' && inputType != 'checkbox'){ this.inputs[i].focus();
} } 
 this.inputObsFuncs[i] = this.fieldCheck.bindAsEventListener(this.inputs[i], this); Event.observe(this.inputs[i], 'blur', this.inputObsFuncs[i]); 
 if($w(this.inputs[i].className).indexOf('val_ajax') != -1 ){ this.ajaxRunning[this.inputs[i].id] = false;
} } 
 this.originalSubmit = this.form.onsubmit; this.form.onsubmit = null; this.formObsFunc = this.submitCheck.bindAsEventListener(this.form, this); 
 Event.observe(this.form, 'submit', this.formObsFunc); }; this.reset = function(){
 this.failed = true;
this.ajaxRunning = new Object(); if(this.inputs){ for(var i=0; i<this.inputs.length; i++){ Event.stopObserving(this.inputs[i], 'blur', this.inputObsFuncs[i]); 
 } } this.inputs = new Array(); this.inputObsFuncs = new Array(); if(this.formObsFunc){ Event.stopObserving(this.form, 'submit', this.formObsFunc); 
 } }; this.submitCheck = function(event){ var Va956af09 = $A(arguments); var parent = Va956af09[1]; 
 parent.errorFocusedFlag = false; parent.submitBtn.disabled = true; parent.submitBtn.value = 'Please wait...';
parent.errors = new Object(); 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){ 
 parent.inputs[i].focus(); parent.errorFocusedFlag = true; } } parent.submitAjaxChk();
 Event.stop(event); 
 return false; }; this.submitAjaxChk = function(){ var Vc5417c1e = false; for(var fieldID in this.ajaxRunning){
 if(this.ajaxRunning[fieldID]){ Vc5417c1e = true; } else{ if(this.errors[fieldID] && !this.errorFocusedFlag){ 
 $(fieldID).focus(); this.errorFocusedFlag = true; } } } if(Vc5417c1e){ var valFormIndex = getValFormIndex(this.form.id);
setTimeout('valForms[' + valFormIndex + '].submitAjaxChk()', 100); } else if(!this.failed){ var tosubmit = true; 
 if(this.originalSubmit){ tosubmit = this.originalSubmit.call(this.form); } if(tosubmit == 'dont reset'){ 
 } else if(tosubmit){ this.form.submit(); } else{ this.resetSubmit(); } } else{ if(this.alertErrorsFlag){
 var Vcefb778c = ''; for(var fieldID in this.errors){ Vcefb778c += this.errors[fieldID] + "\n"; } alert(Vcefb778c);
} this.resetSubmit(); } }; this.resetSubmit = function(){ this.submitBtn.disabled = false; this.submitBtn.value = this.submitBtnDefaultVal;
}; this.fieldCheck= function(event){ var Va956af09 = $A(arguments); var parent = Va956af09[1]; 
 var classes = $w(this.className);
 var index = classes.indexOf('val_combo'); if(index != -1){ 
 if(index+1 == classes.length){ alert('val_combo id required'); return; } var comboID = classes[index + 1];
if($(parent.comboID + '_error')){ $(parent.comboID + '_error').remove(); } if(parent.errors[comboID]){ 
 parent.errors[comboID] = false; } var comboFields = parent.form.select('.' + comboID); 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){ var classes = $w(field.className); var index = classes.indexOf('val_combo');
if(index != -1){ if(index + 1 == classes.length){ alert('val_combo id required'); return; } var comboID = classes[index + 1];
if($(this.comboID + '_error')){ $(this.comboID + '_error').remove(); } if(this.errors[comboID]){ 
 this.errors[comboID] = false; } var comboFields = this.form.select('.' + comboID); 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){ if(field.value && field.type.toLowerCase() != 'file'){ 
 field.value = field.value.strip(); } var classes = $w(field.className); 
 var V0fb06b86 = classes.indexOf('val_skipifis');
if(V0fb06b86 != -1 && V0fb06b86 != (classes.length - 1)){ var ifisInput = $(classes[V0fb06b86 + 1]);
if( ifisInput.value != '' && field.value == ifisInput.value){ if(classes.indexOf('val_ajax') !=-1 ){ 
 this.ajaxRunning[field.id] = false; } this.errorHandler(field, false); return; } } for(var i=0; i<classes.length; i++){
 if(this.classList.indexOf(classes[i]) == -1){ continue; } if(this.dependents.indexOf(classes[i]) == -1){ 
 var run = 'var error = this.'+classes[i]+'(field);'; } else{ if(i+1 == classes.length){ alert('valForm dependent required');
return false; } var run = 'var error = this.'+classes[i]+'(field, "'+classes[i+1]+'");'; } eval(run); 
 if(classes[i] == 'val_ajax'){ continue; } var V3cf7317e = field; if(comboID){ V3cf7317e = $(comboID);
} if(this.errorHandler(V3cf7317e, error)){ break; } } }; this.errorHandler= function(field, error){ 
 if(field.name.indexOf('[') != -1 ){ var V943db850 = this.form.select('[name="'+field.name+'"]')[0].id;
} else{ var V943db850 = field.id; } var label = this.form.select('label[for=' + V943db850 + ']'); if($(field.id+'_error')){
 $(field.id+'_error').remove(); label[0].removeClassName('val-error'); } if(!error){ return false; 
 } this.failed = true; 
 if(this.ajaxRunning[field.id]){ this.ajaxRunning[field.id] = false; } if(!label[0]){
 alert(field.id+' label is missing, check label id'); return; }
 var errorMsg = label[0].innerHTML;
var Va8039183 = label[0].innerHTML.indexOf(':'); if(Va8039183 == -1){ var htmlOpenPos = label[0].innerHTML.indexOf('<');
if(htmlOpenPos != -1){ var errorMsg = label[0].innerHTML.substring(0, htmlOpenPos-1); } } else{ var errorMsg = label[0].innerHTML.substring(0, Va8039183);
}
 errorMsg = errorMsg.gsub(/^\s+|\s+$|:|<em>\*<\/em>/i, '') + ' ' + error; errorMsg = errorMsg.stripTags();
 if(!this.hideErrorsFlag){
 var classNames = $w(field.className); var findKeyword = classNames.indexOf('val_errorAfter');
if( findKeyword != -1){ if(findKeyword == (classNames.length - 1)){ alert('val_form: val_errorAfter is missing an id');
} else{ new Insertion.After($(classNames[findKeyword+1]), '<'+this.errorTag+' id="'+field.id+'_error" class="'+this.errorClass+'">'+errorMsg+'</'+this.errorTag+'>');
label[0].addClassName('val-error'); } } else{ new Insertion.After(field, '<'+this.errorTag+' id="'+field.id+'_error" class="'+this.errorClass+'">'+errorMsg+'</'+this.errorTag+'>');
label[0].addClassName('val-error'); } } this.errors[field.id] = errorMsg; return true; }; 
 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) { var fieldType = field.type.toLowerCase();
if(fieldType == 'checkbox' || fieldType == 'radio'){ var values = this.form.select('[name="'+field.name+'"]');
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))){ 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); if(!field2Obj){ alert('val_same: '+field2+' is not defined'); return true;
} if(field.value != field2Obj.value && field2Obj.value != ''){ var label = this.form.select('label[for=' + field2Obj.id + ']');
return 'does not match '+label[0].innerHTML.gsub(/:|<em>\*<\/em>|<EM>\*<\/EM>/, '')+'.'; } return false;
}; this.val_notSame = function(field, field2){ if(!$(field2)){ alert('val_notSame: '+field2+' is not defined');
return 'error'; } if(field.value.length == 0){ return false; } var checkFields = $(field2).value.split(' ');
for(var i=0; i<checkFields.length; i++){ if(checkFields[i] == field.id){ continue; } if(!$(checkFields[i])){
 alert('val_notSame: '+checkFields[i]+' is not defined'); return 'error'; } if(field.value == $(checkFields[i]).value){
 return ' has already been entered.'; } } 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 = this.form.select('[name="'+field.name+'"]'); 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 = this.form.select('[name="'+field.name+'"]');
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 = this.form.select('[name="'+field.name+'"]');
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_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*100)/100;
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}$/)) {
 
 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, ''); if(numbers.length < 10){
 return 'needs to be 10 digits.'; } field.value = numbers.substr(0, 3) + '-' + numbers.substr(3, 3) + '-' + numbers.substr(6, 4);
 
 if(numbers.length > 10){ field.value += ' x ' + numbers.substr(10); } return false; }; } 