// Helper Functions
// Moves Sliders according to their ID and grabs buttons according to their title
function move(id, idmove, move, currentPage, totalPages, pageSize)
{
	var moveNext = $(id).select('[title="moveToNext"]');
	for(var i = 0; i < moveNext.length; i++) 
	{
			moveNext[i].observe('click',function() 
			{
				if(currentPage < totalPages-pageSize)
				{
					new Effect.Move(idmove, { x: -move, y: 0, duration: 0.4, transition: Effect.Transitions.sinoidal, queue: 'end' });
					currentPage++;
				}
			});
	}
	var movePrev = $(id).select('[title="moveToPrev"]');
	for(var i = 0; i < movePrev.length; i++) 
	{
			movePrev[i].observe('click',function() 
			{
				if(currentPage > 0)
				{
					new Effect.Move(idmove, { x: move, y: 0, duration: 0.4, transition: Effect.Transitions.sinoidal, queue: 'end' });
					currentPage--;
				}
			});
	}
}
// Formats type to have a gradiant and softer edge
function typeRenderer(tagName)
{
	var renderTag = document.getElementsByTagName(tagName);
	
	for(var i = 0; i < renderTag.length; i++) {
		var innerTagHtml = renderTag[i].innerHTML;
		renderTag[i].innerHTML = '<span class="overlaptext">'+innerTagHtml+'</span><span class="overlap"></span>'+innerTagHtml;
	}
}
// Clears Form Inner Values onClick and redeclares them if left empty for both <textarea> && <input> 
// Also sets the class to "inputFocus" on rollover and form completion
function clearText()
{
	var inp = document.getElementsByTagName('input');
	for(var i = 0; i < inp.length; i++) {
		if(inp[i].type == 'text') {
			inp[i].setAttribute('rel',inp[i].defaultValue)
			inp[i].onfocus = function() {
				
				if(this.value == this.getAttribute('rel')) {
					this.value = '';
					this.setAttribute('class', 'inputFocus')
				} else {
					return false;
				}
			}
			inp[i].onblur = function() {
				if(this.value == '') {
					this.setAttribute('class', '')
					this.value = this.getAttribute('rel');
				} else {
					return false;
				}
			}
			inp[i].ondblclick = function() {
				this.value = this.getAttribute('rel')
				this.setAttribute('class', '')
			}
		}
	}
	
	var txt = document.getElementsByTagName('textarea');
	for(var i = 0; i < txt.length; i++) {
		txt[i].onfocus = function() {
			if(this.value == '') {
				this.setAttribute('class','inputFocus');
			} else {
				this.setAttribute('class','');
			}
		}
		txt[i].onkeypress = function() { 
			this.setAttribute('class','inputFocus'); 
		}
		txt[i].onblur = function() {
			if(this.value != '') {
				this.setAttribute('class','inputFocus');
			} else {
				this.setAttribute('class','');
			}
		}
	}		
}

// Toggles Text Less and More, Changes Class between "a keyup" and "a keydown"
function toggle(ToggleButtonID, SelectionID)
{
	$(ToggleButtonID).observe('click',function() {
		if (!$(SelectionID).visible()) {
			new Effect.BlindDown($(SelectionID),{ duration: 0.0 });
			document.getElementById(ToggleButtonID).innerHTML = 'Close';
			document.getElementById(ToggleButtonID).setAttribute("class", "a keyup");
		} else {
			new Effect.BlindUp($(SelectionID),{ duration: 0.0 });
			document.getElementById(ToggleButtonID).innerHTML = 'Learn More';
			document.getElementById(ToggleButtonID).setAttribute("class", "a keyright");
		}
	});
}