$(function() {
	
	if($('.crumbs').length > 0){
		$('.crumbs a:contains(Home)').addClass('home');
	}

	if($('#slider').length > 0) {
		$('#slider').anythingSlider({width:620, height: 293, buildArrows: false, delay:7000});
	}
	
	$('.top-nav li:not(:last-child)').after('<li>|</li>');
	
	$('#menu-main-nav .sub-menu').prev('a').addClass('parent');
	$('#menu-main-nav > li:first-child > a').addClass('first');
	
	$('.parent').parent('li').removeClass('current_page_item').removeClass('current-menu-item');
	
	$('.nav > ul > li').hover(function() {
		$(this).addClass('hover');
	},function() {
		$(this).removeClass('hover');
	});
	
	if($('.right-rail').length > 0) {
		var c = 1;
		$('.right-rail .row').each(function(){
			$(this).addClass('row-'+c);
			c++;
		});
	}
	
	if($('.boxes').length > 0) {
		var c = 1;
		$('.boxes .box').each(function(){
			$(this).addClass('box-'+c);
			c++;
		});
	}
	
	if($('.list-cats').length > 0){
		$('.label:contains(Toner)').removeClass('label-b');
	}
	
	var mf = $('#menu-footer-nav li').length/4;
	mf = Math.round(mf);
	
	var f = 1, fc = 1;
	$('#menu-footer-nav li').each(function() {
		if(f < (mf+1) ){
			if(fc==1){
				$(this).appendTo($('#footer .col-1 ul'));
			}else if(fc==2){
				$(this).appendTo($('#footer .col-2 ul'));	
			}else if(fc==3){
				$(this).appendTo($('#footer .col-3 ul'));	
			}else if(fc==4){
				$(this).appendTo($('#footer .col-4 ul'));	
			}
		}
		if(f == mf) {
			fc++;
			f = 1;
		}else{
			f++;
		}		
	});
	$('#menu-footer-nav').remove();
	
	if($('.parent-pagename-product-range').length>0){
		var t = $('.main-title').text();
		$('.list-cats').find('.label:contains('+t+')').parents('li').addClass('current');
	}
	
	$('.content p a img').unwrap();
	
    $('.ctext').focus(function() {
        if ($(this).val() == $(this)[0].title) { $(this).val(''); }
    });
    $('.ctext').blur(function() {
        if ($(this).val() == '') { $(this).val($(this)[0].title); }
    });
    $('.ctext').blur();      
});

$(window).load(function() {
	if($('.cf-ol').length > 0) {

		$('.reqtxt').each(function() {
			var tx = $(this).text();
			$(this).siblings('label').append('<em>'+tx+'</em>');
			$(this).remove();
		});
		$('.emailreqtxt').each(function() {
			var etx = $(this).text();
			$(this).siblings('label').append('<em>'+etx+'</em>');
			$(this).remove();
		});
		
		$('.cf-sb').prepend('<span>* indicatse a required field</span>');
	}
});
