// JavaScript Document
//header quick search
function checkQuicksearch(entry) {
	if (!document.quicksearch.term.value || document.quicksearch.term.value == entry)
	 {
		alert("please enter a search term");
		return false;
	}
	termArray = document.quicksearch.term.value.replace(/(^\s*)|(\s*$)/g, "").split(" ");
	custom3Array = new Array('beige:KK', 'khaki:KK', 'tan:KK', 'black:BK', 'blue:BL', 'bronze:BR', 'brown:BN', 'cream:IV', 'ivory:IV', 'green:GN', 'gray:GR', 'grey:GR', 'metallic:MT', 'multi:MU', 'navy:NV', 'dark blue:NV', 'orange:OR', 'pink:PK', 'hot pink:PK', 'purple:PP', 'lilac:PP', 'red:RD', 'maroon:RD', 'burgundy:RD', 'silver:SV', 'turquoise:AQ', 'aqua:AQ', 'aquamarine:AQ', 'white:WT', 'yellow:YL');
	isCustom3 = "false";
	custom3 = "";
	keyword = "";
	for (i = 0; i < termArray.length; i++)
	 {
		if (termArray[i] != "")
		 {
			for (j = 0; j < custom3Array.length; j++)
			 {
				colorArray = custom3Array[j].split(":");
				if (colorArray[0].toLowerCase() == termArray[i].toLowerCase())
				 {
					isCustom3 = "true";
					break;
				}
			}
			if (isCustom3 == "true")
			 {
				custom3 = custom3 + colorArray[0] + " ";
				isCustom3 = "false";
			}
			 else
			 {
				keyword = keyword + termArray[i] + " ";
			}
		}
	}
	if (custom3 != "")
	 {
		document.quicksearch.term.value = custom3.substring(0, custom3.length - 1);
	}
	 else
	 {
		document.quicksearch.term.value = "";
	}
	if (keyword != "")
	 {
		document.quicksearch.keyword.value = keyword.substring(0, keyword.length - 1);
	}
	 else
	 {
		document.quicksearch.keyword.value = "";
	}
}
//clear box content when user focus
function clearBox(id, term) {
	va = document.getElementById(id).value;
	if (va == term) {
		document.getElementById(id).value = '';
	}
}
//show the detail layout | car.tpl, catalogdetail.tpl, catalogrelated.tpl, e-giftcardsdetail.tpl, outfitsdetail.tpl
function showdetail(id)
 {
	document.getElementById(id).style.display = '';
}
//hide the detail layout | car.tpl, catalogdetail.tpl, catalogrelated.tpl, e-giftcardsdetail.tpl, outfitsdetail.tpl
function hidedetail(id)
 {
	document.getElementById(id).style.display = 'none';
}
//reset the input box | register.tpl
function resetColor(id, colorCode) {
	id.style.color = colorCode;
}
//set cookie value
function setCookie(name, value) {
	var today = new Date();
	var expires = new Date();
	document.cookie = name + "=" + escape(value) + ";path=/";
}
//set the ex time for return cookie | header.tpl
function setCookieEx(name, value, days) {
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime() + 1000 * 60 * 60 * 24 * days);
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + ";path=/";
}
//get the photo image | emailfriend.tpl
function getCookie(Name) {
	var search = Name + "=";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
		 else return "";
	}
}
//phone validation
var digits = "0123456789";
var phoneNumberDelimiters = "()-. ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;
function isInteger(s)
 {
	var i;
	for (i = 0; i < s.length; i++)
	 {
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	return true;
}
function stripCharsInBag(s, bag)
 {
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++)
	 {
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}
function checkInternationalPhone(strPhone) {
	s = stripCharsInBag(strPhone, validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
//form check | checkout-anon.tpl
function ValidateFormCheckout() {
	var Phone = document.getElementById('Phone');
	if ((Phone.value == null) || (Phone.value == "")) {
		alert("Please Enter your Phone Number")
		 Phone.focus();
		return false;
	}
	if (checkInternationalPhone(Phone.value) == false) {
		alert("Please Enter a Valid Phone Number")
		 Phone.focus();
		return false;
	}
	if (document.getElementById('Street')) {
		var Street = document.getElementById('Street');
		StringStreet = Street.value;
		StringStreet = StringStreet.replace(/(^\s*)|(\s*$)/g, "");
		if ((StringStreet == null) || (StringStreet == "")) {
			alert("Please Enter your Address");
			Street.focus();
			return false;
		}
	}
	return true;
}
//unknow
if (window.attachEvent)
 window.attachEvent("onload", setListeners);
function setListeners() {
	inputList = document.getElementsByTagName("INPUT");
	for (i = 0; i < inputList.length; i++) {
		inputList[i].attachEvent("onpropertychange", restoreStyles);
		inputList[i].style.backgroundColor = "";
	}
	selectList = document.getElementsByTagName("SELECT");
	for (i = 0; i < selectList.length; i++) {
		selectList[i].attachEvent("onpropertychange", restoreStyles);
		selectList[i].style.backgroundColor = "";
	}
}
//use in unknow
function restoreStyles() {
	if (event.srcElement.style.backgroundColor != "")
	 event.srcElement.style.backgroundColor = "";
}
//open a new window to show the size chart | cartadd.tpl
function open_scF11() {
	window.open('http://www.lafayette148ny.com/php/size-charts-popup.html', 'SizeChart', 'height=600,width=900,top=20,left=50,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no');
}
//highlight the left nav | all the help template page
function HelpFocus(id) {
	document.getElementById(id).className = "onblod";
}
//check the Attribute2 | cartadd.tpl
function checkAttrib2() {
	var ColorSubmit = document.getElementById('colors').value;
	var SizeSubmit = document.getElementById('sizes').value;
	if (ColorSubmit != "" && SizeSubmit != "") {
		document.getElementById('color').value = ColorSubmit + " - " + SizeSubmit;
		document.cartadd.submit();
	} else {
		alert("Please choose a color and a size, thanks.");
		return false;
	};
}
//highlight the selected swatch image | cartadd.tpl, outfitsrelated.tpl
function focusColorFunc(no) {
	$('#focusColor').text($('.swatchImage').slice(no, no + 1).attr('id'));
	$('.swatchImage').css("border-width", "1px");
	$('.swatchImage').slice(no, no + 1).css("border-width", "2px");
}
//get the shipdate of order | cart.tpl, invoice.tpl
function estimateShipDate(fullDate, weeks) {
	dateArray = fullDate.split("/");
	orderDate = new Date('20' + dateArray[2], dateArray[0] - 1, dateArray[1]);
	orderDate.setDate(orderDate.getDate() + (weeks * 7));
	shipDate = orderDate.getMonth() + 1;
	shipDate = shipDate + '/' + orderDate.getDate();
	shipDate = shipDate + '/' + orderDate.getFullYear();
	return shipDate;
}
//show the giftcart box | cartadd.tpl
function checkGB() {
	if (document.getElementById("gbCheck").checked) {
		addattr2(1);
		if (document.getElementById("addqty").value > 1) {
			document.getElementById("gbQty").options.length = 0;
			for (x = 1; x <= document.getElementById("addqty").value; x++) {
				insertOptionGB(x);
			}
			showdetail('gbQtyDiv');
		} else {
			document.getElementById("gbQty").options.length = 0;
			insertOptionGB(1);
		}
	} else {
		addattr2(0);
		hidedetail('gbQtyDiv');
	}
}
//add attr2 value
function addattr2(n){
	if(n == 0){
		$("#gbQty").remove();
	} else {
		if($("#gbQty").length==0) $("#gbQtyDiv span").after('<select id="gbQty" name="attributevalue_2"><option value="">select</option></select>');
	}
}
//add options to the gb selector
function insertOptionGB(tempQty)
 {
	selectOption = document.createElement('option');
	selectOption.text = tempQty;
	selectOption.value = tempQty;
	selectOption.value = tempQty + ' Gift Box';
	if (tempQty > 1) {
		selectOption.value += 'es';
	}
	selectBox = document.getElementById("gbQty");
	try
	 {
		selectBox.add(selectOption, null);
	}
	 catch(ex)
	 {
		selectBox.add(selectOption);
	}
}
//unique the values in an array
function unique(data) {
	data = data || [];
	var a = {};
	for (var i = 0; i < data.length; i++) {
		var v = data[i];
		if (typeof(a[v]) == 'undefined') {
			a[v] = 1;
		}
	};
	data.length = 0;
	for (var i in a) {
		data[data.length] = i;
	}
	return data;
}
//get the colors array from an array | cartadd.tpl, outfitsrelated.tpl
function getAllColors(data_sortbysize)
 {
	var colorAry = new Array();
	for (index in data_sortbysize)
	 {
		if (typeof data_sortbysize[index][0] != "undefined") colorAry.push(data_sortbysize[index][0]);
	}
	var colorAry = colorAry.sort();
	return colorAry;
}
//show the swatch | cartadd.tpl, outfitsrelated.tpl
function showColors(size, s_id, pdc_id, sourcedata, swatchLibrary, swatchUrl, c_id, simage_id)
 {
	var size_int = size;
	size = size.replace('/', '');
	if (s_id.indexOf("_") != -1)
	 {
		var ary = s_id.split("_");
		var pd_size = 'pd_size' + ary[1];
		var ul_id = '#ul' + ary[1] + '_' + size;
	}
	 else
	 {
		var pd_size = 'pd_size';
		var ul_id = '#ul_' + size;
	}
	var colorAry = getColorBySize(size_int, sourcedata);
	if (colorAry.length > 0)
	 {
		for (p = 0; p <= colorAry.length - 1; p++)
		 {
			colorCount = colorCount + 1;
			swatchUrl = colorAry[p].replace(reBlank, '-');
			if (colorAry[p].indexOf('/ ') == -1 && colorAry[p].indexOf(' /') == -1) {
				swatchUrl = swatchUrl.replace('/', '-');
			} else {
				swatchUrl = swatchUrl.replace('/', '');
			}
			if (swatchUrl.indexOf('--') != -1) {
				swatchUrl = swatchUrl.replace('--', '-');
			}
			if (colorsHasPhoto.indexOf(swatchUrl) == -1 || s_id.indexOf("_") != -1) {
				$(ul_id).append('<li><label><img src="http://dq8mbsbwwh6qq.cloudfront.net/swatch/' + swatchLibrary + '/' + swatchUrl + '.jpg" width="24" height="24" alt="' + colorAry[p] + '" id="' + colorAry[p] + '" class="' + simage_id + '" onmouseover="focusColorFunc(' + p + ')" onclick="selectColor(this,\'' + c_id + '\',\'' + simage_id + '\');$(\'#pd_color span b\').append(\'&nbsp;&nbsp;&nbsp;<span>Image Unavailable</span>\');"></label></li>');
			} else {
				var colorPhoto = photoTemp.split('_')[0] + "_" + swatchUrl;
				$(ul_id).append('<li><label><img rel="{gallery: \'gal1\', smallimage: \'http://dq8mbsbwwh6qq.cloudfront.net/catalog/' + colorPhoto + '_DTL.jpg\',largeimage: \'http://dq8mbsbwwh6qq.cloudfront.net/photo/' + colorPhoto + '.jpg\'}" src="http://dq8mbsbwwh6qq.cloudfront.net/swatch/' + swatchLibrary + '/' + swatchUrl + '.jpg" width="24" height="24" alt="' + colorAry[p] + '" id="' + colorAry[p] + '" class="' + simage_id + '" onmouseover="focusColorFunc(' + p + ')" onclick="selectColor(this,\'' + c_id + '\',\'' + simage_id + '\'); swapIt(\'' + colorPhoto + '\')"></label></li>');
			}
		}
	}
}
//get all the colors as an array group by size
function getColorBySize(size, sourcedata)
 {
	var colorAry = new Array();
	for (index in sourcedata)
	 {
		if (sourcedata[index][1] == size)
		 {
			colorAry.push(sourcedata[index][0]);
		}
	}
	var colorAry = colorAry.sort();
	return colorAry;
}
function sortFun(a, b)
 {
	var arrSize = new Array();
	arrSize["1X"] = 0;
	arrSize["2X"] = 1;
	arrSize["3X"] = 2;
	arrSize["P"] = 3;
	arrSize["S"] = 4;
	arrSize["M"] = 5;
	arrSize["L"] = 6;
	arrSize["XL"] = 7;
	arrSize["XXL"] = 8;
	arrSize["One"] = 9;
	arrSize["ONE"] = 10;
	arrSize["P/S"] = 11;
	arrSize["S/M"] = 12;
	arrSize["M/L"] = 13;
	arrSize["L/XL"] = 14;
	if (isNaN(a[1]))
	 {
		c = arrSize[a[1]] - arrSize[b[1]];
	}
	 else
	 {
		c = a[1] - b[1];
	}
	return c;
}
function getArray(arr)
 {
	var a = new Array();
	for (i = 0; i < arr.length; i++)
	 {
		a[i] = arr[i].split(" - ");
	}
	return a;
}
function selectColor(obj, c_id, simage_id) {
	if (c_id.indexOf("_") != -1)
	 {
		var ary = c_id.split("_");
		var pd_color = 'pd_color' + ary[1];
		$("#" + ary[1] + "cartchk").attr("checked", "checked");
		changeChk2(c_id, $(obj).attr('id'));
	}
	 else
	 {
		var pd_color = 'pd_color';
	}
	$("#" + pd_color + " span b").replaceWith('<b>' + $(obj).attr('id') + '</b>');
	$("#" + pd_color + " ul li").removeClass("active");
	$(obj).parent().parent().addClass("active");
	$("#" + c_id).val($(obj).attr('id'));
}
function choose_size(size, pku)
 {
	if (pku == 0)
	 {
		var ls_color = $("#colors").val();
		$("#pd_size ul li").removeClass('on');
		$('#colors').removeAttr("value");
		$('#pd_color span b').empty();
		$("#pd_color ul li").removeClass("active");
		$("#pd_size ul li a:contains(" + size + "):first").parent().parent().addClass('on');
		$("#pd_size span b").replaceWith("<b>" + size + "</b>");
		$("#sizes").val(size);
		$(".color_ul").hide();
		$("#ul_" + size.replace('/', '')).show();
		defaultColor(size.replace('/', ''), 0, ls_color);
	}
	 else
	 {
		var ls_color = $("#colors_" + pku).val();
		$("#pd_size" + pku + " ul li").removeClass('on');
		$('#colors_' + pku).removeAttr("value");
		$('#pd_color' + pku + ' span b').empty();
		$("#pd_color'+pku+' ul li").removeClass("active");
		$("#pd_size" + pku + " ul li a:contains(" + size + "):first").parent().parent().addClass('on');
		$("#pd_size" + pku + " span b").replaceWith("<b>" + size + "</b>");
		$("#sizes_" + pku).val(size);
		$("#pd_color" + pku + " ul").hide();
		$("#ul" + pku + "_" + size.replace('/', '')).show();
		defaultColor(size.replace('/', ''), pku, ls_color);
	}
}
//swatch default color selected
function defaultColor(size, pku, ls_color)
 {
	isin = 0;
	if (pku == 0)
	 {
		ulid = '#ul_' + size;
		$("#pd_color ul li").removeClass("active");
		if ($(ulid + ' li').length == 1)
		 {
			$(ulid + ' li:first-child').addClass("active");
			$("#pd_color span b").replaceWith('<b>' + $(ulid + ' li:first-child label img').attr('id') + '</b>');
			$("#colors").val($(ulid + ' li:first-child label img').attr('id'));
		}
		 else
		 {
			$(ulid + ' li').each(function() {
				if ($(this).children().children().attr('id') == ls_color) {
					isin = 1;
				}
			});
			if ((ls_color != "" && isin == 1))
			 {
				$(ulid + ' li label img[id="' + ls_color + '"]').parent().parent().addClass("active");
				$("#pd_color span b").replaceWith('<b>' + $(ulid + ' li label img[id="' + ls_color + '"]').attr('id') + '</b>');
				$("#colors").val($(ulid + ' li label img[id="' + ls_color + '"]').attr('id'));
			}
		}
	}
	 else
	 {
		ulid = '#ul' + pku + '_' + size;
		$("#pd_color" + pku + " ul li").removeClass("active");
		if ($(ulid + ' li').length == 1)
		 {
			$(ulid + ' li:first-child').addClass("active");
			$("#pd_color" + pku + " span b").replaceWith('<b>' + $(ulid + ' li:first-child label img').attr('id') + '</b>');
			$("#colors_" + pku).val($(ulid + ' li:first-child label img').attr('id'));
			$("#" + pku + "cartchk").attr("checked", "checked");
			changeChk2($("#colors_" + pku).attr('id'), $(ulid + ' li:first-child label img').attr('id'));
		}
		 else
		 {
			$(ulid + ' li').each(function() {
				if ($(this).children().children().attr('id') == ls_color) {
					isin = 1;
				}
			});
			if ((ls_color != "" && isin == 1))
			 {
				$(ulid + ' li label img[id="' + ls_color + '"]').parent().parent().addClass("active");
				$("#pd_color" + pku + " span b").replaceWith('<b>' + $(ulid + ' li label img[id="' + ls_color + '"]').attr('id') + '</b>');
				$("#colors_" + pku).val($(ulid + ' li label img[id="' + ls_color + '"]').attr('id'));
				$("#" + pku + "cartchk").attr("checked", "checked");
				changeChk2($("#colors_" + pku).attr('id'), $(ulid + ' li label img[id="' + ls_color + '"]').attr('id'));
			}
		}
	}
}
//street level validation for ups
function show_addressvalidation(in_address, in_city, in_state, in_zip, sbType) {
	var address = in_address;
	var city = in_city;
	var state = in_state;
	var zip = in_zip;
	reg_state = /^[A-Za-z]{2}$/;
	reg_zip = /^(-?\d*)(\.\d+)?$/;
	$("#show_tips").hide();
	if (in_address == '' || in_city == '' || in_state == '' || in_zip == '') {
		alert("Some required fields were not provided.");
		return false;
	}
	if (!reg_state.test(in_state)) {
		alert('wrong state format');
		return false;
	}
	if ($.cookie('upsed')) {
		if ($.cookie('upsed').toLocaleLowerCase() == (in_address + '%' + in_city + '%' + in_state + '%' + in_zip).toLocaleLowerCase()) {
			return true;
		}
	}
	var url = "/php/ups_adress_validation_street/index.php?address=" + address + "&city=" + city + "&state=" + state + "&zip=" + zip;
	$.ajax({
		type: "GET",
		url: url,
		datatype: "xml",
		cache: false,
		success: function(xml) {
			var ResponseStatusCode = $(xml).find('ResponseStatusCode').text();
			if (ResponseStatusCode == 0) {
				if (sbType == 'shipto') {
					document.shipto.submit();
				}
				 else if (sbType == 'billingto') {
					document.customer.submit();
				}
				 else if (sbType == 'invoice') {
					document.invoiceconfirm2.submit();
				}
			} else {
				$("#advisebox tbody").empty();
				var response_ary = new Array();
				$(xml).find('AddressKeyFormat').each(function(index) {
					var result_ary = new Array();
					result_ary['AddressLine'] = $(this).find('AddressLine').text();
					result_ary['Region'] = $(this).find('Region').text();
					result_ary['city'] = $(this).find('PoliticalDivision2').text();
					result_ary['state'] = $(this).find('PoliticalDivision1').text();
					result_ary['postalCode'] = $(this).find('PostcodePrimaryLow').text()
					 response_ary[index] = result_ary;
				});
				if (response_ary.length == 0) {
					$.fancybox('<table width="800" border="0" cellspacing="5" cellpadding="0" id="show_tips" ><tr><td width="50%" style="vertical-align:top;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><span class="error">UPS cannot verify the shipping address you entered.</span></td></tr><tr><td><div>Please doublecheck address below and confirm.</div></td></tr><tr><td><div>Press "Edit Address" if it is not correct.</div></td></tr><tr><td><div id="show_address"></div></td></tr><tr><td>&nbsp;</td></tr><tr><td><input type="image" border="0" onclick="goUse(1);" alt="Continue Checkout" src="/images/PS12/use.gif">&nbsp;<input type="image" border="0" onclick="goEdit();" alt="Continue Checkout" src="/images/PS12/edit.gif"></td></tr></table></td><td valign="top" width="50%" id="show_tips_right"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><strong>Other possible suggestions: </strong><p>Click below to select address.</p></td></tr><tr><td>&nbsp;</td></tr><tr><td><table width="100%" cellspacing="5" cellpadding="0" border="0" style="font-size:11px;" id="advisebox"><tbody></tbody></table></td></tr></table></td></tr></table>', {
						'autoDimensions': false,
						'width': 820,
						'height': 170,
						'hideOnOverlayClick': false,
						'transitionIn': 'none',
						'transitionOut': 'none'
					});
					$("#show_address").empty().append("<p>" + in_address + "</p><p>" + in_city + ', ' + in_state + ' ' + in_zip + "</p>");
					$("#show_tips_right").hide();
					return false;
				} else {
					if (response_ary.length == 1) {
						if ($('#street').val().toLocaleLowerCase() == response_ary[0]['AddressLine'].toLocaleLowerCase() && $('#city').val().toLocaleLowerCase() == response_ary[0]['city'].toLocaleLowerCase() && $('#state').val().toLocaleLowerCase() == response_ary[0]['state'].toLocaleLowerCase() && $('#postalCode').val() == response_ary[0]['postalCode'])
						 {
							if (sbType == 'shipto') {
								document.shipto.submit();
							}
							 else if (sbType == 'billingto') {
								document.customer.submit();
							}
							 else if (sbType == 'invoice') {
								document.invoiceconfirm2.submit();
							}
							return false;
						}
					}
					$.fancybox('<table width="800" border="0" cellspacing="5" cellpadding="0" id="show_tips" ><tr><td width="50%" style="vertical-align:top;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><span class="error">UPS cannot verify the shipping address you entered.</span></td></tr><tr><td><div>Please doublecheck address below and confirm.</div></td></tr><tr><td><div>Press "Edit Address" if it is not correct.</div></td></tr><tr><td><div id="show_address"></div></td></tr><tr><td>&nbsp;</td></tr><tr><td><input type="image" border="0" onclick="goUse(1);" alt="Continue Checkout" src="/images/PS12/use.gif">&nbsp;<input type="image" border="0" onclick="goEdit();" alt="Continue Checkout" src="/images/PS12/edit.gif"></td></tr></table></td><td valign="top" width="50%" id="show_tips_right"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><strong>Other possible suggestions: </strong><p>Click below to select address.</p></td></tr><tr><td>&nbsp;</td></tr><tr><td><table width="100%" cellspacing="5" cellpadding="0" border="0" style="font-size:11px;" id="advisebox"><tbody></tbody></table></td></tr></table></td></tr></table>', {
						'autoDimensions': false,
						'width': 820,
						'height': 170,
						'hideOnOverlayClick': false,
						'transitionIn': 'none',
						'transitionOut': 'none'
					});
					for (value in response_ary) {
						if (sbType != 'invoice') $("#advisebox tbody").append('<tr><td><a style="text-decoration:underline;" href="javascript:void(0);" onclick="takeSuggestion(\'' + response_ary[value]['AddressLine'] + ":" + response_ary[value]['city'] + ":" + response_ary[value]['state'] + ":" + response_ary[value]['postalCode'] + '\');"">' + response_ary[value]['AddressLine'] + ', ' + response_ary[value]['Region'] + '</a></td></tr>');
						else $("#advisebox tbody").append('<tr><td><a style="text-decoration:underline;" href="javascript:void(0);" onclick="takeSuggestion_2(\'' + response_ary[value]['AddressLine'] + ":" + response_ary[value]['city'] + ":" + response_ary[value]['state'] + ":" + response_ary[value]['postalCode'] + '\');"">' + response_ary[value]['AddressLine'] + ', ' + response_ary[value]['Region'] + '</a></td></tr>');
						if ($("#advisebox tbody tr").length == 5) break;
					}
					$("#show_address").empty().append("<p>" + in_address + "</p><p>" + in_city + ', ' + in_state + ' ' + in_zip + "</p>");
					$("#show_tips_right").show();
					return false;
				}
			}
		}
	});
}
function takeSuggestion(option) {
	var str = option;
	ary = str.split(':');
	$('#street').val(ary[0]);
	$('#city').val(ary[1]);
	$('#state').val(ary[2]);
	$('#postalCode').val(ary[3]);
	$("#postalCode").attr("value", ary[3]);
	goUse(0);
}
function takeSuggestion_2(option) {
	var str = option;
	ary = str.split(':');
	$('#street_info').empty().append(ary[0]);
	$('#city_info').empty().append(ary[1]);
	$('#state_info').empty().append(ary[2]);
	$('#zip_info').empty().append(ary[3]);
	$('#street').val(ary[0]);
	$('#city').val(ary[1]);
	$('#state').val(ary[2]);
	$('#postalCode').val(ary[3]);
	$("#postalCode").attr("value", ary[3]);
	goUse(0);
}
