﻿var Navigator = new Object();
if(navigator.userAgent.indexOf("MSIE") != -1)
{
    Navigator.IE = true;
    if(navigator.userAgent.indexOf("MSIE 6.0") != -1)
    {
        Navigator.IE6 = true;
    }
    if(navigator.userAgent.indexOf("MSIE 7.0") != -1)
    {
        Navigator.IE7 = true;
    }
}
if(navigator.userAgent.indexOf("Firefox") != -1)
{
    Navigator.Firefox = true;
}
if(!Navigator.IE6 && !Navigator.IE7 && !Navigator.Firefox)
{
    //alert('您的浏览器暂不支持，因此可能显示有问题，建议使用Microsoft IE 6.0+或Mozilla Firefox浏览');
}
function $(id)
{
    return document.getElementById(id);
}
function SetCookie(sName, sValue)
{
    var date = new Date();
    date.setTime(date.getTime()+1200*1000); 
    document.cookie = sName + "=" + escape(sValue) + "; domain=fuedf.org; expires=" + date.toGMTString();
}
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 GetPrefix()
{
    var url = window.location.href;
    var spaceIndex = url.indexOf('space.');
    var communityIndex = url.indexOf('qun.');
    alert(spaceIndex);
    alert(communityIndex);
    if(spaceIndex == -1)
    {
        if(communityIndex >= 0)
        {
            alert(url.indexOf('.yi-qiao.com'));
            var temp = url.substring(17,url.indexOf('.yi-qiao.cn'));
            alert(temp);
            return temp;
        }
        else
            return null;
    }
    else if(communityIndex == -1)
    {
        return url.substring(communityIndex+6,url.indexOf('.yi-qiao.cn'));
    }
    else
        return null;
}
function SetHomePage(url)
{
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage(url);
}
function NewWindow(url)
{
    window.open(url);
}
function Reload()
{
    window.location.href = window.location.href;
    //document.execCommand('Refresh');
}
function ToggleDisplay_none_block(controlID)
{
    var control = $(controlID);
    if (control.style.display == 'none')
    {
        control.style.display = 'block';
    }
    else
    {
        control.style.display = 'none';
    }
}
function ToggleDisplay(control)
{
    if (control.style.display == 'none')
    {
        control.style.display = 'block';
    }
    else
    {
        control.style.display = 'none';
    }
}
function SetDisplayNone(controlID)
{
    var control = $(controlID);
    control.style.display = 'none';
}
function SetDisplayBlock(controlID)
{
    var control = $(controlID);
    control.style.display = 'block';
}
function SetDisplayInline(controlID)
{
    var control = $(controlID);
    control.style.display = 'inline';
}
function SetHidden(controlID)
{
    var control = $(controlID);
    control.style.visibility = 'hidden';
}
function SetVisible(controlID)
{
    var control = $(controlID);
    control.style.visibility = 'visible';
}
function SetEnable(controlID)
{
    $(controlID).disabled = false;
}
function SetDisable(controlID)
{
    $(controlID).disabled = true;
}
function SetFocus(controlID)
{
    var control = $(controlID);
    try
    {
        control.focus();
    }
    catch(e){}
}
function SetFloatLeft(control)
{
    if(document.all)
    {
        control.style.styleFloat = 'left';
    }
    else
    {
        control.style.cssFloat = 'left';
    }
}
function SetFloatRight(control)
{
    if(document.all)
    {
        control.style.styleFloat = 'right';
    }
    else
    {
        control.style.cssFloat = 'right';
    }
}
function SetFrameHeight(height)
{
    if(height != null)
    {
        window.frameElement.style.height = height + "px";
    }
    else
    {
        window.frameElement.style.height = document.body.scrollHeight + "px";
    }
}
function SetFrameHeightAtLeast(height)
{
    if(document.body.scrollHeight < height)
    {
        SetFrameHeight(height);
    }
    else
    {
        SetFrameHeight();
    }
}
function AddFrameHeight(height)
{
    window.frameElement.style.height = window.frameElement.offsetHeight + height + "px";
}
function SetHeight(controlID,height)
{
    $(controlID).style.height = height + "px";
}
function SetMaxHeight(control,maxHeight)
{
    if(control.scrollHeight > maxHeight)
    {
        control.style.height = maxHeight + 'px';
        control.style.overflow = 'auto';
    }
    else
    {
        control.style.height = '';
        control.style.overflow = '';
    }
}
function IsNone(controlID)
{
    if($(controlID).style.display == "none")
    {
        return true;
    }
    return false;
}
function IsBlock(controlID)
{
    if($(controlID).style.display == "block")
    {
        return true;
    }
    return false;
}
function CancelBubble(e)
{
    if(document.all)
    {
        event.cancelBubble = true;
    }
    else
    {
        e.stopPropagation();
    }
}
function FireEvent(obj,eventName)
{
    if(document.all)
    {
        obj.fireEvent('on' + eventName);
    }
    else
    {
        var evt = document.createEvent('MouseEvents'); 
        evt.initEvent(eventName, 1, 1)
        obj.dispatchEvent(evt);
    }
}
function CancelEvent(e)
{
    if(document.all)
    {
        event.returnValue = false;
    }
    else
    {
        if (e)
        {
            e.preventDefault();
        }
    }   
}
function GetOffsetLeft(control)
{
    var offsetLeft = 0;
    while(control != null)
    {
        offsetLeft += control.offsetLeft;
        control = control.offsetParent;
    }
    return offsetLeft;
}
function GetOffsetTop(control)
{
    var offsetTop = 0;
    while(control != null)
    {
        offsetTop += control.offsetTop;
        control = control.offsetParent;
    }
    return offsetTop;
}
function Redirect(url)
{
    window.location.href = url;
}
function DisableContextMenu()
{
    document.oncontextmenu = ReturnFalse;
}
function FixPng(img)
{
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
	{
		var span = document.createElement('span');
		span.id = img.id;
		span.className = img.className;
		span.title = img.title? img.title:img.alt;
		span.style.width = img.offsetWidth + 'px';
		span.style.height = img.offsetHeight + 'px';
		span.style.display = 'inline-block';
		span.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + img.src + '", sizingMethod="crop")';
		img.parentNode.replaceChild(span,img);
   }
}
Function.createDelegate = function(object, method)
{
	if(arguments.length == 2)
    {
        return function()
        {        
            method.apply(object,arguments);
        }
    }
    if(arguments.length > 2)
    {
        var args = new Array();
        for(var i = 0; i < arguments.length - 2; i++)
	    {
		    args[i] = arguments[i + 2];
	    }
        return function()
        {
            method.apply(object,args);
        }
    }
}
var scriptQueue = new Array();
var isLoadingScript = false;
function AddScript(src,onload)
{
    scriptQueue[scriptQueue.length] = new ScriptObj(src,onload);
    if(!isLoadingScript)
    {
        CheckScriptQueue();
    } 
}
function ScriptObj(src,onload)
{
    this.Src = src;
    this.Onload = onload;
}
function CheckScriptQueue()
{
    if(scriptQueue.length > 0)
    {
        isLoadingScript = true;
        var scriptObj = scriptQueue[0];
        scriptQueue.splice(0,1);
        var script = document.createElement('script');
        script.language = 'javascript';
        script.type = 'text/javascript';
        script.src = scriptObj.Src;
        script.loadDone = scriptObj.Onload;
        script.onload = script.onreadystatechange = LoadScriptDone;
        var head = document.getElementsByTagName('head')[0];
        head.appendChild(script);
    }
    else
    {
        isLoadingScript = false;
    }
}
function LoadScriptDone()
{
    if(!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')
    {
        if(this.loadDone)
        {
            this.loadDone();
        }
        CheckScriptQueue();
    } 
}
function AddCSS(src)
{
    var css = document.createElement('link');
    css.rel	= 'stylesheet';
	css.type = 'text/css';
	css.href = src;
	var head = document.getElementsByTagName('head')[0];
    head.appendChild(css);
}
// 复制到剪贴板
function CopyToClipboard(control)
{
    if (control.createTextRange)
    {
        var range = control.createTextRange();
        range.select();
        range.execCommand('Copy');
    } 
    else
    {
        var flashcopier = 'flashcopier';
        if(!$(flashcopier)) 
        {
            var divholder = document.createElement('div');
            divholder.id = flashcopier;
            document.body.appendChild(divholder);
        }
        $(flashcopier).innerHTML = '';
        var divinfo = '<embed src="http://www.yi-qiao.cn/images/_clipboard.swf" FlashVars="clipboard='
                    + escape(control.value) + '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
        $(flashcopier).innerHTML = divinfo;
    }
}
function TrimEnd(stringToTrim)
{
    if (stringToTrim != null && stringToTrim.length > 0 )    
    {          
        var temp = stringToTrim.charAt(stringToTrim.length - 1);
        while (stringToTrim.length > 0  && temp == ' ')  
        {
            stringToTrim = stringToTrim.substr(0, stringToTrim.length - 1); 
            temp = stringToTrim.charAt(stringToTrim.length - 1);
        }
    }
    return stringToTrim;          
}
function TimeFormat(dateTime)
{
    if(typeof dateTime == 'string')
    {
        return dateTime.toLocaleString().substr(0,dateTime.toLocaleString().length - 3);
    }
    var minutes = dateTime.getMinutes();
    if (minutes < 10)
    {
        minutes = '0' + minutes;
    }
    var time = dateTime.getFullYear() + '-' + (dateTime.getMonth() + 1) + '-' + dateTime.getDate() + ' ' + dateTime.getHours() + ':' + minutes;
    return time;
}
function DateFormat(dateTime)
{
    return dateTime.getFullYear() + '-' + (dateTime.getMonth() + 1) + '-' + dateTime.getDate();
}
String.Format = function()
{
    if(arguments.length == 0)
    {
        return null;
    }
    var exp = arguments[0];
    for(var i = 1; i < arguments.length; i++)
    {
        var reg = new RegExp('\\{' + (i-1) + '\\}','gm');

        exp = exp.replace(reg, arguments[i]);
    }
    return exp;
}
function RssTimeFormat(dateTime)
{
    return dateTime.toLocaleString().substr(0,dateTime.toLocaleString().length - 7);
}
function TagsFormat(tags)
{
    var tagsFormated="";
    if(tags.length > 0)
    {
        for(var i = 0; i < tags.length - 1; i++)
        {
            if (typeof(tags[i].Name) != 'undefined')
            {
                tagsFormated += tags[i].Name + " ";  
            }
            else
            {
                tagsFormated += tags[i] + " "; 
            }
        }
        if (typeof(tags[tags.length - 1].Name) != 'undefined')
        {
            tagsFormated += tags[tags.length - 1].Name;
        }
        else
        {
           tagsFormated += tags[tags.length - 1];  
        }
    }
    return tagsFormated;
}
function HtmlEncode(s)
{
    var c,r = '';
    for(var i = 0; i < s.length; i ++)
    {
        c = s.substr(i,1);
        switch(c)
        {
            case "&" : r += "&amp;";break;
            case "<" : r += "&lt;";break;
            case ">" : r += "&gt;";break;
            case "\"": r += "&quot;";break;
            case "'" : r += "&#39;";break;
            default  : r += c;
        }
    }
    return r;
}
function HtmlDecode(s)
{
    for(var i = 0; i < s.length; i ++)
    {
        if(s.substr(i,1) != "&")
        {
            continue;
        }
        if(s.substr(i + 1, 4) == "amp;")
        {
            s = s.substring(0,i) + "&" + s.substring(i + 5, s.length);
            continue;
        }
        if(s.substr(i + 1, 3) == "lt;")
        {
            s = s.substring(0,i) + "<" + s.substring(i + 4, s.length);
            continue;
        }
        if(s.substr(i + 1, 3) == "gt;")
        {
            s = s.substring(0,i) + ">" + s.substring(i + 4, s.length);
            continue;
        }
        if(s.substr(i + 1, 5) == "quot;")
        {
            s = s.substring(0,i) + "\"" + s.substring(i + 6, s.length);
            continue;
        }
        if(s.substr(i + 1, 4) == "#39;")
        {
            s = s.substring(0,i) + "'" + s.substring(i + 5, s.length);
            continue;
        }
    }
    return s;
}
function ResizeImage(htmlNode, maxWidth)
{
    var imgNodes = htmlNode.getElementsByTagName('IMG'); 
    if (imgNodes!= null)
    {
        for (var i = 0; i < imgNodes.length; i++)
        {
            var node = imgNodes[i];
            if (node != null) 
            {
                if (node.offsetWidth > 150)
                {
                    node.style.display = 'block';
                }
                if (node.readyState == 'loaded' || node.readyState == 'complete')
                {
                    if (node.offsetWidth > maxWidth)
                    {
                            
                        node.style.height = (maxWidth / node.offsetWidth) * node.offsetHeight + 'px';
                        node.style.width = maxWidth + 'px';
                        if (node.parentNode.tagName != 'A')
                        {
                            node.oldAlt = node.alt;
                            node.alt = node.alt + '(点击查看原图)';
                            node.onclick = ViewImage;
                            node.style.cursor = 'pointer';
                        }
                    }
                }
                else
                {
			        node.MaxWidth = maxWidth;
				    node.onload = ResizeAfterLoad;
                }
            }           
        }
    } 
}
function ResizeImage(htmlNode, maxWidth, maxHeight)
{
    var imgNodes = htmlNode.getElementsByTagName('IMG'); 
    if (imgNodes!= null)
    {
        for (var i = 0; i < imgNodes.length; i++)
        {
            var node = imgNodes[i];
            if (node != null) 
            {
                if (node.offsetWidth > 150)
                {
                    node.style.display = 'block';
                }
                if (node.readyState == 'loaded' || node.readyState == 'complete')
                {
                    if (node.offsetWidth > maxWidth)
                    {
                            
                        node.style.height = (maxWidth / node.offsetWidth) * node.offsetHeight + 'px';
                        node.style.width = maxWidth + 'px';
                        if((maxWidth / node.offsetWidth) * node.offsetHeight > maxHeight)
                        {
                            node.style.width = (maxHeight / node.offsetHeight) * node.offsetWidth + 'px';
                            node.style.height = maxHeight + 'px';
                        }
                        if (node.parentNode.tagName != 'A')
                        {
                            node.oldAlt = node.alt;
                            node.alt = node.alt + '(点击查看原图)';
                            node.onclick = ViewImage;
                            node.style.cursor = 'pointer';
                        }
                    }
                }
                else
                {
			        node.MaxWidth = maxWidth;
			        node.MaxHeight = maxHeight;
				    node.onload = ResizeAfterLoad;
                }
            }           
        }
    } 
}
function ResizeAfterLoad(e)
{
    var node;
    if(document.all)
    {
        node = window.event.srcElement;
	}
	else
	{
	    node = e.currentTarget;
	}
	if (node.offsetWidth > node.MaxWidth)
	{
		node.style.height = (node.MaxWidth / node.offsetWidth) * node.offsetHeight + 'px';
		node.style.width = node.MaxWidth + 'px';
		if((node.MaxWidth / node.offsetWidth) * node.offsetHeight > node.MaxHeight)
        {
            node.style.width = (node.MaxHeight / node.offsetHeight) * node.offsetWidth + 'px';
            node.style.height = node.MaxHeight + 'px';
        }
        if (node.parentNode.tagName != 'A')
        {
            node.oldAlt = node.alt;
            node.alt = node.alt + '(点击查看原图)';
            node.onclick = ViewImage;
            node.style.cursor = 'pointer';
        }
	}
}
function ViewImage(evt)
{
    if(document.all)
    {
        var node = window.event.srcElement;
	}
	else
	{
	    var node = evt.srcElement;
	}   
    window.open(node.src);    
}
function GetString(s, length)
{
    if(s == null)
    {
        return null;
    }
    var temp = HtmlDecode(s);
    var needEncode = false;
    if(temp != s)
    {
        needEncode = true;
    }
    if(temp.length <= length)
    {
        return needEncode? HtmlEncode(temp):temp;
    }    
    return needEncode? HtmlEncode(temp.substr(0, length - 1) + "…"):(temp.substr(0, length - 1) + "…");
}
function CheckEnterKey(e,handler)
{
    if(e.keyCode != 13)
    {
        return true;
    }
    if(handler != null)
    {
        handler();
    }
    return false; 
}
function IsOverLap(div1,div2)
{
    if(GetOffsetLeft(div1) < GetOffsetLeft(div2) + div2.offsetWidth && GetOffsetLeft(div1) + div1.offsetWidth > GetOffsetLeft(div2) && GetOffsetTop(div1) < GetOffsetTop(div2) + div2.offsetHeight && GetOffsetTop(div1) + div1.offsetHeight > GetOffsetTop(div2))
    {
        return true;
    }
    if(GetOffsetLeft(div2) < GetOffsetLeft(div1) + div1.offsetWidth && GetOffsetLeft(div2) + div2.offsetWidth > GetOffsetLeft(div1) && GetOffsetTop(div2) < GetOffsetTop(div1) + div1.offsetHeight && GetOffsetTop(div2) + div2.offsetHeight > GetOffsetTop(div1))
    {
        return true;
    }
    return false;
}
function ReturnFalse()
{
    return false;
}
function FixPng(img)
{
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
	{
		var span = document.createElement('span');
		span.id = img.id;
		span.className = img.className;
		span.title = img.title? img.title:img.alt;
		span.style.width = img.offsetWidth + 'px';
		span.style.height = img.offsetHeight + 'px';
		span.style.display = 'inline-block';
		span.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + img.src + '", sizingMethod="crop")';
		img.parentNode.replaceChild(span,img);
   }
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function GetInputValue(name)
{
    var inputs = document.getElementsByName(name);
    var value = '';
    for(var i = 0; i < inputs.length; i++)
    {
        var input = inputs[i];
        var type = input.type;
        switch(type)
        {
            case 'text':
            case 'textarea':
            case 'hidden':
                value = input.value;
                break;
            case 'radio':
                if(input.checked)
                {
                    value = input.value;
                }
                break;
            case 'checkbox':
                var checkValue = '';
                if(input.checked)
                {
                    checkValue = input.value;
                }
                if(checkValue != '')
                {
                    if(value == '')
                    {
                        value = checkValue;
                    }
                    else
                    {
                        value += ',' + checkValue;
                    }
                }
                break;
            default:
                break;
        }
    }
    return value;
}
function SetInputValue(name, value)
{
    var inputs = document.getElementsByName(name);
    for(var i = 0; i < inputs.length; i++)
    {
        var input = inputs[i];
        input.value = value;
    }
}
function ResetSelects()
{
    var selects = document.getElementsByTagName('select');
    for(var i = 0; i < selects.length; i++)
    {
        selects[i].selectedIndex = 0;
    }
}
function YQAlert(content, btnText, btnOnclickHandler, isRight)
{
    if(btnOnclickHandler == null || btnOnclickHandler == 'undefined')
    {
        btnOnclickHandler = "YiQiaoAlertPanel.Hide()";
    }
    else
    {
        btnOnclickHandler += ";YiQiaoAlertPanel.Hide();";
    }
    if(btnText == null || btnText == 'undefined')
    {
        btnText = '确 定';
    }
    var noteDiv
    var html = '';
    html += '<div class="close"><a href="javascript:void(0)" onclick="YiQiaoAlertPanel.Hide()" class="f3">[关闭]</a></div>';
    html += '<div class="content2">';
    if((isRight || isRight == null) || isRight == 'undefined')
    {
        html += '<div class="alert" style="height:50px">';
    }
    else
    {
        html += '<div class="alert" style="height:50px;background:url(/Themes/Theme3/images/regts_arr.gif) left 30px no-repeat">';
    }
    html += content;
    html += '</div>';
    html += '<div align="right"><input name="Submit" type="button" class="input2" id="Submit" onclick="'+btnOnclickHandler+'" value="'+btnText+'" /></div>';
    html += '</div>';
    html += '<div class="clear"></div>';
    var divMainLeft = Math.floor((document.body.offsetWidth - 451) / 2);
    var divMainTop = document.body.scrollTop  + 200;
    if(!window.YiQiaoAlertPanel)
    {
        noteDiv = InitialPopupMenu(false);
        noteDiv.id = 'YiQiaoNoteDiv';
        noteDiv.className = 'Direct_Successbox';
        noteDiv.style.display = 'none';
        noteDiv.innerHTML = html;
        YiQiaoAlertPanel = new PopupMenu(noteDiv, divMainLeft, divMainTop, 451, 0, false, false, null, false, true);
        YiQiaoAlertPanel.Div.style.zIndex = 999;
        YiQiaoAlertPanel.Show();
    }
    else
    {
        YiQiaoAlertPanel.Div.innerHTML = html;
        YiQiaoAlertPanel.Show();
    }
}
function YQConfirm(content, confirmText, cancelText, confirmOnclickHandler, cancelOnclickHandler)
{
    if(confirmText == null || confirmText == 'undefined')
    {
        confirmText = "确 定";
    }
    if(cancelText == null || cancelText == 'undefined')
    {
        cancelText = "取 消";
    }
    if(confirmOnclickHandler == null)
    {
        confirmOnclickHandler = "YiQiaoConfirmPanel.Hide();return true;";
    }
    else
    {
        confirmOnclickHandler += ";YiQiaoConfirmPanel.Hide();return true;";
    }
    if(cancelOnclickHandler == null)
    {
        cancelOnclickHandler = "YiQiaoConfirmPanel.Hide();return false;";
    }
    else
    {
        cancelOnclickHandler += ";YiQiaoConfirmPanel.Hide();return false;";
    }
    var noteDiv
    var html = '';
    html += '<div class="close"><a href="javascript:void(0)" onclick="YiQiaoConfirmPanel.Hide()" class="f3">[关闭]</a></div>';
    html += '<div class="content2">';
    html += '<div class="alert" style="height:50px;background:url(/Themes/Theme3/images/tsarr2.gif) left 30px no-repeat">';
    html += content;
    html += '</div>';
    html += '<div align="right"><input name="Submit" type="button" onclick="'+confirmOnclickHandler+'" id="Submit" value="'+confirmText+'" />    <input name="Submit" type="button" class="input2" value="'+cancelText+'" onclick="'+cancelOnclickHandler+'" id="Submit" /></div>';
    html += '</div>';
    html += '<div class="clear"></div>';
    var divMainLeft = Math.floor((document.body.offsetWidth - 451) / 2);
    var divMainTop = 200;
    if(!window.YiQiaoConfirmPanel)
    {
        noteDiv = InitialPopupMenu(false);
        noteDiv.id = 'YiQiaoNoteDiv';
        noteDiv.className = 'Direct_Successbox';
        noteDiv.style.display = 'none';
        noteDiv.innerHTML = html;
        YiQiaoConfirmPanel = new PopupMenu(noteDiv, divMainLeft, divMainTop, 451, 0, false, false, null, false, true);
        YiQiaoConfirmPanel.Div.style.zIndex = 999;
        YiQiaoConfirmPanel.Show();
    }
    else
    {
        YiQiaoConfirmPanel.Div.innerHTML = html;
        YiQiaoConfirmPanel.Show();
    }
}


/********** Pop *****************/

function YQPopConfirm(control, content, confirmText, cancelText, confirmOnclickHandler, cancelOnclickHandler, type)
{
    if(confirmText == null || confirmText == 'undefined')
    {
        confirmText = "确 定";
    }
    if(cancelText == null || cancelText == 'undefined')
    {
        cancelText = "取 消";
    }
    if(type == null || type == 'undefined')
    {
        type = "down";
    }
    if(confirmOnclickHandler == null || confirmOnclickHandler == 'undefined')
    {
        confirmOnclickHandler = "YiQiaoPopConfirmPanel.Hide();return true;";
    }
    else
    {
        confirmOnclickHandler += ";YiQiaoPopConfirmPanel.Hide();return true;";
    }
    if(cancelOnclickHandler == null || cancelOnclickHandler == 'undefined')
    {
        cancelOnclickHandler = "YiQiaoPopConfirmPanel.Hide();return false;";
    }
    else
    {
        cancelOnclickHandler += ";YiQiaoPopConfirmPanel.Hide();return false;";
    }
    
    var noteDiv;
    var html = '';
    var divMainLeft = 0;
    var divMainTop = 0;
    
    if(type == "down")
    {
        html += '<div class="top">';
        html += '<div class="arr"></div>';
        html += '</div>';
        html += '<div class="border">';
        html += '<div class="content">'+content+'</div>';
        html += '<div class="but"><input name="" onclick="'+confirmOnclickHandler+'" type="button"  value="'+confirmText+'" class="button1" /> <input name="" type="button"  value="'+cancelText+'" onclick="'+cancelOnclickHandler+'"  class="button1" /></div>';
        html += '</div>';
        html += '<div class="bottom"></div>';
    }
    else if(type == "up")
    {
        html += '<div class="top"></div>';
        html += '<div class="border">';
        html += '<div class="content">'+content+'</div>';
        html += '<div class="but"><input name="" onclick="'+confirmOnclickHandler+'" type="button"  value="'+confirmText+'" class="button1" /> <input name="" type="button"  value="'+cancelText+'" onclick="'+cancelOnclickHandler+'"  class="button1" /></div>';
        html += '</div>';
        html += '<div class="bottom"><div class="arr"></div></div>';
    }
    
    if(control == null || control == 'defined')
    {
        divMainLeft = Math.floor((document.body.offsetWidth - 221) / 2);
        divMainTop = 200;
    }
    else
    {
        if(type == "up")
        {
            divMainLeft = GetOffsetLeft(control) + control.offsetWidth;
            divMainTop = GetOffsetTop(control) - 80;
        }
        else if(type == "down")
        {
            divMainLeft = GetOffsetLeft(control) - 221;
            divMainTop = GetOffsetTop(control) + control.offsetHeight;
        }
    }
    if(!window.YiQiaoPopConfirmPanel)
    {
        noteDiv = InitialPopupMenu(false);
        noteDiv.id = 'YiQiaoConfirmDiv';
        if(type == "up")
        {
            noteDiv.className = 'popoboxBlueAPI';
        }
        else if(type == "down")
        {
            noteDiv.className = 'popoboxOrangeAPI';
        }
        noteDiv.style.display = 'none';
        noteDiv.innerHTML = html;
        YiQiaoPopConfirmPanel = new PopupMenu(noteDiv, divMainLeft, divMainTop, 221, 0, false, false, null, false, true);
        YiQiaoPopConfirmPanel.Div.style.zIndex = 999;
        YiQiaoPopConfirmPanel.Show();
    }
    else
    {
        YiQiaoPopConfirmPanel.Hide();
        noteDiv = InitialPopupMenu(false);
        noteDiv.id = 'YiQiaoConfirmDiv';
        if(type == "up")
        {
            noteDiv.className = 'popoboxBlueAPI';
        }
        else if(type == "down")
        {
            noteDiv.className = 'popoboxOrangeAPI';
        }
        noteDiv.style.display = 'none';
        noteDiv.innerHTML = html;
        YiQiaoPopConfirmPanel = new PopupMenu(noteDiv, divMainLeft, divMainTop, 221, 0, false, false, null, false, true);
        YiQiaoPopConfirmPanel.Div.style.zIndex = 999;
        YiQiaoPopConfirmPanel.Show();
    }
}

/**********End Pop****************/
/*PageContainer Start*/
function PageContainer(content,pageSize)
{
    this.PageIndex = 0;
    this.Content = content;
    this.PageSize = pageSize;
}
PageContainer.prototype.GetPageIndex = function()
{
    return this.PageIndex;
}
PageContainer.prototype.GetCount = function()
{
    if (this.Content == null)
    {
        return 0;
    }
    return this.Content.length;
}
PageContainer.prototype.GetPageNum = function()
{
    return Math.ceil(this.GetCount() / this.PageSize);
}
PageContainer.prototype.IsLastPage = function()
{
    if (this.PageIndex == this.GetPageNum() - 1 || this.GetPageNum() == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}
PageContainer.prototype.IsFirstPage = function()
{
    if (this.PageIndex == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}
PageContainer.prototype.GetPage = function(index)
{
    if(index > this.GetPageNum() - 1 || index < 0)
    {
        return null;
    }
    this.PageIndex = index;
    if(index < this.GetPageNum() - 1)
    {
        var result = new Array(this.PageSize);
        for(var i = 0 ; i < this.PageSize ; i ++)
        {
            result[i] = this.Content[this.PageIndex * this.PageSize + i];            
        }
        return result;
    }
    else
    {
        var result = new Array(this.Content.length - this.PageSize * index);
        for(var i = 0 ; i < this.Content.length - this.PageSize * index ; i ++)
        {
            result[i] = this.Content[this.PageIndex * this.PageSize + i];            
        }
        return result;
    }
}
PageContainer.prototype.GetFirstPage = function()
{
    return this.GetPage(0);
}
PageContainer.prototype.GetLastPage = function()
{
    return this.GetPage(this.GetPageNum() - 1);
}
PageContainer.prototype.GetNextPage = function()
{
    return this.GetPage(this.PageIndex + 1);
}
PageContainer.prototype.GetPrePage = function()
{
    return this.GetPage(this.PageIndex - 1);
}
PageContainer.prototype.GetCurrentPage = function()
{
    return this.GetPage(this.PageIndex);
}
PageContainer.prototype.GetItem = function(itemIndex)
{
    if(itemIndex < 0 || itemIndex > this.Content.length - 1)
    {
        return null;
    }
    return this.Content[itemIndex];
}
PageContainer.prototype.DeleteItem = function(itemIndex)
{
    if(itemIndex < 0 || itemIndex > this.Content.length - 1)
    {
        return;
    }
    this.Content.splice(itemIndex,1);
}
PageContainer.prototype.DeleteItemInCurrentPage = function(indexInPage)
{
    this.DeleteItem(this.PageSize * this.PageIndex + indexInPage);
}
PageContainer.prototype.AddItemAt = function(atIndex,item)
{
    if(atIndex < 0 || atIndex > this.Content.length)
    {
        return;
    }
    this.Content.splice(atIndex,0,item);
}
PageContainer.prototype.AddItems = function(newContent)
{
    for(var i = 0; i < newContent.length; i ++)
    {
        this.AddItemAt(this.GetCount(),newContent[i]);       
    } 
}
/*PageContainer End*/
/*NPageContainer Start*/
function NPageContainer(getMethod,callback,pageSize)
{
    this.GetMethod = getMethod;
    this.PageSize = pageSize;
    this.Callback = callback;
    this.ItemCount = 0;
    this.PageCount = 0;
}
NPageContainer.prototype.GetFirstPage = function()
{
    this.PageIndex = 0;
    this.GetCurrentPage();
}
NPageContainer.prototype.GetPrePage = function()
{
    this.PageIndex = Math.max(0,this.PageIndex - 1);
    this.GetCurrentPage();
}
NPageContainer.prototype.GetNextPage = function()
{
    if(this.PageCount)
    {
        this.PageIndex = Math.min(this.PageCount - 1,this.PageIndex + 1);
        this.GetCurrentPage();
    }
}
NPageContainer.prototype.GetLastPage = function()
{
    if(this.PageCount)
    {
        this.PageIndex = this.PageCount - 1;
        this.GetCurrentPage();
    }
}
NPageContainer.prototype.GetCurrentPage = function()
{
    this.GetPage(this.PageIndex);
}
NPageContainer.prototype.GetPage = function(pageIndex)
{
    this.PageIndex = pageIndex;
    var callback = Function.createDelegate(this, this.GetPageSuccess);
    this.GetMethod(this.PageIndex,this.PageSize, callback);
}
NPageContainer.prototype.GetPageSuccess = function(result)
{
    if(result != null)
    {
        this.ItemCount = result.ItemCount;
        this.PageCount = Math.ceil(this.ItemCount / this.PageSize);
        if (result.Items == null || result.Items.length == 0)
        {
            if (this.PageIndex > this.PageCount - 1)
            {
                this.PageIndex = this.PageCount - 1; 
                this.GetCurrentPage();
            }  
            else
            {
                this.Callback(null);
            }
        }   
        else
        {
            this.Callback(result.Items);
        }
    }
}
NPageContainer.prototype.IsFirstPage = function()
{
    return (this.PageIndex == 0);
}
NPageContainer.prototype.IsLastPage = function()
{
    return (this.PageIndex == this.PageCount - 1);
}
/*PageContainer End*/
/*Popup Menu Start*/
var hasShown;
var _SelfClickClose;
var _OutClickClose;
var _CloseHandler;
var _PopupMenuContent;
/*
    弹出菜单（全局，只出现一个）
    content:需要显示的内容
    left:左顶点绝对位置
    top:上顶点绝对位置
    width:宽度
    height:高度
    selfClickClose:菜单内部点击是否关闭菜单
    outClickClose:菜单外部点击是否关闭菜单
    closeHandler:关闭是调用的外部函数句柄
*/
function TogglePopupMenu(content,left, top, width, height,selfClickClose,outClickClose,closeHandler)
{
    if(selfClickClose != null)
    {
        _SelfClickClose = selfClickClose;
    }
    else
    {
        _SelfClickClose = true;
    }
    if(outClickClose != null)
    {
        _OutClickClose = outClickClose;
    }
    else
    {
        _OutClickClose = true;
    }
    if(closeHandler != null)
    {
        _CloseHandler = closeHandler;
    }
    else
    {
        _CloseHandler = null;
    }
    var divPopupMenu = $("divPopupMenu");
    var divPopupMenuBg = $("divPopupMenuBg");
    var iframePopupMenu = $("iframePopupMenu");
    if(divPopupMenu == null)
    {
        divPopupMenu = document.createElement('div');
        divPopupMenu.id = 'divPopupMenu';
        divPopupMenu.style.position = 'absolute';
        divPopupMenu.className = 'divPopupMenu';
        divPopupMenuBg = document.createElement('div');
        divPopupMenuBg.id = 'divPopupMenuBg';
        divPopupMenuBg.style.position = 'absolute';
        iframePopupMenu = document.createElement('iframe');
        iframePopupMenu.id = 'iframePopupMenu';
        iframePopupMenu.frameBorder = '0';
        iframePopupMenu.allowTransparency = false;
        iframePopupMenu.src = "http://www.yi-qiao.cn/None.htm"
        divPopupMenuBg.appendChild(iframePopupMenu);        
        /*if(document.forms.length > 0)
        {
            var parent = document.forms[0];
        }
        else
        {
            var parent = document.body;
        }*/
        var parent = document.body;
        parent.insertBefore(divPopupMenuBg, parent.firstChild);
        parent.insertBefore(divPopupMenu, parent.firstChild);
    }    
    divPopupMenu.style.zIndex = 10;
    divPopupMenuBg.style.zIndex = 9;
    if(typeof content == 'object')
    {
        divPopupMenu.appendChild(content)
    }
    else
    {
        divPopupMenu.innerHTML = content;
    }
    if(width && width != 0)
    {
        divPopupMenu.style.width = width + "px";
    }
    /*if(height != 0)
    {
        divPopupMenu.style.height = height + "px";
    }*/
    if(left)
    {
        divPopupMenuBg.style.left = divPopupMenu.style.left = left + "px";
    }
    if(top)
    {
        divPopupMenuBg.style.top = divPopupMenu.style.top = top + "px";
    }
    hasShown = false;
    document.onclick = DocumentClick;
    if(_PopupMenuContent == content)//Normal Toggle
    {
        if(divPopupMenu.style.display == "block")
        {
            HideMenu();
        }
        else
        {
            divPopupMenuBg.style.display = divPopupMenu.style.display = "block";
            iframePopupMenu.style.width = divPopupMenuBg.style.width = divPopupMenu.offsetWidth + "px";
            iframePopupMenu.style.height = divPopupMenuBg.style.height = divPopupMenu.offsetHeight + "px";
            if(!document.all)
            {
                iframePopupMenu.style.display = 'none';
            }
            HideObjects_Popup();
        }
    }
    else//Open Another new Popup Menu
    {
        _PopupMenuContent = content;
        divPopupMenuBg.style.display = divPopupMenu.style.display = "block";
        iframePopupMenu.style.width = divPopupMenuBg.style.width = divPopupMenu.offsetWidth + "px";
        iframePopupMenu.style.height = divPopupMenuBg.style.height = divPopupMenu.offsetHeight + "px";
        if(height != 0)
        {
            SetMaxHeight(divPopupMenu,height);
            SetMaxHeight(divPopupMenuBg,height);
        }
        if(!document.all)
        {
            iframePopupMenu.style.display = 'none';
        }
        HideObjects_Popup();
    }
}
function DocumentClick(e)
{
    if(hasShown == false)
    {
        hasShown = true;
        return;
    }
    var divPopupMenu = $("divPopupMenu");
    if(divPopupMenu == null)
    {
        return;
    }
    var top = divPopupMenu.offsetTop;
    var left = divPopupMenu.offsetLeft;
    var width = divPopupMenu.offsetWidth;
    var height = divPopupMenu.offsetHeight;
    var x,y;
    if(document.all)
    {
        x = event.offsetX + GetOffsetLeft(event.srcElement);
        y = event.offsetY + GetOffsetTop(event.srcElement);
    }
    else
    {
        x = e.offsetX >= 0 ? e.offsetX:0;
        x += GetOffsetLeft(e.target);
        y = e.offsetY >= 0 ? e.offsetY:0;
        y += GetOffsetTop(e.target);
    }    
    if(_OutClickClose == true)
    {
        if(x < left || x > left + width || y < top || y > top + height)
        {
            HideMenu();
        }
    }
    if(_SelfClickClose == true)
    {
        if(x > left && x < left + width && y > top && y < top + height)
        {
            HideMenu();
        }
    }
}
function ChangeMenu(content)
{
    var divPopupMenu = $("divPopupMenu");
    var divPopupMenuBg = $("divPopupMenuBg");
    var iframePopupMenu = $("iframePopupMenu");
    if(divPopupMenu != null)
    {
        divPopupMenu.innerHTML = content;
        iframePopupMenu.style.width = divPopupMenuBg.style.width = divPopupMenu.offsetWidth + "px";
        iframePopupMenu.style.height = divPopupMenuBg.style.height = divPopupMenu.offsetHeight + "px";
    }
}
function HideMenu()
{   
    var divPopupMenu = $("divPopupMenu");
    var divPopupMenuBg = $("divPopupMenuBg");
    if(divPopupMenu == null || divPopupMenu.style.display == "none")
    {
        return;
    }
    divPopupMenuBg.style.display = divPopupMenu.style.display = "none";
    ShowObjects_Popup();
    if(_CloseHandler != null)
    {
        _CloseHandler();
    }    
    document.onclick = null;
}
function GetPopupMenuHeight()
{
    var divPopupMenu = $("divPopupMenu");
    if(divPopupMenu != null)
    {
        return divPopupMenu.offsetHeight;
    }
    else
    {
        return 0;
    }
}
function IsPopupMenuShown()
{
    var divPopupMenu = $("divPopupMenu");
    if(divPopupMenu != null && divPopupMenu.style.display == 'block')
    {
        return true;
    }
    return false;
}
function SetPopupMenuPosition(left,top)
{
    $("divPopupMenu").style.left = $("divPopupMenuBg").style.left = left + 'px';
    $("divPopupMenu").style.top = $("divPopupMenuBg").style.top = top + 'px';
}
function ResizePopupMenu(width,height)
{
    var divPopupMenu = $("divPopupMenu");
    var divPopupMenuBg = $("divPopupMenuBg");
    var iframePopupMenu = $("iframePopupMenu");
    if(width == 0)
    {
        iframePopupMenu.style.width = divPopupMenuBg.style.width = divPopupMenu.offsetWidth + "px";        
    }
    else
    {
        iframePopupMenu.style.width = divPopupMenuBg.style.width = divPopupMenu.style.width = width + "px";
    }
    if(height == 0)
    {
        iframePopupMenu.style.height = divPopupMenuBg.style.height = divPopupMenu.offsetHeight + "px";
    }
    else
    {
        iframePopupMenu.style.height = divPopupMenuBg.style.height = divPopupMenu.style.height = height + "px";
    }
}
function SetZIndex(zIndex)
{
    var divPopupMenu = $("divPopupMenu");
    var divPopupMenuBg = $("divPopupMenuBg");
    if(divPopupMenu != null)
    {
        divPopupMenu.style.zIndex = zIndex;
    }
    if(divPopupMenuBg != null)
    {
        divPopupMenuBg.style.zIndex = zIndex - 1;
    }
}
function SetBgColor(control)
{
    control.className = 'divPopupOn';
}
function RemoveBgColor(control)
{
    control.className = 'divPopupOff';
}
var hiddenObjects_Popup = new Array();
function HideObjects_Popup()
{
    var divPopupMenu = $('divPopupMenu');
    var objects = document.getElementsByTagName('object');
    for(var i = 0; i < objects.length; i++)
    {
        if(IsOverLap(objects[i],divPopupMenu) && objects[i].style.visibility != 'hidden')
        {
            objects[i].style.visibility = 'hidden';
            hiddenObjects_Popup.push(objects[i]);
        }
    }
    var embeds = document.getElementsByTagName('embed');
    for(var i = 0; i < embeds.length; i++)
    {
        if(IsOverLap(embeds[i],divPopupMenu) && embeds[i].style.visibility != 'hidden')
        {
            embeds[i].style.visibility = 'hidden';
            hiddenObjects_Popup.push(embeds[i]);
        }
    }
}
function ShowObjects_Popup()
{
    var divPopupMenu = $('divPopupMenu');
    for(var i = hiddenObjects_Popup.length - 1; i >= 0 ; i--)
    {
        var object = hiddenObjects_Popup.pop();
        object.style.visibility = 'visible';
    }
}
function InitialPopupMenu(hasBackgroud)
{
    var divBackground;
    var parent = window.document.body;
    if(!$("divCommonBoxBackground"))
    {
        divBackground = window.document.createElement('div');
        divBackground.id = 'divCommonBoxBackground';
        divBackground.style.position = 'absolute';
        divBackground.style.left = '0px';
        divBackground.style.top = '0px';
        divBackground.style.background = '#000000';
        divBackground.style.width = Math.max(window.top.document.documentElement.scrollWidth,window.top.document.documentElement.clientWidth) + 'px';
        divBackground.style.height = Math.max(window.top.document.documentElement.scrollHeight,window.top.document.documentElement.clientHeight) + 'px';
        divBackground.style.display = "none";
   
        if(document.all)
        {
            divBackground.style.filter = 'Alpha(Opacity=70)';
        }
        else
        {
            divBackground.style.MozOpacity = 0.7;
        }
        
        parent.insertBefore(divBackground, parent.firstChild);  
    }
    else
    {
        divBackground = $("divCommonBoxBackground");
        if(hasBackgroud)
        {
            divBackground.style.display = 'block';
        }
        else
        {
            //divBackground.style.display = 'hidden';
        }
    }
    
    var contentDiv = window.document.createElement('div');
    contentDiv.style.position = "absolute";
    parent.insertBefore(contentDiv, parent.firstChild);
    
    
    return contentDiv;
}
/*Popup Menu End*/
/*OO PopupMenu Start*/
/*
    弹出菜单（面向对象）
    divElement:需要显示的div
    left:左顶点绝对位置
    top:上顶点绝对位置
    width:宽度
    height:高度
    selfClickClose:菜单内部点击是否关闭菜单
    outClickClose:菜单外部点击是否关闭菜单
    isMenu:是否是浮动菜单，类似短消息二级浮动菜单
    hideSelect:是否在弹出时关闭所有与其有交叉的下拉框（修正 ie6 bug）
*/
function PopupMenu(divElement, left, top, width, height, selfClickClose, outClickClose, closeHandler, isMenu, hideSelect)
{
    this.Div = divElement;
    this.Left = left;
    this.Top = top;
    this.Width = width;
    this.Height = height;
    this.SelfClickClose = selfClickClose;
    this.OutClickClose = outClickClose;
    this.CloseHandler = closeHandler;
    this.IsMenu = isMenu;
    this.HideSelect = hideSelect;
    this.HasShown = false;
    this.Visible = false;
    this.Div.style.zIndex = 10;
    this.HideObjects = new Array();
}
PopupMenu.prototype.DocClick = function(e)
{
//    if(this.HasShown == false)
//    {
//        this.HasShown = true;
//        return;
//    }
    if(document.all)
    {
        var x = event.offsetX + GetOffsetLeft(event.srcElement);
        var y = event.offsetY + GetOffsetTop(event.srcElement);
    }
    else
    {
        var x = e.offsetX >= 0 ? e.offsetX:0;
        x += GetOffsetLeft(e.target);
        var y = e.offsetY >= 0 ? e.offsetY:0;
        y += GetOffsetTop(e.target);
    }
    var left = GetOffsetLeft(this.Div);
    var top = GetOffsetTop(this.Div);
    var width = this.Div.offsetWidth;
    var height = this.Div.offsetHeight;
    if(this.OutClickClose == true)
    {        
        if(x < left || x > left + width || y < top || y > top + height)
        {
            this.Hide();
        }
    }
    if(this.SelfClickClose == true)
    {
        if(x > left && x < left + width && y > top && y < top + height)
        {
            this.Hide();
        }
    }
}
PopupMenu.prototype.Show = function(left,top)
{
    if(left != null)
    {
        this.Left = left;
    }
    if(top != null)
    {
        this.Top = top;
    }
    
    this.Visible = true;
    if(this.HideTimer)
    {
        clearTimeout(this.HideTimer);
    }
    if(this.Div.style.display == 'block')
    {
        this.Div.style.left = this.Left + "px";
        this.Div.style.top = this.Top + "px"; 
        return;
    }    
    this.Div.style.display = "block";  
    if(this.Width && this.Width != 0)
    {
        this.Div.style.width = this.Width  + "px";
    }
    if(this.Height && this.Height != 0)
    {
        this.Div.style.height = this.Height + "px";
    }
    this.Div.offsetWidth  + "px";
    this.Div.offsetHeight + "px";
    this.Div.style.left = this.Left + "px";
    this.Div.style.top = this.Top + "px";    
    this.Div.style.position = "absolute";    
   
    document.body.insertBefore(this.Div,document.body.firstChild);
    
    if(this.IsMenu)
    {
        this.Div.onmouseover = Function.createDelegate(this,this.Show);
        this.Div.onmouseout = Function.createDelegate(this,this.DelayHide);
    }
    this.HasShown = false;
    this.preDocClick = document.onclick;
    document.onclick = Function.createDelegate(this, this.DocClick);
    var objects = document.getElementsByTagName('object');
    for(var i = 0; i < objects.length; i++)
    {
        if(IsOverLap(objects[i],this.Div) && objects[i].style.visibility != 'hidden')
        {
            objects[i].style.visibility = 'hidden';
            this.HideObjects.push(objects[i]);
        }
    }
    var embeds = document.getElementsByTagName('embed');
    for(var i = 0; i < embeds.length; i++)
    {
        if(IsOverLap(embeds[i],this.Div) && embeds[i].style.visibility != 'hidden')
        {
            embeds[i].style.visibility = 'hidden';
            this.HideObjects.push(embeds[i]);
        }
    }
    if(this.HideSelect)
    {
        var selects = document.getElementsByTagName('select');
        for(var i = 0; i < selects.length; i++)
        {
            if(selects[i].style.visibility == 'hidden')
            {  
                continue;
            }
            selects[i].style.visibility = 'hidden';
            this.HideObjects.push(selects[i]);
        }
    }
}
PopupMenu.prototype.DelayHide = function()
{
    this.HideTimer = setTimeout(Function.createDelegate(this,this.Hide),100);
}
PopupMenu.prototype.Hide = function()
{
    this.Visible = false;
    if(this.Div.style.display == "none")
    {
        return;
    }
    this.Div.style.display = "none";
    if(this.CloseHandler != null)
    {
        this.CloseHandler();
    }
    document.body.removeChild(this.Div);
    document.onclick = this.preDocClick; 
    
//    if(this.HideSelect)
//    {
        var length = this.HideObjects.length;
        for(var i = 0; i < length; i++)
        {
            var select = this.HideObjects.pop();
            select.style.visibility = '';
        }
//    }
}
PopupMenu.prototype.Toggle = function()
{
    if(this.Visible)
    {
        this.Hide();
    }
    else
    {
        this.Show();
    }
}
PopupMenu.prototype.GetPopupMenuHeight = function()
{
    return this.Div.offsetHeight;
}
PopupMenu.prototype.ChangeMenu = function(content)
{
    this.Div.innerHTML = content;
}
PopupMenu.prototype.SetZIndex = function(zIndex)
{
    this.Div.style.zIndex = zIndex;
}
/*OO PopupMenu End*/
/*
    弹出框（半透明黑底色）
    content:显示内容
    title:框左上角标题
    left:左顶点绝对位置
    top:上顶点绝对位置
    width:宽度
    height:高度
    middle:是否居中，若是则top和left将被忽略
    closeHandler:关闭是调用的外部函数句柄
*/
function CommonBox(content, title, left, top, width, height, middle, closeHandler)
{
    var div = window.top.document.createElement('div');
    var divTitle = window.top.document.createElement('div');
    div.appendChild(divTitle);
    var spanTitle = window.top.document.createElement('span');
    spanTitle.innerHTML = title;
    spanTitle.style.lineHeight = 'normal';
    SetFloatLeft(spanTitle);
    divTitle.appendChild(spanTitle);    
    var imgClose = window.top.document.createElement('img');
    imgClose.id = 'imgClose';
    imgClose.style.position = 'absolute';
    imgClose.style.width = '9px';
    imgClose.style.height = '9px';
    imgClose.style.cursor = 'pointer';
    imgClose.style.right = '10px';
    imgClose.src = 'http://www.yi-qiao.cn/images/close_common.gif';
    imgClose.onclick = Function.createDelegate(this,this.Hide);
    imgClose.alt = '关闭';
    divTitle.appendChild(imgClose);
    this.divContent = window.top.document.createElement('div');
    div.appendChild(this.divContent);
    if(height)
    {
        this.divContent.style.height = height + 'px';
    }    
    if(width)
    {
        this.divContent.style.width = width + 'px';
    }
    this.divContent.style.clear = 'both';
    if (typeof content == 'object')
    {
        this.divContent.appendChild(content);
    }
    else
    {
        this.divContent.innerHTML = content;
    }    
    
    this.divCommonBox = window.top.document.createElement('div');
    this.divCommonBox.style.position = 'absolute';
    this.divCommonBox.style.background = '#EEEEEE';
    this.divCommonBox.style.padding = '10px';
    this.divCommonBox.style.fontSize = '12px';
    this.divCommonBox.appendChild(div);
    this.defaultZIndex = 150;
    this.divCommonBox.style.zIndex = this.defaultZIndex;
    if(left)
    {
        this.divCommonBox.style.left = left + 'px';
    }
    if(top)
    {
        this.divCommonBox.style.top = top + 'px';
    }
    this.divCommonBox.style.display = 'none';    
    this.divBackground = window.top.document.createElement('div');
    this.divBackground.id = 'divCommonBoxBackground';
	this.divBackground.style.position = 'absolute';
	this.divBackground.style.left = '0px';
	this.divBackground.style.top = '0px';
	this.divBackground.style.background = '#000000';
    this.divBackground.style.zIndex = this.defaultZIndex - 1;
    this.divBackground.style.display = 'none';
    if(document.all)
    {
        this.divBackground.style.filter = 'Alpha(Opacity=70)';
    }
    else
    {
        this.divBackground.style.MozOpacity = 0.7;
    }
    var parent = window.top.document.body;
    parent.insertBefore(this.divBackground, parent.firstChild);  
    parent.insertBefore(this.divCommonBox, parent.firstChild);
    this.middle = middle;
    this.CloseHandler = closeHandler;
    this.HiddenObjects = new Array();
}
CommonBox.prototype.Show = function(left,top)
{
    if(left != null)
    {
        this.divCommonBox.style.left = left + 'px';
    }
    if(top != null)
    {
        this.divCommonBox.style.top = top + 'px';
    }
    this.divCommonBox.style.display = "block";
    this.divBackground.style.left = '0px';
    this.divBackground.style.top = '0px';
    this.divBackground.style.width = Math.max(window.top.document.documentElement.scrollWidth,window.top.document.documentElement.clientWidth) + 'px';
    this.divBackground.style.height = Math.max(window.top.document.documentElement.scrollHeight,window.top.document.documentElement.clientHeight) + 'px';
    this.divBackground.style.display = "block";
    if(this.middle == true)
    {
        ShowMiddle(this.divCommonBox);
    }
    var objects = document.getElementsByTagName('object');
    for(var i = 0; i < objects.length; i++)
    {
        if(IsOverLap(objects[i],this.divCommonBox) && objects[i].style.visibility != 'hidden')
        {
            objects[i].style.visibility = 'hidden';
            this.HiddenObjects.push(objects[i]);
        }
    }
    var embeds = document.getElementsByTagName('embed');
    for(var i = 0; i < embeds.length; i++)
    {
        if(IsOverLap(embeds[i],this.divCommonBox) && embeds[i].style.visibility != 'hidden')
        {
            embeds[i].style.visibility = 'hidden';
            this.HiddenObjects.push(embeds[i]);
        }
    }
    var selects = document.getElementsByTagName('select');
    for(var i = 0; i < selects.length; i++)
    {
        if(selects[i].style.visibility == 'hidden')
        {  
            continue;
        }
        selects[i].style.visibility = 'hidden';
        this.HiddenObjects.push(selects[i]);
    }
}
CommonBox.prototype.Hide = function()
{
    this.divCommonBox.style.display = "none";
    this.divBackground.style.display = "none";
    for(var i = this.HiddenObjects.length - 1; i >= 0 ; i--)
    {
        var object = this.HiddenObjects.pop();
        object.style.visibility = 'visible';
    }
    if(this.CloseHandler != null)
    {
        this.CloseHandler();
    }
}
CommonBox.prototype.SetContent = function(content)
{
    this.divContent.innerHTML = content;    
}
CommonBox.prototype.Toggle = function(left,top)
{
    if(this.divCommonBox.style.display == "block")
    {
        this.Hide();
    }
    else
    {
        this.Show(left,top);
    }
}
CommonBox.prototype.SetZIndex = function(zIndex)
{
    this.divCommonBox.style.zIndex = zIndex;
    this.divBackground.style.zIndex = zIndex - 1;
}
function ShowProcess(message)
{
    var topWindow = window.top;
    var topDocument = topWindow.document;
    var divProcess = topDocument.getElementById('divProcess');
    if(divProcess != null)
    {
        divProcess.style.display = 'block';
        divProcess.innerHTML = message;
    }
    else
    {
        divProcess = topDocument.createElement('div');
        divProcess.id = 'divProcess';
        divProcess.style.position = 'absolute';
        divProcess.style.padding = '3px';
        divProcess.style.color = '#FFFFFF';
        divProcess.style.fontSize = '12px';
        divProcess.style.fontWeight = 'bold';
        divProcess.style.backgroundColor = '#CC0000';
        divProcess.style.zIndex = 100;
        divProcess.innerHTML = message;
        topDocument.body.insertBefore(divProcess, topDocument.body.firstChild);
        if(topWindow.addEventListener)
        {
            window.addEventListener('scroll', MoveProcess, false);
            window.addEventListener('resize', MoveProcess, false);
        }
        else if(window.attachEvent)
        {
            window.attachEvent('onscroll', MoveProcess);
	        window.attachEvent('onresize', MoveProcess);
        }
    }
    MoveProcess();
}
function HideProcess()
{
    var divProcess = window.top.$('divProcess');
    if(divProcess != null)
    {
        divProcess.style.display = 'none';
    }
}
function MoveProcess()
{
    var scrollYT, scrollXT;
    var topWindow = window.top;
    var topDocument = topWindow.document;
    var divProcess = topDocument.getElementById('divProcess');
    if(divProcess == null)
    {
        return;
    }
    if(document.all)
    {
        scrollYT = topDocument.documentElement.scrollTop; 
		scrollXT = topDocument.body.scrollLeft;
    }
    else
    { 
		scrollYT = topWindow.pageYOffset; 
		scrollXT = topWindow.pageXOffset; 
	}
	divProcess.style.top = scrollYT + 1 + "px";
	divProcess.style.right = -scrollXT + "px";
	divProcess.style.top = scrollYT + "px";
	
}
function ShowResultBox(message, success)
{
    HideProcess();
    var title = '提示';
    var html = ''+
    '<div id="divResult" style="margin:20px auto 20px auto;text-align:center;">'+
        message + '<br /><br /><input id="btnResultClose" type="button" onclick="HideResultBox()" value="确定" class="btnCommon2"/>'+
    '</div>';
    if(window.top.boxResult)
    {
        window.top.boxResult.SetContent(html);        
    }
    else
    {
        window.top.boxResult = new window.top.CommonBox(html,title,0,0,200,100,true,null);
    }
    window.top.boxResult.SetZIndex(window.top.boxResult.defaultZIndex + 2);
    window.top.boxResult.Show();
    window.top.$('btnResultClose').focus();
    if(success)
    {        
        setTimeout("HideResultBox()",1000);
    }    
}
function HideResultBox()
{
    if(window.top.boxResult)
    {
        window.top.boxResult.Hide();
    }
}
/*Login Related*/
function GetPassword()
{
    var html = '<div style="text-align:center;">您可以通过用户名或注册邮箱获取密码：<br /><br />';
    html += '用 户 名：<input type="text" id="txtUsername_GetPassword" /><br /><br />';
    html += '注册邮箱：<input type="text" id="txtEmail_GetPassword" /><br /><br />（任填一项即可，若两者都填，以邮箱为准）<br /><br />';
    html += '<input type="button" onclick="DoGetPassword();" value="获取密码" />';
    html += '</div>';
    if(!window.boxGetPassword)
    {
        boxGetPassword = new CommonBox(html, '获取密码', 0, 0, 250, 125, true, null);
    }
    boxGetPassword.SetContent(html);
    boxGetPassword.Show();
}
function DoGetPassword()
{
    var username = $('txtUsername_GetPassword').value;
    var email = $('txtEmail_GetPassword').value;
    if(username == '' && email == '')
    {
        alert('请任填一项！');
        return;
    }
    
    ShowProcess('正在提交请求，请稍候...');
    YiQiao.Web.WebService.User.GetPassword(username, email, GetPasswordSuccess);
    if(window.boxGetPassword)
    {
        boxGetPassword.Hide();
    }
}
function GetPasswordSuccess(result)
{
    HideProcess();
    switch(result)
    {
        case 0:
            ShowResultBox('获取密码请求已发送至您的注册邮箱，请注意查收',false);
            break;
        case 1:
            ShowResultBox('您的注册邮箱尚未通过验证，无法获取密码',false);
            break;
        case 2:
            ShowResultBox('您的用户名不存在，请确认后重试',false);
            break;
        case 3:
            ShowResultBox('您输入的身份证号不正确，请确认后重试',false);
            break;
        default:
            ShowResultBox('有错误发生，请重试',false);
            break;
    }    
}

function ResendValidateMail()
{
    var html = '<div style="text-align:center;">您可以通过用户名及注册邮箱申请重发激活：<br /><br />';
    html += '用 户 名：<input type="text" id="txtUsername_Resend" /><br /><br />';
    html += '注册邮箱：<input type="text" id="txtEmail_Resend" /><br /><br />';
    html += '<input type="button" onclick="DoResendValidateMail();" value="重发激活" />';
    html += '</div>';
    if(!window.boxResendValidateMail)
    {
        boxResendValidateMail = new CommonBox(html, '重发激活', 0, 0, 250, 125, true, null);
    }
    boxResendValidateMail.SetContent(html);
    boxResendValidateMail.Show();
}
function DoResendValidateMail()
{
    var username = $('txtUsername_Resend').value;
    var email = $('txtEmail_Resend').value;
    if(username == '' || email == '')
    {
        alert('请填写完整！');
        return;
    }
    
    ShowProcess('正在提交请求，请稍候...');
    YiQiao.Web.WebService.User.ResendValidateEmail(username, email, ResendValidateEmailSuccess);
    if(window.boxResendValidateMail)
    {
        boxResendValidateMail.Hide();
    }
}
function ResendValidateEmailSuccess(result)
{
    HideProcess();
    switch(result)
    {
        case 0:
            ShowResultBox('激活邮件已发送至您的注册邮箱，请注意查收',false);
            break;
        case 1:
            ShowResultBox('您的注册邮箱和用户名无法匹配，请重新输入',false);
            boxResendValidateMail.Show();
            break;
        case 2:
            ShowResultBox('您的用户名不存在，请确认后重试',false);
            break;
        default:
            ShowResultBox('有错误发生，请重试',false);
            break;
    }    
}

var _username = null;
function LoginImmediate(username, password)
{
    YiQiao.Web.WebService.User.Login(username, password, GetResultFromLogin_NotRedirect);
}
function Login(username,password)
{
    if(username == "")
    {
        alert("请填写用户名");
        return;
    }        
    if(password == "")
    {
        alert("请填写密码");
        return;
    }    
    _username = username;
    PLogin(username, password);
    
}
function GetResultFromLogin(result)
{
    HideProcess();
    if(result == 0)
    {
        var url = window.location.href;
        if(url.indexOf('ReturnUrl=') > -1)
        {
            url = unescape(url.substr(url.indexOf('ReturnUrl=') + 10));            
        }
        //Redirect(url);
        Redirect('http://space.' + _username + '.yi-qiao.cn/owner');
    }
    if(result == -1)
    {
        ShowResultBox("该用户名不存在",false);
    }
    if(result == -2)
    {
        ShowResultBox("密码错误",false);
    }
    if(result == -3)
    {
        ShowResultBox("有错误发生",false);
    }
}
function PLogin(username, password)
{
    var HiddenIframe;
    HiddenIframe = document.createElement('iframe');
    HiddenIframe.id = 'iframePopupMenu';
    HiddenIframe.frameBorder = '0';
    HiddenIframe.allowTransparency = false;
    HiddenIframe.src = 'http://www.pulmonary-rehabilitation.com.cn/Login.aspx?username='+username+'&password='+password;
    HiddenIframe.style.width = 0;
    HiddenIframe.style.height = 0;
    
    document.body.insertBefore(HiddenIframe,document.body.firstChild);
    window.setTimeout('YiQiao.Web.WebService.User.Login("'+username+'", "'+password+'",GetResultFromLogin);', 3000);
    //window.open('http://www.pulmonary-rehabilitation.com.cn/Login.aspx?username='+username+'&password='+password, "win", "fullscreen");
    
    ShowProcess('正在登陆，请稍候...');
}

// 登录后不转向，刷新本页
function Login_NotRedirect(username,password)
{
    if(username == "")
    {
        alert("请填写用户名");
        return;
    }        
    if(password == "")
    {
        alert("请填写密码");
        return;
    }    
    _username = username;
    YiQiao.Web.WebService.User.Login(username, password,GetResultFromLogin_NotRedirect);
    ShowProcess('正在登陆，请稍候...');
}  
function GetResultFromLogin_NotRedirect(result)
{
    HideProcess();
    if(result == 0)
    {
        Reload();
    }
    if(result == -1)
    {
        ShowResultBox("该用户名不存在",false);
    }
    if(result == -2)
    {
        ShowResultBox("密码错误",false);
    }
    if(result == -3)
    {
        ShowResultBox("有错误发生",false);
    }
}

// 登录后跳转到制定URL,刷新本页
function Login_AndRedirect(username,password,url)
{
    if(username == "")
    {
        alert("请填写用户名");
        return;
    }        
    if(password == "")
    {
        alert("请填写密码");
        return;
    }    
    _username = username;
    YiQiao.Web.WebService.User.Login_Redirect(username, password, url, GetResultFromLogin_AndRedirect);
    ShowProcess('正在登陆，请稍候...');
}  
function GetResultFromLogin_AndRedirect(result)
{
    HideProcess();
    if(result[0] == 0)
    {
        window.location.href = result[1];
    }
    if(result[0] == -1)
    {
        ShowResultBox("该用户名不存在",false);
    }
    if(result[0] == -2)
    {
        ShowResultBox("密码错误",false);
    }
    if(result[0] == -3)
    {
        ShowResultBox("有错误发生",false);
    }
}

function LogoutImmediate()
{
    YiQiao.Web.WebService.User.Logout(LogoutSuccess);
}
function Logout()
{
    ShowProcess('正在注销，请稍候...');
    PLogout();
}
function LogoutSuccess(result)
{
    if(result == true)
    {
        //Reload();
        //window.location.redirect
        window.location.href='http://www.yi-qiao.cn';
    }
    else
    {
        ShowResultBox("注销失败，请重试",false);
    }
}
function PLogout()
{
    var HiddenIframe;
    HiddenIframe = document.createElement('iframe');
    HiddenIframe.id = 'iframePopupMenu';
    HiddenIframe.frameBorder = '0';
    HiddenIframe.allowTransparency = false;
    HiddenIframe.src = 'http://www.pulmonary-rehabilitation.com.cn/Logout.aspx';
    HiddenIframe.style.width = 0;
    HiddenIframe.style.height = 0;
    document.body.insertBefore(HiddenIframe,document.body.firstChild);
    window.setTimeout('YiQiao.Web.WebService.User.Logout(LogoutSuccess);', 3000);
    //window.open('http://www.pulmonary-rehabilitation.com.cn/Login.aspx?username='+username+'&password='+password, "win", "fullscreen");
    //YiQiao.Web.WebService.User.Login(username, password,GetResultFromLogin);
    //ShowProcess('正在登陆，请稍候...');
}

function ShowMiddle(div)
{
    var scrollYT, scrollXT;
    var topWindow = window.top;
    var topDocument = topWindow.document;
    if(div == null)
    {
        return;
    }
    if(document.all)
    {
        scrollYT = topDocument.documentElement.scrollTop; 
		scrollXT = topDocument.documentElement.scrollLeft;
    }
    else
    { 
		scrollYT = topWindow.pageYOffset; 
		scrollXT = topWindow.pageXOffset; 
	}
	var top = Math.floor((topDocument.documentElement.clientHeight - div.offsetHeight) / 2) + scrollYT;
	if(top < 0)
	{
	    top = 0;
	}
	var left = Math.floor((topDocument.documentElement.clientWidth - div.offsetWidth) / 2) + scrollXT;
	if(left < 0)
	{
	    left = 0;
	}
    div.style.top = top + 'px';
    div.style.left = left + 'px';
}

function UIGenerator_CreateLinklistTable(targetDocument, linkList)
{
    var table = targetDocument.createElement('TABLE');
    table.width = "100%";
    table.border = 0;
    table.align = "center";
    table.cellPadding = 0;
    table.cellSpacing = 0;
    table.style = "word-break:break-all;width:100%";
    for (var i = 0; i < linkList.length; i++)
    {
        row = table.insertRow(-1);
        cell = row.insertCell(-1);
        var div = document.createElement('div');
        div.style.width = "100%";
        div.style.overflow = "hidden";
        div.style.lineHeight = "auto";
        div.className = "divBottomLine1";
        div.appendChild(linkList[i]);
        cell.appendChild(div);
    }
    return table;
}
function UIGenerator_CreateList_HTML(linkList)
{
    
    var html = '<table width=100% border=0 align="center" cellPadding=0 cellSpacing=0 style="word-break: break-all;overflow:hidden;width:100%">';    
    for (var i = 0; i < linkList.length; i++)
    {
        html += '<tr><td><div class="divBottomLine1" style="width:100%;overflow:hidden">' + linkList[i] + '</div></td></tr>';
    }
    html += '</table>';
    return html
}
function RemoveElementEvents(element)
{
    if (element != null)
    { 
        if (typeof(element.onclick) != 'undefined' && element.onclick != ViewImage)
        {   
            element.onclick = null;
        }        
        if (typeof(element.onload) != 'undefined')
        {   
            element.onload = null;
        }
        if (typeof(element.onmouseout) != 'undefined')
        {   
            element.onmouseout = null;
        }
        if (typeof(element.onmouseover) != 'undefined')
        {   
            element.onmouseover = null;
        }
        if (typeof(element.onmouseup) != 'undefined')
        {   
            element.onmouseup = null;
        }
        if (typeof(element.onblur) != 'undefined')
        {   
            element.onblur = null;
        }
        if (typeof(element.onactivate) != 'undefined')
        {   
            element.onload = null;
        }
        if (typeof(element.onactivate) != 'undefined')
        {   
            element.onload = null;
        }
        if (typeof(element.onmousedown) != 'undefined')
        {   
            element.onmousedown = null;
        }if (typeof(element.onmousemove) != 'undefined')
        {   
            element.onmousemove = null;
        }
        if (typeof(element.onmouseup) != 'undefined')
        {   
            element.onmouseup = null;
        }
        if (typeof(element.onkeypress) != 'undefined')
        {   
            element.onkeypress = null;
        }
        // to do
        
        var oChilds = element.childNodes;
        for (var i = oChilds.length - 1; i >= 0; i--)
        {
            if(oChilds[i].tagName && (oChilds[i].tagName.toLowerCase() == 'script' || oChilds[i].tagName.toLowerCase() == 'link'))
            {
                element.removeChild(oChilds[i]);
            }
            else
            {
                RemoveElementEvents(oChilds[i]);           
            }
        }
    }    
}
function IsSafeElement(e)
{
    if(e.onabort || e.onactive|| e.onafterprint || e.onafterupdate || e.onbeforeactive || e.onbeforecopy || e.onbeforecut || e.onbeforedeactive || e.onbeforeeditfocus || e.onbeforepaste || e.onbeforeprint ||
     e.onbeforeupload || e.onbeforeupdate || e.onblur || e.onbounce || e.oncellchange || e.onchange || e.onclick || e.oncontextmenu || e.oncontrolselect || e.oncopy || e.oncut || e.ondataavailable || e.ondatasetchanged ||
     e.ondatasetcomplete || e.ondblclick || e.ondeactive || e.ondrag || e.ondragend || e.ondragenter || e.ondragleave || e.ondragover || e.ondragstart || e.ondrop || e.onerror || e.onerrorupdate || e.onfilterchange ||
     e.onfinish || e.onfocus || e.onfocusin || e.onfocusout || e.onhelp || e.keydown || e.onkeypress || e.onkeyup || e.onlayoutcomplete || e.onload || e.onlosecapture || e.onmousedown || e.onmouseenter || e.onmouseleave ||
     e.onmousemove || e.onmouseout || e.onmouseover || e.onmouseup || e.onmousewheel || e.onmove || e.onmoveend || e.onmovestart || e.onpaste || e.onpropertychange || e.onreadystatechange || e.onreset || e.onresize ||
     e.onresizeend || e.onresizestart || e.onrowenter || e.onrowdelete || e.onrowinserted || e.onscroll || e.onselect || e.onselectionchange || e.onselectstart || e.onstart || e.onstop || e.onsubmit || e.onunload)
    {
        alert('由于安全原因，不允许定义事件');
        return false;
    }
    if(e.tagName && e.tagName.toLowerCase() == 'script')
    {
        alert('由于安全原因，不允许运行脚本');
        return false;
    }
    if(e.tagName && e.tagName.toLowerCase() == 'link')
    {
        alert('由于安全原因，不允许使用<Link>标签');
        return false;
    }
    if(e.tagName && e.tagName.toLowerCase() == 'style')
    {
        if(e.innerHTML.toLowerCase().indexOf('javascript:') != -1)
        {
            alert('请勿在<style>标签中使用脚本进行黑客行为');
            return false;
        }
    }
    if(e.attributes)
    {
        for(var i = 0; i < e.attributes.length; i++)
        {
            if(e.attributes[i].value.toLowerCase().indexOf('javascript:') != -1)
            {
                alert('由于安全原因，不允许运行脚本');
                return false;
            }
        }
    }
    for(var i = 0; i < e.childNodes.length; i++)
    {
        if(!IsSafeElement(e.childNodes[i]))
        {
            return false;
        }
    }
    return true;   
}
function ReplaceEnter(strContent)
{
    var returnData = strContent;
    while(returnData.indexOf('\n') != -1)
    {
        returnData = returnData.replace('\n', '<br />');
    }
    return returnData;
}
function ReplaceBR(strContent)
{
    var returnData = strContent;
    while(returnData.indexOf('<br />') != -1)
    {
        returnData = returnData.replace('<br />', '\n');
    }
    return returnData;
}
function RemoveBR(strContent)
{
    var returnData = strContent;
    while(returnData.indexOf('<br>') != -1)
    {
        returnData = returnData.replace('<br>', ' ');
    }
    return returnData;
}

// 匹配字符串是否是英文字母+数字+'_'
function CheckIfEnglish(String) 
{ 
    var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
    var i; 
    var c; 
    for( i = 0; i < String.length; i ++ ) 
    { 
        c = String.charAt( i ); if (Letters.indexOf( c ) < 0) return false; 
    }
    return true;
}

function CheckEmailFormat(emailStr) 
{
    var emailPat=/^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/;
    var matchArray=emailStr.match(emailPat);
    if (matchArray==null) {
        return false;
    }
    return true;
}

function CheckPhoneFormat(phoneStr)
{
    return /^(((\()?\d{2,4}(\))?[-(\s)*]){0,2})?(\d{7,8})$/.test(phoneStr);
}


pageIndexDisplayNum = 5;
function DisplayPageBar(FirstPageFun, PrePageFun, GetPageFun, NextPageFun, LastPageFun, PageBarDiv)
{
    var pageNum = Math.ceil(itemCount / pageSize);  // 页码从0开始，如果没有任何数据则为0
    pageCount = pageNum;
    var currentPageIndex = pageIndex<0?0:pageIndex;
    var displayNum = 0;
    var table = '';
    if(pageNum <= 5)    // startPageIndex = 0;
    {
        displayNum = pageNum == 0?1:pageNum;    
    }
    else if(pageNum > 5)
    {
        displayNum = pageIndexDisplayNum;
        
        if(currentPageIndex+2 >= pageNum)
        {
            startPageIndex = pageNum - 5;
        }
        else
        {
            startPageIndex = currentPageIndex - 2;
            if(startPageIndex < 0)
            {
                startPageIndex = 0;
            }
        }
        
    }
    if(currentPageIndex > 0)   // 页数多于1页，并且不是最后页
    {
//        table+='<a href="javascript:void(0)" onclick="'+FirstPageFun+'()">首页</a>&nbsp;&nbsp;';
        table+='<div><a href="javascript:void(0)" onclick="'+PrePageFun+'()">Prev</a>&nbsp;&nbsp;';
    }
    else
    {
//        table+='<div class="abs">首页&nbsp;&nbsp; ';
        table+='<div>Prev&nbsp;&nbsp; ';
    }
    for(var i=0; i<displayNum; i++)
    {
        if(startPageIndex + i == currentPageIndex)
        {
            table+=' <span><u><b>'+(startPageIndex+i+1)+'</u></b></span> '
        }
        else
        {
            table+=' <a href="javascript:void(0)" onclick="'+GetPageFun+'('+(startPageIndex+i)+')">'+(startPageIndex+i+1)+'</a> ';
        }
    }
    
    if(pageNum > 1 && currentPageIndex + 1 < pageNum)   // 页数多于1页，并且不是最后页
    {
        table+='&nbsp;&nbsp;<a href="javascript:void(0)" onclick="'+NextPageFun+'()">Next</a>&nbsp;&nbsp;</div>';
//        table+='&nbsp;&nbsp;<a href="javascript:void(0)" onclick="'+LastPageFun+'()">最后页</a>&nbsp;&nbsp;';
    }
    else
    {
        table+='&nbsp;&nbsp;Next</div>';
//        table+='&nbsp;&nbsp;最后页';
    }
    
    table += '';
    
    PageBarDiv.innerHTML = table;
}
function GoToDocuments()
{
    var pwd = prompt("请输入密码：", "");
    if(pwd == 'jyjjh')
    {
        return true;
    }
    else if(pwd == null)
    {
        return false;
    }
    else
    {
        alert('密码错误！');
        return false;
    }
}

function LogOut()
{
    for(var i=topLevel; i>=0; i--)
    {
        SetCookie("level"+i, "false");
    }
    window.top.location.href=window.top.location.href;
}


var loginLevel = 0; // 标示当前需要的登录级别，0="level0", 1="level1".....
var topLevel = 1;   // 标示当前网站中设定的最高级别；
var requiredPwd = {0:"win", 1:"win123456"};

function HasRight(level)
{
    var login;
    for(var i=topLevel; i>=level; i--)
    {
        login = GetCookie("level"+i);
        if(login == requiredPwd[i])
        {
            return true;
        }
    }
    return false;
}

function LogIn()
{
    if(HasRight(loginLevel))
    {
        return;
    }
    
    //var pwd = window.prompt("请输入登录密码：", "")
    try
    {
        var pwd = window.showModalDialog("/Include/password.html",null,"dialogHeight:30px;dialogWidth:400px;status:no;help:no;resizable:no;edge:raised;center:yes;");
        tryCount++;
        if(pwd != requiredPwd[loginLevel])
        {   
            for(var i=loginLevel+1; i<=topLevel; i++)
            {
                if(requiredPwd[i] == pwd)
                {
                    SetCookie("level"+i, requiredPwd[i]);
                    return;
                }
            }
            if(pwd == null || pwd == undefined)
            {
                window.top.location.href="http://www.fuedf.org/";
            }
            else
            {
                if(tryCount == 3)
                {
                    alert("对不起，您输入的密码错误！您已经尝试了3次，将为您转到网站首页！");
                    window.location.href="http://www.fuedf.org/";
                }
                else
                {
                    alert("对不起，您输入的密码错误！请重新输入");
                    LogIn();
                }
            }
            
        }
        else
        {
            SetCookie("level"+loginLevel, requiredPwd[loginLevel]);
            return;
        }
    }
    catch(e)
    {
        alert("请设置您的浏览器，取消对www.fuedf.org域名的弹出窗口的阻止！");
        if(window.document.all)
        {
            document.execCommand("stop");
        }
    }
}

