﻿//将所有script代码整合链接
var mainPath ="";
var mainlink = "mainlink.js" ;
var head = document.getElementsByTagName("head")[0];
var nodes = head.childNodes;
for (var i = 0; i < nodes.length;++i) {
	var src = nodes.item(i).src;
	if(src) {
		var index = src.indexOf(mainlink);
		if (index >= 0) {
			mainPath = src.substring(0, index);
		}
	}
}

IncludeJavaScript(mainPath+"ajaxpro/prototype.ashx");
IncludeJavaScript(mainPath+"ajaxpro/core.ashx");
IncludeJavaScript(mainPath+"ajaxpro/converter.ashx");
IncludeJavaScript(mainPath+"ajaxpro/Topevery.ServerMethods.PublicWork,Topevery.WebSite.Web.ashx");

function IncludeJavaScript(path)
{
	document.write("<script language='javascript' type='text/javascript' src='"+path+"'></script>");		
}

//与后台交互代码


//留言反馈
function notebook(){

    var info =  Topevery.ServerMethods.PublicWork.GetNewNoteBook().value;
    info.Name = document.getElementById("name").value
    info.Sex = document.getElementById("sex").value
    info.Address = document.getElementById("address").value
    info.Tel = document.getElementById("tel").value
    info.Email = document.getElementById("email").value
    info.Postcode = document.getElementById("postcode").value
    info.Department = document.getElementById("unit").value
    info.Url = document.getElementById("web").value
    info.Title = document.getElementById("theme").value
    info.Content = document.getElementById("message").value
    
    var res = Topevery.ServerMethods.PublicWork.notebook(info);
    if(res.value != null)
    {
       if (res.value == true)
        {
            alert('您的留言已保存成功！我们会尽快给予您答复！');
        }
        else
        {
            alert('您的留言保存失败！请稍后再试！');
        }      
    }    
}		



//代理商信息量
function representation(){

    var info =  Topevery.ServerMethods.PublicWork.GetNewRepresentation().value;   
    info.Address = document.getElementById("cadd").value;
    info.Info_from = "";
    info.Appellation = document.getElementById("pnametitle").options[document.getElementById("pnametitle").selectedIndex].text
    info.Case_success = document.getElementById("bcase").value;
    info.City = document.getElementById("ccity").options[document.getElementById("ccity").selectedIndex].text
    info.Description = document.getElementById("bdescription").value;
    info.Email_Contact = document.getElementById("pemail").value;
    info.Email_Representation = document.getElementById("cemail").value;
    info.Income = document.getElementById("bsale").value;

    for(i=0;i<document.forms[0].oinfo.length;i++)   
    {   
        if(document.forms[0].oinfo[i].checked)
        {
            info.Info_from += document.forms[0].oinfo[i].value+",";
        }
    }  
    
    
    info.Market = document.getElementById("bmarket").value;
    info.Name = document.getElementById("pname").value;
    info.Name_chn = document.getElementById("cch").value;
    info.Name_eng = document.getElementById("cen").value;
    info.Number_service = document.getElementById("bsupport").value;
    info.Number_soft = document.getElementById("bsoftsale").value;
    info.Post = document.getElementById("pworkpost").value;
    info.Postcode = document.getElementById("cpostcode").value;
    if(document.getElementById("ccustomerDesc").selectedIndex==0)
    {
        info.Property = "未知";
    }
    else
    {
        info.Property = document.getElementById("ccustomerDesc").options[document.getElementById("ccustomerDesc").selectedIndex].text
    }
    info.Province = document.getElementById("cprovince").options[document.getElementById("cprovince").selectedIndex].text
    if(document.getElementById("ccustomerSize").selectedIndex==0)
    {
        info.Scale = "未知";
    }
    else
    {
        info.Scale = document.getElementById("ccustomerSize").options[document.getElementById("ccustomerSize").selectedIndex].text
    }
    if(document.getElementById("bservices").selectedIndex==0)
    {
        info.Service = "未知";
    }
    else
    {
        info.Service = document.getElementById("bservices").options[document.getElementById("bservices").selectedIndex].text;
    }
    info.Soft_represent = document.getElementById("bagent").value;
    info.Target = document.getElementById("bobject").value;
    info.Tel_mobile = document.getElementById("pmob").value;
    info.Tel_office = document.getElementById("ptel").value;
    info.Url = document.getElementById("cweb").value;
    info.Year = document.getElementById("cyear").value;
    
    var res = Topevery.ServerMethods.PublicWork.representation(info);
    if(res.value != null)
    {
       if (res.value == true)
        {
            alert('您的信息已保存成功！我们会尽快给予您答复！');
        }
        else
        {
            alert('您的信息保存失败！请稍后再试！');
        }      
    }    
}		
      

