/*------------- [ DECLARATION OF VARIABLES: CONTENT ] -------------*/
var i = 1;
	var showcase = [
					
						['<h1>Pethouse Fun &amp; Co</h1><p>Clientul a dorit un magazin virtual destinat detinatorilor de animale de companie. Ca functionalitate aparte, magazinul genereaza oferte personalizate dupa modul in care user-ul navigheaza pe site si realizarea unui joc interactiv.  </p>','showcase/pethouse.jpg', 'Pethouse Fun &amp; Co', false, false]
						
				   ];
	var sections = [
						['content/acasa.php', 'acasa_div'],
						['content/companie.php', 'companie_div'],
						['content/webdesign.php', 'webdesign_div'],
						['content/identitate_print.php', 'identitate_div'],
						['content/media.php', 'media_div'],	
						['content/dezvoltare.php', 'dezvoltare_div'],
						['content/internet_marketing.php', 'marketing_div'],
						['content/mentenanta.php', 'mentenanta_div'],
						['content/hosting.php', 'hosting_div'],
						
						
						['content/join.php', 'join_div'],
						[false, 'portafolio_div']
				   ];
				   
	var portfolio = [ 	
					 	['MAT Craiova', 'portofoliu/mat_thumb.jpg', 'http://www.matcraiova.ro/',''],
						['Birotica si papetarie online', 'portofoliu/birotica_thumb.jpg', 'http://www.biroticapapetarieonline.ro/',''],
						['Multimobila', 'portofoliu/multimobila_thumb.jpg', 'http://www.magazinmultimobila.ro/',''],
					 	['Restaurant Prestige', 'portofoliu/prestige_thumb.jpg', 'http://www.restaurantprestige.ro/',''],
					 	['Hoteluri Craiova', 'portofoliu/hoteluri_thumb.jpg', 'http://www.hotelcraiova.k13.ro/',''],
					 	['Taff Line', 'portofoliu/taff_thumb.jpg', 'http://www.taffline.ro/',''],
					 	['Terapii Alternative', 'portofoliu/terapii_thumb.jpg', 'http://www.terapii-alternative.com/',''],
						['Ford Plusauto', 'portofoliu/plusauto_thumb.jpg', 'http://www.plusauto.ro/',''],
					 	['Iluminari Elite', 'portofoliu/iluminari_thumb.jpg', 'http://www.iluminari-elitedecor.ro/',''],
					 	['Restaurant Pallace', 'portofoliu/pallace_thumb.jpg', 'http://www.restaurantpallace.ro',''],
					 	['Erpia', 'portofoliu/erpia_thumb.jpg', 'http://www.erpia.ro',''],
					 	['Imcorp Minerals', 'portofoliu/imcorp_thumb.jpg', 'http://www.httpsolutions.com/imcorp',''],
					 	['Palatul R.S.R.', 'portofoliu/rsr_thumb.jpg', 'http://www.palatul-rsr.ro/',''],
						['Plus Hotel', 'portofoliu/plushotel_thumb.jpg', 'http://www.plushotel.ro/',''],
						['Elind', 'portofoliu/elind_thumb.jpg', 'http://www.elind.ro',''],
						['Mr Moto', 'portofoliu/mrmoto_thumb.jpg', 'http://www.mr-moto.ro/',''],
					 	['Aksoy', 'portofoliu/aksoy_thumb.jpg', 'http://www.aksoygold.ro/',''],
						['Arhi Design', 'portofoliu/arhidesign_thumb.jpg', 'http://www.arhidesign.ro/',''],			
						['Marcello Benne', 'portofoliu/marcellobenne_thumb.jpg', 'http://www.marcellobenne.ro/',''],			
						['Indstel', 'portofoliu/indstel_thumb.jpg', 'http://www.indstel.ro/',''],			
						['Artt Color', 'portofoliu/arttcolor_thumb.jpg', 'http://www.arttcolor.ro/',''],
						['Super Ocazii', 'portofoliu/superocazii_thumb.jpg', 'http://www.superocazii.ro/',''],
						['Auto Adriatica', 'portofoliu/autoadriatica_thumb.jpg', 'http://www.autoadriatica.ro/',''],
						['Car Trade India (design only)', 'portofoliu/cartradeindia_thumb.jpg', 'http://www.cartradeindia.com/',''],
						/*['AM Marketing', 'portofoliu/ammarketing_thumb.jpg', 'http://www.ammarketing.ro/',''],	*/					
						['Eurogenetic', 'portofoliu/eurogenetic_thumb.jpg', 'http://www.eurogenetic.ro/',''],
						['HDV Pro', 'portofoliu/hdvpro_thumb.jpg', 'http://www.hdvpro.ro/',''],
						['Cascada de ciocolata', 'portofoliu/cdc_thumb.jpg', 'http://www.cascadadeciocolatadj.ro/',''],
						['Aplicatie stoc Mr Moto', 'portofoliu/stoc_thumb.jpg', 'http://www.mrmoto.ro/','']
					];
/*------------- [ DECLARATION OF VARIABLES: GLOBALS ] -------------*/
	var scrollOffset;
	var showcaseProcess;
	var showcaseStop = true;
	var animationFlag = false;
	var done = 0;
	var currentPosition = 0;
	var itemPosition = 0;
	var currentSection = 'acasa_div';
	var tabTag = '_link';
	var paneTag = '_div';
	var scrollanimation = [
								{ time: 0, begin: 0, change: 0.0, duration: 0.0, element: null, timer: null },
								{ time: 0, begin: 0, change: 0.0, duration: 0.0, element: null, timer: null }
						  ];
/*------------- [ LOADING ] -------------*/
	Event.observe(window, 'load', function() {
		//initShowcase();
		initSections();
		initPortfolio();
	});
/*------------- [ SPECIFIC FUNCTIONS: SECTIONS ] -------------*/
	function initSections(){
		$(sections[0][1].split('_')[0] + tabTag).className = 'active';
		sections.each(function(section) {
			if( section[0] == false )
				$('content').insert('<div id="' + section[1] + '" class="section"></div>');
			else
				new Ajax.Request(section[0], {
					asynchronous: false,
					onComplete: function(content) {
	    				$('content').insert('<div id="' + section[1] + '" class="section">' + content.responseText + '</div>');
	  				}
				});
		});
		
		done = 2;
	}
	function displaySection(link){
		if (done == 2) {
			scrollSection(link, 'content', 'acasa_div', 'vertical');
			changeLink(link);
		}
		else 
			if (done == 0) {
				done = 1;
				
				new PeriodicalExecuter(function(process){
					if (done == 2) {
						process.stop();
						scrollSection(link, 'content', 'acasa_div', 'vertical');
						changeLink(link);
					}
				}, 0.015);
			}
	}
	
	function changeLink(link){
		if (currentSection == link)
			return;
		
		lastSection = currentSection;
		currentSection = link;
		
		Try.these(function(){
			$(currentSection.split('_')[0] + tabTag).className = 'active';
			
			if (lastSection)
				$(lastSection.split('_')[0] + tabTag).className = 'inactive';
		});
		
		adjustViewport();
	}
	function adjustViewport(){
		new PeriodicalExecuter(function(process){
			if (scrollanimation[0].timer == null) {
				if (scrollOffset != document.viewport.getScrollOffsets()[1]) {
					wide = -(document.viewport.getHeight() - 425);
					scrollEffect = new Effect.ScrollTo('menu_comment', {
						afterFinish: updateOffset,
						offset: wide,
						queue: {
							scope: 'scroll',
							position: 'end'
						}
					});
				}
				process.stop();
			}
		}, 0.25);
	}
	
	function updateOffset(){
		scrollOffset = document.viewport.getScrollOffsets()[1];
	}
/*------------- [ SPECIFIC FUNCTIONS: PORTFOLIO ] -------------
	function initPortfolio(){
		cont = 0;
		page = -1;
		$('portafolio_div').insert('<div id="portafolio_scroller" class="clearfix">');
		portfolio.each(function(item) {
			if ( (cont / 6) % 1 == 0) {
				pagePortfolio(page);
				page = cont / 6;
				$('portafolio_scroller').insert('<div id="portafolio_content_' + page + '" class="portafolio_content"><h1>Portofoliu</h1><div id="portafolio_images_' + page + '" class="portafolio_images"></div></div>');
			}
			cont++;
			$('portafolio_images_' + page).insert('<a id="portafolio_' + cont + '" class="highslide" href="' + item[1].split('_')[0] + '.jpg" onclick="openPortfolio(this, ' + cont + ', ' + page + '); return false;" onmouseover="hoverPortfolio.defer(this, \'over\')" onmouseout="hoverPortfolio.defer(this, \'out\');"><img src="' + item[1] + '" alt="' + item[0] + '" title="' + item[0] + '" /><span>' + item[0] + '</span></a>');
			caption = '<div id="caption_' + cont + '" class="highslide-caption"><div>';
			if(item[2])
				caption += '<a href="' + item[2] + '"  target="_blank">' + item[2] + '</a>';
			if(item[3])
				caption += '<p>' + item[3] + '</p>';
			caption += '</div><div class="caption_right"><a href="javascript:void(0);" onclick="return hs.close(this);">INCHIDE</a></div></div>';
			$('portafolio_images_' + page).insert(caption);
			$('portafolio_' + cont).addClassName('portafolio');
			$('portafolio_' + cont).setStyle({ opacity: 0.6 });
		});
		pagePortfolio(page);
	}
	function pagePortfolio(page){
		if( portfolio.length > 6 && page != -1 ){
			if( page != 0 )
				$('portafolio_content_' + page).insert('<a class="content" href="javascript: displayPortfolio(\'portafolio_content_' + (page - 1) + '\');"><img src="images/content_sageata_stanga.gif" alt="Pagina anterioara" title="Pagina anterioara" /><span>Pagina anterioara</span></a>');
			else
				if( page != portfolio.length / 6 )
					$('portafolio_content_' + page).insert('<a class="content" href="javascript: displayPortfolio(\'portafolio_content_' + (page + 1) + '\');"><span>Pagina urmatoare</span><img src="images/content_sageata_dreapta.gif" alt="Pagina urmatoare" title="Pagina urmatoare" /></a>');
		}
	}
	function displayPortfolio(link){
		scrollSection(link, 'portafolio_div', 'portafolio_content_0', 'horizontal');
	}
	
	function hoverPortfolio(element, type){
		if(type == 'over')
			newOpacity = 1.0;
		else
			newOpacity = 0.6;
		queue = Effect.Queues.get( $(element).identify() );
		queue.each( function(effect){ effect.cancel(); } );
		oldOpacity = $(element).getStyle('opacity');
		if(oldOpacity!=newOpacity)
			new Effect.Opacity(element, { duration: 0.25, from: oldOpacity, to: newOpacity, queue: { scope: $(element).identify() } } );
	}
	function openPortfolio(element, cont, page){
		return hs.expand(element, {
			captionId: 'caption_' + cont,
			slideshowGroup: 'portfolio' + page
		} );
	}
---------------------------------------------------------------------------------*/
/*------------- [ SPECIFIC FUNCTIONS: PORTFOLIO ] -------------*/
	function initPortfolio(){
		cont = 0;
		page = -1;
		
		$('portafolio_div').insert('<div id="portafolio_scroller" class="clearfix">');
		
		portfolio.each(function(item) {
			if ( (cont / 6) % 1 == 0) {
				pagePortfolio(page);
				
				page = cont / 6;
				$('portafolio_scroller').insert('<div id="portafolio_content_' + page + '" class="portafolio_content"><h1>Portofoliu</h1><div id="portafolio_images_' + page + '" class="portafolio_images"></div></div>');
			}
			cont++;
			$('portafolio_images_' + page).insert('<a id="portafolio_' + cont + '" class="highslide" href="' + item[1].split('_')[0] + '.jpg" onclick="openPortfolio(this, ' + cont + ', ' + page + '); return false;" onmouseover="hoverPortfolio.defer(this, \'over\')" onmouseout="hoverPortfolio.defer(this, \'out\');"><img src="' + item[1] + '" alt="' + item[0] + '" title="' + item[0] + '" /><span>' + item[0] + '</span></a>');
			caption = '<div id="caption_' + cont + '" class="highslide-caption"><div>';
			if(item[2])
				caption += '<a href="' + item[2] + '" target="_blank">' + item[2] + '</a>';
			if(item[3])
				caption += '<p>' + item[3] + '</p>';
			
			caption += '</div><div class="caption_right"><a href="#" onclick="return hs.close(this);">INCHIDE</a></div></div>';
			
			$('portafolio_images_' + page).insert(caption);
			
			$('portafolio_' + cont).addClassName('portafolio');
			$('portafolio_' + cont).setStyle({ opacity: 0.6 });
		});
		
		pagePortfolio(page);
	}
	function pagePortfolio(page){
		if( portfolio.length > 6 && page != -1 ){
			element = $('portafolio_content_' + page).insert('<div class="buttons"></div>');
			if (page != 0)
				element.insert('<a  class="content back" href="javascript: displayPortfolio(\'portafolio_content_' + (page - 1) + '\');"><img src="images/content_sageata_stanga.gif" alt="Pagina anterioara" title="Pagina anterioara" /><span>Pagina anterioara</span></a>');
			if (page < Math.floor(portfolio.length / 6))
				element.insert('<a  class="content next" href="javascript: displayPortfolio(\'portafolio_content_' + (page + 1) + '\');"><span>Pagina urmatoare</span><img src="images/content_sageata_dreapta.gif" alt="Pagina urmatoare" title="Pagina urmatoare" /></a>');
		}
	}
	function displayPortfolio(link){
		scrollSection(link, 'portafolio_div', 'portafolio_content_0', 'horizontal');
	}
	
	function hoverPortfolio(element, type){
		if(type == 'over')
			newOpacity = 1.0;
		else
			newOpacity = 0.6;
		
		queue = Effect.Queues.get( $(element).identify() );
		queue.each( function(effect){ effect.cancel(); } );
			
		oldOpacity = $(element).getStyle('opacity');
		
		if(oldOpacity!=newOpacity)
			new Effect.Opacity(element, { duration: 0.25, from: oldOpacity, to: newOpacity, queue: { scope: $(element).identify() } } );
	}
	
	function openPortfolio(element, cont, page){
		return hs.expand(element, {
			captionId: 'caption_' + cont,
			slideshowGroup: 'portfolio' + page
		} );
	}
/*------------- [ SPECIFIC FUNCTIONS: PRODUCTS ] -------------*/
	function displayProduct(link){
		scrollSection(link, 'products_div', 'products_back', 'horizontal');
	}
	
	
/*------------- [ SPECIFIC FUNCTIONS: ACASA ] -------------*/
	function displayAcasa(link){
		scrollSection(link, 'acasa_div', 'acasa_back', 'horizontal');
	}	
	
/*------------- [ SPECIFIC FUNCTIONS: ACASA ] -------------*/
	function displayCompanie(link){
		scrollSection(link, 'companie_div', 'companie_back', 'horizontal');
	}	
	
	
/*------------- [ SPECIFIC FUNCTIONS: WEBDESIGN ] -------------*/
	function displayWebdesign(link){
		scrollSection(link, 'webdesign_div', 'webdesign_back', 'horizontal');
	}	
	
/*------------- [ SPECIFIC FUNCTIONS: IDENTITATE & PRINT ] -------------*/
	function displayIdentitate(link){
		scrollSection(link, 'identitate_div', 'identitate_back', 'horizontal');
	}
/*------------- [ SPECIFIC FUNCTIONS: MEDIA ] -------------*/
	function displayMedia(link){
		scrollSection(link, 'media_div', 'media_back', 'horizontal');
	}
/*------------- [ SPECIFIC FUNCTIONS: MARKETING ] -------------*/
	function displayMarketing(link){
		scrollSection(link, 'marketing_div', 'marketing_back', 'horizontal');
	}
/*------------- [ SPECIFIC FUNCTIONS: HOSTING ] -------------*/
	function displayHosting(link){
		scrollSection(link, 'hosting_div', 'hosting_back', 'horizontal');
	}	
/*------------- [ SPECIFIC FUNCTIONS: DEZVOLTARE WEB ] -------------*/
	function displayDezvoltare(link){
		scrollSection(link, 'dezvoltare_div', 'dezvoltare_back', 'horizontal');
	}
/*------------- [ SPECIFIC FUNCTIONS: MENTENANTA SITE ] -------------*/
	function displayMentenanta(link){
		scrollSection(link, 'mentenanta_div', 'mentenanta_back', 'horizontal');
	}
/*------------- [ SPECIFIC FUNCTIONS: SERVICII CONEXE ] -------------*/
	function displayServicii(link){
		scrollSection(link, 'servicii-conexe_div', 'servicii-conexe_back', 'horizontal');
	}
/*------------- [ SPECIFIC FUNCTIONS: Join the team] -------------*/
	function displayJoin(link){
		scrollSection(link, 'join_div', 'join_back', 'horizontal');
	}
/*------------- [ SPECIFIC FUNCTIONS: CONTACT US ] -------------*/
	function scrollToDiv(link){
		new Effect.ScrollTo(link, { queue: { scope: 'scroll', position: 'end' } } );
	}
/*------------- [ SPECIFIC FUNCTIONS: SHOWCASE ] -------------*/
	/*function initShowcase(){
		$('back').setStyle( { opacity: 0.5, 'cursor': 'default' } );
		$('next').setStyle( { opacity: 1, 'cursor': 'pointer' } );
		
		for (cont = 0; cont < showcase.length; cont++)
			loadShowcase(cont);
		
		$('showcase_images').scrollLeft = 15;
		//$('showcase_text').scrollTop = 5;
		$('link').update(showcase[currentPosition][2]);
		
		if (showcase[currentPosition][3])
			$('link').writeAttribute('href', showcase[currentPosition][3]);
	}
	
	function timeShowcase(){
		if(showcaseProcess)
			showcaseProcess.stop();
		
		if(showcaseStop)
			showcaseProcess = new PeriodicalExecuter(function(process){
				changeShowcase('next', 'auto');
			}, 4);
	}
	function changeShowcase(orientation, type){
		lastPosition = currentPosition;
		
		if (orientation == 'next' && currentPosition < showcase.size() - 1) {
			currentPosition++;
			$('back').setStyle({ opacity: 1, 'cursor': 'pointer' });
		}
		else 
			if (orientation == 'back' && currentPosition != 0) {
				currentPosition--;
				$('next').setStyle({ opacity: 1, 'cursor': 'pointer' });
			}
			else 
				if (orientation == 'next' && currentPosition == showcase.size() - 1) {
					if(type == 'auto'){
						currentPosition = 0;
						$('next').setStyle({ opacity: 1, 'cursor': 'pointer' });
					}
					else
						return;
				}
		
		if(currentPosition == 0)
			$('back').setStyle( { opacity: 0.5, 'cursor': 'default' } );
		else
			if(currentPosition == showcase.size()-1)
				$('next').setStyle( { opacity: 0.5, 'cursor': 'default' } );
		
		if (!showcase[currentPosition][4])
			loadShowcase(currentPosition);
		
		if (lastPosition != currentPosition) {
			position = findElementPos($('image_' + currentPosition));
			position = position[0];
			
			offsetPos = findElementPos($('image_0'));
			position -= offsetPos[0];
			
			if (currentPosition > lastPosition) {
				first = position + 45;
				first_text = 0;
				second = position + 15;
				second_text = position - 117*i;
				i++;
			}
			else {
				i--;
				first = position - 15;
				first_text = 0;
				second = position + 15;
				second_text = position - 117*(i-1);
				
			}
			scrollStart($('showcase_text'), $('showcase_text').scrollTop, 0, 'vertical', 1, 1);
			scrollStart($('showcase_images'), $('showcase_images').scrollLeft, first, 'horizontal', 25, 1);
			
						
			new PeriodicalExecuter(function(process){
				if( scrollanimation[1].timer == null ) {
					process.stop();
					scrollStart($('showcase_images'), $('showcase_images').scrollLeft, second, 'horizontal', 15, 1);
										
					$('link').update(showcase[currentPosition][2]);
					$('link').writeAttribute('href', showcase[currentPosition][3]);
				}
			}, 0.015);
			new PeriodicalExecuter(function(process){
				if( scrollanimation[1].timer == null ) {
					process.stop();
					scrollStart($('showcase_text'), $('showcase_text').scrollTop, second_text, 'vertical', 11, 1);
					//alert(position);
				}
			}, 0.015);
		}
	}
	function loadShowcase(currentPosition){
		html = '';
		if(showcase[currentPosition][3])		
			html += '<a href="' + showcase[currentPosition][3] + '">';	
			
		html += '<div><img id="image_' + currentPosition + '" src="' + showcase[currentPosition][1] + '" alt="' + showcase[currentPosition][2] + '" title="' + showcase[currentPosition][2] + '" /></div>';
		if(showcase[currentPosition][3])
			html += '</a>';
		htm='<div>' + showcase[currentPosition][0] + '</div>';
		$('showcase_scroller').insert(html);
		//$('text_scroller').insert(htm);
		showcase[currentPosition][4] = true;
	}*/
/*------------- [ SCROLLING FUNCIONS ] -------------*/
	function scrollSection(link, scrollArea, offset, direction){
		theScroll = $(scrollArea);
		
		position = findElementPos($(link));
		
		if( direction == 'horizontal' )
			position=position[0];
		else
			position=position[1];
		
		if ( offset != '' ) {
			offsetPos = findElementPos($(offset));
			
			if (direction == 'horizontal') {
				position -= offsetPos[0];
				start = theScroll.scrollLeft;
			}
			else {
				position -= offsetPos[1];
				start = theScroll.scrollTop;
			}
		}
	
		scrollStart(theScroll, start, position, direction, 25, 0);
	}
	
	function scrollStart(elem, start, end, direction, duration, position){
		if (scrollanimation[position].timer != null) {
			clearInterval(scrollanimation[position].timer);
			scrollanimation[position].timer = null;
		}
		
		scrollanimation[position].time = 0;
		scrollanimation[position].begin = start;
		scrollanimation[position].change = end - start;
		scrollanimation[position].duration = duration;
		scrollanimation[position].element = elem;
		
		scrollanimation[position].timer = setInterval('scrollAnimation(' + position  + ', \'' + direction + '\');', 15);
	}
	
	function scrollAnimation(position, direction){
		if (scrollanimation[position].time > scrollanimation[position].duration) {
			clearInterval(scrollanimation[position].timer);
			scrollanimation[position].timer = null;
		}
		else {
			move = sineInOut(scrollanimation[position].time, scrollanimation[position].begin, scrollanimation[position].change, scrollanimation[position].duration);
			
			if(direction == 'vertical')
				scrollanimation[position].element.scrollTop = move; 
			else
				scrollanimation[position].element.scrollLeft = move;
			
			scrollanimation[position].time++;
		}
	}
	function sineInOut(t, b, c, d){
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	}
/*------------- [ POSITIONING FUNCTIONS ] -------------*/
	
	function findElementPos(elemFind){
		var elemX = 0;
		var elemY = 0;
		
		do {
			elemX += elemFind.offsetLeft;
			elemY += elemFind.offsetTop;
		}
		while ( elemFind = elemFind.offsetParent )
	
		return Array(elemX, elemY);
	}
	
	function centerElement(element, parent) {
        elementDimensions = $(element).getDimensions();
        
		if (!parent) {
            viewportDimensions = document.viewport.getDimensions();
            parentWidth = viewportDimensions.width;
            parentHeight = viewportDimensions.height;
        }
		else {
            parentWidth = $(parent).offsetWidth;
            parentHeight = $(parent).offsetHeight;
        }
		
		viewportOffset = document.viewport.getScrollOffsets();
		
		$(element).absolutize();
		$(element).style.top = (parentHeight/2) - (elementDimensions.height/2) + viewportOffset.top + 'px';
        $(element).style.left = (parentWidth/2) - (elementDimensions.width/2) + viewportOffset.left + 'px';
	}
//-------------------------------------------------
function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}
function addClassName(elm, className){
    var currentClass = elm.className;
    if(!new RegExp(("(^|\\s)" + className + "(\\s|$)"), "i").test(currentClass)){
        elm.className = currentClass + ((currentClass.length > 0)? " " : "") + className;
    }
    return elm.className;
}
function removeClassName(elm, className){
    var classToRemove = new RegExp(("(^|\\s)" + className + "(\\s|$)"), "i");
    elm.className = elm.className.replace(classToRemove, "").replace(/^\s+|\s+$/g, "");
    return elm.className;
}
function activateThisColumn(column) {
	var table = document.getElementById('pricetable');
	
	// first, remove the 'on' class from all other th's
	var ths = table.getElementsByTagName('th');
	for (var g=0; g<ths.length; g++) {
		removeClassName(ths[g], 'on');
	}
	// then, remove the 'on' class from all other td's
	var tds = table.getElementsByTagName('td');
	for (var m=0; m<tds.length; m++) {
		removeClassName(tds[m], 'on');
	}
	
	// now, add the class 'on' to the selected th
	var newths = getElementsByClassName(column, 'th', table);
	for (var h=0; h<newths.length; h++) {
		addClassName(newths[h], 'on');
	}
	// and finally, add the class 'on' to the selected td
	var newtds = getElementsByClassName(column, 'td', table);
	for (var i=0; i<newtds.length; i++) {
		addClassName(newtds[i], 'on');
	}
}