﻿// JScript File

    function GetInfo()
    {
       var info=null;
       info = AddQueryString(info,"itemid",$("itemid").value);
       info = AddQueryString(info,"mid",$("mid").value);
       info = AddQueryString(info,"username",$("username").value);
       info = AddQueryString(info,"phone",$("phone").value);
       info = AddQueryString(info,"mobile",$("mobile").value);
       info = AddQueryString(info,"address",$("address").value);
       info = AddQueryString(info,"postcode",$("postcode").value);
       info = AddQueryString(info,"email",$("email").value);
       info = AddQueryString(info,"content",$("content").value);
       
       return info;
    }
	
	function Submit()
	{
	    var emailReg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
        var username=$('username');
        if(username.value.length==0)
        {
            alert('姓名必须填写,请填写您的姓名');
            username.focus();
            return false;
        }
        
        var phone=$('phone');
        if(phone.value.length==0)
        {
            alert('联系电话必须填写,请填写您的联系电话');
            phone.focus();
            return false;
        }
		
		var address=$('address');
        if(address.value.length==0)
        {
            alert('地址必须填写,请填写您的地址');
            address.focus();
            return false;
        }
        
           
         var content=$('content');
        if(content.value.length==0)
        {
            alert('留言必须填写,请填写您的留言');
            content.focus();
            return false;
        }
		
		var info =GetInfo();
		document.form1.action="http://www.moooli.com/jm/reply.aspx?"+info;
	    document.form1.submit();
	}
	
	
	 function HandleProcess()
    {
        if( ajax && ajax.readyState )
        {
            if( ajax.readyState == 4 ) 
            {
                var addok = false;
            
                addok = false;
                
                if( ajax.status == 200 )
                {
                    var ret = ajax.responseText;
                    
                    if( ret.indexOf("OK") != -1 )
                    {
                        addok = true;
                    }    
                    else
                    {
                        errinfo = "提交留言信息失败";
                    }
                }
                else
                {
                    errinfo = "提交留言信息失败";
                }
                
                MagicProcessBarClose();
                
                if( addok == false )
                {
                    alert(errinfo);
                }
                else
                {
                    alert("提交留言信息成功");
                    Reset();
                }
                    
            }
        }
    }
    
    function Reset()
    {
         $("username").value="";
         $("phone").value="";
         $("mobile").value="";
         $("address").value="";
         $("postcode").value="";
         $("email").value="";
         $("content").value="";
    }
    
    var text1= new Array() 
    text1[0]="<table border='0' cellpadding='3' cellspacing='1' style='border-collapse: collapse'><tr><td><span style='font-size:12px;color:#FF0000;line-height:15px;'>(必填)</span><span style='font-size:12px;color:#919490;line-height:15px;'>您的真实姓名，请使用中文 </span></td></tr></table>"
    text1[1]="<table border='0' cellpadding='3' cellspacing='1' bordercolor='#000000' bgcolor='#000000' style='border-collapse: collapse'><tr><td bgcolor='#F7FFDE'><span style='font-size:12px;color:#FF0000;line-height:15px;'>(必填)</span><span style='font-size:12px;color:#4A5D00;line-height:15px;'>您的真实姓名，请使用中文 </span></td></tr></table>"

    var text2= new Array()
    text2[0]="<table border='0' cellpadding='3' cellspacing='1' style='border-collapse: collapse'><tr><td><span style='font-size:12px;color:#FF0000;line-height:15px;'>(必填) </span><span style='font-size:12px;color:#919490;line-height:15px;'>电话是与您联系的重要方式,请正确填写,如果是固定电话或小灵通请填写区号 </span></td></tr></table>"
    text2[1]="<table border='0' cellpadding='3' cellspacing='1' bordercolor='#000000' bgcolor='#000000' style='border-collapse: collapse'><tr><td bgcolor='#F7FFDE'><span style='font-size:12px;color:#FF0000;line-height:15px;'>(必填) </span><span style='font-size:12px;color:#4A5D00;line-height:15px;'>电话是与您联系的重要方式,请正确填写,如果是固定电话或小灵通请填写区号 </span></td></tr></table>"

    var text3= new Array()
    text3[0]="<table border='0' cellpadding='3' cellspacing='1' style='border-collapse: collapse'><tr><td><span style='font-size:12px;color:#919490;line-height:15px;'>&nbsp;&nbsp;为了便于和你本人联系,请务必填写手机号</span></td></tr></table>"
    text3[1]="<table border='0' cellpadding='3' cellspacing='1' bordercolor='#000000' bgcolor='#000000' style='border-collapse: collapse'><tr><td bgcolor='#F7FFDE'><span style='font-size:12px;color:#4A5D00;line-height:15px;'>&nbsp;&nbsp;为了便于和你本人联系,请务必填写手机号</span></td></tr></table>"

    var text4= new Array()
    text4[0]="<table border='0' cellpadding='3' cellspacing='1' style='border-collapse: collapse'><tr><td><span style='font-size:12px;color:#919490;line-height:15px;'>&nbsp;&nbsp;请正确填写电子信箱,以便给您发送相关资料</span></td></tr></table>"
    text4[1]="<table border='0' cellpadding='3' cellspacing='1' bordercolor='#000000' bgcolor='#000000' style='border-collapse: collapse'><tr><td bgcolor='#F7FFDE'><span style='font-size:12px;color:#4A5D00;line-height:15px;'>&nbsp;&nbsp;请正确填写电子信箱,以便给您发送相关资料</span></td></tr></table>"

    var text5= new Array()
    text5[0]="<table border='0' cellpadding='3' cellspacing='1' style='border-collapse: collapse'><tr><td><span style='font-size:12px;color:#FF0000;line-height:15px;'>(必填)</span><span style='font-size:12px;color:#919490;line-height:15px;'>地址是与您联系的重要方式,以保证资料邮递</span></td></tr></table>"
    text5[1]="<table border='0' cellpadding='3' cellspacing='1' bordercolor='#000000' bgcolor='#000000' style='border-collapse: collapse'><tr><td bgcolor='#F7FFDE'><span style='font-size:12px;color:#FF0000;line-height:15px;'>(必填)</span><span style='font-size:12px;color:#4A5D00;line-height:15px;'>地址是与您联系的重要方式,以保证资料邮递</span></td></tr></table>"

    var text6= new Array()
    text6[0]="<table border='0' cellpadding='3' cellspacing='1' style='border-collapse: collapse'><tr><td><span style='font-size:12px;color:#919490;line-height:15px;'>&nbsp;&nbsp;请正确填写邮政编码</span></td></tr></table>"
    text6[1]="<table border='0' cellpadding='3' cellspacing='1' bordercolor='#000000' bgcolor='#000000' style='border-collapse: collapse'><tr><td bgcolor='#F7FFDE'><span style='font-size:12px;color:#4A5D00;line-height:15px;'>&nbsp;&nbsp;请正确填写邮政编码</span></td></tr></table>"
    
    function init()
    {
        $("tdinfo1").innerHTML=text1[0];
        $("tdinfo2").innerHTML=text2[0];
        $("tdinfo3").innerHTML=text3[0];
        $("tdinfo4").innerHTML=text4[0];
        $("tdinfo5").innerHTML=text5[0];
        $("tdinfo6").innerHTML=text6[0];
    }
    
    function init1()
    {
        init();
        $("tdinfo1").innerHTML=text1[1];
    }
    
    function init2()
    {
        init();
        $("tdinfo2").innerHTML=text2[1];
		showtip();
    }
    
    function init3()
    {
        init();
        $("tdinfo3").innerHTML=text3[1];
    }
    
    function init4()
    {
        init();
        $("tdinfo4").innerHTML=text4[1];
    }
    
    function init5()
    {
        init();
        $("tdinfo5").innerHTML=text5[1];
    }
    
    function init6()
    {
        init();
        $("tdinfo6").innerHTML=text6[1];
    }
    
    function showdiv()
    {
       document.getElementById("menu_1").style.display="block";
       document.getElementById("menu_1").style.clip="rect(0 0 0 0)";
    }

    function hiddendiv()
    {
      document.getElementById("menu_1").style.display="none";
    }

    function keepdiv()
    {
       document.getElementById("menu_1").style.display="block";
    }


    function sel(theinput)
    {

		    if(document.getElementById("content").value!="")
			    document.getElementById("content").value+="\n"+theinput
		    else
			    document.getElementById("content").value=theinput

    }
	
	
	function showtip()
   {
       document.getElementById("PhoneTip").style.left=GetBelowX(document.getElementById('phone'))+'px';
       document.getElementById("PhoneTip").style.top=(GetBelowY(document.getElementById('phone'))+5)+'px';
       
       document.getElementById("PhoneTip").style.display="block";
   }
   
   function hidetip()
   {
        document.getElementById("PhoneTip").style.display="none";
   }
   
   function GetBelowX(tt)  
{  
   var  ttop   =  tt.offsetTop;       //TT控件的定位点高  
   var  thei   =  tt.clientHeight;    //TT控件本身的高  
   var  tleft  =  tt.offsetLeft;      //TT控件的定位点宽  
   var  ttyp   =  tt.type;            //TT控件的类型  
   while  (tt  =  tt.offsetParent){ttop+=tt.offsetTop;  tleft+=tt.offsetLeft;}  

   return tleft;
}

function GetBelowY(tt)
{
   var  ttop   =  tt.offsetTop; 
   var  thei   =  tt.clientHeight;
   var  tleft  =  tt.offsetLeft;
   var  ttyp   =  tt.type;
   while  (tt  =  tt.offsetParent){ttop+=tt.offsetTop;  tleft+=tt.offsetLeft;}  

   return ttop+thei;
}
