function locationTo(url,num){
	if(typeof(url)!='string'){
		url = url.value;
	}
	num = num*1000;
	window.setTimeout("location='"+url+"'",num)

}

function bytes(str){
	if(typeof(str)!='string'){
		str = str.value;
	}
	var len = 0;
	for(var i = 0; i < str.length; i++){
		if(str.charCodeAt(i) > 127){
			len++;
		}
		len++;
	}
	return len;
}
function chkstr(str){
	if(typeof(str)!='string'){
		str = str.value;
	}
	for(var i = 0; i < str.length; i++){
		if (str.charCodeAt(i) < 127 && !str.substr(i,1).match(/^\w+$/ig)){
			return false;
		}
	}
	return true;
}
function getMsg(name){
	itm = document.getElementById('err_msg');
	for (var i=0; i<itm.childNodes.length; i++){
		if (itm.childNodes[i].id == name){
			return itm.childNodes[i].innerHTML;
		}
	}
	return -1;
}

function getItem(itm){
	var itm2 = new Array(); 
     
	if (itm.className == 'm_5 p_1' || itm.className == 'item'){
		
		itm1 = itm;
	}else{
		itm1 = itm.parentNode.parentNode;
	}
	for (var i=0; i<itm1.childNodes.length; i++){
		//if (itm1.childNodes[i].className == 'item_end'){
			itm2[i] = itm1.childNodes[i];
			
			//break;
		//}
	}
	return new Array(itm1, itm2);
}
function showError(msg, itm, onclickun){
	arr  = getItem(itm);
	arr1 = arr[1];
	msg2 = msg;
//start 这段只能用于检查用户名！只有setUserNameUsable和onloadError中用了onclickun参数。
	if(typeof(onclickun)=="boolean" && onclickun==true)
	{
		//var uname = document.getElementById("usernameforload").value;
		var uname = itm.value;
		re=/###/gi;
		msg2 = msg.replace(re,uname);
		document.getElementById("username").value="";
	}
//end
	for (var i=0; i<arr1.length; i++)
	{
		
		if(arr1[i].className == "form_error" || arr1[i].className == "item_error")
		{
			arr1[i].innerHTML = msg2;
			 
			arr1[i].style.display = 'block';
			
			break;
		}
	}
	//arr[1].innerHTML = msg2;
	//arr[1].style.display = 'block';
	
}
function hideError(itm){
	arr = getItem(itm);
	arr1 = arr[1];
	/*
	alert(arr1[0].className);
	alert(arr1.length);
	*/
	
	for (var i=0; i<arr1.length; i++)
	{
		if(arr1[i].className == "form_error" || arr1[i].className == "item_error")
		{
			//alert();
			if(arr1[i].innerHTML!='')
			{
				arr1[i].style.display = 'none';
			}
			
		}
	}
	
}

function checkObject(itm)
{
	if(!document.all.itm)   
	{   
		return false;  
	}   
	else   
	{   
		return true;  
	}   	
}

function checkInput(itm, blank){
	 
	str = checkItem(itm, blank);
	if (str != ''){
		 
		showError(str, itm);
		return false;
	}else{
		 
		hideError(itm);
		return true;
	}
}
function checkOnChange(itm){
	 
	return checkInput(itm, false);
}
function checkOnClick(itm){
	return checkInput(itm, true);
}
function onloadError(msg,itmname){
	if(msg=="msg_user_exists")
		showError(getMsg(msg), document.getElementById(itmname),true);
	else
		showError(getMsg(msg), document.getElementById(itmname));
}
function setUserNameUsable(bol){
	document.reg.username.readOnly = false;
    
	if (bol){
		showError(getMsg('msg_un_ok'), document.reg.username);
	}else{
		showError(getMsg('msg_user_exists'), document.reg.username, true);
	}
}

function setNickNameUsable(bol){
	document.reg.nickname.readOnly = false;
    
	if (bol){
		showError(getMsg('msg_nn_ok'), document.reg.nickname);
	}else{
		showError(getMsg('msg_nickename_exists'), document.reg.nickname, true);
	}
}
function setpersonNameUsable(bol){
	document.reg.personName.readOnly = false;

	if (bol){
		showError("恭喜你!该用户存在,你可以添加为好友", document.reg.personName);
	}else{
		showError("对不起!该用户不存在", document.reg.personName);
	}
}
/*
function readfile(file)
{
		var objXMLHTTP = new ActiveXObject("MICROSOFT.XMLHTTP");
		objXMLHTTP.open("GET",file,false);
		objXMLHTTP.send();
		var history_list = objXMLHTTP.ResponseText;
		return history_list;
}
*/

function readfile(file,type)
{
     var pars = '';
	 var myAjax = new Ajax.Request(
                    file,
                    {
					  method: 'get', 
					  parameters: pars, 
					  onComplete:function(requestHttp)
					  {
						   
						   if ( type=='username' )
						   {
							   
							   if ( requestHttp.responseText == 1 )
								{
									setUserNameUsable(true);
								}
								else
								{
									setUserNameUsable(false);
								}
						   }
						   
						   if ( type=='nickname' )
						   {
							   if ( requestHttp.responseText == 1 )
								{
									setNickNameUsable(true);
								}
								else
								{
									setNickNameUsable(false);
								}
						   }
						   if ( type=='personName' )
						   {
							   //alert(requestHttp.responseText);
							   if ( requestHttp.responseText == 0 )
								{
									setpersonNameUsable(true);
								}
								else
								{
									setpersonNameUsable(false);
								}
						   }
						   if( type == "headico" )
						   {
							   //删除用户头像
							   var result = requestHttp.responseText;
							    
							   if( result != "0")
							   {
								   document.images["headimg"].src = result;
								   document.getElementById('modhead').style.display    = 'none';
								   document.getElementById('uploadhead').style.display = '';
                                   showError("<font color='red'>头像删除成功</font>",document.getElementById("headico"));
							   }
							   else
							   {
                                   showError("<font color='red'>头像删除失败</font>",document.getElementById("headico"));
							   }
						   }
					  }
					}
                );
}

function DelUserHeadImg(file)
{
	showError("<font color='green'>头像删除中,请稍等....</font>",document.getElementById("headico"));
	 
	var src = file + '?delheadimg';
	 
	readfile(src,"headico");
}

function checkFriendName(file){
	un = document.reg.personName;
	 
	if(checkOnClick(un)){
		showError(getMsg('msg_un_checking'), document.reg.personName);
		if (typeof(encodeURIComponent) == 'function'){
			unstr = encodeURIComponent(un.value) + '&e=u';
		}else{
			unstr = un.value;
		}
		var src = file + '?check_username&un=' + unstr;
		readfile(src,'personName');
	}
}


function checkUserName(file){
	un = document.reg.username;
	//alert(document.getElementById("usernameforload").value);
	//alert(un.value);
	if(checkOnClick(un)){
		showError(getMsg('msg_un_checking'), document.reg.username);
		if (typeof(encodeURIComponent) == 'function'){
			unstr = encodeURIComponent(un.value) + '&e=u';
		}else{
			unstr = un.value;
		}
		var src = file + '?check_username&un=' + unstr;
		readfile(src,'username');
	}
}
function checkNickName(file){
	un = document.reg.nickname;
	if(checkOnClick(un)){
		showError(getMsg('msg_nn_checking'), document.reg.nickname);
		if (typeof(encodeURIComponent) == 'function'){
			unstr = encodeURIComponent(un.value) + '&e=u';
		}else{
			unstr = un.value;
		}
		var src = file + '?check_nickname&un=' + unstr;
	    readfile(src,'nickname');
	}
}
function checkItem(itm, blank){
	
	   
	if (itm.parentNode.parentNode.id == 'username'){
		 
		if (!blank && itm.value.Trim() == ''){
			 
			return getMsg('msg_un_blank');
		}else if (bytes(itm) > 18){
			return getMsg('msg_un_length');
		}else if (!chkstr(itm)){
			return getMsg('msg_un_format');
		}else if (blank && itm.value.Trim() == ''){
			return getMsg('msg_un_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'nickname'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_nn_blank');
		}else if (bytes(itm) > 18){
			return getMsg('msg_nn_length');
		}else if (!chkstr(itm)){
			return getMsg('msg_nn_format');
		}else if (blank && itm.value.Trim() == ''){
			return getMsg('msg_nn_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'loginpass'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_pw_blank');
		}else if (bytes(itm) > 14 || bytes(itm) < 4){
			return getMsg('msg_pw_length');
		}else if (itm.value.Trim() != '' && !itm.value.match(/^[\x21-\x7e]{1,14}$/ig)) {
			return getMsg('msg_pw_format');
		}
	}else if (itm.parentNode.parentNode.id == 'oldpassword'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_opw_blank');
		}else if (bytes(itm) > 14 || bytes(itm) < 4){
			return getMsg('msg_pw_length');
		}else if (itm.value.Trim() != '' && !itm.value.match(/^[\x21-\x7e]{1,14}$/ig)) {
			return getMsg('msg_pw_format');
		}
	}else if (itm.parentNode.parentNode.id == 'verifypass'){
		if (itm.value != document.reg.loginpass.value){
			return getMsg('msg_pw_verify');
		}
	}else if (itm.parentNode.parentNode.id == 'email'){
		if (blank && itm.value.Trim() == ''){
			return getMsg('msg_email_blank');
		}else if (!blank && itm.value.Trim() != '' && !itm.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
			return getMsg('msg_email');
		}else if (blank && !itm.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
			return getMsg('msg_email');
		}
	}else if (itm.parentNode.parentNode.id == 'security_email'){
		if (!blank && itm.value.Trim() != '' && !itm.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
			return getMsg('msg_email');
		}else if (blank && itm.value.Trim() != ''  && !itm.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
			return getMsg('msg_email');
		}
	}else if (itm.parentNode.parentNode.id == 'verifycode'){
		 
		if (blank && itm.value.Trim() == ''){
			return getMsg('msg_vc_blank');
		}else if (!blank && itm.value.Trim() != '' && !itm.value.match(/^[a-zA-Z0-9]{4,4}$/ig)) {
			return getMsg('msg_vc_format');
		}else if (blank && !itm.value.match(/^[a-zA-Z0-9]{4,4}$/ig)) {
			return getMsg('msg_vc_format');
		}
	}else if (itm.parentNode.parentNode.id == 'verify'){
		if (blank && itm.value.Trim() == ''){
			return getMsg('msg_vc_blank');
		}else if (!blank && itm.value.Trim() != '' && !itm.value.match(/^[a-zA-Z0-9]{4,4}$/ig)) {
			return getMsg('msg_vc_format');
		}else if (blank && !itm.value.match(/^[a-zA-Z0-9]{4,4}$/ig)) {
			return getMsg('msg_vc_format');
		}
	}else if (itm.parentNode.parentNode.id == 'mobile'){
		if (blank && itm.value.Trim() == ''){
			return getMsg('msg_mobile_blank');
		}else if (!blank && itm.value.Trim() != '' && !itm.value.match(/^[1]\d{10}$/ig)) {
			return getMsg('msg_mobile_format');
		}else if (blank && !itm.value.match(/^[1]\d{10}$/ig)) {
			return getMsg('msg_mobile_format');
		}
	}else if (itm.parentNode.parentNode.id == 'security_mobile'){
		if (!blank && itm.value.Trim() != '' && !itm.value.match(/^[1]\d{10}$/ig)) {
			return getMsg('msg_security_mobile_format');
		}else if (blank && itm.value.Trim() != '' && !itm.value.match(/^[1]\d{10}$/ig)) {
			return getMsg('msg_security_mobile_format');
		}
	}else if (itm.parentNode.parentNode.id == 'protocal'){
		if (!itm.checked){
			return getMsg('msg_protocal_no');
		}
	}else if (itm.parentNode.parentNode.id == 'question'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_question_blank');
		}else if (blank && itm.value.Trim() == '') {
			return getMsg('msg_question_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'answer'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_answer_blank');
		}else if (blank && itm.value.Trim() == '') {
			return getMsg('msg_answer_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'oldanswer'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_oldanswer_blank');
		}else if (blank && itm.value.Trim() == '') {
			return getMsg('msg_oldanswer_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'content'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_content_blank');
		}else if (blank && itm.value.Trim() == '') {
			return getMsg('msg_content_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'subject'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_subject_blank');
		}else if (blank && itm.value.Trim() == '') {
			return getMsg('msg_subject_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'card'){
		if (blank && itm.value.Trim() == ''){
			return getMsg('msg_card_blank');
		}else if (!blank && itm.value.Trim() != '' && !itm.value.match(/^\d{16,18}$/ig)){
			return getMsg('msg_card_format');
		}else if (blank && itm.value.Trim() != '' && !itm.value.match(/^\d{16,18}$/ig)) {
			return getMsg('msg_card_format');
		}
	}else if (itm.parentNode.parentNode.id == 'truename'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_truename_blank');
		}else if (blank && itm.value.Trim() == '') {
			return getMsg('msg_truename_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'address'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_address_blank');
		}else if (blank && itm.value.Trim() == '') {
			return getMsg('msg_address_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'telephone'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_telephone_blank');
		}else if (blank && itm.value.Trim() == '') {
			return getMsg('msg_telephone_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'amount'){
		if (blank && itm.value.Trim() == ''){
			return getMsg('msg_amount_blank');
		}else if (!blank && itm.value.Trim() != '' && !itm.value.match(/^\d{1,10}$/ig)){
			return getMsg('msg_amount_format');
		}else if (blank && itm.value.Trim() != '' && !itm.value.match(/^\d{1,10}$/ig)) {
			return getMsg('msg_amount_format');
		}
	}else if (itm.parentNode.parentNode.id == 'personName'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_personName_blank');
		}else if (blank && itm.value.Trim() == '') {
			return getMsg('msg_personName_blank');
		}
	}else if (itm.parentNode.parentNode.id == 'toUsername'){
		if (!blank && itm.value.Trim() == ''){
			return getMsg('msg_toUsername_blank');
		}else if (blank && itm.value.Trim() == '') {
			return getMsg('msg_subject_blank');
		}
	}
	
	return '';
}
var submited = false;
function checkForm(itm){
	err = false;
	if (!submited){
		with (itm){
			for (var i=0; i<elements.length; i++){
				//alert(elements[i].type);
				if ((elements[i].type=='textarea' || elements[i].type == 'text' || elements[i].type == 'password' || (elements[i].type == 'checkbox' && elements[i].name == 'protocal')) && !checkOnClick(elements[i])){
					if (!err){
						err = true;
					}
				}
			}
		}
		if (err){
			alert('您输入的资料不完整，请根据提示重新输入');
			return false;
		}else{
			submited = true;
			document.getElementById('btn_submit').disabled = true;
			return true;
		}
	}else{
		alert('请勿重复提交请求');
		return false;
	}
	/*
	*/
	return false;
}

function headchange()
{
	with(document.reg){
		if(question.selectedIndex==(question.length-1)){
			pass_question.style.display = "";
			pass_question.value = "";
			hideError(pass_question);
		}else{
			pass_question.style.display = "none";
			pass_question.value = question.options[question.selectedIndex].value;
			checkOnChange(pass_question);
		}
	}

}

function setsex(sexvalue)
{
	with(document.reg){
		if(sexvalue==2){
			sex[0].checked=false;
			sex[1].checked=true;
		}else{
			sex[0].checked=true;
			sex[1].checked=false;
		}
	}
}

function setlockmail(securevalue)
{
	if(securevalue=="N"){
		document.reg.lockmail.checked=false;
	}

}

function setprotocal(pvalue)
{
	if(pvalue=="Y"){
		document.reg.protocal.checked=true;
	}
}


function setpq(qvalue)
{


	with(document.reg){

		if(qvalue=="")
			qvalue=question.options[0].value;

		for (i=0;i<question.options.length;i++){
			if(question.options[i].value==qvalue){
				question.selectedIndex = i;
				break;
			}else{
				question.selectedIndex = question.options.length - 1;
			}
		}


		//autoSelect(question,qvalue);
		if(question.selectedIndex==(question.length-1)){
			pass_question.style.display = "";
		}
		pass_question.value = qvalue;
	}
}

function preview(img,newSrc,defaultSrc)
{
	if("" != newSrc)
	{
		document.images[img].style.display = "";
		document.images[img].src = newSrc;
	}
	else
	{
		if("" != defaultSrc)
		{
			document.images[img].style.display = "";
			document.images[img].src = defaultSrc;
		}
		else
		{
			document.images[img].style.display = "none";
		}
	}
}

function headPreview(img,value)
{
	if("" != value)
	{
	    document.images[img].src = value;
		document.images[img].style.display = "";
    }
	else
	{
		document.images[img].style.display = "none";
	}
}

function newverifypic(url)
{
	var timenow = new Date().getTime();
	url += "&verifypic";
	id = url.indexOf('?');
	if(id >= 0  ){
		if(id == (url.length-1))
			url += "t="+ timenow;
		else 
			url += "&t="+ timenow;
	}else{
		url += "?t="+ timenow;
	}

	document.getElementById("verifypic").src=url;
}


function checkRemitForm(theform)
{
	var submited = false;
	var err = false;
	var info;
	if (!submited){
		if (theform.truename.value == '')
		{
			info = '请填写充值人';
			err = false;
		}
		else if (theform.address.value == '')
		{
			info = '请输联系地址！';
			err = false;
		}
		else if (theform.telephone.value == '')
		{
			info = '请输入联系电话！';
			err = false;
		}
		else if (theform.amount.value == '')
		{
			info = '请输入充值金额！';
			err = false;
		}else{
			err = true;
		}
		if (!err){
			alert(info);
			return false;
		}else{
			submited = true;
			theform.btn_submit.disabled = true;
			return true;
		}
	}else{
		alert('请勿重复提交请求');
		return false;
	}
	return true;
}

 

String.prototype.Trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.LTrim = function()
{
	return this.replace(/(^\s*)/g, "");
}

String.prototype.RTrim = function()
{
	return this.replace(/(\s*$)/g, "");
}

document.getElementByClass = function (classname) {
   var elements = [];
   var alltags = document.all ? document.all : document.getElementsByTagName("*")
   for (var i=0; i<alltags.length; i++) { 
      var classNames = alltags[i].className.split(" ");
      if (classNames.contain(classname))
          elements[elements.length] = alltags[i];
   }
   return elements;
}

function ChangeAndSubmitForm(form1,inputname,inputvalue)
{
	inputname.value = inputvalue;
	form1.submit();
}



function doTab(tab,loc) {
    var obj = $(tab+'_'+loc);
    if (Element.hasClassName(obj, tab+'_active')) return;

    $(tab+'_c').innerHTML = $(loc).innerHTML;

    var nodes = $A(document.getElementsByClassName(tab+'_active'));
    nodes.each(function(node){
        Element.removeClassName(node, tab+'_active');
        Element.addClassName(node, tab+'_unactive');
    });

    if (obj) {
        Element.removeClassName(obj, tab+'_unactive');
        Element.addClassName(obj, tab+'_active');
    }
}

function chg_rs()
{

    var reother=/^其[他它]/gi;
	if(document.getElementById("rs1").value.match(reother)){
		if(document.getElementById("reside_site1").style.display=="none")
			document.getElementById("reside_site1").value="";
		document.getElementById("reside_site1").style.display="";
	}else{
		document.getElementById("reside_site1").value=$("rs1").value;
		document.getElementById("reside_site1").style.display="none";
	}

	if(document.getElementById("rs2").value.match(reother)){
		document.getElementById("reside_site2").value="";
		document.getElementById("reside_site2").style.display="";
	}else{
		document.getElementById("reside_site2").value=$("rs2").value;
		document.getElementById("reside_site2").style.display="none";
	}
}

function getCookieVal(offset) {
      var endstr=document.cookie.indexOf(";",offset);
      if(endstr==-1)
        endstr=document.cookie.length;
      return unescape(document.cookie.substring(offset,endstr));
    }

function GetCookie(name)
{
      var arg=name+ "=";
      var alen=arg.length;
      var clen=document.cookie.length;
      var i=0;
	  var r_null="";
      while (i<clen)
		{
			var j=i+alen;
			if(document.cookie.substring(i,j)==arg)
			return getCookieVal(j);
			i=document.cookie.indexOf("",i)+1;
			if(i==0)break;
		}
      return r_null;
}
 if (typeof document.attachEvent!='undefined') {
   window.attachEvent('onload',init);
   document.attachEvent('onmousemove',moveMouse);
   document.attachEvent('onclick',checkMove); }
else {
   window.addEventListener('load',init,false);
   document.addEventListener('mousemove',moveMouse,false);
   document.addEventListener('click',checkMove,false);
}

var oDv=document.createElement("div");
var dvHdr=document.createElement("div");
var dvBdy=document.createElement("div");
var windowlock,boxMove,fixposx,fixposy,lockX,lockY,fixx,fixy,ox,oy,boxLeft,boxRight,boxTop,boxBottom,evt,mouseX,mouseY,boxOpen,totalScrollTop,totalScrollLeft;
boxOpen=false;
ox=10;
oy=10;
lockX=0;
lockY=0;

function init() {
	oDv.appendChild(dvHdr);
	oDv.appendChild(dvBdy);
	oDv.style.position="absolute";
	oDv.style.visibility='hidden';
	document.body.appendChild(oDv);	
}

function defHdrStyle() {
}

function defBdyStyle() {
	dvBdy.style.border='1px solid #CDCDCD';
	dvBdy.style.width='144px';
	dvBdy.style.fontFamily='arial';
	dvBdy.style.fontSize='11';
	dvBdy.style.textAlign='left';
	dvBdy.style.padding='4';
	dvBdy.style.color='#999900';
	dvBdy.style.background='#FFFFFF';
	dvBdy.style.filter='alpha(opacity=95)'; // IE
	dvBdy.style.opacity='0.95'; // FF
}

function checkElemBO(txt) {
if (!txt || typeof(txt) != 'string') return false;
if ((txt.indexOf('body')>-1)&&(txt.indexOf('[')>-1)&&(txt.indexOf('[')>-1)) 
   return true;
else
   return false;
}

function scanBO(curNode) {
	  if (checkElemBO(curNode.title)) {
         curNode.boHDR=getParam('header',curNode.title);
         curNode.boBDY=getParam('body',curNode.title);
			curNode.boCSSBDY=getParam('cssbody',curNode.title);			
			curNode.boCSSHDR=getParam('cssheader',curNode.title);
			curNode.IEbugfix=(getParam('hideselects',curNode.title)=='on')?true:false;
			curNode.fixX=parseInt(getParam('fixedrelx',curNode.title));
			curNode.fixY=parseInt(getParam('fixedrely',curNode.title));
			curNode.absX=parseInt(getParam('fixedabsx',curNode.title));
			curNode.absY=parseInt(getParam('fixedabsy',curNode.title));
			curNode.offY=(getParam('offsety',curNode.title)!='')?parseInt(getParam('offsety',curNode.title)):10;
			curNode.offX=(getParam('offsetx',curNode.title)!='')?parseInt(getParam('offsetx',curNode.title)):10;
			curNode.fade=(getParam('fade',curNode.title)=='on')?true:false;
			curNode.fadespeed=(getParam('fadespeed',curNode.title)!='')?getParam('fadespeed',curNode.title):0.04;
			curNode.delay=(getParam('delay',curNode.title)!='')?parseInt(getParam('delay',curNode.title)):0;
			if (getParam('requireclick',curNode.title)=='on') {
				curNode.requireclick=true;
				document.all?curNode.attachEvent('onclick',showHideBox):curNode.addEventListener('click',showHideBox,false);
				document.all?curNode.attachEvent('onmouseover',hideBox):curNode.addEventListener('mouseover',hideBox,false);
			}
			else {// Note : if requireclick is on the stop clicks are ignored   			
   			if (getParam('doubleclickstop',curNode.title)!='off') {
   				document.all?curNode.attachEvent('ondblclick',pauseBox):curNode.addEventListener('dblclick',pauseBox,false);
   			}	
   			if (getParam('singleclickstop',curNode.title)=='on') {
   				document.all?curNode.attachEvent('onclick',pauseBox):curNode.addEventListener('click',pauseBox,false);
   			}
   		}
			curNode.windowLock=getParam('windowlock',curNode.title).toLowerCase()=='off'?false:true;
			curNode.title='';
			curNode.hasbox=1;
	   }
	   else
	      curNode.hasbox=2;   
}


function getParam(param,list) {
	var reg = new RegExp('([^a-zA-Z]' + param + '|^' + param + ')\\s*=\\s*\\[\\s*(((\\[\\[)|(\\]\\])|([^\\]\\[]))*)\\s*\\]');
	var res = reg.exec(list);
	var returnvar;
	if(res)
		return res[2].replace('[[','[').replace(']]',']');
	else
		return '';
}

function Left(elem){	
	var x=0;
	if (elem.calcLeft)
		return elem.calcLeft;
	var oElem=elem;
	while(elem){
		 if ((elem.currentStyle)&& (!isNaN(parseInt(elem.currentStyle.borderLeftWidth)))&&(x!=0))
		 	x+=parseInt(elem.currentStyle.borderLeftWidth);
		 x+=elem.offsetLeft;
		 elem=elem.offsetParent;
	  } 
	oElem.calcLeft=x;
	return x;
	}

function Top(elem){
	 var x=0;
	 if (elem.calcTop)
	 	return elem.calcTop;
	 var oElem=elem;
	 while(elem){		
	 	 if ((elem.currentStyle)&& (!isNaN(parseInt(elem.currentStyle.borderTopWidth)))&&(x!=0))
		 	x+=parseInt(elem.currentStyle.borderTopWidth); 
		 x+=elem.offsetTop;
	         elem=elem.offsetParent;
 	 } 
 	 oElem.calcTop=x;
 	 return x;
 	 
}

var ah,ab;
function applyStyles() {
	if(ab)
		oDv.removeChild(dvBdy);
	if (ah)
		oDv.removeChild(dvHdr);
	dvHdr=document.createElement("div");
	dvBdy=document.createElement("div");
	CBE.boCSSBDY?dvBdy.className=CBE.boCSSBDY:defBdyStyle();
	CBE.boCSSHDR?dvHdr.className=CBE.boCSSHDR:defHdrStyle();
	dvHdr.innerHTML=CBE.boHDR;
	dvBdy.innerHTML=CBE.boBDY;
	ah=false;
	ab=false;
	if (CBE.boHDR!='') {		
		oDv.appendChild(dvHdr);
		ah=true;
	}	
	if (CBE.boBDY!=''){
		oDv.appendChild(dvBdy);
		ab=true;
	}	
}

var CSE,iterElem,LSE,CBE,LBE, totalScrollLeft, totalScrollTop, width, height ;
var ini=false;

// Customised function for inner window dimension
function SHW() {
   if (document.body && (document.body.clientWidth !=0)) {
      width=document.body.clientWidth;
      height=document.body.clientHeight;
   }
   if (document.documentElement && (document.documentElement.clientWidth!=0) && (document.body.clientWidth + 20 >= document.documentElement.clientWidth)) {
      width=document.documentElement.clientWidth;   
      height=document.documentElement.clientHeight;   
   }   
   return [width,height];
}


var ID=null;
function moveMouse(e) {
   //boxMove=true;
	e?evt=e:evt=event;
	
	CSE=evt.target?evt.target:evt.srcElement;
	
	if (!CSE.hasbox) {
	   // Note we need to scan up DOM here, some elements like TR don't get triggered as srcElement
	   iElem=CSE;
	   while ((iElem.parentNode) && (!iElem.hasbox)) {
	      scanBO(iElem);
	      iElem=iElem.parentNode;
	   }	   
	}
	
	if ((CSE!=LSE)&&(!isChild(CSE,dvHdr))&&(!isChild(CSE,dvBdy))){		
	   if (!CSE.boxItem) {
			iterElem=CSE;
			while ((iterElem.hasbox==2)&&(iterElem.parentNode))
					iterElem=iterElem.parentNode; 
			CSE.boxItem=iterElem;
			}
		iterElem=CSE.boxItem;
		if (CSE.boxItem&&(CSE.boxItem.hasbox==1))  {
			LBE=CBE;
			CBE=iterElem;
			if (CBE!=LBE) {
				applyStyles();
				if (!CBE.requireclick)
					if (CBE.fade) {
						if (ID!=null)
							clearTimeout(ID);
						ID=setTimeout("fadeIn("+CBE.fadespeed+")",CBE.delay);
					}
					else {
						if (ID!=null)
							clearTimeout(ID);
						COL=1;
						ID=setTimeout("oDv.style.visibility='visible';ID=null;",CBE.delay);						
					}
				if (CBE.IEbugfix) {hideSelects();} 
				fixposx=!isNaN(CBE.fixX)?Left(CBE)+CBE.fixX:CBE.absX;
				fixposy=!isNaN(CBE.fixY)?Top(CBE)+CBE.fixY:CBE.absY;			
				lockX=0;
				lockY=0;
				boxMove=true;
				ox=CBE.offX?CBE.offX:10;
				oy=CBE.offY?CBE.offY:10;
			}
		}
		else if (!isChild(CSE,dvHdr) && !isChild(CSE,dvBdy) && (boxMove))	{
			// The conditional here fixes flickering between tables cells.
			if ((!isChild(CBE,CSE)) || (CSE.tagName!='TABLE')) {   			
   			CBE=null;
   			if (ID!=null)
  					clearTimeout(ID);
   			fadeOut();
   			showSelects();
			}
		}
		LSE=CSE;
	}
	else if (((isChild(CSE,dvHdr) || isChild(CSE,dvBdy))&&(boxMove))) {
		totalScrollLeft=0;
		totalScrollTop=0;
		
		iterElem=CSE;
		while(iterElem) {
			if(!isNaN(parseInt(iterElem.scrollTop)))
				totalScrollTop+=parseInt(iterElem.scrollTop);
			if(!isNaN(parseInt(iterElem.scrollLeft)))
				totalScrollLeft+=parseInt(iterElem.scrollLeft);
			iterElem=iterElem.parentNode;			
		}
		if (CBE!=null) {
			boxLeft=Left(CBE)-totalScrollLeft;
			boxRight=parseInt(Left(CBE)+CBE.offsetWidth)-totalScrollLeft;
			boxTop=Top(CBE)-totalScrollTop;
			boxBottom=parseInt(Top(CBE)+CBE.offsetHeight)-totalScrollTop;
			doCheck();
		}
	}
	
	if (boxMove&&CBE) {
		// This added to alleviate bug in IE6 w.r.t DOCTYPE
		bodyScrollTop=document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;
		bodyScrollLet=document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft;
		mouseX=evt.pageX?evt.pageX-bodyScrollLet:evt.clientX-document.body.clientLeft;
		mouseY=evt.pageY?evt.pageY-bodyScrollTop:evt.clientY-document.body.clientTop;
		if ((CBE)&&(CBE.windowLock)) {
			mouseY < -oy?lockY=-mouseY-oy:lockY=0;
			mouseX < -ox?lockX=-mouseX-ox:lockX=0;
			mouseY > (SHW()[1]-oDv.offsetHeight-oy)?lockY=-mouseY+SHW()[1]-oDv.offsetHeight-oy:lockY=lockY;
			mouseX > (SHW()[0]-dvBdy.offsetWidth-ox)?lockX=-mouseX-ox+SHW()[0]-dvBdy.offsetWidth:lockX=lockX;			
		}
		oDv.style.left=((fixposx)||(fixposx==0))?fixposx:bodyScrollLet+mouseX+ox+lockX+"px";
		oDv.style.top=((fixposy)||(fixposy==0))?fixposy:bodyScrollTop+mouseY+oy+lockY+"px";		
		
	}
}

function doCheck() {	
	if (   (mouseX < boxLeft)    ||     (mouseX >boxRight)     || (mouseY < boxTop) || (mouseY > boxBottom)) {
		if (!CBE.requireclick)
			fadeOut();
		if (CBE.IEbugfix) {showSelects();}
		CBE=null;
	}
}

function pauseBox(e) {
   e?evt=e:evt=event;
	boxMove=false;
	evt.cancelBubble=true;
}

function showHideBox(e) {
	oDv.style.visibility=(oDv.style.visibility!='visible')?'visible':'hidden';
}

function hideBox(e) {
	oDv.style.visibility='hidden';
}

var COL=0;
var stopfade=false;
function fadeIn(fs) {
		ID=null;
		COL=0;
		oDv.style.visibility='visible';
		fadeIn2(fs);
}

function fadeIn2(fs) {
		COL=COL+fs;
		COL=(COL>1)?1:COL;
		oDv.style.filter='alpha(opacity='+parseInt(100*COL)+')';
		oDv.style.opacity=COL;
		if (COL<1)
		 setTimeout("fadeIn2("+fs+")",20);		
}


function fadeOut() {
	oDv.style.visibility='hidden';
	
}

function isChild(s,d) {
	while(s) {
		if (s==d) 
			return true;
		s=s.parentNode;
	}
	return false;
}

var cSrc;
function checkMove(e) {
	e?evt=e:evt=event;
	cSrc=evt.target?evt.target:evt.srcElement;
	if ((!boxMove)&&(!isChild(cSrc,oDv))) {
		fadeOut();
		if (CBE&&CBE.IEbugfix) {showSelects();}
		boxMove=true;
		CBE=null;
	}
}

function showSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
      elements[i].style.visibility='visible';
   }
}

function hideSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
   elements[i].style.visibility='hidden';
   }
}
