// UTF8‼
$(document).ready(function(){

	// Product Page Add To Order
	$("#v_prd_add").click(function(){
		$.post(v_url_root + "store/cart/index.codebehind.php",$("#addtocartform").serialize()+'&v_action=Add+To+Order',function(data){
			if (typeof data.Message != 'undefined') {
				alert(data.Message);
			}
			if (typeof data.Error == 'undefined') {
				// Display Order Products
				f_ord_prd(data.t_ord_prd);
				// Display Order Total
				f_ord(data.t_ord[0]);
			}
		},"json");
		return false;
	});

	// IE 7+ Only: Product Options Resizing
	if (/MSIE/.test(navigator.userAgent) == true) {
		if (/MSIE\s(5\.5|6\.|7\.)/.test(navigator.userAgent) == true) {
			$("#addtocart select")
			.css({"width":"204px"})
			.focus(function(){
				$(this).css({"width":"auto"});
			})
			.blur(function(){
				$(this).css({"width":"204px"});
			});
			
		} else {
			$("#addtocart select")
				.focus(function(){
					$(this).data("origWidth",$(this).css("max-width")).css({"max-width":"none","width":"auto"});
				})
				.blur(function(){
					$(this).css({"max-width":$(this).data("origWidth")});
				});
		}
	}

	// Product Page Related Items
	$("#product #related .product")
	.css({'cursor':'pointer'})
	.hover(
		function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		}
	)
	.click(function(){
		location.href = $(this).find("a").attr("href");
	});

	// Category Page Products
	$("#category #products .product")
	.append(
		$("<ul />")
			.addClass("nav")
			.hide()
			.append(
				$("<li />").append(
					$("<a />").html("View")
				)
			)
	)
	.css({'cursor':'pointer'})
	.hover(
		function(){
			$(this).addClass("hover").find(".nav").show();
		},function(){
			$(this).removeClass("hover").find(".nav").hide();
		}
	)
	.click(function(){
		location.href = $(this).find("a").attr("href");
	});
	// Replace Font (Exclude IE5&6)
	if (/MSIE\s(5\.5|6\.)/.test(navigator.userAgent) == false) {
		// Render The Text (Cufon.refresh not working with version 2009-07-09)
		Cufon.replace('#category #products .product .nav a',{
			fontFamily:'Myriad Pro'
		})
		//Cufon.refresh('#category .nav a');
	}
});
