﻿// JScript 文件
function SubmitForm()
{
    var returnValue = false;
	var reg = /^(\w|[\u4E00-\u9FA5])*$/;
	if(ValidatorGetValue('txt_keyWord')!=""&&ValidatorGetValue('txt_keyUrl')!="")
	{
	   if(ValidatorGetValue('txt_keyUrl').indexOf('http://')==0)
	   {
	        if(ValidatorGetValue('txt_keyUrl').indexOf('.')>7 && ValidatorGetValue('txt_keyUrl').indexOf('.')<ValidatorGetValue('txt_keyUrl').length-1)
		   {
				if(ValidatorGetValue('txt_keyUrl').substring(7,ValidatorGetValue('txt_keyUrl').indexOf('.')).match(reg))
				{
					returnValue = true;
				}
				else
				{
					alert("url is not valid");
				}
		   }
	        else
		   {
	            alert('url is not valid');
		   }
	   }
	   else
	   {
	        if(ValidatorGetValue('txt_keyUrl').indexOf('.')>1 && ValidatorGetValue('txt_keyUrl').indexOf('.')<ValidatorGetValue('txt_keyUrl').length-1)
		   { 
				if(ValidatorGetValue('txt_keyUrl').substring(0,ValidatorGetValue('txt_keyUrl').indexOf('.')).match(reg))
				{
					returnValue = true;
				}
				else
				{
					alert("url is not valid");
				}
		   }
	        else
		   {
	            alert('url is not valid');
		   }
	   }
	}		
	else
	{
	    alert('keyword or url is null');
	}		
	if(returnValue == true)
	{
		var pp = Math.random();
		document.SeoSrch.action="/tool~"+pp+".htm";				
		document.SeoSrch.submit();	
	}
}
function ValidatorTrim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

function ValidatorGetValue(id) 
{
    var strValue = "";
    var obj = document.getElementById(id);
    if(obj == null)
    {
        return strValue ;
    }
    strValue = ValidatorTrim(obj.value );
    return strValue ;
}