$(function(){
	text_replace();
	ie6_cart_display();
	ie6_png_fix();
	delete_from_cart();
	add_to_the_cart();
	delete_recommendation();
});
function toggle_the_menu() {
	$('#default-kit-menu').css('display','none');
	$('#kit-save-kit-toggle').css('display','block');
}
function refresh_minicart() {
	var uri = document.location.pathname.substr(1);

	$.post('/minicart'+'/'+new Date().getTime(),{uri:uri},function(data){
		$('#minicart-int').html(data);
	});
}
function delete_from_cart() {
	$('a.product-delete-cart').live('click',function(){
		var href = $(this).attr('href')+'/'+new Date().getTime();
		var uri = document.location.pathname.substr(1);
		$.post(href,{uri:uri},function(data){
			$('#minicart-int').html(data.mp_top);
			if($('#mypilla-saved-kits').length>0)$('#mypilla-saved-kits').html(data.mp_bottom);
			if($('#order-details-area').length>0) refresh_cart();
			if($('#method-form').length>0) shipping_init(); 
		},'json');
		return false;
	});
}
function delete_recommendation() {
	$('a.delete-recommendation').live('click',function(){
		var href = $(this).attr('href')+'/'+new Date().getTime();
		var uri = document.location.pathname.substr(1);
		$.post(href,{uri:uri},function(data){
			$('#mypilla-recommended-display-kits-cart').html(data.minicart);
			if($('#mypilla-recommended-display-kits').length>0)$('#mypilla-recommended-display-kits').html(data.mypilla);
		},'json');
		return false;
	});
}
function add_to_the_cart() {
	$('a.add-to-the-cart').live('click',function(){
		if($(this).hasClass('toggle-cart-add')) toggle_the_menu();
		var href = $(this).attr('href')+'/'+new Date().getTime();
		var uri = document.location.pathname.substr(1);
		$.post(href,{uri:uri},function(data){
			$('#minicart-int').html(data.mp_top);
			if($('#mypilla-saved-kits').length>0)$('#mypilla-saved-kits').html(data.mp_bottom);
		},'json');
		return false;
	});
}
function text_replace() {
	//alert($('#top-menu>li>a'))
	Cufon.replace($('#top-menu>li>a'),{hover:true,textShadow: '1px 1px rgba(255,255,255,1.0)'});
	Cufon.replace($('#mypilla #t-col-left a'),{hover:true});
	Cufon.replace($('#credit-menu>li>a'),{hover:true});
	Cufon.replace($('#tech-pitch-menu span.title'),{fontFamily:'TGW'});
	Cufon.replace($('#nav-block span.title'),{fontFamily:'TGW'});
	Cufon.replace($('.slim-gold'));
	Cufon.replace($('.basic'));
	Cufon.replace($('.gold-gradient'),{color: '-linear-gradient(#d0c281,#a59751)'});
	Cufon.replace($('.silver-gradient'),{color: '-linear-gradient(#ffffff,#999)',fontFamily:'TGW'});
	$(window).load(function(){
		Cufon.now();
	});
}
function ie6_png_fix() {
	if ($('body').hasClass('ie6')) {
		$('body').supersleight({shim:'/public/img/shim.gif'});
	}
}
function ie6_cart_display() {
	if ($('body').hasClass('ie6')) {
		$('#cart-container').hover(function(){
			$('#cart-cnt').css('display','block');
		},function(){
			$('#cart-cnt').css('display','none');
		});
		$('#mypilla-container').hover(function(){
			$('#mypilla-cart-cnt').css('display','block');
		},function(){
			$('#mypilla-cart-cnt').css('display','none');
		});
	}
}