function hRow(id)
{
	elm = document.getElementById(id);
	if(elm.style.border != '#555555 1px solid')
	{
		elm.style.border = '#555555 1px solid';
		elm.style.color = 'blue';
		elm.style.background = '#CAB700';
	}
	else
	{
		elm.style.border = '#3bbbd1 1px solid';
		elm.style.color = 'black';
		elm.style.background = '';
	}
}

function minMax(id)
{
	elm = document.getElementById(id);
	img = document.getElementById(id+'_img');
	
	if(elm.style.display == '')
	{
		elm.style.display = 'none';
		img.src = 'graphics/default/navbar/nav_max.gif';
	}
	else
	{
		elm.style.display = '';
		img.src = 'graphics/default/navbar/nav_min.gif';
	}
}

// ---------------------------------------------------------
// Email Encoder
// ---------------------------------------------------------

var key = "BAD4@.56CEGFHIJKLVWdfTUhijXYZbacemngMNOPQRSopqrstuvz018923klwxy7";
var base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@.0123456789";

function DecodeLink(encoded)
{
	document.write("<a hr"+"ef=\"ma"+"ilto"+":"+decode(encoded)+"\">"
	+decode(encoded)+"</"+"a>");
}

function encode(str)
{
	return codec(key, base, str);
}

function decode(str)
{
	return codec(base, key, str);
}

function codec(from, to, str)
{
	var codedResult = "";
	
	for (i = 0; i < str.length; i++)
	{
		current = str.charAt(i);
		idx = from.indexOf(current);
		nextVal = (idx == -1) ? current : to.charAt(idx);
		codedResult += nextVal;
	}
	
	return codedResult;
}

// ---------------------------------------------------------
// Calendar
//----------------------------------------------------------

function jsCalendar(formId) 
{
	this.init(formId);
}

jsCalendar.prototype.init = function(formId)
{
	// Form Object Identifiers
	this.formId				= formId;
	this.triggerId			= 't_'+formId;
	this.displayId			= 'd_'+formId;
	this.objectId			= 'o_'+formId;
	
	// Calendar Settings
	this.currentDate 		= new Date();
	this.selectedDate		= new Date();
	this.startDay 			= 0; //Sun=0, Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6
	this.monthBrowse		= 'on';
	this.yearBrowse			= 'on';
	
	// Grpahic Settings
	this.nextMonthG			= '<img src="/graphics/calendar/next.gif">';
	this.prevMonthG			= '<img src="/graphics/calendar/prev.gif">';
	this.nextYearG			= '<img src="/graphics/calendar/next_year.gif">';
	this.prevYearG			= '<img src="/graphics/calendar/prev_year.gif">';
	
	// Table Settings
	this.tableWidth			= '200px';
	this.tableBorder1		= '1px solid #4682B4';
	this.tableBorder2		= '2px solid #4682B4';
	this.tableFont			= '';
	
	this.headerBorder		= '';
	this.headerHeight		= '23px';
	this.headerBG			= '#4682B4';
	this.headerFontColor	= 'white';
	this.headerFontSize		= '10pt';
	this.headerFontWeight	= 'bold';
	this.headerFontFamily	= 'Verdana';
	
	this.dayBorder			= '1px solid #4682B4';
	this.dayHeight			= '';
	this.dayWidth			= '14.28%';
	this.dayBG				= '#87CEFA';
	this.dayFontColor		= 'white';
	this.dayFontSize		= '8pt';
	this.dayFontWeight		= 'bold';
	this.dayFontFamily		= 'Verdana';
	
	this.selectedColor		= '#FF9696';
	this.weekendColor		= '#A596FF';
	this.nonmonthColor		= '#E1E1E1';
	this.defaultColor		= 'white';
	
	// Calendar Data
	this.lShDays			= new Array('Su','Mo','Tu','We','Th','Fr','Sa');
	this.lLhDays			= new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
	this.lShMonths			= new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
	this.lLhMonths			= new Array('January','Febuary','March','April','May','June','July','August','September','October','November','December');
	this.daysPerMonth		= new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	// Regular Expressions
	this.slash 				= new RegExp('/');
	this.dash 				= new RegExp('-');
	this.dateCheck			= /^(\d\d?)[\/-](\d\d?)[\/-](\d{2,4})$/;
}

jsCalendar.prototype.triggerTable = function()
{
	if(document.getElementById(this.formId).value != '')
		this.initializeValue(document.getElementById(this.formId).value);
	
	if(document.getElementById(this.displayId).innerHTML != '')
		this.closeTable();
	else
		this.buildTable();
}

jsCalendar.prototype.checkValue = function(initValue)
{
	if(initValue!='' && !initValue.match(this.dateCheck))
	{
		document.getElementById(this.formId).value = '';
		
		alert('The date format you entered is invalid'+"\r\n"+'Please use the MM/DD/YYYY format');
	}
	else
		document.getElementById(this.formId).value = initValue.replace(/-/g,'/');
		
}

jsCalendar.prototype.initializeValue = function(initValue)
{
	if(initValue.match(this.slash))
		initValueArray = initValue.split('/');
	else if(initValue.match(this.dash))
		initValueArray = initValue.split('-');
	
	if(typeof(initValueArray[1])!='undefined')
	{
		this.selectedDate.setDate(initValueArray[1]);
		this.currentDate.setDate(initValueArray[1]);
	}
	if(typeof(initValueArray[0])!='undefined')
	{
		this.selectedDate.setMonth(initValueArray[0]-1);
		this.currentDate.setMonth(initValueArray[0]-1);
	}
	if(typeof(initValueArray[2])!='undefined')
	{
		this.selectedDate.setYear(initValueArray[2]);
		this.currentDate.setYear(initValueArray[2]);
	}
}

jsCalendar.prototype.buildTable = function()
{
	displayCal = '<table cellspacing=0 cellpadding=0 style="border-left:'+this.tableBorder2+';border-top:'+this.tableBorder2+';border-right:'+this.tableBorder1+';border-bottom:'+this.tableBorder1+'; width:'+this.tableWidth+'">'
					+ this.generateTitle()
					+ this.generateDaysOfWeek()
					+ this.generateDaysOfMonth()
				+'</table>';
	
	document.getElementById(this.displayId).innerHTML = displayCal;
}

jsCalendar.prototype.generateTitle = function()
{
	// Values
	tDay	= this.currentDate.getDate();
	tMonth	= this.currentDate.getMonth();
	tYear	= this.currentDate.getFullYear();
	
	// Init
	var leftData = '';
	var rightData = '';
	var displayedDate = '';
	var outputData = '';
	
	// toggle month Browse
	if(this.monthBrowse == 'on')
	{
		leftData = '<span onClick="'+this.objectId+'.prevMonth()" style="cursor:hand;">'+this.prevMonthG+'</span>&nbsp;';
		rightData = '&nbsp;<span onClick="'+this.objectId+'.nextMonth()" style="cursor:hand;">'+this.nextMonthG+'</span>';
	}	
	
	// toggle month Browse
	if(this.yearBrowse == 'on')
	{
		leftData = '<span onClick="'+this.objectId+'.prevYear()" style="cursor:hand;">'+this.prevYearG+'</span>&nbsp;&nbsp;'+leftData;
		rightData = rightData+'&nbsp;&nbsp;<span onClick="'+this.objectId+'.nextYear()" style="cursor:hand;">'+this.nextYearG+'</span>';
	}	
		
	// Displayed Date
	displayedDate = this.lShMonths[tMonth]+' '+tDay+', '+tYear;
	
	outputData = '<tr>'
					+'<td colspan=7 valign="middle">'
						+'<table cellspacing=0 cellpadding=0 width=100% style="background:'+this.headerBG+'; border:'+this.headerBorder+'; height:'+this.headerHeight+'; font-weight:'+this.headerFontWeight+'; color:'+this.headerFontColor+'; font-size:'+this.headerFontSize+'; font-family:'+this.headerFontFamily+';">'
							+'<tr align=center valign="middle">'
								+'<td>'+leftData+'</td>'
								+'<td>'+displayedDate+'</td>'
								+'<td>'+rightData+'</td>'
							+'</tr>'
						+'</table>'
					+'</td>'
				+'</tr>';
	
	return outputData;
}

jsCalendar.prototype.generateDaysOfWeek = function()
{
	for(i=0,j=this.startDay,outputData=''; i<7; i++)
	{
		if(j>6)
			j=0;
		
		outputData = outputData+'<td width="'+this.dayWidth+'" style="border-right:'+this.dayBorder+'; border-bottom:'+this.dayBorder+';">'+this.lShDays[j]+'</td>';
		
		j++;
	}
	
	outputData = '<tr align="center" style="background:'+this.dayBG+'; height:'+this.dayHeight+'; font-weight:'+this.dayFontWeight+'; color:'+this.dayFontColor+'; font-size:'+this.dayFontSize+'; font-family:'+this.dayFontFamily+';">'+outputData+'</tr>';
	
	return outputData;

}

jsCalendar.prototype.generateDaysOfMonth = function()
{
	var isLeapMonth = new Date();
		isLeapMonth.setMonth(this.currentDate.getMonth());
		isLeapMonth.setYear(this.currentDate.getFullYear());
		isLeapMonth.setDate(29);
	
	var newDate = new Date();
		newDate.setMonth(this.currentDate.getMonth());
		newDate.setYear(this.currentDate.getFullYear());
		newDate.setDate(1);
	
	monthStarts = newDate.getDay();
	
	if(newDate.getMonth()==1 && isLeapMonth.getDate()!=1)
		monthEnds = 29;
	else
		monthEnds = this.daysPerMonth[newDate.getMonth()];
	
	for(i=0,counter=0,outputData=''; i<monthEnds;)
	{
		for(j=0,k=this.startDay,outputLine=''; j<7; j++)
		{	
			if(k>6)
				k=0;
			
			if(k==0||k==6)
				bgColor=this.weekendColor;
			else
				bgColor=this.defaultColor;
			
			if(counter==0)
			{
				if(monthStarts==k)
				{
					counter=1;
					dateVal=i+1;
				}
				else
					dateVal='';
			}
			else
			{
				if(i>=monthEnds)
					dateVal='';
				else
					dateVal=i+1;
			}
			
			if(this.selectedDate.getDate() == dateVal && this.selectedDate.getMonth() == this.currentDate.getMonth())
				bgColor=this.selectedColor;
			
			if(dateVal!='')
				outputLine = outputLine+'<td style="border-right:'+this.dayBorder+'; border-bottom:'+this.dayBorder+'; background:'+bgColor+';"><span onClick="'+this.objectId+'.setVal('+dateVal+')" style="cursor:hand;">'+dateVal+'</span></td>';
			else
				outputLine = outputLine+'<td style="border-right:'+this.dayBorder+'; border-bottom:'+this.dayBorder+'; background:'+this.nonmonthColor+';">&nbsp;</td>';
			
			if(counter==1)
				i++;
			
			k++;
		}
		
		outputData = outputData+'<tr align="center">'+outputLine+'</tr>';
	}
		
	return outputData;
}

jsCalendar.prototype.hideTable = function()
{
	document.getElementById(this.displayId).innerHTML = '';
}

jsCalendar.prototype.nextMonth = function()
{
	this.currentDate.setDate(1);
	this.currentDate.setMonth(this.currentDate.getMonth()+1);
	
	this.buildTable();
}

jsCalendar.prototype.prevMonth = function()
{
	this.currentDate.setDate(1);
	this.currentDate.setMonth(this.currentDate.getMonth()-1);
	
	this.buildTable();
}

jsCalendar.prototype.nextYear = function()
{
	this.currentDate.setDate(1);
	this.currentDate.setYear(this.currentDate.getFullYear()+1);
	
	this.buildTable();
}

jsCalendar.prototype.prevYear = function()
{
	this.currentDate.setDate(1);
	this.currentDate.setYear(this.currentDate.getFullYear()-1);
	
	this.buildTable();
}

jsCalendar.prototype.closeTable = function()
{
	document.getElementById(this.displayId).innerHTML = '';
}

jsCalendar.prototype.setVal = function(dateVal)
{
	monthVal = this.currentDate.getMonth();
	yearVal = this.currentDate.getFullYear();
	
	document.getElementById(this.formId).value = (monthVal+1)+'/'+dateVal+'/'+yearVal;
	this.closeTable();
}




//Terms and Conditions
function termsnconditions(f) {
  if (f.verify.checked == false) {
    alert('You must agree to the Terms and Conditions before you can create a new account.');
    return false;
  } else
    return true;
}



//JA: enable/disable fields for trial signups
function trial_account_country_usa()
{
	document.signup.state.disabled=false;
	document.signup.state_other.disabled=true;
	document.signup.state_other.value='';
}

function trial_account_country_other()
{
	document.signup.state.disabled=true;
	document.signup.state_other.disabled=false;
	document.signup.state.value='';

}