// Search keyword
function go_search(){
	if (f1.keyword.value == ""){
		alert("Please enter a keyword");
		f1.keyword.focus();
		return false;
	}
	return true;
}

function go_search_main(){
	if (main_search.keyword.value == ""){
		alert("Please enter a keyword");
		main_search.keyword.focus();
		return false;
	}
	return true;
}

function go_search_main_nlia(){
	if (main_search_nlia.keyword.value == ""){
		alert("Please enter a keyword");
		main_search_nlia.keyword.focus();
		return false;
	}
	return true;
}

function fn_nliaCartView()
{
	location.href = "/register/nliaCart.jsp";
}
function fn_nlkaCartView()
{
	location.href = "/register/nlkaCart.jsp";
}

// Delete shopping cart
function fn_nliaCartDel(){
	if(confirm("Do you want to empty shopping cart?") != true) {
			 return;
	}
	f1.mode.value="deleteCart";
	f1.action = "nliaCartProcess.jsp";
	f1.submit();
}

// Delete shopping cart
function fn_nlkaCartDel(){
	if(confirm("Do you want to empty shopping cart?") != true) {
			 return;
	}
	f1.mode.value="deleteCart";
	f1.action = "nlkaCartProcess.jsp";
	f1.submit();
}

// Find zipcode
function fn_zipsearch(){
	window.open("/advinfo/zipcode.jsp", "zip", "resizable=yes,scrollbars=no,width=400,height=280");
}

// Rule for advertisement
function fn_ad(){
	window.open("/info/ad_write.pop.jsp", "pop", "resizable=yes,scrollbars=yes,width=610,height=600");
}

// This function formats numbers by adding commas
function numberFormat(nStr){
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1))
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	return x1 + x2;
}

// This function removes non-numeric characters
function stripNonNumeric( str ){  str += '';
	var rgx = /^\d|\.|-$/;
	var out = '';
	for( var i = 0; i < str.length; i++ ){
		if( rgx.test( str.charAt(i) ) ){
			if( !( ( str.charAt(i) == '.' && out.indexOf( '.' ) != -1 ) || ( str.charAt(i) == '-' && out.length != 0 ) ) ){
				out += str.charAt(i);
			}
		}
	}
	return out;
}
