﻿function searchInputfocus(obj)
{
    if(obj.value==obj.defaultValue)
    {
        obj.value='';
        obj.style.color='#505050';
    }
}
function searchInputblur(obj)
{
    if (obj.value=='' || obj.value==obj.defaultValue)
    {
        obj.value=obj.defaultValue;
        obj.style.color="#cccccc";
    }
}
function searchFormSubmit(obj)
 {
    var parent=obj.parentNode;
    while(parent.tagName.toLowerCase()!="form")
       {
	      if(parent.tagName.toLowerCase()=="body" || parent.tagName.toLowerCase()=="html")
	         {
	            alert('无法提交');
	            return;
	         }
	      obj=parent;
	      parent=obj.parentNode;
        }
    if(parent.tagName.toLowerCase()=="form")
       {
          obj=parent.wd;
          if(obj.value==obj.defaultValue || obj.value=="undefined" || obj.value=="")
            {
                alert("请输入关键字");
                return;
            }
            var img=new Image();
            img.src="http://search.shengyidi.com/tools/Ajax/Ajax_RecordKeyword.aspx?keyword="+encodeURIComponent(obj.value);
            parent.submit();
       }
}
function RecordSearch(keyword)
{
    var img=new Image();
    img.src="http://search.shengyidi.com/tools/Ajax/Ajax_RecordKeyword.aspx?keyword="+encodeURIComponent(obj.value);
}
function RecordsearchSubmit()
{
    var obj=document.getElement("search_wd");
    if(obj.value==obj.defaultValue || obj.value=="undefined" || obj.value=="")
    {
        alert("请输入关键字");
        return false;
    }
    var img=new Image();
    img.src="http://search.shengyidi.com/tools/Ajax/Ajax_RecordKeyword.aspx?keyword="+encodeURIComponent(obj.value);
    return true;
}
//图片缩放
function zoompic(obj,width,height)
{
    var pw=obj.width;
    var ph=obj.height;
    if(pw<=width && ph<=height) return;
    if(pw!=0 && ph!=0)
    {
        if(pw/ph>=width/height)
        {
            obj.width=width;
            obj.height=ph*width/pw;
        }
        else
        {
            obj.height=height;
            obj.width=pw*height/ph;
        }
    }
}
