// JavaScript Document

		var defaultLandingPage = "login-form";
		
		var nowSituation = getPageShow();
		var nextSituation;
		
		var member_timeout = 20 * 60 * 1000;
		
		var liveTimer;
		var totalWaitLiveTime = 10000;
		
		
		var outletAccessTimer;
		
		var mins = 5;
		var seconds = 0;
		
		var currentMemberPic;
		
		$(window).load(function() {
			$('#loading-bar-container').fadeOut(300);
			$('#loading-bar-Box').fadeOut(300);
		});
		
		$(document).ready(function() {
		
			//User thumbnail Event
			accInit();
			
			check_user_login();
			
			gen_information();
			//setInterval(gen_information, 1000);
			
			// Check User active or not
			$(document).bind("idle.idleTimer", function(){
				if (window.location.hash != "" && window.location.hash != "#") {
					logoutBtnClickHandler();
				}
			});
			
			$('.user-thumbnail').css('cursor','pointer');
			
			$.idleTimer(member_timeout);
			
		});
		
		function check_outlet_access() {
			if (window.location.hash != "" && window.location.hash != "#loading" && window.location.hash != "#checkout" && window.location.hash != "#thank") {
				$.ajax({
					 type: "GET",
					 url: './json/get_outlet_time.json.php',
					 data: { action: "accessOutlet" }, 
					 async: false,
					 beforeSend: function(x) {
					  if(x && x.overrideMimeType) {
					   x.overrideMimeType("application/j-son;charset=UTF-8");
					  }
				 },
				 dataType: "json",
				 success: function(data){
					if (data.blnOutletAccess) {
						
						outletAccessTimer = setInterval(outletBtnClickHandler, data.rand_time);
						
					}
				 }
				});				
				/*$.getJSON('./json/get_outlet_time.json.php', { action: "accessOutlet" }, function(data) {
					if (data.blnOutletAccess) {
						
						outletAccessTimer = setInterval(outletBtnClickHandler, data.rand_time);
						
					}
				});*/
			}
		}	
			
		function return_json(value) {
			if (typeof (JSON) !== 'undefined' && typeof (JSON.parse) === 'function')
			  return JSON.parse(value);
			else
			  return eval('(' + value + ')');
		}
		
		function check_user_login() {
			if (window.location.hash != "") {
				$.ajax({
					 type: "GET",
					 url: './json/check_login.json.php',
					 data: { action: "check_login" }, 
					 async: false,
					 beforeSend: function(x) {
					  if(x && x.overrideMimeType) {
					   x.overrideMimeType("application/j-son;charset=UTF-8");
					  }
				 },
				 dataType: "json",
				 success: function(data){
					if (!data.check_login) {
						window.location = 'index.php';
					} else {
						if (!data.isMemberExpired) {
							if (data.login_member.profilePicPath != '') {
								//alert('testing');
								$('.user-thumbnail').attr('src', 'member/t/'+data.login_member.profilePicPath);
								$('#thumbnail_s').attr('src', 'member/s/'+data.login_member.profilePicPath);
							} else {
								$('.user-thumbnail').attr('src', 'img/store/thumbnail.jpg');
								$('#thumbnail_s').attr('src', 'img/store/thumbnail_s.jpg');
							}
							$('.user-name').text(data.login_member.username+" 's cart");
							$('#thank_email').html(data.login_member.email);
							$('#thank_email').fadeIn(300);
						} else {
							window.location = 'index.php';
						}
					}
				 }
				});				
				/*$.getJSON('./json/check_login.json.php', { action: "check_login" }, function(data) {
					if (!data.check_login) {
						window.location = 'index.php';
					} else {
						if (!data.isMemberExpired) {
							if (data.login_member.profilePicPath != '') {
								//alert('testing');
								$('.user-thumbnail').attr('src', 'member/t/'+data.login_member.profilePicPath);
								$('#thumbnail_s').attr('src', 'member/s/'+data.login_member.profilePicPath);
							} else {
								$('.user-thumbnail').attr('src', 'img/store/thumbnail.jpg');
								$('#thumbnail_s').attr('src', 'img/store/thumbnail_s.jpg');
							}
							$('.user-name').text(data.login_member.username+" 's cart");
							$('#thank_email').html(data.login_member.email);
							$('#thank_email').fadeIn(300);
						} else {
							window.location = 'index.php';
						}
					}
				});*/
			}
		}	
			
		function gen_information() {
			if (window.location.hash != "") {
				$.ajax({
					 type: "GET",
					 url: './json/gen_shoping_cart.json.php',
					 async: false,
					 beforeSend: function(x) {
					  if(x && x.overrideMimeType) {
					   x.overrideMimeType("application/j-son;charset=UTF-8");
					  }
				 },
				 dataType: "json",
				 success: function(data){
					if (data.ShippingInfo !== undefined) {
						$('#bill_fullName').html(data.ShippingInfo.fullName);
						$('#bill_address').html(data.ShippingInfo.address);
						$('#bill_city').html(data.ShippingInfo.city);
						$('#bill_zip').html(data.ShippingInfo.zip);
						$('#bill_state').html(data.ShippingInfo.state);
						$('#bill_country').html(data.ShippingInfo.country);
						$('#bill_contactno').html(data.ShippingInfo.contactno);
						$('#bill_email').html(data.ShippingInfo.email);
					}
				 }
				});				
				/*$.getJSON('./json/gen_shoping_cart.json.php', function(data) {
					if (data.ShippingInfo !== undefined) {
						$('#bill_fullName').html(data.ShippingInfo.fullName);
						$('#bill_address').html(data.ShippingInfo.address);
						$('#bill_city').html(data.ShippingInfo.city);
						$('#bill_zip').html(data.ShippingInfo.zip);
						$('#bill_state').html(data.ShippingInfo.state);
						$('#bill_country').html(data.ShippingInfo.country);
						$('#bill_contactno').html(data.ShippingInfo.contactno);
						$('#bill_email').html(data.ShippingInfo.email);
					}
				});*/
				
				$.get('./gen_content/gen_cart_row.php', {shop_mode:"store"}, function(data) {
					
					//store
					$('div#cart_table_div').html(data);
					$("#cart_table_div table.cart_row img.store_remove_btn").unbind();
					$("#cart_table_div table.cart_row img.store_remove_btn").click(function () {
						removeFromCart(this);
					});
					$("#cart_table_div table.cart_row input#store_qty").unbind();
					$("#cart_table_div table.cart_row input#store_qty").change(function () {
						updateProducPriceFromCart(this);
					});
					
					if ($('#cart_table_div table.cart_row').length > 8) {
						$('#cart_table_div').css('height', '264px');
						$('#store_arrow').css('display', 'block');
					} else {
						$('#cart_table_div').css('height', 'auto');
						$('#store_arrow').css('display', 'none');
					}
					//checkout
					$('div#checkout_table_div').html(data);
					$("div#checkout_table_div table.cart_row img.store_remove_btn").unbind();
					$("div#checkout_table_div table.cart_row img.store_remove_btn").click(function () {
						removeFromCheckout(this);
					});
					$("#checkout_table_div table.cart_row input#store_qty").unbind();
					$("#checkout_table_div table.cart_row input#store_qty").change(function () {
						updateProducPriceFromCheckout(this);
					});
					if ($('#checkout_table_div table.cart_row').length > 8) {
						$('#checkout_table_div').css('height', '264px');
						$('#checkout_arrow').css('display', 'block');
					} else {
						$('#checkout_table_div').css('height', 'auto');
						$('#checkout_arrow').css('display', 'none');
					}
					//update total price
					calStoreTotalPrice();
					//getSubTotal();
					//getShippingFee();
					//getTotal();
				});
			}
		}
		
		function calStoreTotalPrice() {
			if (window.location.hash != "") {
				$.ajax({
					 type: "GET",
					 url: './json/get_total.json.php',
					 data: {action:'updateTotal', shop_mode:"store"},
					 async: false,
					 beforeSend: function(x) {
					  if(x && x.overrideMimeType) {
					   x.overrideMimeType("application/j-son;charset=UTF-8");
					  }
				 },
				 dataType: "json",
				 success: function(data){
					$('#cart_subtotal').html("$"+data.sub_total);								 
					$('#checkout_subtotal').html("$"+data.sub_total);					 
					$('#checkout_shippingFee').html(data.shipping_fee);
					$('#shipping_fee_needed').html(data.shipping_fee_need);
					$('#checkout_total').html("$"+data.total);					 
				 }
				});				
			}
		}
		
		function getSubTotal() {
			if (window.location.hash != "") {
				$.ajax({
					 type: "GET",
					 url: './json/get_total.json.php',
					 data: {action:'subtotal', shop_mode:"store"},
					 async: false,
					 beforeSend: function(x) {
					  if(x && x.overrideMimeType) {
					   x.overrideMimeType("application/j-son;charset=UTF-8");
					  }
				 },
				 dataType: "json",
				 success: function(data){
					$('#cart_subtotal').html("$"+data.sub_total);								 
					$('#checkout_subtotal').html("$"+data.sub_total);					 
				 }
				});				
				/*$.getJSON('./json/get_total.json.php', {action:'subtotal', shop_mode:"store"}, function(data) {
					$('#cart_subtotal').html("$"+data.sub_total);								 
					$('#checkout_subtotal').html("$"+data.sub_total);					 
				});*/
			}
		}
			
		function getShippingFee() {
			if (window.location.hash != "") {
				$.ajax({
					 type: "GET",
					 url: './json/get_total.json.php',
					 data: {action:'shippingFee', shop_mode:"store"},
					 async: false,
					 beforeSend: function(x) {
					  if(x && x.overrideMimeType) {
					   x.overrideMimeType("application/j-son;charset=UTF-8");
					  }
				 },
				 dataType: "json",
				 success: function(data){
					$('#checkout_shippingFee').html(data.shipping_fee);
					$('#shipping_fee_needed').html(data.shipping_fee_need);
				 }
				});				
				/*$.getJSON('./json/get_total.json.php', {action:'shippingFee', shop_mode:"store"}, function(data) {
					$('#checkout_shippingFee').html(data.shipping_fee);
					$('#shipping_fee_needed').html(data.shipping_fee_need);
				});*/
			}
		}
			
		function getTotal() {
			if (window.location.hash != "") {
				$.ajax({
					 type: "GET",
					 url: './json/get_total.json.php',
					 data: {action:'total', shop_mode:"store"},
					 async: false,
					 beforeSend: function(x) {
					  if(x && x.overrideMimeType) {
					   x.overrideMimeType("application/j-son;charset=UTF-8");
					  }
				 },
				 dataType: "json",
				 success: function(data){
					$('#checkout_total').html("$"+data.total);					 
				 }
				});				
				/*$.getJSON('./json/get_total.json.php', {action:'total', shop_mode:"store"}, function(data) {
					$('#checkout_total').html("$"+data.total);					 
				});*/
			}
		}
			
		function divShow(id) {$(id).fadeIn(300);}
		
		function divHidden(id) {$(id).fadeOut(300);}
		
		function btnDivShow(id) {$('#'+nowSituation+'-container '+id).fadeIn(300);}
		
		function btnDivHidden(id) {$('#'+nowSituation+'-container '+id).fadeOut(300);}
			
		function getPageShow() {
			
			var startIndex = window.location.href.indexOf('#', 0) + 1;
			
			if (startIndex > 0) {
			
				var lengthOfPage = window.location.href.length - startIndex;
				
				var getPage = window.location.href.substr(startIndex, lengthOfPage);
				
				if (getPage == "") {
					getPage = defaultLandingPage;
				}
				
			} else {
				getPage = defaultLandingPage;
			}
			
			if (getPage == "store" || getPage == "checkout" || getPage == "about" || getPage == "support" || getPage == "contact" || getPage == "terms" || getPage == "privacy" || getPage == "return" || getPage == "loading") {
				if (getPage == "checkout") {
					$('#storeBtn .grey-btn').css('display','none');
					$('#storeBtn .white-btn').css('display','block');
					$('#storeBtn').css({right: '465px', width: '120px'});
					$('#store-title').css('display','block');
				}
				if (getPage != "checkout") {
					$('#'+getPage+'Btn .grey-btn').css('display','none');
					$('#'+getPage+'Btn .white-btn').css('display','block');
					$('#'+getPage+'Btn').css({right: '465px', width: '120px'});
					$('#'+getPage+'-title').css('display','block');
				}
				$('#mid-btn').css('display','block');
			}
					
			return getPage;
					
		}

		function sizeChartEvent() {
			window.open('pdf/sizing_4A.pdf', '_blank');
			window.moveTo(0,0);
		}

		//login init set Event -------------------------
		
		function loginInit() {
			
			  idCounter = 0;
			  passCounter = 0;
			  loginCounter = 0;
			  
			  clearInterval(idTimer);
			  clearInterval(passTimer);
			  clearInterval(loginTimer);
			  
			  $('#user-id').unbind();
			  $('#user-pass').unbind();
			
			  $("#username_btn").hide();
			  $("#create-account-btn").hide();
			  $("#create-account-btn-over").hide();
			  $('#user-pass').hide();
			  $('#submitbtn').hide();
			  $('#submitbtn_wd').hide();
			  $('#submitbtn_wd_ro').hide();
			  $('#password-btn').hide();
			  $('#lost-password-btn').hide();
			  $('#lost-password-btn-over').hide();
			  $('#login_info-box').hide();
			  $('#login_error-box').hide();
			  $('#logo-ng').hide();
			  
//				$('input').bind('keydown', function (e) {
//					if(e.keyCode == 9) {
//						return false;
//					}
//				});
//			  			  
//				//Login Page//
//				$('#user-id').bind('keydown', function (e) {
//					if(e.keyCode == 13) {
//						$('#user-pass').focus();
//					}
//				});
				
		}
		
		//Account Event Handler ----------------------
		
		function accInit() {
			
			var accBoxDiv = nowSituation;
			
			if (nowSituation == 'support') {
				accBoxDiv = 'question';
			}
			
			$('#'+accBoxDiv+'-container img#thumbnail').bind('mouseover', function() {
			   if ($('#'+accBoxDiv+'-container div#user-pw-box').css('display') == "none") {
					divShow('#'+accBoxDiv+'-container div#user_hint3');
			   }
			});
			
			$('#'+accBoxDiv+'-container img#thumbnail').bind('mouseout', function() {
			   //if ($('#'+accBoxDiv+'-container div#user-pw-box').css('display') == "block") {
					divHidden('#'+accBoxDiv+'-container div#user_hint3');
			   //}
			});
			
			$('#'+accBoxDiv+'-container img#thumbnail').bind('click', function() {
			   divShow('#'+accBoxDiv+'-container div#user-pw-box');
				divHidden('#'+accBoxDiv+'-container div#user_hint3');
				divShow('#'+accBoxDiv+'-container div#user_hint1');
				$('#'+accBoxDiv+'-container img#deny_btn_ro').css('display', 'none');
			});
			
//			$('#'+accBoxDiv+'-container div#user_hint3').bind('click', function() {
//				divShow('#'+accBoxDiv+'-container div#user-pw-box');
//				divHidden('#'+accBoxDiv+'-container div#user_hint3');
//				divShow('#'+accBoxDiv+'-container div#user_hint1');
//				$('#'+accBoxDiv+'-container img#deny_btn_ro').css('display', 'none');
//			});
		
//			$('#'+accBoxDiv+'-container div#user_hint3').bind('mouseover', function() {
//				$('#'+accBoxDiv+'-container div#user_hint3').bind('mouseout', function() {
//					$('#'+accBoxDiv+'-container div#user_hint3').fadeOut(300, function() {
//						$('#'+accBoxDiv+'-container div#user_hint3').unbind('mouseout');
//					});
//				});
//			});
		
			$('#'+accBoxDiv+'-container img#deny_btn_ro').bind('click', function() {
				divHidden('#'+accBoxDiv+'-container div#user_hint1');
				divHidden('#'+accBoxDiv+'-container div#user_hint2');
				divHidden('#'+accBoxDiv+'-container div#user_hint3');
				divHidden('#'+accBoxDiv+'-container div#user-pw-box');
				$('#'+accBoxDiv+'-container input#user-pw-box').val('');
				$('#'+accBoxDiv+'-container img#deny_btn_ro').css('display', 'none');
			});
			
			//alert(accBoxDiv);
		}
		

	//-------------------------------tandcBtnClickHandler--------------------------------
	var changeContainerMoveSetIntervalHandler;
	function changeBackToStoreBtnClickHandler(){
		$.ajax({
			 type: "GET",
			 url: './json/update_lock.json.php',
			 async: false,
			 beforeSend: function(x) {
			  if(x && x.overrideMimeType) {
			   x.overrideMimeType("application/j-son;charset=UTF-8");
			  }
		 },
		 dataType: "json",
		 success: function(data){
			changeBtnClickHandler('store');
		 }
		});				
	}

	function changeBtnClickHandler(setNextSituation){
		if (moveFlag == false) {
			moveFlag = true;
			nextSituation = setNextSituation;
			
			if (nowSituation == "store" || nowSituation == "checkout" || nowSituation == "about" || nowSituation == "support" || nowSituation == "contact") {
				if (nowSituation == "checkout") {
					$('#w-store-title').fadeOut(300);
					$('#storeBtn').delay(300).animate({width: '40px',right: '545px'}, 200);
					$('#storeBtn .grey-btn #'+nowSituation+'-title').css('display','none');
					$('#storeBtn .grey-btn').css('display','block');
					$('#storeBtn .white-btn').css('display','none');
				}
				if (nowSituation != "checkout") {
					$('#w-'+nowSituation+'-title').fadeOut(300);
					$('#'+nowSituation+'Btn').delay(300).animate({width: '40px',right: '545px'}, 200);
					$('#'+nowSituation+'Btn .grey-btn #'+nowSituation+'-title').css('display','none');
					$('#'+nowSituation+'Btn .grey-btn').css('display','block');
					$('#'+nowSituation+'Btn .white-btn').css('display','none');
				}
				if (nowSituation == "store") {
					$('#sizeBtn').animate({top: '558px', height: '23px'}, 200);
					$('#colorBtn').animate({top: '558px', height: '23px'}, 200);
					$('#brandBtn').animate({top:'16px', height: '23px'}, 200);
					$('#typeBtn').animate({top:'16px', height: '23px'}, 200);
				}
				if (nowSituation == "contact") {
					$('#contact_thankyou').fadeOut(300);
					$('#contact_email_invalid').fadeOut(300);
					$('#contact_name_ro').fadeOut(300);
					$('#contact_email_ro').fadeOut(300);
					$('#contact_subject_ro').fadeOut(300);
					$('#contact_content_ro').fadeOut(300);
					$('#contact_missing').fadeOut(300);
					$('#contact_msg').fadeOut(300);
				}
			
			}
			
			window.location = '#'+nextSituation;

			if (nowSituation != 'thank') {
				$('#'+nowSituation+'-container').animate({
					top: '-600px'
				}, 500);
			} else {
				var stageHeight = document.documentElement.clientHeight;
				$('#thank-container').animate({
					top: '-'+stageHeight+'px'
				}, 500);
			}
			changeContainerMoveSetIntervalHandler = setInterval(changeContainerFadeOutCompHandler, 900);
		}
	}
	
	
	function changeContainerFadeOutCompHandler(){
		
		$('#'+nowSituation+'-container #terms_brn_ro').css('display', 'none');
		$('#'+nowSituation+'-container #privacy_brn_ro').css('display', 'none');
		$('#'+nowSituation+'-container #returns_brn_ro').css('display', 'none');
		
		clearInterval( changeContainerMoveSetIntervalHandler );
		document.getElementById( nowSituation+"-container" ).style.display = "none";
		
		if (nextSituation == 'checkout') {
			$('#acc_for_store').css('display', 'block');
			$('#acc_for_outlet').css('display', 'none');
		}
		
		if (nowSituation == 'thank') {
			$('#mid-btn').fadeIn(300);
			getProduct(false);
		}
		
		//about
		document.getElementById( nextSituation+"-container" ).style.top = String( -620 ) + "px";
		document.getElementById( nextSituation+"-container" ).style.display = "block";
		var stageHeight = document.documentElement.clientHeight;
		var containerY = ( stageHeight - 600) / 2;
		$('#'+nextSituation+'-container').animate({top: containerY + 'px' }, 500);
		changeContainerMoveSetIntervalHandler = setInterval(changeContainerFadeInCompHandler, 510);
	}
	
	
	function changeContainerFadeInCompHandler(){
		moveFlag = false;
		nowSituation = nextSituation;
		clearInterval( changeContainerMoveSetIntervalHandler );
		
		if (nowSituation == "loading") {
			$('#checkout_iframe').attr('src', 'checkout_form.php');
		}
		
		if (nowSituation == "store" || nowSituation == "checkout" || nowSituation == "about" || nowSituation == "support" || nowSituation == "contact") {
			if (nowSituation == "checkout") {
				$('#storeBtn .grey-btn').css('display','none');
				$('#storeBtn .white-btn').css('display','block');
				$('#storeBtn').animate({right: '465px', width: '120px'}, 200);
				$('#w-store-title').fadeIn(300);
			}
			
			if (nowSituation == "store" || nowSituation == "checkout" || nowSituation == "support") {
				accInit();
			}
			
			if (nowSituation != "checkout") {
				$('#'+nowSituation+'Btn .grey-btn').css('display','none');
				$('#'+nowSituation+'Btn .white-btn').css('display','block');
				$('#'+nowSituation+'Btn').animate({right: '465px', width: '120px'}, 200);
				$('#w-'+nowSituation+'-title').fadeIn(300);
			}
			if (nowSituation == "support") {
				liveTimer = setInterval(genLiveSupport, totalWaitLiveTime);
			} else {
				genLiveSupport();
				clearInterval(liveTimer);
			}
		}
		
	}
	
	//-------------------------------tandcBtnClickHandler--------------------------------
	var outletContainerMoveSetIntervalHandler;
	function outletBtnClickHandler() {
		if (moveFlag == false) {
			moveFlag = true;
			
			if (nowSituation == "checkout") {
				$('#store-title').fadeOut(300);
				$('#storeBtn').delay(300).animate({width: '40px',right: '545px'}, 200, function(){
					$('#storeBtn').fadeOut(300);
					$('#aboutBtn').fadeOut(300);
					$('#contactBtn').fadeOut(300);
					//$('#supportBtn').fadeOut(300);
				});
				$('#storeBtn .grey-btn #'+nowSituation+'-title').css('display','none');
				$('#storeBtn .grey-btn').css('display','block');
				$('#storeBtn .white-btn').css('display','none');
			}
			if (nowSituation != "checkout") {
				$('#'+nowSituation+'-title').fadeOut(300);
				$('#'+nowSituation+'Btn').delay(300).animate({width: '40px',right: '545px'}, 200, function(){
					$('#storeBtn').fadeOut(300);
					$('#aboutBtn').fadeOut(300);
					$('#contactBtn').fadeOut(300);
					//$('#supportBtn').fadeOut(300);
				});
				$('#'+nowSituation+'Btn .grey-btn #'+nowSituation+'-title').css('display','none');
				$('#'+nowSituation+'Btn .grey-btn').css('display','block');
				$('#'+nowSituation+'Btn .white-btn').css('display','none');
			}
			
			nextOutletCheck = 'outlet';
			
			$('#checkout-container #terms_btn').css('display', 'none');
			$('#checkout-container #privacy_btn').css('display', 'none');
			$('#checkout-container #returns_btn').css('display', 'none');
			$('#checkout-container #terms_btn_ro').css('display', 'none');
			$('#checkout-container #privacy_btn_ro').css('display', 'none');
			$('#checkout-container #returns_btn_ro').css('display', 'none');
			
			$('#'+nowSituation+'-container').animate({
				top: '-600px'
			}, 500);
			outletContainerMoveSetIntervalHandler = setInterval(outletContainerFadeOutCompHandler, 900);
		}
	}
	
	
	function outletContainerFadeOutCompHandler() {
		
		$('#'+nowSituation+'-container #terms_brn_ro').css('display', 'none');
		$('#'+nowSituation+'-container #privacy_brn_ro').css('display', 'none');
		$('#'+nowSituation+'-container #returns_brn_ro').css('display', 'none');
		
		clearInterval( outletContainerMoveSetIntervalHandler );
		document.getElementById( nowSituation+"-container" ).style.display = "none";

		gen_outlet_information();
		genUnwishList();

		//about
		document.getElementById( "outlet-confirm-container" ).style.top = String( -620 ) + "px";
		document.getElementById( "outlet-container" ).style.top = String( -620 ) + "px";
		document.getElementById( "outlet-confirm-container" ).style.display = "block";
		document.getElementById( "outlet-container" ).style.display = "block";
		var stageHeight = document.documentElement.clientHeight;
		var containerY = ( stageHeight - 600) / 2;
		$('#outlet-confirm-container').animate({top: '0px' }, 500);
		$('#outlet-container').animate({top: containerY + 'px' }, 500);
		outletContainerMoveSetIntervalHandler = setInterval(outletContainerFadeInCompHandler, 510);
	}
	
	
	function outletContainerFadeInCompHandler() {
		moveFlag = false;
		clearInterval( outletContainerMoveSetIntervalHandler );
		clearInterval( outletAccessTimer );
		$('#outlet-messageBox').fadeIn(300);
		$.get('./json/update_outlet_accesstime.json.php', {action:"updateAccessTime"});
	}
	

	/*--------------------------EditProfileEventHandler-----------------------------*/
	
	function editProfileBtnClickHandler(){

		var accBoxDiv = nowSituation;
		
		if (nowSituation == 'support') {
			accBoxDiv = 'question';
		}

		divHidden('#'+accBoxDiv+'-container #user_hint1');
		divHidden('#'+accBoxDiv+'-container #user_hint2');
		divHidden('#'+accBoxDiv+'-container #user_hint3');
		
		
		if ($('#'+accBoxDiv+'-container input#user-pw-box').val() == "") {
			
			divShow('#'+accBoxDiv+'-container #user_hint1');
			
		} else {
			
			$.ajax({
			  type: 'POST',
			  url: './json/check_password.json.php?action=edit_login',
			  dataType: 'json',
			  data: { password: $('#'+accBoxDiv+'-container input#user-pw-box').val()},
			  success: function(data) {
				if (data.login_success) {
					editProfilePasswordSuccess();
				} else {
					editProfilePasswordFailed();
				}
			  }
			});
		
		}
		
	}
	
	function editProfilePasswordSuccess() {
		
		var accBoxDiv = nowSituation;
				
		divHidden('#'+accBoxDiv+'-container div#user-pw-box');
		$('#'+accBoxDiv+'-container input#user-pw-box').val('');
		$('#'+accBoxDiv+'-container img#confirm_brn_ro').css('display', 'none');
		
		resetEditForm();
		
		var heighY = parseInt(document.getElementById( "edit-container" ).style.height);
		
		document.getElementById("edit-container").style.top = String(-heighY)+"px";
		document.getElementById("edit-container").style.display = "block";
		$('#edit-container').animate({top:0},600);
		setEditProfileIntervalHandler = setInterval(setEditProfileIntervalCompHandler, 500);
				
	}
	
	function setEditProfileIntervalCompHandler(){
		clearInterval( setEditProfileIntervalHandler );
		
	}

	function editProfilePasswordFailed() {
		
		var accBoxDiv = nowSituation;
		
		divShow('#'+accBoxDiv+'-container #user_hint2');
				
	}
	
	function resetEditForm() {
		$.ajax({
			 type: "GET",
			 url: './json/get_member.json.php',
			 async: false,
			 beforeSend: function(x) {
			  if(x && x.overrideMimeType) {
			   x.overrideMimeType("application/j-son;charset=UTF-8");
			  }
		 },
		 dataType: "json",
		 success: function(data){
			$('#Euser-box2').html(data.username);
			$('#Epoint-box2').html(data.memberPoint);
			$('#Epw-inputbox').val('');
			$('#ECpw-inputbox').val('');
			$('#Eemail-inputbox').val(data.email);
			$('#Ephone-inputbox').val(data.contactno);
			$('#Eadd1-inputbox').val(data.address_1);
			$('#Eadd2-inputbox').val(data.address_2);
			$('#Ecity-inputbox').val(data.city);
			$('#Ezip-inputbox').val(data.zip);
			$('#Estate-inputbox').val(data.state);
			$('#Ecountry-inputbox').val(data.countryId);
			$('#Ebday-inputbox').val(data.birthYear+"/"+data.birthMonth+"/"+data.birthDay);
			$('#Egender-inputbox').val(data.gender);
			//$('#edit-pickfile-btn-orange').fadeIn(300);
			$('#edit-pickfile-btn-grey').fadeIn(300);
			//$('#edit-uploaded-photo-box').css('display', 'none');
			
			//alert(data.profilePicPath);
			
			if (data.profilePicPath != '') {
				//$('#edit-default-btn').css('display', 'block');
				//$('#edit-default-btn-ro').css('display', 'none');
				$('#edit-uploded-photo img').attr('src', 'member/m/'+data.profilePicPath+ "?" + Math.random());
			} else {
				//$('#edit-default-btn').css('display', 'none');
				//$('#edit-default-btn-ro').css('display', 'none');
				$('#edit-uploded-photo img').attr('src', 'img/reg_form/uploaded_photo.gif');
			}
			
			$('#edit-deny-btn').css('display', 'none');
			$('#edit-deny-btn-ro').css('display', 'none');
			
			currentMemberPic = data.profilePicPath;
			//$('#edit-uploded-photo-confirm').attr('checked', false);
			//$('#edit-uploded-photo-confirm').dgUncheck('#edit-uploded-photo-confirm-span');
		 }
		});				
		/*$.getJSON('./json/get_member.json.php', function(data) {
			$('#Euser-box2').html(data.username);
			$('#Epoint-box2').html(data.memberPoint);
			$('#Epw-inputbox').val('');
			$('#ECpw-inputbox').val('');
			$('#Eemail-inputbox').val(data.email);
			$('#Ephone-inputbox').val(data.contactno);
			$('#Eadd1-inputbox').val(data.address_1);
			$('#Eadd2-inputbox').val(data.address_2);
			$('#Ecity-inputbox').val(data.city);
			$('#Ezip-inputbox').val(data.zip);
			$('#Estate-inputbox').val(data.state);
			$('#Ecountry-inputbox').val(data.countryId);
			$('#Ebday-inputbox').val(data.birthYear+"/"+data.birthMonth+"/"+data.birthDay);
			$('#Egender-inputbox').val(data.gender);
			//$('#edit-pickfile-btn-orange').fadeIn(300);
			$('#edit-pickfile-btn-grey').fadeIn(300);
			//$('#edit-uploaded-photo-box').css('display', 'none');
			
			//alert(data.profilePicPath);
			
			if (data.profilePicPath != '') {
				//$('#edit-default-btn').css('display', 'block');
				//$('#edit-default-btn-ro').css('display', 'none');
				$('#edit-uploded-photo img').attr('src', 'member/m/'+data.profilePicPath+ "?" + Math.random());
			} else {
				//$('#edit-default-btn').css('display', 'none');
				//$('#edit-default-btn-ro').css('display', 'none');
				$('#edit-uploded-photo img').attr('src', 'img/reg_form/uploaded_photo.gif');
			}
			
			$('#edit-deny-btn').css('display', 'none');
			$('#edit-deny-btn-ro').css('display', 'none');
			
			currentMemberPic = data.profilePicPath;
			//$('#edit-uploded-photo-confirm').attr('checked', false);
			//$('#edit-uploded-photo-confirm').dgUncheck('#edit-uploded-photo-confirm-span');
		});*/
	}
	
	/*--------------------------LogoutEventHandler-----------------------------*/

	function thankLogoutBtnClickHandler(){
		if (moveFlag == false) {
			
			$.ajax({
				 type: "GET",
				 url: './json/delete_lock.json.php',
				 async: false,
				 beforeSend: function(x) {
				  if(x && x.overrideMimeType) {
				   x.overrideMimeType("application/j-son;charset=UTF-8");
				  }
			 },
			 dataType: "json",
			 success: function(data){
				moveFlag = true;
				
				var stageHeight = document.documentElement.clientHeight;
				$('#thank-container').animate({
					top: '-'+stageHeight+'px'
				}, 500, function() {logoutBtnClickHandler();});
			 }
			});				
		}
	}

	function logoutBtnClickHandler(){
		
		loginInit();
		
		var heighY = parseInt(document.getElementById( "login-form-container" ).style.height);
		
		//var heighY = 694;
		
		document.getElementById("login-form-container").style.top = String(-heighY)+"px";
		document.getElementById("login-form-container").style.display = "block";
		//var targetY = String(document.documentElement.clientHeight) + "px";
		$('#login-form-container').animate({top:0},600);
		setLogoutIntervalHandler = setInterval(setLogoutIntervalCompHandler, 500);
		
	}
	
	function setLogoutIntervalCompHandler(){
		clearInterval( setLogoutIntervalHandler );
		document.getElementById(nowSituation+"-container").style.display = "none";
		if ($('#outlet-container').css('display') == "block") {
			$("#outlet-container").css('display', 'none');
		}
		$('#mid-btn').css('display','none');
		nowSituation = "login-form";
		
		$('#storeBtn').css({right: '465px', width: '120px'});
		$('#store-title').css('display','block');
		$('#store-container').css('display','none');
		
		idTimer = setInterval(idTimerStart, 1000);
		passTimer = setInterval(passFoucs, 1000);
		initEvent();
		
		window.location.hash = "";
		
		//reset timer
		clearInterval(outletTimer);
		resetNavButton();
		logoutClearLiveSupport();
		mins = 5;
		seconds = 0;
		$('#outlet-timer-box').html('time left: '+ mins+":0"+seconds);
		
		$.get('./json/logout.json.php');
		
		moveFlag = false;

	}
	
	function logoutClearLiveSupport() {
		
		$('#support_username').html('');
		$('#user_time_text').html('');
		$('#question').html('<textarea id="support_question"></textarea>');
		$('#support_adminname').html('');
		$('#admin-name').html('');
		$('#admin_time_text').html('');
		$('#answer').html('');
		$('.page_no').html('&nbsp;');
		$('#sd_btn').css('display', 'block');
		clearInterval(liveTimer);
			
	}
	
	function resetNavButton() {
		
		var navName = Array('store', 'about', 'contact', 'support', 'logout', 'fullscreen');
		
		for(i=0;i<navName.length;i++) {
			btnName = navName[i];
			$('#w-'+btnName+'-title').css('display','none');
			$('#'+btnName+'Btn').animate({width: '40px',right: '545px'},0);
			$('#'+btnName+'Btn #'+btnName+'-title').css('display','none');
			$('#'+btnName+'Btn .grey-btn #'+btnName+'-title').css('display','none');
			$('#'+btnName+'Btn .grey-btn').css('display','block');
			$('#'+btnName+'Btn .white-btn').css('display','none');
		}
		
		$('#w-store-title').css('display','block');
		
	}
	
	function maxChar(obj) {
		//alert(obj.value.length);
		if (obj.value.length > 132) {
			obj.value = obj.value.substr(0, 132);
		}
	}

