﻿//-- 控制层删除start of script -->
function ssdel()
{
    if (event)
    {
    lObj = event.srcElement ;
    while (lObj && lObj.tagName != "DIV") lObj = lObj.parentElement ;
    }
    var id=lObj.id
     document.getElementById(id).removeNode(true);
     //document.getElementById(id).outerHTML="";//这样也可以;
  }
//-- 控制层删除End of script -->


//-- 控制层移动start of script -->
var Obj=''
var index=10000;//z-index;
document.onmouseup=MUp
document.onmousemove=MMove

function MDown(Object){
Obj=Object.id
document.all(Obj).setCapture()
pX=event.x-document.all(Obj).style.pixelLeft;
pY=event.y-document.all(Obj).style.pixelTop;
}

function MMove(){
if(Obj!=''){
 document.all(Obj).style.left=event.x-pX;
 document.all(Obj).style.top=event.y-pY;
 }
}

function MUp(){
if(Obj!=''){
 document.all(Obj).releaseCapture();
 Obj='';
 }
}
//-- 控制层移动end of script -->


//获得焦点;
function getFocus(obj)
{
       if(obj.style.zIndex!=index)
       {
               index = index + 2;
               var idx = index;
               obj.style.zIndex=idx;
               //obj.nextSibling.style.zIndex=idx-1;
       }
}
//查找祝福纸条
function Srch(obj)
{//alert(obj);
	if(obj.style.zIndex!=index)
	{
		index = index + 1000;
		var idx = index;
		obj.style.zIndex = idx;
		obj.style.width = 400;
		obj.style.height = 300;
		obj.style.left = 200;
		obj.style.top = 200;
	}
}

function ChkSrch()
{
if (SrchFrm.srchId.value == "")
	{alert("\n\n\n你总得告诉我查找哪一个吧！！\n\n\n");
	SrchFrm.srchId.focus();
	return false; }
return true;
}


function checkNum(obj){
	var checkOK = "0123456789 ";
	var checkStr = obj.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length){
			allValid = false;
			break;
		}
	}
	if (!allValid){
		alert("只能由数字组成！");
		obj.select();
		return (false);
	}
	return (true);
}

var ie = false;
function getObj(id) {
    if (ie) { return document.all[id]; }
    else { return document.getElementById(id); }
}

//设置背景色
function setColor(color) {
    document.getElementById("ccsample").style.background = color;
    document.getElementById("_ctl0__ctl0_cphMain_cphList_tagcolor").value = color;
}

//设置悬浮Div内容
function textCounter() {
    var contentsample = document.getElementById("contentsample"); //Div标签内容
    var messages = document.getElementById("_ctl0__ctl0_cphMain_cphList_messages"); //内容
    var remLen = document.getElementById("remLen"); //100个字
    if (StrLen(messages.value) > 100) {
        messages.value = messages.value.substring(0, 100);
    }
    else {
        remLen.value = 100 - StrLen(messages.value);
        contentsample.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + messages.value;
    }
}

//检查提交登录
function chkform() {
    if (document.getElementById("_ctl0__ctl0_cphMain_cphList_sendName").value == "") {
        alert("\n\n\n您要给谁许愿呢？留下他（她）的大名吧！\n\n");
        document.getElementById("_ctl0__ctl0_cphMain_cphList_sendName").focus();
        return false;
    }
    if (document.getElementById("_ctl0__ctl0_cphMain_cphList_messages").value == "") {
        alert("\n\n\n至少说点什么吧！！\n\n\n");
        document.getElementById("_ctl0__ctl0_cphMain_cphList_messages").focus();
        return false;
    }
    return true;
}

//获取字符串长度
function StrLen(s) {
    var l = 0;
    var a = s.split("");
    for (var i = 0; i < a.length; i++) {
        if (a[i].charCodeAt(0) < 299) {
            l++;
        } else {
            l += 2;
        }
    }
    return l;
} 
