$(document).ready(function(){
	
	DD_belatedPNG.fix('#cta-badge img, #primary-top, #tertiary, #tertiary-bottom, .mini-basket .inner-box, .tab-link-products-active, #header h1 a, .swatch-overlay');
	
	$('#header h1 a').text('');
	
	$('#top-search input#keywords').attr({
			value: "Search our products..."
			});
			
	var keywords = $('#top-search input#keywords').attr("value");
	
	if(keywords == 'Search our products...'){
	$('#top-search input#keywords').click(function() {
		$('#top-search input#keywords').removeAttr("value");
		});
	}
			
	$('#top-search input.submit').removeAttr("value");
	$('#top-search input.submit').attr({ 
    value: "Go"
  });

	$('.homepage-button-pink').click(function(){
	var rel = $('.homepage-button-pink a').attr('href');
      window.location.href = (''+rel);
      return false;
	});
	
	$('.homepage-button-pink').hover(
	      function () {
	        $('.homepage-button-pink a').each(function(idx,el){
	    	el.style.color='#dddddd';
		});
		},
	       function () {
		$('.homepage-button-pink a').each(function(idx,el){
	    	el.style.color='';
		});
	});
	
	$('.homepage-button-blue').click(function(){
	var rel = $('.homepage-button-blue a').attr('href');
      window.location.href = (''+rel);
      return false;
	});
	
	$('.homepage-button-blue').hover(
	      function () {
	        $('.homepage-button-blue a').each(function(idx,el){
	    	el.style.color='#dddddd';
		});
		},
	       function () {
		$('.homepage-button-blue a').each(function(idx,el){
	    	el.style.color='';
		});
	});
	
	$('#primary').prepend('<div id="primary-top"></div>');

	$('#header').prepend('<div id="cta-contact"><h3>Freephone 0800 072 5334</h3></div><div class="clear"></div><div id="cta-badge"><a href="http://www.shirtworks.co.uk/services.php" title="More info on print and embroidery services" ><img src="http://catalogue.shirtworks.co.uk/static/images/cta-badge.png" alt="Call to action badge" height="86px" width="105px" /></a></div>');
	$('li.tab-link-products').attr("class", "tab-link-products-active");	
	
	$('#tertiary').append('<div id="tertiary-bottom"></div>');
	
	$('li.cat-link-branded-promotional-items ul').css({
			display: "none"
			});
	
	$('li.cat-link-branded-promotional-items').hover(function(){
		$('li.cat-link-branded-promotional-items ul').slideDown();
		});
			
	$('li.cat-link-printed-embroidered-clothing ul').css({
			display: "none"
			});
	
	$('li.cat-link-printed-embroidered-clothing').hover(function(){
		$('li.cat-link-printed-embroidered-clothing ul').slideDown();
		});
				
	$('li.location ul').slideDown();

	$('.mini-basket li:last').css({display: "none"});

	$('.mini-basket .inner-box').append('<p><a class="proceed-link" href="/enquiry-form.html" title="View your enquiry basket">View your enquiry basket</a></p>');
	$('.product-list ol li').click(function(event){
		var thisClass = $(this).attr('class');
		thisClass = thisClass.replace('supplier-highlight', '');
		thisClass = thisClass.replace('odd ', '');
		thisClass = thisClass.replace('even ', '');
		var remClass = thisClass.split(' ');
		thisClass = remClass[1];
		var thisHref = $('.product-list ol li.'+thisClass+' h3 a').attr('href');
		//alert('Class = '+thisClass+' Href = '+thisHref);
		window.location.href = (thisHref);
	});

	$('.product-list ol li').hover(
		function(){
			var thisClass = $(this).attr('class');
			thisClass = thisClass.replace('supplier-highlight', '');
			thisClass = thisClass.replace('odd ', '');
			thisClass = thisClass.replace('even ', '');
			var remClass = thisClass.split(' ');
			thisClass = remClass[1];
			var thisHref = $('.product-list ol li.'+thisClass+' h3 a').attr('href');
			$('.product-list ol li.'+thisClass).css({
				background: '#f2f2f2'
			});
			$('.product-list ol li.'+thisClass+' h3 a').css({
				color: '#333333'
			});
		},
		function(){
			var thisClass = $(this).attr('class');
			thisClass = thisClass.replace('supplier-highlight', '');
			thisClass = thisClass.replace('odd ', '');
			thisClass = thisClass.replace('even ', '');
			var remClass = thisClass.split(' ');
			thisClass = remClass[1];		thisClass = remClass[1];
			$('.product-list ol li.'+thisClass).css({
				background: '#ffffff'
			});
			$('.product-list ol li.'+thisClass+' h3 a').css({
				color: ''
			});
	});
	
	//function popUp(URL) {
	//day = new Date();
	//id = day.getTime();
	//eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=760,left = 590,top = 145');");
	//}

	$('.colour-swatches span.swatch').append('<div class="swatch-overlay"></div>');	
	
	var quoteprod = $('#primary h1').html();
	$('<h4>'+quoteprod+'</h4>').insertAfter('#product h3:eq(1)');
	$('<p class="needhelp"><strong>Getting confused? Need help?</strong> Call the Shirtworks Team on <strong>08000725334</strong> or send us a <a href="#" id="hurry" title="Quick Contact">Quick Contact!</a></p>').appendTo('#product form.basket > fieldset');
	$('<div class="basket-bottom"></div>').appendTo('#product form.basket');
	//$('a.proceed-link').text('Submit Quote Request');


	$('a#hurry').click(function(){
	Shadowbox.open({
        content:    "http://www.shirtworks.co.uk/includes/hurry.php",
        player:     "iframe",
        height:     760,
        width:      500
    });
    return false;

	});

	$('#wrapper #enquiry a.proceed-link').text('');
	
	var oldButton = jQuery('form.datamate fieldset.submit input.submit');
    var newButton = oldButton.clone();
    newButton.attr({
		type: 'image',
		src: 'static/images/submit-quote-button.jpg',
		value: '',
		align: 'right'
		});
		newButton.attr("class", "newsubmit");
    newButton.insertBefore(oldButton);
    oldButton.remove();
    newButton.attr("class", "submit");
	
});


