/* $Id : common.js www.mvmmall.com $ */
//发送一个请求
function makeRequest(url, functionName, httpType, sendData) {

	http_request = false;
	if (!httpType) httpType = "GET";

	if (window.XMLHttpRequest) { // Non-IE...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/plain');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Cannot send an XMLHTTP request');
		return false;
	}

	var changefunc="http_request.onreadystatechange = "+functionName;
	eval (changefunc);
	http_request.open(httpType, url, true);
	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http_request.send(null);
}
//会员用户名检验
function Usercheck(mode)
{
    if (typeof(mode) == 'undefined'){
        return false;
    } else{
        var uData = encodeURIComponent(document.getElementById('' + mode + '').value);
        
        var gourl="ajax.php?action=user"+"&id="+uData+"&date="+Math.random();;
    }
    makeRequest(gourl,'check_member','GET')
    　
}
function check_member() {
	var show=document.getElementById('div_user');
	if (http_request.readyState == 1) {
	   show.innerHTML=user_msg['check']
	}
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			show.innerHTML = http_request.responseText;
			savetime=-1000;
		}  else {
			alert(user_msg['error']);
		}
	}
}
//end

//层，打开，关闭
function toggle(targetid)
{
	var target=document.getElementById(targetid);
	target.style.display=(target.style.display=="block")?"none":"block";
	try
	{
		parent.loaded(document.body.scrollHeight);
	}
	catch(e)
	{
	}
}
//字母变大写
function pressCaptcha(obj)
{
    obj.value = obj.value.toUpperCase();
 }
 //字母变小写
function pressRegname(obj)
  {
    obj.value = obj.value.toLowerCase();
  }
 
  // popup移动脚本
function open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  newWin= window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}
//打开窗口
function winopen(url,title,w,h) {
		newwin = window.open(url,title,"toolbar=0,location=0,status=0,menubar=0,scrollbars=yes,resizable=1,width=" + w + ",height=" + h + ",alwaysRadised=0");
		newwin.focus();
}

function HighlightAll(obj) {
	obj.focus();
	obj.select();
	if(document.all) {
		obj.createTextRange().execCommand("Copy");
		window.status = "将内容复制到剪贴板";
		setTimeout("window.status=''", 1800);
	}
}
var globopObject;
var opIndex=0;
var cleared=true;
var direction=10;

function dynOpacity(opObject,stop) {
  if (stop) {
    clearInterval(window.tm);
    cleared=true;
    opIndex=10;
    return;
  }
  globopObject=opObject;
  if (opIndex>105) direction=-4;
  if (opIndex<100) direction=4;
  opIndex+=direction;
  globopObject.style.filter='alpha(opacity:' + opIndex + ')';
  if (cleared) {
    window.tm=setInterval("dynOpacity(globopObject,false);",1);
    cleared=false;
  }
}

function opacity(num) {
  if(num == 1) {
    dynOpacity(event.srcElement,false);
  }
  if(num == 2) {
    event.srcElement.style.filter="";
    dynOpacity(event.srcElement,true);
  }
}
// 20100116 add by xiaos  
function Layers_findObj(n, d) { //v4.0
	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=Layers_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function Layers_showHideLayers(strArg1, strArg2, strArg3) { //v3.0

	var i,p,v,obj,args=Layers_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=30) if ((obj=Layers_findObj(args[i]))!=null) { v=args[i+2];
	  if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	  obj.visibility=v; }


}
// 20100127 add bank pop window!
function openwinbanka() { window.open ("../bank/banka.html", "newwindow", "height=457, width=400, toolbar= no, menubar=no, scrollbars=no, resizable=no, location=no, status=no")  
//写成一行  
} 
function openwinliuyana() { window.open ("../liuyana.php?action=freeboard&my_board=1", "newwindow", "height=655, width=615, toolbar= no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no")  
//写成一行  
} 
// 20100621 add link!
function setTab(name,cursel,n){
	for(i=1;i<=n;i++){
	var menu=document.getElementById(name+i);
	var con=document.getElementById("con_"+name+"_"+i);
	menu.className=i==cursel?"hover":"";
	con.style.display=i==cursel?"block":"none";
	}
}