jQuery(document).ready(function()
{
	jQuery('#home-page-seo').append('<p><a href="javascript:;" class="home-page-seo-hide">Close</a></p>');
	jQuery('#home-page-seo').find('p').hide();
	jQuery('#home-page-seo').find('p:first').append(' <a href="javascript:;" class="home-page-seo-show">Read More</a>').show();
	
	jQuery('a.home-page-seo-show').click(function()
	{
		jQuery('#home-page-seo').find('p').show();
		jQuery(this).hide();
	});
	
	jQuery('a.home-page-seo-hide').click(function()
	{
		jQuery('#home-page-seo').find('p').hide();
		jQuery('#home-page-seo').find('p:first').show();
		jQuery('a.home-page-seo-show').show();
	});
	
	jQuery('.category-description').append('<p><a href="javascript:;" id="category-description-hide">Read Less</a></p>');
	jQuery('.category-description').find('p').hide();
	jQuery('.category-description').find('h2').hide();
	jQuery('.category-description').find('h3').hide();
	jQuery('.category-description').find('h4').hide();
	jQuery('.category-description').find('ul').hide();
	jQuery('.category-description').find('li').hide();
	jQuery('.category-description').find('p:first').append(' <a href="javascript:;" id="category-description-show">Read More</a>').show();
	
	jQuery('a#category-description-show').click(function()
	{
		jQuery('.category-description').find('p').show();
		jQuery('.category-description').find('h2').show();
		jQuery('.category-description').find('h3').show();
		jQuery('.category-description').find('h4').show();
		jQuery('.category-description').find('ul').show();
		jQuery('.category-description').find('li').show();
		jQuery(this).hide();
	});
	
	jQuery('a#category-description-hide').click(function()
	{
		jQuery('.category-description').find('p').hide();
		jQuery('.category-description').find('h3').hide();
		jQuery('.category-description').find('h2').hide();
		jQuery('.category-description').find('h4').hide();
		jQuery('.category-description').find('ul').hide();
		jQuery('.category-description').find('li').hide();
		jQuery('.category-description').find('p:first').show();
		jQuery('a#category-description-show').show();
	});
	
	var hb_noOfImages = jQuery('#home-page-mainimg-slide li').length;
	if(hb_noOfImages > 1)
	{
		var is_running = false, current_img = 0, current_topdiv = 0, current_tab = 1;
		var imageDivList = new Array('home-page-mainimg-top','home-page-mainimg-bottom');
		var hb_slideWidth = 940, liArray = new Array();	
		
		for(var i =0; i < hb_noOfImages; i++){liArray.push(jQuery('#home-page-mainimg-slide li')[i].innerHTML);}		

		jQuery('#home-page-mainimg-slide').remove();
		jQuery('#'+imageDivList[0]).css('position','absolute').css('z-index','51');
		jQuery('#'+imageDivList[1]).css('position','absolute').css('z-index','50');
		jQuery('#'+imageDivList[0]).html(liArray[current_img]);

		var playSlideshow = setInterval(function()
		{
			if(is_running == false)
			{
				var next_img = current_img + 1;if(next_img >= liArray.length){next_img = 0;}is_running  = true;
				jQuery('#'+imageDivList[1-current_topdiv]).html(liArray[next_img]);
				jQuery('#'+imageDivList[current_topdiv]).css('display', 'inline-block').fadeOut(1500, function()
				{
					jQuery('#'+imageDivList[current_topdiv]).css('z-index','49');
					jQuery('#'+imageDivList[1-current_topdiv]).css('z-index','51');
					jQuery('#'+imageDivList[current_topdiv]).css('z-index','50');
					jQuery('#'+imageDivList[current_topdiv]).fadeIn(0, 1);
					current_topdiv = 1-current_topdiv;current_img = next_img;is_running = false;
				});
			}	
		}, 5000);
	}
	
	var hometabs=new Array();
	jQuery('div.home-tab-features > div.home-tab-block').each(function(i){
		var h2=jQuery('h2',this);if(h2){
			hometabs.push(new Array(String(i+1),h2.html()));
			h2.hide();
			jQuery(this).attr('id', 'home-tab-block-'+String(i+1));
			jQuery(this).hide();
		}
	});
	if(hometabs.length>=1){
		jQuery('div.home-tab-features').prepend(jQuery('<ul class="home-tab-navi clearfix"></ul>'));
		jQuery.each(hometabs, function(index, value){
			jQuery('div.home-tab-features > ul.home-tab-navi').append(jQuery('<li><a href="javascript:hometabselect(\''+value[0]+'\');" id="home-tab-link-'+value[0]+'">'+value[1]+'</a></li>'));
		});
		hometabselect('1');
	}
	
});

function hometabselect(a)
{
	jQuery('div.home-tab-features > ul.home-tab-navi').find('a').each(function(i){jQuery(this).removeClass('current');});
	jQuery('#home-tab-link-'+a).addClass('current');
	jQuery('div.home-tab-features > div.home-tab-block').each(function(i){jQuery(this).hide();});
	jQuery('#home-tab-block-'+a).show();
}

function setYearFilter(a)
{
	for(var i=1;i<=39;i++){
		var t=String(i);
		if(t.length==1){t='00'+t;}
		else if(t.length==2){t='0'+t;}
		var y = document.getElementById(t);
		if (y.innerHTML.substr(y.innerHTML.length-4,4) == a || a ==0){y.parentNode.className = 'press-list-item';}
		else{y.parentNode.className = 'displayoff';}
	}
}

