function makeTabs(containerId, targetClass, suffix, modtitle) {
	if ($(containerId).getChildren().length > 0)
	{
		suffix = suffix || '';
        modtitle = modtitle || '';
		//create total wrapper
		var megaWrapper = new Element('div', {'class':'newsPanelTabs'+suffix});
		megaWrapper.injectTop($(containerId));
        
        if(modtitle != '') {
            var titleTag = new Element('h3');
            titleTag.setText(modtitle);
            titleTag.injectTop($(containerId));
        }
        
	 
		//create module content wrapper
		var modWrapper = new Element('div', {'class':'modWrapper'+suffix});
		modWrapper.injectTop(megaWrapper);
		
		//create (another) module content wrapper
		var modWrapperInside = new Element('div', {'class':'modWrapperInside'+suffix});
		modWrapperInside.injectTop(modWrapper);
	 
		//create tab wrapper
		var tabWrapper = new Element('ul', {'class':'tabWrapper'+suffix});
		tabWrapper.injectTop(megaWrapper);
	 
		$$('#'+containerId+' .moduletable').each(function(module,idx)
		{
			if(module.hasClass(targetClass)) {	
				//create new tab from module title and remove it
				var newTab = new Element('li', {'class': 'newsTab tab-'+idx});
				newTab.innerHTML = '<div>'+module.getElement('h3').innerHTML+'</div>';
				module.getElement('h3').remove();
				newTab.injectInside(tabWrapper);
	 
				//move module content to module wrapper
				module.injectInside(modWrapperInside);
	 
				//create click event on tab
				newTab.addEvent('click', function()
				{
					//show chosen module
					$$('#'+containerId+' div.modWrapper div.moduletable').setStyle('display', 'none');
					module.setStyle('display', 'block');
	 
					//update tabs
					$$('#'+containerId+' .newsTab').removeClass('newsTab_active');
					newTab.addClass('newsTab_active');
				});
			}
		});
	 
		//only show first one
		tabWrapper.getFirst().fireEvent('click');
	}
}

function refreshFlir() {
  if(!window.ie6) {
    FLIR.init();
    $$("h2, h3, h4, h5, h6, #lightbox_text, p.intro, div.blog div.articletitle h2, #flypage_producttitle h1").each( function(el) { FLIR.replace(el, new FLIRStyle({ cFont:'din', mode:'wrap', output:'png' })); } );
    $$("h1, div.componentheading, div.contentheading, div.news_month, div.flypage_back2 a, div.form_container label, #cyclescheme_calc label").each( function(el) { FLIR.replace(el, new FLIRStyle({ cFont:'din', output:'png' })); } );
    $$("div.news_day, #flypage_price, div.cbBox h3, ul.search_results span.number").each( function(el) { FLIR.replace(el, new FLIRStyle({ cFont:'dinbold', output:'png' })); } );
    $$('.wsbanner_slide_title').each( function(el) { FLIR.replace(el, new FLIRStyle({ cFont:'din', output:'png', mode:'wrap', realFontHeight: true })); } );
 
    }
}

/*var evnt = (window.webkit) ? 'load' : 'domready';*/
window.addEvent('domready', function() {
    refreshFlir();    
    
	if($defined($('index_socialnetworks'))) {
		// this line tells all modules in #index_left with a class of 'tabbed' to become tabs
		makeTabs('index_socialnetworks','tabmodule','','Social Networks');
	}
	
	if($$('.vm_griditem').length > 0) {
		$$('.vm_griditem').each(function(el, idx) {
			if(idx%3 == 0) {
				$(el).addClass('griditem_left');
			} else if(idx%3 == 2) {
				$(el).addClass('griditem_right');
			}
		});
	}
	/*
    if($defined($('ie6_sniffer'))) {
		$('ie6_sniffer').setStyles({ overflow:'hidden','margin-top':'-160px'});
		var ie6_slider = new Fx.Style('ie6_sniffer', 'margin-top', {duration:1000});	
		if(window.ie6) {		
			if(Cookie.get('iesixer') != 'closed') {
				ie6_slider.start(0);
			}
		}
		$('ie6_closer').addEvent('click', function(ev) {
			ie6_slider.start(-160);
			Cookie.set('iesixer','closed', {duration:1});
		});
	}	
    */

	if (document.title == 'Page Not Found' || document.title == '404'){ 
		$('inner_body').setStyle('display', 'block');
		$('inner_bodymid').getElement('.articletitle').setStyle('display', 'none');
		$('index_cta').setStyle('display', 'none');
		//$('featured_products').setStyle('display', 'none');
		$('index_socialarea').setStyle('display', 'none');
		$('banner').innerHTML='';
		$('banner').setStyle('height', '150px');
		//window.location = "http://www.condorcycles.com/index.php?option=com_content&Itemid=82&id=30&lang=en&view=article"

	}
    
    if ($defined($('inner_banner')) && $('inner_banner').getChildren().length == 0)
    {
        $('inner_banner').remove();
    }

});
