
function search(){
	//window.location = "http://www.usa-licenses-records.cn/pages/lookupPlate.jsp?plate=" + document.getElementById("q").value;
	var s = document.getElementById("q").value;
	s = getTrimmedString(s);
	if(s == null || s == ""){
		alert("Please input your license plate number!");
		document.getElementById("q").focus();
		return false;
	}
	window.location = "http://www.license-plates-100.com/pages/lpf_searching.jsp?plate_number=" + document.getElementById("q").value;
}

function detail(){
	window.location = '/detail/' + document.getElementById("phone").value;	
}

function isCorrectFormat(){
	var s = document.getElementById("q").value;
	s = getTrimmedString(s);
	if(s != ""){
		var pattern = /\d{3}[-]{1}\d{3}[-]{1}\d{4}/;
		
		if(pattern.exec(s)){
			return true;
		}else{
			alert("Please input correct format! (XXX-YYY-ZZZZ)");
			document.getElementById("q").focus();
			document.getElementById("q").select();
			return false;
		}
	}
}

function getTrimmedString(sSrc){
    if("string" != typeof(sSrc)){
        return "";
    }
    var sTmpStr = sSrc;
    while(sTmpStr != "" && sTmpStr.charAt(0) == ' '){
        sTmpStr = sTmpStr.substring(1, sTmpStr.length);
    }
    while(sTmpStr != "" && sTmpStr.charAt(sTmpStr.length - 1) == ' '){
        sTmpStr = sTmpStr.substring(0, sTmpStr.length - 1);
    }
    return sTmpStr;
}

