/*###############################*/
/*       HTML NODE CREATION      */
/*###############################*/

// DIV AND SPAN
function makeDiv( theClass , theID , theAction , theAppendee ) {
	var tmpRef = document.createElement( 'div' );
	if ( theClass ) tmpRef.setAttribute( 'className' , theClass );
	if ( theAction ) tmpRef.onclick = function () { eval( theAction ); };
	if ( theID ) tmpRef.setAttribute( 'id' , theID );
	if ( theAppendee) tmpRef.appendChild( theAppendee );
	return tmpRef;
}
function makeSpan( theClass , theID , theAction , theAppendee ) {
	var tmpRef = document.createElement( 'span' );
	if ( theClass ) tmpRef.setAttribute( 'className' , theClass );
	if ( theID ) tmpRef.setAttribute( 'id' , theID );
	if ( theAppendee ) tmpRef.appendChild( theAppendee );
	return tmpRef;
}

// TEXT ELEMENTS
function makeLink( theClass , theHref , theAction , theAppendee , theText, theTarget ) {
	var tmpRef = document.createElement( 'a' );
	if ( theClass ) tmpRef.setAttribute( 'className' , theClass );
	if ( theHref ) tmpRef.setAttribute( 'href' , theHref );
	if ( theTarget ) tmpRef.setAttribute( 'target' , theTarget );
	if ( theAction ) tmpRef.onclick = function () { eval( theAction ); };
	if ( theAppendee ) tmpRef.appendChild( theAppendee );
	if ( theText ) tmpRef.appendChild( makeText(theText) );
	return tmpRef;
}
function makeText( theText ) {
	var tmpRef = document.createTextNode( theText );
	return tmpRef;
}
function makeParagraph( theText , theClass , theId ) {
	tmpRef = document.createElement( 'p' );
	if ( theText ) tmpRef.appendChild( document.createTextNode( theText ) );
	if ( theClass ) tmpRef.setAttribute( 'className' , theClass );
	if ( theId ) tmpRef.setAttribute( 'id' , theId );
	return tmpRef;
}
function makeBr() {
	var tmpRef = document.createElement( 'br' );
	return tmpRef;
}
function makeHSix( theText ) {
	tmpRef = document.createElement( 'h6' );
	if ( theText ) tmpRef.appendChild( document.createTextNode( theText ) );
	return tmpRef;
}

// IMAGE
function makeImg( theSrc, theClass, theID, theAction ) {
	var tmpRef = document.createElement( 'img' );
	tmpRef.setAttribute( 'src' , theSrc );
	if ( theClass ) tmpRef.setAttribute( 'className' , theClass );
	if ( theID ) tmpRef.setAttribute( 'id' , theID );
	if ( theAction ) tmpRef.onclick = function () { eval( theAction ); };
	return tmpRef;
}

// TABLES
function makeTableRow( theClass , theID , theAction , theAppendee ) {
	var tmpRef = document.createElement( 'tr' );
	if ( theClass ) tmpRef.setAttribute( 'className' , theClass );
	if ( theID ) tmpRef.setAttribute( 'id' , theID );
	if ( theAction ) tmpRef.onclick = function () { eval( theAction ); };
	if ( theAppendee ) tmpRef.appendChild( theAppendee );
	return tmpRef;
}
function makeTableCell( theClass , theID , theAction , theAppendee ) {
	var tmpRef = document.createElement( 'tr' );
	if ( theClass ) tmpRef.setAttribute( 'className' , theClass );
	if ( theID ) tmpRef.setAttribute( 'id' , theID );
	if ( theAction ) tmpRef.onclick = function () { eval( theAction ); };
	if ( theAppendee ) tmpRef.appendChild( theAppendee );
	return tmpRef;
}

// FORMS
function makeCheckbox( theClass, theID, theName, theAction ) {
	var tmpRef = document.createElement( 'input');
	tmpRef.type = 'checkbox';
	if ( theClass ) tmpRef.className = theClass;
	if ( theID ) tmpRef.id = theID;
	if ( theName ) tmpRef.name = theName;
	if ( theAction ) tmpRef.onclick = function () { eval( theAction ); };
	return tmpRef;
}
function makeInputButton( theClass, theID, theName, theAction ) {
	var tmpRef = document.createElement( 'input');
	tmpRef.type = 'button';
	if ( theClass ) tmpRef.className = theClass;
	if ( theID ) tmpRef.id = theID;
	if ( theName ) tmpRef.name = theName;
	if ( theAction ) tmpRef.onclick = function () { eval( theAction ); };
	return tmpRef;
}

/*###############################*/
/*           UTILITIES           */
/*###############################*/
function clearElement( theElement ) {
	if (theElement.firstChild) {
		while (theElement.firstChild) {
			theElement.removeChild(theElement.firstChild);
		}
	}
}

/*###############################*/
/*         SCROLLER CODE         */
/*###############################*/
function goLeft() {
	var scrollReference = document.getElementById( 'items' );
	var currentPosition = scrollReference.scrollLeft;
	scrollReference.scrollLeft = currentPosition - 30;
	time = setTimeout('goLeft()',50);
}
function goRight() {
	var scrollReference = document.getElementById( 'items' );
	var currentPosition = scrollReference.scrollLeft;
	scrollReference.scrollLeft = currentPosition + 30;
	time = setTimeout('goRight()',50);
}
function stopScroll() {
	if (time) clearTimeout(time);
}
