//=======latest news=====		
function latestNews(id,loop){
	var i=1;
	for (i=1;i<=3;i++){
		document.getElementById('latest-news-content-'+i).style.display='none';
		document.getElementById('latest-news-btn-'+i).className='';
	}
	document.getElementById('latest-news-content-'+id).style.display='block';
	document.getElementById('latest-news-btn-'+id).className='active';
	if (loop){
		if (id<3){
			id++;
			setTimeout("latestNews('"+id+"','loop')",4000);
		} else {
			setTimeout("latestNews('1')",4000);
		}
	}
}
//===============

//=======window onload=====
/*
window.onload=function(){
	// latest news
	var bodyClass=document.body.className;			
	if (bodyClass.search('cms-home')!=-1){
		setTimeout("latestNews('2','loop')",4000);
	}
}
*/
//===============

//=======jquery on dom ready=====
jQuery(function($){

	// get current URL
	var thisUrl = window.location.href;
	
	//=======update breadcrum=====	
	if (thisUrl.match(/(\?cat=)/)){
		var parentCategoryUrl = thisUrl.replace(/(\?)(.+)/, '');
		var parentCategoryName = $('.breadcrumbs strong').text();
		$('.breadcrumbs strong').replaceWith('<a href="' + parentCategoryUrl + '" title="' + parentCategoryName + '">' + parentCategoryName + '</a><span>&nbsp;</span>');
		$('.breadcrumbs ul').append('<li><strong>' + $('.category-title h2').text() + '</strong></li>');
	}
	//===============	
					
	//=======category titles=====	
	// get body class to determine catetory
	var bodyClass = document.body.className;				

	// set active tab in top menu
	if (bodyClass.search('cms-home')!=-1){
		$('#nav .home').addClass('active');
	}
	
	if (bodyClass.search('cms-why-kutters')!=-1){
		$('#nav .why-kutters').addClass('active');
	}
	
	if (bodyClass.search('contacts-index-index')!=-1){
		$('#nav .contacts').addClass('active');
	}	
	
	// hide text if parent category
	if (thisUrl.match(/(\/clearance.html|\/kitchen-knives.html|\/outdoor-knives.html|\/military-knives.html|\/swords.html|\/accessories.html|\/manufacturers.html)$/)){
		$('.category-title h2').wrapInner('<span></span>');
	}
	
	// set category title image based on category
	if (bodyClass.search('categorypath-clearance')!=-1){
		$('.category-title h2').css({'background':'url(/skin/frontend/blank/theme110/images/cat-title-clearance.gif) no-repeat'});
	}
	
	if (bodyClass.search('categorypath-kitchen-knives')!=-1){
		$('.category-title h2').css({'background':'url(/skin/frontend/blank/theme110/images/cat-title-kitchen-knives.gif) no-repeat'});
	}
	
	if (bodyClass.search('categorypath-outdoor-knives')!=-1){
		$('.category-title h2').css({'background':'url(/skin/frontend/blank/theme110/images/cat-title-outdoor-knives.gif) no-repeat'});
	}
	
	if (bodyClass.search('categorypath-military-knives')!=-1){
		$('.category-title h2').css({'background':'url(/skin/frontend/blank/theme110/images/cat-title-military-knives.gif) no-repeat'});
	}
	
	if (bodyClass.search('categorypath-swords')!=-1){
		$('.category-title h2').css({'background':'url(/skin/frontend/blank/theme110/images/cat-title-swords.gif) no-repeat'});
	}
	
	if (bodyClass.search('categorypath-accessories')!=-1){
		$('.category-title h2').css({'background':'url(/skin/frontend/blank/theme110/images/cat-title-accessories.gif) no-repeat'});
	}
	
	if (bodyClass.search('categorypath-manufacturers')!=-1){
		$('.category-title h2').css({'background':'url(/skin/frontend/blank/theme110/images/cat-title-manufacturers.gif) no-repeat'});
	}
	//===============	
	
	// cart totals
    $(".a-right:contains('Shipping')").css('white-space', 'normal');
	//===============
	
});	
