$j(document).ready(function(){
	// Rounded corners
	DD_roundies.addRule('#shoppingcart', '15px 15px 0 0', true);
	DD_roundies.addRule('#featured ul a, a.button', '10px', true);
	
	//Fix PNG for IE6
	DD_belatedPNG.fix('.details, .flag, #featuredWrap, #featured ul');
	
	// Search Field
	$j('#search').addClass('inactive');
	$j('#searchQ').val('Search').focus(function(){
		if($j(this).val()=='Search') { $j(this).val(''); }
		$j('#search').removeClass('inactive');
	}).blur(function(){
		if($j(this).val()=='') { $j(this).val('Search'); }
		$j('#search').addClass('inactive');
	});
	
	// Add some style to microformats
	$j('.vcard .tel').prepend('t. ');
	$j('.vcard .fax').prepend('f. ');
	
	// Home Featured Images
	$j('#featured div, #featured ul').removeClass('hide');
	$j("#featured")
		.tabs({fx:{opacity: "toggle"}})
		.mouseover(function(){$j(this).tabs("rotate", 0, true);})
		.mouseout(function(){$j(this).tabs("rotate", 5000, true);})
		.tabs("rotate", 5000, true);
	$j('#featured ul').wrap('<div id="featuredWrap" />');
	$j('#featuredWrap ul').width(($j('#featuredWrap li:last').width()+8)*$j('#featuredWrap li').length);
		
	// Product Page Images
	$j('#productImages div, #productImages ul').removeClass('hide');
	$j('#productImages').tabs({fx:{opacity: "toggle"}});
	
	// Left Nav Accordion
	$j("#styleSearch ul").removeClass('hide');
	$j("#styleSearch").accordion({autoHeight: false,collapsible: true, active: false});
	
	// Fix Page Title
	if(!$$('.catalog-product-view').length && $$('#contentMain > h1').length) {
		$$('#contentMain > h1')[0].update($$('head title')[0].innerHTML);
	}
	
	// Fix Collection Section
	if($j('#navMain .active a').text().toLowerCase()=='collections') {
		if($$('#contentMain > h1').length) {
			$$('#contentMain > h1')[0].update('Collections');
		}
		if($j('#breadcrumb .last').text().toLowerCase()=='jewellery') {
			$j('#breadcrumb .last').text('Collections');
		}
	}
	
	// Add (Product Page) Collection Name
	if($j('.catalog-product-view table #attribute-manufacturer').length) {
		$j('.info .description').append('<p class="collection">' + $j('.catalog-product-view table #attribute-manufacturer th').html() + ': ' + $j('.catalog-product-view table #attribute-manufacturer td').html() + '</p>');
		$j('#contentMain > h1').append(' - ' + $j('.catalog-product-view table #attribute-manufacturer td').text());
	}
	
	// Add (Product Page) Default Quantity
	if($j('.catalog-product-view input#qty').length && $j('.catalog-product-view input#qty').val()=='') {
		$j('.catalog-product-view input#qty').val(1);
	}
	
	// Add (Product Page) Breadcrumb Category
	if($j('.catalog-product-view #productCategories .primary:first').length) {
		$j('.catalog-product-view #breadcrumb li').eq($j(this).length).after('<li>' + $j('.catalog-product-view #productCategories .primary:first').html() + '</li>');
	}

	// Contact Page Form Adjustements
	if($$('.contacts-index-index').length) {
		$('rtype').observe('change', contactFormUpdate);
		$('fname').observe('change', contactFormUpdate);
		$('lname').observe('change', contactFormUpdate);
		$('commentO').observe('change', contactFormUpdate);
	}
	
	// Collection Page Banner Link
	if($$('.catalog-category-view .collectionInfo a').length && $j('.catalog-category-view .collectionInfo a:first').attr('href')!='#') {
		$j('.catalog-category-view .collectionInfo').css('cursor', 'pointer');
		$j('.catalog-category-view .collectionInfo').click(function(){$j.fn.colorbox({href: $j('.catalog-category-view .collectionInfo a').attr('href')});});
	}
	
	// Lightwindow
	$j(".openInside, .collectionInfo a").colorbox({opacity: 0.7});
});

function contactFormUpdate() {
	$('name').setValue($F('fname') + ', ' + $F('lname'));
	$('comment').setValue('Type: ' + $F('rtype') + "\r\nNote:" + $F('commentO'));
}