﻿//引用prototype.js文件(AJAX)
document.write("<script src=\"\/style\/js\/prototype.js\"><\/script>")
//----------------------------------
//AJAX CMS SERVICE 客户端调用程序//document.location的链接地址根据网站实际需要修改//Created By Syf 20061117(START)
//----------------------------------

//-------------------------Used by mmtea----------------------------

function SetSearchLog(strKeyWords)
{
    if (strKeyWords != null && strKeyWords.length > 0)
      {
        
         var strUrl = "/LOG/SearchLog.aspx";

         var strPars = "KeyWords=" + strKeyWords;

         var myAjax = new Ajax.Request(strUrl, {method: 'post', parameters: strPars, onComplete: DoResult});
        
       }
}

function GetHtmlTitle()
{
    GetLabel('HTML_TITLE', 'Constant_HTML_TITLE');
}
function GetLabel(strLabelId, strLabelName)
{

    if (strLabelId != null && strLabelId.length > 0 && strLabelName != null && strLabelName.length > 0)
    {
        
        var strUrl = "/NewsAndGuangGao/GetLabel.aspx";
        var strPars = "LabelName=" + strLabelName + "&LabelId=" + strLabelId;
        var myAjax = new Ajax.Request(strUrl, {method: 'post', parameters: strPars, onComplete: DoResult});
        
    }
}

 
function AjaxLogin(strOpTag,strUserName,strPass,strYanZhengMa)
{
   if (strUserName != null && strUserName.length > 0&& strPass != null && strPass.length > 0&&strYanZhengMa != null && strYanZhengMa.length>0)
      {
        
         var strUrl = "/LOGIN/QYLogin.aspx";

         var strPars = "OpType=" + strOpTag + "&UserName=" + strUserName + "&Pass=" +strPass + "&YanZhengMa=" + strYanZhengMa;

         var myAjax = new Ajax.Request(strUrl, {method: 'post', parameters: strPars, onComplete: DoResult});
        
       }
	else
	{
    	alert("请输入用户名和密码以及验证码!");
	}
}

 function OnQiYeLogin(){
       
       var strUserName = document.getElementById("UserName").value;
       var strPass = document.getElementById("Pass").value;
       var strYanZhengMa =  document.getElementById("YanZhengMa").value;
       
       AjaxLogin("Login",strUserName,strPass,strYanZhengMa); 
     }
    
function OnQiYeLogOut(){

      AjaxLogin("Logout","parker","parker","parker"); 
	}

function DoResult(originalRequest)
{
    var strResponseText = originalRequest.responseText;
    //alert(strResponseText);
    if (strResponseText != null && strResponseText.length > 0)
    {
        if (strResponseText.indexOf("|") > 0)
        {
            strLabelId = strResponseText.substring(0, strResponseText.indexOf("|"));
            strText = strResponseText.substring(strResponseText.indexOf("|") + 1);
            if (strLabelId == "HTML_TITLE")
            {
                document.title = strText;
                
            }
            else if(strLabelId=="loginHiden")
            {
               alert("您输入的用户名或者密码不正确!也有可能还未通过总部审核。");
	         }
            else if(strLabelId=="loginError")
            {
               alert("您输入的验证码不正确，可能是验证码过期，尝试刷新页面获得新验证码。");
	        }  
	        else if(strLabelId=="loginPasDate")
            {
               alert("验证码已过期，请刷新页面!");
	         }  
            else
            {
               
                $(strLabelId).innerHTML = strText;
                var straa=strText.indexOf("loginOK");

                if(straa>0)
                {
                    var win = null;
                    win = window.open("/QY/QYIndexFrame.aspx");
                    if  (  win   ==   null  )
                    window.alert(   "管理后台正在弹出，请允许弹出式窗口或点击连接进入 "   ); 
                    
                    //window.showModalDialog("/QY/QYIndexFrame.aspx",,"dialogWidth=200px;dialogHeight=100px");
                    
                }

            }
        }
    }
}


function GetValue(strLabelId, strLabelName)
{
    if (strLabelId != null && strLabelId.length > 0 && strLabelName != null && strLabelName.length > 0)
    {
        var strUrl = "/AjaxService/GetLabel.aspx";
        var strPars = "LabelName=" + strLabelName + "&LabelId=" + strLabelId;
        var myAjax = new Ajax.Request(strUrl, {method: 'post', parameters: strPars, onComplete: DoResultValue});
    }
}
function DoResultValue(originalRequest)
{
    var strResponseText = originalRequest.responseText;
    //alert(strResponseText);
    if (strResponseText != null && strResponseText.length > 0)
    {
        if (strResponseText.indexOf("|") > 0)
        {
        
            strLabelId = strResponseText.substring(0, strResponseText.indexOf("|"));
            strText = strResponseText.substring(strResponseText.indexOf("|") + 1);
            $(strLabelId).value = strText;
        }
    }
}