function js_reset( as_obj )
{
	document.getElementById(as_obj).reset() ;
	return false;
}

function addSupplier(as_id)
{
	self.location.href='/supplier_add.php?id='+as_id;
}
function winReload(as_url){
	top.location.href=as_url;
	
	}



// ********************************************************************************
// Function:	_isInteger()
// Arguments:	Field
// Usage: _isInteger( inpufForm.sle_login )
// It returns FALSE if the Field is not an integer
// ********************************************************************************
function _isInteger(input)
{
	checkString = input.value;

    // LOOP THROUGH STRING CHARACTER BY CHARACTER
    for (i = 0; i < checkString.length; i++) {
        ch = checkString.substring(i, i+1);

        // ENSURE CHARACTER IS A DIGIT
        if (!(ch >= "0" && ch <= "9")) {
        	input.focus();
            return false;
        }
    }
	return true;
}

// ********************************************************************************
// Function:	_isGroupBuySubmit()
// Arguments:	Field
// Usage: _isGroupBuySubmit( inpufForm )
// It returns FALSE if the Field is submit the the group buy 
// ********************************************************************************

function _isGroupBuySubmit(obj)
{

	//alert(obj.txt_hkid.value);
	if( eval( "obj.txt_name.value" )=="" ){
		_printErrorMsg( "姓名(香港身份証上的名字)不能為空。" );
		return false;
		}

	if( eval( "obj.txt_hkid.value" )=="" ){
		_printErrorMsg( "香港身份証號碼不能為空。" );
		return false;
		}
	if( eval( "obj.txt_hkid.value.length" )<4 ){
		_printErrorMsg( "香港身份証號碼必須頭4位數字。" );
		return false;
		}

	if( eval( "obj.txt_tel.value" )=="" ){
		_printErrorMsg( "手提電話號碼" );
		return false;
		}
	if( !_isInteger( obj.txt_tel ) ){
		_printErrorMsg( "手提電話號碼有誤!" );
		return false;
		}
	if( !_isInteger( obj.txt_hkid ) ){
		_printErrorMsg( "香港身份証號碼(頭4位數字)有誤!" );
		return false;
		}


	return true;

}


// ********************************************************************************
// Function:	_isGroupBuySubmit()
// Arguments:	Field
// Usage: _isGroupBuySubmit( inpufForm )
// It returns FALSE if the Field is submit the the group buy 
// ********************************************************************************

function _isUserDetailsSubmit(obj)
{

	//alert(obj.txt_hkid.value);
	if( eval( "obj.txt_pwd.value" )=="" ){
		_printErrorMsg( "密碼不能為空。" );
		return false;
		}

	if( eval( "obj.txt_pwd.value" )!= eval( "obj.txt_pwd2.value" ) ){
			_printErrorMsg( "密碼不一致。" );
		return false;
		}
	return true;

}





function _printErrorMsg(showMsg){
	
var errorMsg = document.createElement("DIV");
errorMsg.id = "jsvErrMsg";
errorMsg.className = "rpbContentStyle24f";
errorMsg.innerHTML = showMsg;
document.getElementById("jsv").replaceChild(errorMsg, document.getElementById("jsvErrMsg"));
return ;

}


function _searchResult(){
	document.search01.method = 'GET';
	document.search01.submit();
	return false;
}
function _clearResult(){


document.search01.brandid.focus();
document.search01.brandid.options[0].selected = true;
document.search01.txt_area.focus();
document.search01.txt_area.options[0].selected = true;
document.search01.txt_pri.focus();
document.search01.txt_pri.options[0].selected = true;
document.search01.txt_sor.focus();
document.search01.txt_sor.options[0].selected = true;

return false;
	
}

function searchSubmit(){
	document.searchForm.method = 'GET';
	document.searchForm.target = 'win_result';
	document.searchForm.submit();
	location.href = "#";
	return false;
}

function searchReset(){
	document.searchForm.reset();
	return false;
	
	}
	
function _searchResultby2(){
	//alert("location='"+location.href+'&txt_sor'+document.search01.txt_sor.options[document.search01.txt_sor.selectedIndex].value+"'");
	var args = location.search;
	if ((args == null)||(args=='')){
		eval("location.href='"+location.href+'?txt_sor='+document.search01.txt_sor.options[document.search01.txt_sor.selectedIndex].value+"'");
		return false;
	}
	eval("location.href='"+location.href+'&txt_sor='+document.search01.txt_sor.options[document.search01.txt_sor.selectedIndex].value+"'");
	return false;
}	