function Show(id){
	alert($("#productimage_"+id).html());
}
$(document).ready(function(){
	/**
	**	ABOUT US
	**/

	//reset profile submenus id
	function resetProfileMenu(){
		$("#profile_html").attr('class','');
		$("#awards_html").attr('class','');
		$("#stores_html").attr('class','');
	}
	
	//reset whats up submenus id
	function resetProfileMenu2(){
		$("#kamiseta-ads_html").attr('class','');
		$("#kamiseta-tv_html").attr('class','');
		$("#vip-cards_html").attr('class','');
	}

	//view profile
	$("#profile_html").live("click", function () {
		resetProfileMenu();
		resetStoreMenu();
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/profile.php");
	});
	
	//view awards
	$("#awards_html").live("click", function () {
		resetProfileMenu();
		resetStoreMenu();
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/awards.php");
	});
	
	//view stores
	$("#stores_html").live("click", function () {
		resetProfileMenu();
		resetStoreMenu();
		$(this).attr('class','mid_nav-on');
		$("#stores_philippines").attr('class','store-on');
		$("#content_container").load("remote/stores.php");
	});
	
	//view kamiseta ads
	$("#kamiseta-ads_html").live("click", function () {
		resetProfileMenu2();
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/kamiseta-ads.php");
	});
	
	//view kamiseta ads
	$("#kamiseta-tv_html").live("click", function () {
		resetProfileMenu2();
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/kamiseta-tv.php");
	});
	
	//view vip
	$("#vip-cards_html").live("click", function () {
		resetProfileMenu2();
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/vip.php");
	});
	

	/**
	**	YOU AND KAMISETA
	**/
	
	//reset profile submenus id
	function resetYouKamisetaMenu(){
		$("#cool-emails_html").attr('class','');
		$("#feedback_html").attr('class','');
		$("#franchise_html").attr('class','');
		$("#mailing-list_html").attr('class','');
		$("#career_html").attr('class','');
	}
	
	//view kamiseta ads
	$("#cool-emails_html").live("click", function () {
		resetYouKamisetaMenu();
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/cool-emails.php");
	});
	
	//view feedback
	$("#feedback_html").live("click", function () {
		resetYouKamisetaMenu();
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/feedback.php");
	});
	
	//reset feedback
	$("#reset_feedback").live("click", function () {
		$("#feedback_name").val('');
		$("#feedback_email").val('');
		$("#feedback_comments").val('');
	});
	
	//submit feedback
	$("#feedback_submit").live("click", function () {
		var name = jQuery.trim($("#feedback_name").val());
		var email = jQuery.trim($("#feedback_email").val());
		var comments = jQuery.trim($("#feedback_comments").val());
		
		if(name.length == 0 || email.length == 0 || comments.length == 0){
			alert('All fields are required');
		}
		else{
			$.get("remote/feedback.php", {action: 'email', name: name, email: email, comments: comments},
			function(data){
				
				if(data == 1)
					alert("Email sent");
				else
					alert("An error was encountered. Please try again later");
			});
		}
	});
	
	//view franchise
	$("#franchise_html").live("click", function () {
		resetYouKamisetaMenu();
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/franchise.php");
	});
	
	//view mailing list
	$("#mailing-list_html").live("click", function () {
		resetYouKamisetaMenu();
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/mailing-list.php");
	});
	
	//subscribe show
	$(".subscribe_show").live("click", function () {
		$("#subscribe_div").draggable();
		$("#subscribe_div").show();
	});
	
	//subscribe hide
	$("#subscribe_hide").live("click", function () {
		$("#subscribe_div").hide();
	});
	
	//subscribe mailing list
	$("#mailing_subscribe").live("click", function () {
		var email = $("#mailing_email").val();
		var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;

		$("#mailing_email").attr("value","");


		if(email.search(emailRegEx) == -1 || email == ''){
			alert('Invalid email format');
		}
		else{
			$.get("remote/mailing-list.php", {email: email, action: 'subscribe'},
			function(data){
				alert('Thank you');
			});
		}
	});

	//unsubscribe mailing list
	$("#mailing_unsubscribe").live("click", function () {
		var email = $("#mailing_email").val();
		var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;

		$("#mailing_email").attr("value","");

		if(email.search(emailRegEx) == -1 || email == ''){	
			alert('Invalid email format');			
		}
		else{
			$.get("remote/mailing-list.php", {email: email, action: 'unsubscribe'},
			function(data){
				alert('Thank you');
			});
		}
	});
	
	//view career html
	$("#career_html").live("click", function () {
		resetYouKamisetaMenu();
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/career.php");
	});
	
	//view graphic artist career
	$("#career_graphic").live("click", function () {
		$(".cr-wb-on").attr('class', '');
		$("#career_graphic").attr('class', 'cr-wb-on');
		$("#popup_graphic").draggable();
		$("#popup_graphic").show();
	});
	
	//close graphic artist career
	$("#popup_graphic_close").live("click", function () {
		$("#popup_graphic").hide();
	});
	
	//view accounting staff career
	$("#career_accounting").live("click", function () {
		$(".cr-wb-on").attr('class', '');
		$("#career_accounting").attr('class', 'cr-wb-on');
		$("#popup_accounting").draggable();
		$("#popup_accounting").show();
	});
	
	//close accounting staff career
	$("#popup_accounting_close").live("click", function () {
		$("#popup_accounting").hide();
	});
	
	//view inventory staff career
	$("#career_inventory").live("click", function () {
		$(".cr-wb-on").attr('class', '');
		$("#career_inventory").attr('class', 'cr-wb-on');
		$("#popup_inventory").draggable();
		$("#popup_inventory").show();
	});
	
	//close inventory staff career
	$("#popup_inventory_close").live("click", function () {
		$("#popup_inventory").hide();
	});
	
	//view final assembly operator career
	$("#career_final").live("click", function () {
		$(".cr-wb-on").attr('class', '');
		$("#career_final").attr('class', 'cr-wb-on');
		$("#popup_final").draggable();
		$("#popup_final").show();
	});
	
	//close final assembly operator career
	$("#popup_final_close").live("click", function () {
		$("#popup_final").hide();
	});
	
	//view popup_patternmaker career
	$("#career_patternmaker").live("click", function () {
		$(".cr-wb-on").attr('class', '');
		$("#career_patternmaker").attr('class', 'cr-wb-on');
		$("#popup_patternmaker").draggable();
		$("#popup_patternmaker").show();
	});
	
	//close popup_patternmaker career
	$("#popup_patternmaker_close").live("click", function () {
		$("#popup_patternmaker").hide();
	});
	
	//view career_encoder career
	$("#career_encoder").live("click", function () {
		$(".cr-wb-on").attr('class', '');
		$("#career_encoder").attr('class', 'cr-wb-on');
		$("#popup_encoder").draggable();
		$("#popup_encoder").show();
	});
	
	//close popup_encoder career
	$("#popup_encoder_close").live("click", function () {
		$("#popup_encoder").hide();
	});
	
	//view career_encoder career
	$("#career_quality").live("click", function () {
		$(".cr-wb-on").attr('class', '');
		$("#career_quality").attr('class', 'cr-wb-on');
		$("#popup_quality").draggable();
		$("#popup_quality").show();
	});
	
	//close popup_patternmaker career
	$("#popup_quality_close").live("click", function () {
		$("#popup_quality").hide();
	});
	
	//view career_merchandising career
	$("#career_merchandising").live("click", function () {
		$(".cr-wb-on").attr('class', '');
		$("#career_merchandising").attr('class', 'cr-wb-on');
		$("#popup_merchandising").draggable();
		$("#popup_merchandising").show();
	});
	
	//close popup_merchandising career
	$("#popup_merchandising_close").live("click", function () {
		$("#popup_merchandising").hide();
	});
	
	//view career_marketing career
	$("#career_marketing").live("click", function () {
		$(".cr-wb-on").attr('class', '');
		$("#career_marketing").attr('class', 'cr-wb-on');
		$("#popup_marketing").draggable();
		$("#popup_marketing").show();
	});
	
	//close popup_marketing career
	$("#popup_marketing_close").live("click", function () {
		$("#popup_marketing").hide();
	});
	
	/**
	** STORES
	**/
	//reset stores submenus id
	function resetStoreMenu(){
		$("#stores_metromanila").attr('class','');
		$("#stores_luzon").attr('class','');
		$("#stores_visayas").attr('class','');
		$("#stores_mindanao").attr('class','');
		$("#stores_indonesia").attr('class','');
		$("#stores_dubai").attr('class','');
		$("#stores_bahrain").attr('class','');
		$("#stores_guam").attr('class','');
	}

	$("#stores_metromanila").live("click", function () {
		resetStoreMenu();
		resetProfileMenu();
		//$(this).attr('class','store-on');
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/stores.php?country=metromanila");
	});
	
	$("#stores_luzon").live("click", function () {
		resetStoreMenu();
		resetProfileMenu();
		//$(this).attr('class','store-on');
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/stores.php?country=luzon");
	});
	
	$("#stores_visayas").live("click", function () {
		resetStoreMenu();
		resetProfileMenu();
		//$(this).attr('class','store-on');
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/stores.php?country=visayas");
	});
	
	$("#stores_mindanao").live("click", function () {
		resetStoreMenu();
		resetProfileMenu();
		//$(this).attr('class','store-on');
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/stores.php?country=mindanao");
	});
	
	$("#stores_indonesia").live("click", function () {
		resetStoreMenu();
		resetProfileMenu();
		//$(this).attr('class','store-on');
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/stores.php?country=indonesia");
	});
	
	$("#stores_dubai").live("click", function () {
		resetStoreMenu();
		resetProfileMenu();
		//$(this).attr('class','store-on');
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/stores.php?country=dubai");
	});
	
	$("#stores_bahrain").live("click", function () {
		resetStoreMenu();
		//$(this).attr('class','store-on');
		$(this).attr('class','mid_nav-on');
		$("#content_container").load("remote/stores.php?country=bahrain");
	});
	
	/**
	** DRESSING ROOM
	**/
	function resetDressingRoom(){
		$(".dressing_room").each(function(){
			$(this).attr('id','');
		});

	}
	
	$(".dressing_room").live("click", function () {
		var id = $(this).attr('title');

		resetDressingRoom();
		$(this).attr('id','mid_nav-on');
				
		if(id == 'mix_match'){
			$(".content_container").load("remote/product_listing.php?id="+id);
			//$(".content_container").load("remote/product_listing.php?id="+id);
			//$(".content_container").load("remote/product_listing.php?id="+id);
			//$(".content_container").load("remote/product_listing.php?id="+id);
		}else{
			$(".content_container").html('<table style="height:350px;align:center;" width="100%"><tr align="center"><td style="vertical-align:middle;align:center;"><img src="images/loader.gif"></td></tr></table>');
			$(".content_container").load("remote/product_listing.php?id="+id);
		}
	});
	
	$(".color_pick").live("click", function () {
		var id = $(this).attr('title');
		//alert($(this).parent().parent().parent().find("#productimage_738").html());
		//alert($("#productimage_738").attr('display'));
		//$(this).parent().parent().parent().parent().find(".products_images").hide();
		$(this).parent().find(".products_images").hide();
		$("#productimage_"+id).show();
		
		//change price display
		//var test = $(this).parent().parent().parent();
		var test = $(this).parent();
		$.get("remote/view_product.php", {action: 'color_price_listing', product_id: id},
			function(data){
				//change price display
				test.find(".listing_price").html(data);
				//alert($(this).parent().html() + '--');
				//alert(test + '----');				
		});
	});
	
	$(".product_color_pick").live("click", function () {
		var id = $(this).attr('title');
		var product_id = $(this).attr('href').split('#');
		var color_id = id.split('_');

		//alert(product_id[1]);
		//reset select options
		$("select").each( function(){
			// set its value to its first option
			$(this).val( $("#" + $(this).attr("id") + " option:first").val() );
		});

		$("#product_id").val(product_id[1]);
		$("#color_id").val(color_id[1]);

		//$(this).parent().parent().parent().parent().find(".product_info_color").hide().attr('disabled','disabled');
		$(this).parent().parent().parent().parent().find(".product_info_color").hide();
		
		//set color text
		//alert($("#product_color").html() + '---' + $(this).parent().parent().parent().parent().find(".product_info_color").html());
		$("#product_color").html("<b>" + $("#color_" + color_id[1]).find(".product_color_name").val() + "</b>");
		
		$("#available_msg").html('');
		//$("#"+id+"2").show().attr('disabled','');
		$("#"+id+"2").show();
		$("#"+id).show();
		
		//change price and description
		$.post("remote/view_product.php", {action: 'color_price', product_id: product_id[1]},
			function(data){

				//alert(data.price + 'price--' + data.converted_price + '--' + data.edescription);
				//update price hidden value
				//$("#price").val(data.price);
				$("#price").attr("value",data.price);

				//update price display
				//$("#price_display").html("<b>" + data.converted_price + "</b>");
				if(data.discount_price != 0){
					//update price & discounted price display	
					$("#price_display").html("Original Price: " + data.converted_price);
					$("#price_discount").html("NOW " + data.discount_price);						
				}else{
					//update price display
					$("#price_display").html("<b>" + data.converted_price + "</b>");
					$("#price_discount").html(" ");
				}
				
				//update description display
				$("#product_description").html(data.edescription);
				
				
		}, "json");
	});
/*
	$(".product_color_pick").live("click", 
	function () {
		var color_id = $(this).attr('title');
		$.get("remote/mailing-list.php", {color_id: color_id},
		function(data){
			
		});
	});
*/	
	/**
	** SHOPPING BAG
	**/
	$('.shopping_bag_link').hover(
		function() { $('table', this).css('display', 'block'); },
		function() { $('table', this).css('display', 'none'); 
	});
	
	$('#add_shopping_bag').live("click", function () {
		
		var id = $("#product_id").val();
		//var size_id = "product_size_id_"+color_id[1];
		var price = $("#price").val();
		var color = $("#color_id").val();
		var size = $("#product_size_id_"+color+" :selected").val();
		var style = $("#style_name").val();

		//var size = $('#'+ id +'[name=size_id]:selected').val();

		/*$("select").each( function(){
			// set its value to its first option
			
			if($("#" + $(this).attr("id") + " option:selected").val() > 0)
				var size = $("#" + $(this).attr("id") + " option:selected").val();
				//alert($("#" + $(this).attr("id") + " option:selected").val());

			if(size.length){
			//alert(color + size + style);
				$.get("remote/shopping_bag.php", {product_id: id, price: price, size: size, color: color, style: style},
				function(data){
					alert("Successfully added to cart");
					$('.shopping_bag_link').load('remote/shopping_bag.php?action=contents');
					//$("#main-content").load("remote/product.php?action=done");
				});
			}
			else{
				alert('Please choose a size');
			}
		});*/
		
		if(size.length > 0){
			
			$.get("remote/shopping_bag.php", {product_id: id, price: price, size: size, color: color, style: style},
				function(data){
				//alert("Successfully added to cart");
				//alert(data);
				//$('.shopping_bag_link').load('remote/shopping_bag.php?action=contents');
				window.location.reload(true);
				//$("#main-content").load("remote/product.php?action=done");
			});
		}
		else{
			alert("Select a size");
		}
	});
	
	//update shopping bag
	$('#update_shopping_bag').live("click", function () {
		
		var id = $("#product_id").val();
		var cart_id = $("#cart_id").val();
		var price = $("#price").val();
		var color = $("#color_id").val();
		var size = $("#product_size_id_"+color+" :selected").val();
		var style = $("#style_name").val();

		if(size.length > 0){
			$.get("remote/shopping_bag.php", {action: 'change', cart_id: cart_id, product_id: id, price: price, size: size, color: color, style: style},
				function(data){
				//$('.shopping_bag_link').load('remote/shopping_bag.php?action=contents');
				document.location.href = 'shopping-bag.php';
			});
		}
		else{
			alert("Select a size");
		}
	});
	
	$("#add_wishlist").live("click", function() {
	
		var id = $("#product_id").val();
		var price = $("#price").val();
		var color = $("#color_id").val();
		var size = $("#product_size_id_"+color+" :selected").val();
		var style = $("#style_name").val();
		
		//alert(id + '--' + price + '--' + color + '--' + size + '--' + style);
		if(size.length > 0){
			window.location.href = "your-account-wish-list.php?color=" + color + "&size=" + size +"&style=" + style;
		}
		else{
			alert("Select a size");
		}
	});
	
	//send to friend show
	$("#send_to_friend").live("click", function () {
		var color = $("#color_id").val();
		var size = $("#product_size_id_"+color+" :selected").val();
		
		if(size.length > 0){
			$("#send_friend_div").draggable();
			$("#send_friend_div").show();
		}else{
			alert("Select a size");
		}
	});
	
	//close send to friend
	$("#send_hide").live("click", function () {
		$("#send_friend_div").hide();
	});
	
	
	$("#send_friend").live("click", function() {
	//
		var id = $("#product_id").val();
		var price = $("#price").val();
		var color = $("#color_id").val();
		var size = $("#product_size_id_"+color+" :selected").val();
		var style = $("#style_name").val();
		
		var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
		var email = $("#mailing_email").val();
		
		if(email.search(emailRegEx) != -1){
			$.get("remote/mailing-list.php", {action: 'send_friend', product_id: id, email: email, size: size, color: color, style: style},function(){
				$("#mailing_email").attr('value', '');
				alert('The item has been emailed to your friend.');
			});
		}else{
			alert("Please enter a valid email address");
		}
	});

	$(".remove_wishlist").live("click", function(){
		var id = $(this).attr('title');
		
		$(".wish_"+id).hide();
	});
	
	/**
	** SHOPPING BAG
	**/
	$("#view_shopping_bag").live("click", function(){
		window.location.href = "shopping-bag.php";
	});
	
	/**
	** HELP SECTION
	**/
	$(".help_menu").live("click", function(){
		var title = $(this).attr('title');
		//reset other ids
		$(".help_menu").attr('id','');
		
		//hide other content
		$("#how_help").hide();
		$("#size_help").hide();
		$("#payment_help").hide();
		$("#shipping_help").hide();
		$("#track_help").hide();
		$("#returns_help").hide();
		$("#privacy_help").hide();
		$("#about_help").hide();
		
		//set id
		$(this).attr('id','hhto-on');
		
		/*if(title == 'how_help'){
			//$("#how_help").load('remote/how-to-order.php');
			$("#how_help").show();
		}
		else if(title == 'size_help'){
			//$(".htto-contentwrap").load('remote/size-chart.php');
			$("#size_help").show();
		}
		else if(title == 'payment_help'){
			$("#payment_help").show();
		}
		else if(title == 'shipping_help'){
			$("#shipping_help").show();
		}
		else if(title == 'track_help'){
			//$("#track_help").load('remote/order-tracking.php');
			$("#track_help").show();
		}
		else if(title == 'returns_help'){
			$(".htto-contentwrap").show();
		}
		else if(title == 'privacy_help'){
			$(".htto-contentwrap").show();
		}
		else if(title == 'about_help'){
			$("#about_help").show();
		}
		else{
			$(".htto-contentwrap").load('remote/how-to-order.php');
		}*/
		$("#"+title).show();
	});
	
	/**
	** USER INFO
	**/
	$(".address_radio").live("change", function(){
		var type = $(this).val();
		var user_id = $("#user_id").val();
		
		if($("#country").attr("value") == "Philippines"){
			$("#international").hide();
			$("#domestic").show();
			$(".state_label").html('PROVINCE/REGION');
		}
		else{
			$("#international").show();
			$("#domestic").hide();
			$(".state_label").html('STATE');
		}
		
		$.get("remote/user_info.php", {type: type, user_id : user_id},
			function(data){
			 //alert(data['first_name']);
			 $("#country").val(data['country']);
			 $("#first_name").val(data['first_name']);
			 $("#last_name").val(data['last_name']);
			 $("#address").val(data['address']);
			 $("#address2").val(data['address2']);
			 $("#city").val(data['city']);
			 $("#state").val(data['state']);
			 $("#postal_code").val(data['postal_code']);
			 $("#phone").val(data['phone']);
			 $("#email").val(data['email']);
		}, "json");
		
		//alert(type);
	});
	
	/**
	** WISH LIST
	**/
	$("#add_another_email").live("click", function(){
		var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
		var error = 0;
		/*var email = $("#wishlist_email").val();
		var user_id = $("#user_id").val();
		
		if(email.search(emailRegEx) == -1){
			alert('Invalid email format');
		}
		else{
			$.get("remote/wishlist.php", {email: email, user_id: user_id},
			function(data){
				if(data == 1){
					window.location.href = 'your-account-wish-list.php';
				}
				else{
					alert('Maximum number of emails reached');
				}
			
			});
		}*/
		$(this).parent().find(':input').each(
		function(i) {
			if(this.name == 'wishlist_email[]'){
				//alert(this.name + " = " + this.value);
				if(this.value.search(emailRegEx) == -1){
					//alert('Please enter valid email addresses only.');
					//return false;
					error = 1;
				}
			}
		});
		
		if(error){
			alert("Enter valid emails first before you can add another email.");
		}
		else{
			if($('#wishlist_emails > input').size() < 5){
				$('#wishlist_emails').append('<input type="text" size="20" value="Enter an email address" onclick="value=\'\'" name="wishlist_email[]"/><br /><br />');
			}
			else{
				alert("Maximum number of emails allowed reached");
			}
		}
	});
	
	$("#wishlist_submit").live("click", function(){
		var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
		var error = 0;
		var count = 0;
	
		//check emails
		$(this).parent().find(':input').each(
		function(i) {
			if(this.name == 'wishlist_email[]'){
				//alert(this.name + " = " + this.value);
				if(this.value.search(emailRegEx) == -1){
					//alert('Please enter valid email addresses only.');
					//return false;
					error = 1;
				}
			}
		});

		//check input this time
		$('.yawl-item-wrap').find(':input').each(
		function(i) {
			if(this.checked){
				count = count + 1;
			}
		});
		
		if(count == 0)
			alert('Please select at least one item from the wishlist.');
		else{
			if(error == 1)
				alert('Please enter valid email addresses only.');
			else
				document.form1.submit();
		}
    });
	
	$(".add_to_bag").live("click", function(){
		var product_id = $(this).attr('title');
		
		$(this).parent().parent().hide();

		$.get("remote/wishlist.php", {product_id: product_id},
		function(data){
			if(data == 1){
				$('.shopping_bag_link').load('remote/shopping_bag.php?action=contents');
			}else{
				alert("Sorry, there is no available stock at this time.");
			}
		
		});
	});
	
	//edit shopping bag
	$(".edit_shopping_cart").live("click", function(){
		var id = $(this).parent().parent().parent().parent().parent().parent().find(".shopping_bag_id").val();
		var product_id = $(this).parent().parent().parent().parent().parent().parent().find(".product_id").val();
		var quantity = $(this).parent().parent().parent().parent().parent().parent().find(".shopping_bag_quantity").val();
		//alert(product_id);
		
		if(isNaN(quantity)){
			alert("Quantity must be a number.");
		}
		else{
		
			$.get("remote/shopping_bag.php", {action: 'update', id: id, product_id: product_id, quantity: quantity},
			function(data){
				//$('.shopping_bag_link').load('remote/shopping_bag.php?action=contents');
				if(data == 1){
					alert('Shopping bag updated.');
					window.location.href = "shopping-bag.php";
				}
				else
					alert('Please enter a lower number for the quantity.');
			});
		}
	});
	
	//edit shopping bag with enter key
	$(".shopping_bag_quantity").keyup(function(e) {
		if(e.keyCode == 13) {											
			var id = $(this).parent().parent().find(".shopping_bag_id").val();
			var product_id = $(this).parent().parent().find(".product_id").val();
			var quantity = $(this).parent().parent().find(".shopping_bag_quantity").val();
			//alert(product_id);
			
			if(isNaN(quantity)){
				alert("Quantity must be a number.");
			}
			else if(quantity < 1){
				alert("Quantity must be greater than 0.");
			}
			else{
			
				$.get("remote/shopping_bag.php", {action: 'update', id: id, product_id: product_id, quantity: quantity},
				function(data){
					//$('.shopping_bag_link').load('remote/shopping_bag.php?action=contents');
					if(data == 1){
						alert('Shopping bag updated.');
						window.location.href = "shopping-bag.php";
					}
					else
						alert('Please enter a lower number for the quantity.');
				});
			}
		}
	});
	
	//add mix match to shopping bag
	$(".add_mixmatch_bag").live("click", function(){
		var title = $(this).attr('title');
		var arr = title.split('_');
		var product_id = arr[0];
		var price = arr[1];
		//var product_id = $(this).attr('title');
		//alert(arr[0] + ' -- ' + arr[1]);
		
		//$.get("remote/shopping_bag.php", {product_id: id, price: price, size: size, color: color, style: style},
		$.get("remote/shopping_bag.php", {action: 'mix_match', product_id: product_id, price: price},
		function(data){
			$('.shopping_bag_link').load('remote/shopping_bag.php?action=contents');
		});
	});
});

function setSize(){
	var size = $(this).attr('value');
	alert(size);
	$("#size_id").val(size);
}

function handleSliderChange(e, ui)
{
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
}

function handleSliderSlide(e, ui)
{
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) });
}