﻿ function setms(cans)
    {
    
    var can1,can2,can3,can4,url;
    switch(cans)
    {
    case 1:
    can1="留言标题和内容不能为空!";
    can2="留言标题不能为空!";
    can3="留言内容不能为空!";
    can4="提交成功!";
    url='ms.aspx';
    break;
    case 2:
    can1="Message title and content can not be empty!";
    can2="Title can not be empty!";
    can3="Message content can not be empty!";
    can4="Success,thanks!";
    url='../ms.aspx';
    
    
    case 3:
    can1="Message title and content can not be empty!";
    can2="Title can not be empty!";
    can3="Message content can not be empty!";
    can4="Success,thanks!";
    url='../ms.aspx';
    
    case 4:
    can1="Message title and content can not be empty!";
    can2="Title can not be empty!";
    can3="Message content can not be empty!";
    can4="Success,thanks!";
    url='../ms.aspx';
    
    break;
    default:
    can1="留言标题和内容不能为空!";
    can2="留言标题不能为空!";
    can3="留言内容不能为空!";
    can4="提交成功!";
    url='ms.aspx';
    break;  
    }
//    if(cans==1)
//    {
//    can1="留言标题和内容不能为空!";
//    can2="留言标题不能为空!";
//    can3="留言内容不能为空!";
//    can4="提交成功!";
//    }
//    else 
//    {
//    can1="Message title and content can not be empty!";
//    can2="Title can not be empty!";
//    can3="Message content can not be empty!";
//    can4="Success,thanks!";
//    }
    
      if ($F('txtTitle') == "" && $F('txtContent')=="")
        {
            alert(can1);
        }
        else if($F('txtTitle')=="")
        {
        alert(can2);
        }
        else if($F('txtContent')=="")
        {
        alert(can3);
        }
        else
        {
        var inp=$('txtTitle','txtContent','company','addr','txtName','tel','mob');
        var pars='pars='+$F('txtTitle')+'-'+$F('txtContent')+'-'+$F('company')+'-'+$F('addr')+'-'+$F('txtName')+'-'+$F('tel')+'-'+cans;
        var myAjax=new Ajax.Request(
        url,{method:'POST',
        parameters: pars,
        onComplete: showms
        });
        function showms(ms)
            {
                alert(can4);
                //循环数组清空
                inp.each(function(va){
                va.value="";
                }
                );
            }
        }  
    }
    
    
    
//图片现实功能
function Searchresult(id,pic)
{
var url="Ajax_product.aspx?v="+id+"&time="+(new Date()).getTime();
var pars='v='+id+'&time='+(new Date()).getTime();
var myAjax=new Ajax.Request(
        url,{method:'POST',
        parameters: pars,
        onComplete: showms
        });
        function showms(ms)
        {
        $('cpjj').innerHTML=ms.responseText;
        $('proimg').innerHTML="<a href='upfile/"+pic+ "' rel='lightbox[asd]'><img style='width: 320px; border:0px;' src='upfile/s"+pic+ "' />";
        }
 }


function CheckForm()
{
	if(document.getElementById("txtname").value=="")
	{
		alert("请输入用户名！");
		document.getElementById("txtname").focus();
	}
	else if(document.getElementById("txtname").value !="admin")
	{
	    alert("您输入的用户名错误！");
	    document.getElementById("txtname").value = "";
		document.getElementById("txtname").focus();
	}
	else if(document.getElementById("txtpwd").value == "")
	{
		alert("请输入密码！");
		document.getElementById("txtpwd").focus();
	}
	else if(document.getElementById("txtcode").value == "")
	{
		alert("请输入验证码！");
		document.getElementById("txtcode").focus();
	}
	else
	{
	    window.location.href = "form.html";
	}
}

