﻿document.write("<script type=\"text/javascript\" src=\"/ajaxpro/prototype.ashx\"></script>");
document.write("<script type=\"text/javascript\" src=\"/ajaxpro/core.ashx\"></script>");
document.write("<script type=\"text/javascript\" src=\"/ajaxpro/converter.ashx\"></script>");
document.write("<script type=\"text/javascript\" src=\"/ajaxpro/LeagueRecord.LogicLayer.AjaxLogicLayer,LeagueRecord.LogicLayer.ashx\"></script>");
document.write("<script type=\"text/javascript\" src=\"/ajaxpro/LeagueRecord.LogicLayer.AjaxInterestLogicLayer,LeagueRecord.LogicLayer.ashx\"></script>");

//========================================================================//

String.prototype.trim = function()
{   
    return this.replace(/(^\s*)|(\s*$)/g,"");   
} 

function StringBuilder(value)
{
    this.strings = new Array("");
    this.append(value);
}

StringBuilder.prototype.append = function (value)
{
    if (value)
    {
        this.strings.push(value);
    }
}

StringBuilder.prototype.clear = function ()
{
    this.strings.length = 1;
}

StringBuilder.prototype.toString = function ()
{
    return this.strings.join("");
}

//========================================================================//

function CheckString(value)
{
    if(value.indexOf("'")!=-1 || value.indexOf("--")!=-1 || value.indexOf("<")!=-1 || value.indexOf(">")!=-1 || value.indexOf("\"")!=-1 || value.indexOf(";")!=-1 )
    {
        return false;           
    }
    else{return true;} 
}  

function CheckChar(value,showname)
{
    if(value.indexOf("'")!=-1 || value.indexOf("--")!=-1 || value.indexOf("<")!=-1 || value.indexOf(">")!=-1 || value.indexOf("\"")!=-1 || value.indexOf(";")!=-1 )
    {
        eval("document.getElementById('"+showname+"').innerHTML ='<font style=\"color:Red\" >包含特殊字符被禁止</font>';");return false;           
    }
    else{return true;} 
}   

function FontBegin(Value)
{
  return "<font style=\"color:"+Value+"\" >";
}

function FontEnd()
{
  return "</font>";
}

function $(objName)
{    
    if(document.getElementById)
    {
        return document.getElementById(objName);
    }
    else if(document.layers)
    {
        return eval("document.layers['" + objName +"']");
    }
    else
    {
        return eval('document.all.' + objName);
    }
}

//========================================================================//

function UpImage(ID)
{
   var url="/LogIn/Open.aspx?Laid=" + ID;   
   openwindow(url,"Ysg",602,380);     
}

function openwindow( url, winName, width, height) 
{
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ))
    {
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    theproperty= "width=" + width + "," 
    + "height=" + height + "," 
    + "location=0," 
    + "menubar=0,"
    + "resizable=0,"   //窗体不能调整大小
    + "scrollbars=0,"
    + "status=0," 
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + "," //仅适用于Netscape
    + "screeny=" + yposition + "," //仅适用于Netscape
    + "left=" + xposition + "," //IE
    + "top=" + yposition; //IE 
    window.open(url,winName,theproperty);
}
    
function SetValue(ID,Value)
{
   document.getElementById(ID).value = Value;
} 

//========================================================================//


/* div login */
//LeftText 显示左上角显示文字
//RightText 显示右上角X显示文字
//ShowWidth 弹出层的宽度
//ShowHeight 弹出层的高度
//IframeSrc 嵌入的Iframe路径！要调用页面的路径
//BgDivID 背景层id
//ShowDivID 显示层id

function ShowLoginDiv(LeftName,RightName,DivWidth,DivHeight,FrameSrc,BgDivID,ShowDivID)
{
    var bgdivid=document.getElementById(BgDivID);
    var showdivid=document.getElementById(ShowDivID);
    var builder = new StringBuilder();
    builder.append("<table border='0' cellpadding='0' cellspacing='0'>");
    builder.append("<tr style='background-color:#DBEDF5;'>");
    builder.append("<td align='left'>");
    builder.append(LeftName);
    builder.append("</td>");
    builder.append("<td align='right'>");
    builder.append("<span style=\'cursor:pointer\' title='"+RightName+"' onclick=HideLoginMask('"+BgDivID+"','"+ShowDivID+"')>×</span>");
    builder.append("</td>");
    builder.append("</tr>");
    builder.append("<tr>");
    builder.append("<td colspan='2'>");
    builder.append("<iframe src='"+FrameSrc+"' width='"+DivWidth+"px' height='"+DivHeight+"px' name='loginFrame' ");
    builder.append("id='loginFrame' frameborder='0' scrolling='no'></iframe>");
    builder.append("</td>");
    builder.append("</tr>");
    builder.append("</table>");
    
    bgdivid.style.height=document.body.scrollHeight;
    bgdivid.style.width=document.body.scrollWidth;
    bgdivid.style.display = 'block';
    showdivid.style.display = "block";
    showdivid.innerHTML = builder.toString();
    /*随屏幕滚动*/
    ScrollDiv(ShowDivID);  
    AutoScroll(ShowDivID)

} 

function HideLoginMask(BgDivID,ShowDivID)
{
    var bgdivid=document.getElementById(BgDivID);
    var showdivid=document.getElementById(ShowDivID);
    bgdivid.style.display="none";
    showdivid.style.display="none";
    document.body.scroll="yes";
}

/*随屏幕滚动*/
function ScrollDiv(ShowDivID)
{
  var showdivid=document.getElementById(ShowDivID); 
  if(showdivid!=null)
  {
    showdivid.style.top=(document.body.scrollTop+
    (document.body.clientHeight-showdivid.offsetHeight)/2)+"px";
    
    showdivid.style.left=(document.documentElement.scrollLeft+
    (document.body.clientWidth-showdivid.offsetWidth)/2)+"px";
   }
}

function AutoScroll(ShowDivID)
{
    window.onscroll=ScrollDiv; 
    window.onresize=ScrollDiv; 
    window.onload=ScrollDiv;  
}

//========================================================================//

function AddInterest(ProjectId)
{
    var PId = ProjectId + "";
    var back = LeagueRecord.LogicLayer.AjaxInterestLogicLayer.AddInterest(PId).value;
    if(back=="-1")
    {
        alert("意向添加错误");
    }
    else if (back=="0")
    {
        alert("用户信息获取错误");
    }
    else
    {
        alert("意向添加成功");
    }
}

function SendMessage(i,projectID)
{
    var title=document.getElementById('txt_MsgSubject'+i);
    var content=document.getElementById('txt_MsgContent'+i);
    if(title.value=="")
    {
        alert("请填写留言标题！");
        title.focus();
        return false;
    }
    if(content.value=="")
    {
        alert("请填写留言内容！");
        content.focus();
        return false;
    }

    var userID=document.getElementById('Hidden_UserID').value;
    var consultantID=document.getElementById('Hidden_consultantID').value;
    if(consultantID=="")
    {
        //ShowMsgDiv(strHtml2);
        showLogin();
        return false;
    }
    var back = LeagueRecord.LogicLayer.AjaxLogicLayer.SendMessageToConsultant(title.value,content.value,userID,consultantID,projectID).value;
    if(back=="1")
    {
        document.getElementById('leaveMsg'+i).style.display='none';
        title.value="";
        content.value="";
        alert("留言已发出！");
    }
    else if(back=="0")
    {
        alert("留言失败，请与管理员联系！");
    }
}


function SetCookie(name,value)  
{  
    var Days = 1;  
    var exp = new Date();  
    exp.setTime(exp.getTime() + Days*24*60*60*1000);  
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();  
}   

/*
* 函数说明：取cookie值
* 参数：	cookie字段名
* 返回值：	cookie值
* 时间：2006-5-12
*/
function getCookie(sName) 
{
    var aCookie = document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++)
    {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
            return unescape(aCrumb[1]);
    }
    return null;
}

function delCookie(name)  
{  
 var exp = new Date();  
 exp.setTime(exp.getTime() - 1);  
 var cval=getCookie(name);  
 if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();  
}  

//========================================================================//

function IsNum(Str)
{
    var validChar = "0123456789";
    for(var i = 0;i<Str.length;i++)
    {
        var c = Str.charAt(i);
        if (validChar.indexOf(c) == -1) return false;
    } 
    return true;
} 

function IsEmail(ctl)
{ 
    var regexp=/^[a-zA-Z0-9_]{2,15}[@][a-zA-z0-9-]{1,100}[.]([a-zA-Z]{2,4}|[a-zA-Z]{2,4}[.][a-zA-Z]{2})$/g;
    if(!regexp.test(ctl)){return false;}else{return true;}
}

function CheckLength(Name,ShowName)
{
   if(Name.length==0)
   {
      alert(ShowName + "不能为空");      
      return false;
   }
   if(CheckString(Name)==false)
   {
      alert(ShowName + "包含特殊字符，请去除特殊字符");
      return false;
   }
   return true;
}

//获取坐标 
var top=0;
var left=0;
function getpos(e)
{
    top=e.offsetTop;
    left=e.offsetLeft;
    var height=e.offsetHeight;
    while(e=e.offsetParent)
    { 
        top+=e.offsetTop;
        left+=e.offsetLeft;
    }
}

var strHtml2="<div class=\"lltc\">";
strHtml2+="<div class=\"ibc\">";
strHtml2+="您还没有登录，请登录！";
strHtml2+="</div>";
strHtml2+="<div class=\"input\"><img src=\"/images1/input_close.gif\" width=\"68\" height=\"33\" style=\"cursor:pointer;\" onclick=\"HideMsgDiv();\" /></div>";
strHtml2+="</div>";

function checkIsHave(rank_subID,leaveMsgID,obj)
{
    var substractTop=0;
    var substractLeft=0;
    switch(leaveMsgID)
    {
        case 'leaveMsg2':
            substractTop=150;
            substractLeft=-100;
            break;
        case 'leaveMsg5':
            substractTop=100;
            substractLeft=200;
            break;
        case 'leaveMsg6':
            substractTop=100;
            substractLeft=200;
            break;
        case 'leaveMsg4':
            substractTop=0;
            substractLeft=650;
            break;
        case 'leaveMsg0':
            substractTop=0;
            substractLeft=200;
            break;
            
    }
    if(document.getElementById('Hidden_consultantID').value=="")
    {
        Interest_Or_Message=false;
        popup_show();
        return false;
    }
    if(rank_subID!="")
    {
        document.getElementById(rank_subID).style.display='none';
    }
    
    document.getElementById(leaveMsgID).style.display='block';
    if(leaveMsgID=="leaveMsg6")
    {
        getpos(obj);
        document.getElementById(leaveMsgID).style.top=top-230;
        document.getElementById(leaveMsgID).style.left=left;
    }
    return true;
}

function ShowMsgDiv(str)
{           
    document.getElementById("DivMask").style.height=document.body.scrollHeight;
    document.getElementById("DivMask").style.width=document.body.scrollWidth;
    document.getElementById("DivMask").style.display = 'block';
    document.getElementById("DivLogin").style.display = "block";
    document.getElementById("DivLogin").innerHTML = str;
    document.body.scroll="no";
} 
function HideMsgDiv()
{
    document.getElementById("DivMask").style.display="none";
    document.getElementById("DivLogin").style.display="none";
}