﻿<!--
/**
 * Print login form
 *
 * @param   string   bgimg    登录框顶部背景图片.
 * @param   string   url      登录成功之后的返回地址
 */

document.write('<link rel="stylesheet" rev="stylesheet" href="http://imgcache.qq.com/ad/login/css.css" type="text/css" media="screen" />');
document.write('<div id="login_div" style="display: none;">');

if (navigator.userAgent.indexOf('MSIE') != -1)
{
	document.write('  <iframe src="" width="449" height="294" scrolling="no" border="0" frameborder="0" align="center" style="filter: Alpha(Opacity = 0); Opacity: 0; -moz-Opacity: 0; position: absolute; top: -2px; left: -2px; z-index: -1;"></iframe>');
}

document.write('  <dl>');
document.write('    <dt id="login_div_header" style="">');
document.write('      <h4>请您登录</h4>');
document.write('      <a href="javascript:qq_login_status(\'hide\');"><span class="none">关闭</span></a>');
document.write('    </dt>');
document.write('    <dd>');
document.write('      <iframe name="login_div_iframe" id="login_div_iframe" width="290"  height="250" allowtransparency="true" scrolling="No" border="0" frameborder="0" align="center"  src=""></iframe>');
document.write('    </dd>');
document.write('  </dl>');
document.write('</div>');

function qq_login_form(){
    var argv = qq_login_form.arguments;
    var bgimg = 'vip';
    var url = 'https://account.qq.com/cgi-bin/ptlogin?pageStyle=1';
    if ( argv[0] ) {
        bgimg = argv[0];
    }

		if ( bgimg.substring(1, 7) != "http://" ) {
        bgimg = 'http://imgcache.qq.com/ad/login/' + bgimg + '.gif';
    }

    if ( argv[1] ) {
    	if (argv[1] != '')
    	{
    		url += "&url=" + escape(argv[1]);
    	}
    	else
    	{
    		top_location = window.top.location;
    		url += "&url=" + escape(top_location);
    	}    	
    }
    else
    {
    	top_location = window.top.location;
    	url += "&url=" + escape(top_location);
    }

    try {
        var h = document.getElementById("login_div_header");
        if ( typeof(h) != "undefined" ) {
            h.style.backgroundImage = 'url(' + bgimg + ')';
        }
        var f = document.getElementById("login_div_iframe");
        if ( typeof(f) != "undefined" ) {
            f.src = url;
        }

        qq_login_status("show");
    }
    catch ( x ) {
        //window.alert( x.message );
    }
}

/**
 * Show or hide the login form
 *
 * @param   string   status   显示(status=show)  关闭(status=hide)
 */
function qq_login_status(){
    var argv = qq_login_status.arguments;
    var status = '';
    if ( argv[0] ) {
        status = argv[0];
    }

    try {
        var e = document.getElementById("login_div");
				e.onmousedown=startMove;
				e.style.top = "45%";
        switch ( status ) {
            case "show":
                e.style.display = '';
                break;

            case "hide":
                e.style.display = 'none';
                break;

            default:
                if ( e.style.display == 'none' ) {
                    e.style.display = '';
                } else {
                    e.style.display = 'none';
                }///< if
                break;
        }///< switch
    }
    catch ( x ) {
        //window.alert( x.message );
    }
}

function startMove(evt)
{
  evt=getCurrentEvent(evt);
  if(!isLeftKeyDown(evt)) return;
  var alertDlg=document.getElementById("login_div");
	setEventCapture(alertDlg);
  stopEventTransfer(evt);
  alertDlg.$clientX=evt.clientX;
  alertDlg.$clientY=evt.clientY;
	alertDlg.onmousemove=MoveIt;
  alertDlg.onmouseup=stopMove;
}

function MoveIt(evt)
{
  evt=getCurrentEvent(evt);
  if(!isLeftKeyDown(evt)) return;
	var alertDlg=document.getElementById("login_div");

	alertDlg.style.left=alertDlg.offsetLeft+(evt.clientX - alertDlg.$clientX)+"px";
  alertDlg.style.top=alertDlg.offsetTop+(evt.clientY - alertDlg.$clientY)+"px";

	alertDlg.$clientX=evt.clientX;
  alertDlg.$clientY=evt.clientY;
}

function stopMove(evt)
{
  evt=getCurrentEvent(evt);
  if(!isLeftKeyDown(evt)) return;
  var alertDlg=document.getElementById("login_div");
  alertDlg.onmousemove=null;
  alertDlg.onmouseup=null;

	releaseEventCapture(alertDlg);
}

function getElementPageOffset(x,y){
    return {x:x+document.body.scrollLeft - 2, y:y+document.body.scrollTop  - 2};
}

function getPageOffset(element){
  var left=0,top=0;
  do{ 
    top+=element.offsetTop || 0; 
    left+=element.offsetLeft || 0; 
    element=element.offsetParent; 
  }while(element); 
  return {x:left,y:top};
}

function getCurrentEvent(evt)
{
   return (!evt)?window.event:evt;
}

function getEventTarget(evt)
{
	 evt=((!evt)?window.event:evt);
   return evt.target || event.srcElement;
}

function isLeftKeyDown(evt)
{
   return (((evt.which) && (evt.which==1)) || ((evt.button) && (evt.button==1)));
}

function stopEventTransfer(evt) {
    if(evt.preventDefault) {
      evt.preventDefault();
      evt.stopPropagation();
    }else{
      evt.returnValue = false;
      evt.cancelBubble = true;
    }
}

function setEventCapture(target)
{
  if(target.setCapture)
	  target.setCapture();
  else if(window.captureEvents)
	  window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP|Event.MOUSEDOWN);
}

function releaseEventCapture(target)
{
  if(target.releaseCapture)
	 target.releaseCapture();
  else if(window.releaseEvents)
	 window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP|Event.MOUSEDOWN);
}

function isNULL(e)
{
  if(e==undefined || e==null) return true;
  return false;
}
//-->