﻿//----The Begin of Funoral - Powered by JCNS(www.jinchen.org)

//----------------  Hot Keys ------------------//        
var key = new Array();  // Define key launcher pages here
key['H'] = "http://www.jinchen.org";

function getKey(keyStroke) {
isNetscape=(document.layers);
// Cross-browser key capture routine couresty
// of Randy Bennett (rbennett@thezone.net)
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
for (var i in key) if (which == i) window.location = key[i];
}
document.onkeypress = getKey;

//----------------  Alpha Opacity Changer ------------------//        
var speed = 50; 
var max_opacity = 100;  
var min_opacity = 10;
var do_step  =  5;
function change_opacity(obj,do_option)
{
	if(obj.doing)
		clearInterval(obj.doing);
	obj.doing = setInterval(do_option+"_alpha("+obj.sourceIndex+")",speed);	
}
function down_alpha(obj_index)
{
	var obj = document.all[obj_index];
	
	if(obj.filters.Alpha.Opacity > min_opacity )
	{
		obj.filters.Alpha.Opacity += -do_step;
	}	
	else
	{	
		clearInterval(obj.doing);
		obj.filters.Alpha.Opacity = min_opacity;
		obj.doing = false;
	}	
}	
function up_alpha(obj_index)
{
	var obj = document.all[obj_index];
	
	if(obj.filters.Alpha.Opacity<max_opacity)
		obj.filters.Alpha.Opacity += do_step;
	else
	{	
		clearInterval(obj.doing);
		obj.filters.Alpha.Opacity = max_opacity;
		obj.doing = false;
	}	
}

//----------------  Settings  ------------------//        
var JustMenuID = "";
var SubMenuList = new Array();
var NowSubMenu = "";        
var mouseCanSound = true;          //Sound Gate: True of False//
var menuSpeed     =  5;   //---------- Speed of Menu ------------//
var alphaStep     =  20;   //---------- Step of Alpha -----------//

//------------- Copy Input -------------//
function oCopy(obj){ 
obj.select(); 
js=obj.createTextRange(); 
js.execCommand("Copy") 
}

//------------- Menu_1 -------------//
function MouseMenu(objName)
{
        this.id           = "Menu_"+objName;
        this.obj          = objName;
        this.length  = 0;
        this.addMenu = addMenu;
        this.addLink = addLink;
        this.addHR   = addHR;        
        JustMenuID = this.id;
        document.body.insertAdjacentHTML('beforeEnd','<table id="'+this.id+'" border="0" cellspacing="0" cellpadding="0" style="top: 0; left: 0; visibility: hidden; filter:Alpha(Opacity=0);" class="menutable" onmousedown=event.cancelBubble=true; onmouseup=event.cancelBubble=true></table>');
}
//----------- Menu_2 -------------//
function SubMenu(objName,objID)
{
        this.obj = objName;
        this.id  = objID;
        this.addMenu = addMenu;
        this.addLink = addLink;
        this.addHR   = addHR;
        this.length  = 0;
}
//-------------- makeMenu -----------//
function makeMenu(subID,oldID,word,icon,url,target,thetitle)
{
        var thelink = '';
        if(icon&&icon!="")
        {
                icon = '<img border="0" src="'+IconList[icon].src+'">';
        }
        else
        {
                icon = '';
        }
        if(!thetitle||thetitle=="")
        {
                thetitle = '';
        }
        if(url&&url!="")
        {
                thelink += '<a href="'+url+'" ';
                
                if(target&&target!="")
                {
                        thelink += '  ';
                        thelink += 'target="'+target+'" '
                }
                
                thelink += '></a>';
        }
        var Oobj = document.getElementById(oldID);
        /*--------------------------------------------- html
          <tr class="menutrout" id="trMenu_one_0" title="I am title">
      <td class="menutd0"><img src="icon/sub.gif" border="0" width="16" height="16"></td>
      <td><a href="javascript:alert('I am menu');" target="_self"></a><nobr>Menu</nobr></td>
      <td class="menutd1">4</td>
      <td class="menutd2">&nbsp;</td>
    </tr>
        --------------------------------------------------*/
        Oobj.insertRow();
        with(Oobj.rows(Oobj.rows.length-1))
        {
                id                         = "tr"+subID;
                className        = "menutrout";
                title       = thetitle;
        }
        
        eventObj = "tr"+subID;
        
        eval(eventObj+'.attachEvent("onmouseover",MtrOver('+eventObj+'))');        
        eval(eventObj+'.attachEvent("onclick",MtrClick('+eventObj+'))');        
                
        var trObj = eval(eventObj);

        for(i=0;i<4;i++)
        {
                trObj.insertCell();
        }

        with(Oobj.rows(Oobj.rows.length-1))
        {
                cells(0).className = "menutd0";
                cells(0).innerHTML = icon;

                cells(1).innerHTML = thelink+'<nobr class=indentWord>'+word+'</nobr>';
                cells(1).calssName = "indentWord"
                
                cells(2).className = "menutd1";
                cells(2).innerHTML = "4";
                
                cells(3).className = "menutd2";
                cells(3).innerText = " ";
                
        }        
        document.body.insertAdjacentHTML('beforeEnd','<table id="'+subID+'" border="0" cellspacing="0" cellpadding="0" style="top: 0; left: 0; visibility: hidden; filter:Alpha(Opacity=0);" class="menutable" onmousedown=event.cancelBubble=true; onmouseup=event.cancelBubble=true></table>');
}
//---------------- makeLink ------------//
function makeLink(subID,oldID,word,icon,url,target,thetitle)
{
        var thelink = '';
        if(icon&&icon!="")
        {
                icon = '<img border="0" src="'+IconList[icon].src+'">';
        }
        else
        {
                icon = '';
        }
        if(!thetitle||thetitle=="")
        {
                thetitle = '';
        }
        if(url&&url!="")
        {
                thelink += '<a href="'+url+'" ';
                if(target&&target!="")
                {
                        thelink += '  ';
                        thelink += 'target="'+target+'" '
                }
                thelink += '></a>';
        }
        var Oobj = document.getElementById(oldID);
        /*--------------------------------------------- html
          <tr class="menutrout" id="trMenu_one_0" title="I am title">
      <td class="menutd0"><img src="icon/sub.gif" border="0" width="16" height="16"></td>
      <td><a href="javascript:alert('I am link');" target="_self"></a><nobr>Link</nobr></td>
      <td class="linktd1"></td>
      <td class="menutd2">&nbsp;</td>
    </tr>
        --------------------------------------------------*/        
        Oobj.insertRow();
        with(Oobj.rows(Oobj.rows.length-1))
        {
                id                         = "tr"+subID;
                className        = "menutrout";                
                title       = thetitle;
        }
        eventObj = "tr"+subID;
        eval(eventObj+'.attachEvent("onmouseover",LtrOver('+eventObj+'))');        
        eval(eventObj+'.attachEvent("onmouseout",LtrOut('+eventObj+'))');                
        eval(eventObj+'.attachEvent("onclick",MtrClick('+eventObj+'))');        
        var trObj = eval(eventObj);
        for(i=0;i<4;i++)
        {
                trObj.insertCell();
        }
        with(Oobj.rows(Oobj.rows.length-1))
        {
                cells(0).className = "menutd0";
                cells(0).innerHTML = icon;
                cells(1).innerHTML = thelink+'<nobr class=indentWord>'+word+'</nobr>';
                cells(2).className = "linktd1";
                cells(2).innerText = " ";
                cells(3).className = "menutd2";
                cells(3).innerText = " ";
        }        
}
//-------------- addMenu ------------//
function addMenu(word,icon,url,target,title)
{
        var subID    = this.id + "_" + this.length;
        var subObj  = this.obj+"["+this.length+"]";
        var oldID   = this.id;
        eval(subObj+"= new SubMenu('"+subObj+"','"+subID+"')");
         makeMenu(subID,oldID,word,icon,url,target,title);
         this.length++;
}
//------------- addLink -------------//
function addLink(word,icon,url,target,title)
{
        var subID    = this.id + "_" + this.length;
        var oldID  = this.id;
         makeLink(subID,oldID,word,icon,url,target,title);
         this.length++;        
}
//------------ objMenu addHR Function -----------------//
function addHR()
{
        var oldID = this.id;
        var Oobj = document.getElementById(oldID);
        Oobj.insertRow();
        /*------------------------------------------
         <tr>
      <td colspan="4">
                <hr class="menuhr" size="1" width="95%">
       </td>
    </tr>
        --------------------------------------------*/        
        Oobj.rows(Oobj.rows.length-1).insertCell();
        with(Oobj.rows(Oobj.rows.length-1))
        {
                cells(0).colSpan= 4;
                cells(0).insertAdjacentHTML('beforeEnd','<hr class="menuhr" size="1" width="95%">');                
        }        
        
}
//--------- MtrOver(obj)-------------------//
function MtrOver(obj)
{
        return sub_over;
        function sub_over()
        {
                var sonid = obj.id.substring(2,obj.id.length);
                var topobj = obj.parentElement.parentElement; 
                NowSubMenu = topobj.id;
                if(obj.className=="menutrout")
                {
                        mouseWave();
                }                
                HideMenu(1);                
                SubMenuList[returnIndex(NowSubMenu)] = NowSubMenu;
                ShowTheMenu(sonid,MPreturn(sonid))                
                SubMenuList[returnIndex(obj.id)] = sonid;
                if(topobj.oldTR)
                { 
                        eval(topobj.oldTR+'.className = "menutrout"'); 
                } 
                obj.className = "menutrin"; 
                topobj.oldTR = obj.id; 
        }
}
//--------- LtrOver(obj)-------------------//
function LtrOver(obj)
{
        return sub_over;
        function sub_over()
        {
                var topobj = obj.parentElement.parentElement; 
                NowSubMenu = topobj.id;
                HideMenu(1);
                SubMenuList[returnIndex(NowSubMenu)] = NowSubMenu;
                if(topobj.oldTR)
                { 
                        eval(topobj.oldTR+'.className = "menutrout"'); 
                } 
                obj.className = "menutrin"; 
                topobj.oldTR = obj.id; 
        }
}
//--------- LtrOut(obj)-------------------//
function LtrOut(obj)
{
        return sub_out;
        function sub_out()
        {
                var topobj = obj.parentElement.parentElement; 
                obj.className = "menutrout"; 
                topobj.oldTR = false; 
        }
}
//----------MtrClick(obj)-----------------//
function MtrClick(obj)
{
        return sub_click;
        function sub_click()
        {
                if(obj.cells(1).all.tags("A").length>0)
                {
                        obj.cells(1).all.tags("A")(0).click();
                }        
        }
}
//---------- returnIndex(str)--------------//
function returnIndex(str)
{
        return (str.split("_").length-3)
}
//---------ShowTheMenu(obj,num)-----------------//
function ShowTheMenu(obj,num)
{
        var topobj = eval(obj.substring(0,obj.length-2));
        var trobj  = eval("tr"+obj);
        var obj = eval(obj);
        if(num==0)
        {
                with(obj.style)
                {
                        pixelLeft = topobj.style.pixelLeft +topobj.offsetWidth;
                        pixelTop  = topobj.style.pixelTop + trobj.offsetTop;
                }
        }
        if(num==1)
        {
                with(obj.style)
                {
                        pixelLeft = topobj.style.pixelLeft + topobj.offsetWidth;
                        pixelTop  = topobj.style.pixelTop  + trobj.offsetTop + trobj.offsetHeight - obj.offsetHeight;
                }
        }
        if(num==2)
        {
                with(obj.style)
                {
                        pixelLeft = topobj.style.pixelLeft -  obj.offsetWidth;
                        pixelTop  = topobj.style.pixelTop + trobj.offsetTop;
                }        
        }
        if(num==3)
        {
                with(obj.style)
                {
                        pixelLeft = topobj.style.pixelLeft -  obj.offsetWidth;
                        pixelTop  = topobj.style.pixelTop  + trobj.offsetTop + trobj.offsetHeight - obj.offsetHeight;
                }        
        }
        obj.style.visibility  = "visible";         
        if(obj.alphaing)
        {
                clearInterval(obj.alphaing);
        }
        obj.alphaing = setInterval("menu_alpha_up("+obj.id+","+alphaStep+")",menuSpeed);        
}
//----------HideMenu(num)-------------------//
/*----------------------
var SubMenuList = new Array();
var NowSubMenu = "";        
---------------------*/
function HideMenu(num)
{
        var thenowMenu = "";
        var obj = null;
        if(num==1)
        {
                thenowMenu = NowSubMenu
        }
        for(i=SubMenuList.length-1;i>=0;i--)
        {
                if(SubMenuList[i]&&SubMenuList[i]!=thenowMenu)
                {
                        
                        obj = eval(SubMenuList[i]);
                        
                        if(obj.alphaing)
                        {
                                clearInterval(obj.alphaing);
                        }        

                        obj.alphaing = setInterval("menu_alpha_down("+obj.id+","+alphaStep+")",menuSpeed);
                        
                        obj.style.visibility = "hidden";                
                        
                        eval("tr"+SubMenuList[i]).className = "menutrout";
                                                
                        SubMenuList[i] = null;        
                }
                else
                {
                        if(SubMenuList[i]==thenowMenu)
                        {
                                return;
                        }
                }
        }
        NowSubMenu = "";
}
//-----------MainMenuPosition return()------------//
function MMPreturn()
{
        var obj = eval(JustMenuID);
        var x = event.clientX;
        var y = event.clientY;
        var judgerX = x + obj.offsetWidth;
        var judgerY = y + obj.offsetHeight;
        var px = 0;
        var py = 0;
        if(judgerX>document.body.clientWidth)
        {
                px = 2;
        }
        if(judgerY>document.body.clientHeight)
        {
                py = 1;
        }
        return (px+py);
}
//-----------MenuPosition return(obj)--------------//
function MPreturn(obj)
{
        var topobj = eval(obj.substring(0,obj.length-2));
        var trobj  = eval("tr"+obj);
        var x = topobj.style.pixelLeft + topobj.offsetWidth;
        var y = topobj.style.pixelTop  + trobj.offsetTop;
        obj = eval(obj);
        var judgerY =  obj.offsetHeight + y;
        var judgerX =  obj.offsetWidth  + x;
        var py = 0;
        var px = 0;
        if(judgerY>=document.body.clientHeight)
        {
                py = 1;
        }
        
        if(judgerX>= document.body.clientWidth)
        {
                px = 2;
        } 
        return (px+py);
}
//----------- menu_alpha_down -------//
function menu_alpha_down(obj,num)
{
                var obj = eval(obj);
                
                if(obj.filters.Alpha.Opacity > 0 )
                {
                        obj.filters.Alpha.Opacity += -num;
                }        
                else
                {        
                        clearInterval(obj.alphaing);
                        obj.filters.Alpha.Opacity = 0;
                        obj.alphaing = false;                        
                        obj.style.visibility = "hidden";
                }        
}
//------------ menu_alpha_up --------//
function menu_alpha_up(obj,num)
{
                var obj = eval(obj);
                
                if(obj.filters.Alpha.Opacity<100)
                        obj.filters.Alpha.Opacity += num;
                else
                {        
                        clearInterval(obj.alphaing);
                        obj.filters.Alpha.Opacity = 100;
                        obj.alphaing = false;
                }        
}
//----------- MSIE ContextMenu -----------------//
function document.oncontextmenu()
{
        return false;
}
//----------- MSIE Mouseup ----------------//
function document.onmouseup()
{
        if(event.button==2)
        {
                HideMenu(0);
                var obj = eval(JustMenuID)
                        obj.style.visibility = "hidden";
                        if(obj.alphaing)
                        {
                                clearInterval(obj.alphaing);
                        }
                        
                        obj.filters.Alpha.Opacity = 0;
                        
                        var judger = MMPreturn()
                        
                        if(judger==0)
                        {
                                with(obj.style)
                                {
                                        pixelLeft = event.clientX + document.body.scrollLeft;
                                        pixelTop  = event.clientY + document.body.scrollTop;
                                }
                        }
                        if(judger==1)
                        {
                                with(obj.style)
                                {
                                        pixelLeft = event.clientX + document.body.scrollLeft;
                                        pixelTop  = event.clientY - obj.offsetHeight + document.body.scrollTop;
                                }
                        }
                        if(judger==2)
                        {
                                with(obj.style)
                                {
                                        pixelLeft = event.clientX - obj.offsetWidth + document.body.scrollLeft;
                                        pixelTop  = event.clientY + document.body.scrollTop;
                                }
                        }
                        if(judger==3)
                        {
                                with(obj.style)
                                {
                                        pixelLeft = event.clientX - obj.offsetWidth + document.body.scrollLeft;
                                        pixelTop  = event.clientY - obj.offsetHeight + document.body.scrollTop;
                                }
                        }
                        mouseWave();
                        obj.style.visibility = "visible";
                        obj.alphaing = setInterval("menu_alpha_up("+obj.id+","+alphaStep+")",menuSpeed);
        }
}
//---------- MSIE MouseDown --------------//
function document.onmousedown()
{
		if(event.button==1)
		{
			menu_close();
			JustMenuID = "Menu_one";
		}
}
function menu_close()
{
		HideMenu();
		var obj = eval(JustMenuID)
		if(obj.alphaing)
		{
			clearInterval(obj.alphaing);
		}
		obj.alphaing = setInterval("menu_alpha_down("+obj.id+","+alphaStep+")",menuSpeed);
		sc();
}
	
//---------- Menu Item Self Action --------------//
function Sysrcmnfw(istr,tmpobj)
{
	if (event.button==2)
	{
		JustMenuID = "Menu_one";
		menu_close();
		JustClickObj = tmpobj;
		if (istr=="textbox")
		{
			JustMenuID = "Menu_Sysrcmnxw1";
		}
	}
}
function Sysrcobfd(istr)
{
	menu_close();
	if (istr=="clear")
	{
		if (JustClickObj.readOnly=='')
		{
			if (confirm("Are you sure to clear? "))
			{JustClickObj.value="";}
		}
		else
		{
			alert("You cannot clear the text, because it is read only. ");
		}
	}
	else if (istr=="reset")
	{
		if (JustClickObj.readOnly=='')
		{
			if (confirm("Are you sure to reset? "))
			{JustClickObj.value=JustClickObj.defaultValue;}
		}
		else
		{
			alert("This textbox is read only. ");
		}
	}
	else if (istr=="copy")
	{
		if (JustClickObj.type!='password')
		{
			window.clipboardData.setData('text', JustClickObj.value);
		}
		else
		{
			alert("You cannot copy password. ");
		}
	}
	else if (istr=="paste")
	{
		if ((JustClickObj.type!='password')&&(JustClickObj.readOnly==''))
		{
			JustClickObj.value+=window.clipboardData.getData('text');
		}
		else
		{
			alert("An input error. ");
		}
	}
	JustClickObj.focus();
	JustMenuID = "Menu_one";
}
function syfxoshg(tmpobj,tmpnum)
{
	if (tmpnum==0)
	{
		if (tmpobj.style.display=="")
		{
			tmpobj.style.display="none";
		}
		else
		{
			tmpobj.style.display="";
		}
	}
	else if (tmpnum==1)
	{
		tmpobj.style.display="";
	}
	else if (tmpnum==2)
	{
		tmpobj.style.display="none";
	}
}

//---------- Common Functions ----------//
//-- RTrim(sString)
function JHshRTrim(sString)
{ 
var sStr,i,sResult = "",sTemp = "" ;
sStr = sString.split("");
for (i = sStr.length - 1 ; i >= 0 ; i --)  // 将字符串进行倒序
 { 
  sResult = sResult + sStr[i]; 
 }
sTemp = JHshLTrim(sResult) ; // 进行字符串前空格截除
if (sTemp == "") { return "" ; }
sStr = sTemp.split("");
sResult = "" ;
for (i = sStr.length - 1 ; i >= 0 ; i--) // 将经处理后的字符串再进行倒序
 {
  sResult = sResult + sStr[i];
 }
 return sResult ;
} 
//-- LTrim(sString)
function JHshLTrim(sString)
{ 
var sStr,i,iStart,sResult = "";
sStr = sString.split("");
iStart = -1 ;
for (i = 0 ; i < sStr.length ; i++)
 {
  if (sStr[i] != " ") 
  {
   iStart = i;
   break;
  }
 }
if (iStart == -1) { return "" ;}    //Return null if there are blanks only in sString.
else { return sString.substring(iStart) ;}
}
//-- Trim(sString)
function JHshTrim(sString)
{
var strTmp ;
strTmp = JHshRTrim(JHshLTrim(sString)) ;
return strTmp ;
} 
//-- Numeric 0-9 and (.) and (-) Type Only
function JHshNumberText()
{
if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57))|| (window.event.keyCode == 13) || (window.event.keyCode == 46) || (window.event.keyCode == 45)))
 {
  window.event.keyCode = 0 ;
 }
}
//-- Numeric 0-9 and (.) Type Only
function xIsNumber()
{
if (!(((window.event.keyCode>=48) && (window.event.keyCode<=57))||(window.event.keyCode==13)||(window.event.keyCode==45)))
    {
     window.event.keyCode=0;
 }
}
//-- Numeric 0-9 Type Only
function xIsInt()
{
if (!(((window.event.keyCode>=48) && (window.event.keyCode<=57))||(window.event.keyCode==13)))
    {
     window.event.keyCode=0;
 }
}
//-- Date Type Only
function xIsDate(DateString , Dilimeter) 
{ 
if ((DateString ==null) || (DateString ==""))  return true ;
if (Dilimeter=='' || Dilimeter==null)
Dilimeter = '-'; 
var tempy=''; 
var tempm=''; 
var tempd=''; 
var tempArray; 
if (DateString.length<8 && DateString.length>10) 
return false;  
tempArray = DateString.split(Dilimeter); 
if (tempArray.length!=3) 
return false; 
if (tempArray[0].length!=4) 
{ 
  return false;
} else if(tempArray[1].length!=2)
{
  return false;
}else if(tempArray[2].length!=2)
{
  return false;
}else
{
  tempy = tempArray[0]; 
  tempd = tempArray[2]; 
  tempm = tempArray[1];  
}
var tDateString = tempy + '/'+tempm + '/'+tempd +' 8:0:0';//East+8000
var tempDate = new Date(tDateString); 
if (isNaN(tempDate)) 
return false; 
//alert(((tempDate.getUTCFullYear()).toString()+">>>"+tempy+">>>"+tempDate.getDate()).toString()+">>>"+(parseInt(tempd,10)).toString()+">>>"+(tempDate.getMonth()).toString()+">>>"+(parseInt(tempm,10)-1).toString());
if (((tempDate.getUTCFullYear()).toString()==tempy) && (tempDate.getMonth()==parseInt(tempm,10)-1) && (tempDate.getDate()==parseInt(tempd,10))) 
{ 
return true; 
} 
else 
{ 
return false; 
} 
}
//-- LCase
function JHshToLowerCase() 
{
if ((window.event.keyCode >= 65) && (window.event.keyCode <= 90)) 
 {
   window.event.keyCode = window.event.keyCode + 32 ; 
 } 
}
//-- Ucase
function JHshToUpperCase() 
{
if ((window.event.keyCode >= 97) && (window.event.keyCode <= 122)) 
 {
   window.event.keyCode = window.event.keyCode - 32 ; 
 }
}
//-- Get length (Asian Characters will get 2.)
function strlen(str)
{
var len;
var i;
len = 0;
for (i=0;i<str.length;i++)
{
if (str.charCodeAt(i)>255) len+=2; else len++;
}
return len ;
}
function checkStrComma(str,flag){
//The flag is the length for running, False means only ('), True means both (') and (").
var i,len;
for (i=0;i<str.length;i++)
{
if (flag)
 {if ((str.charCodeAt(i)==34)||(str.charCodeAt(i)==39)) return false ;}    //Both (') and (").
else
 {if (str.charCodeAt(i)==39) return false ;}   //Only check single quoke (').
}
return true ;
}
//-- This function can set a image can auto self config by a cell.
function change_pic(img,td)
//'img' is a image, 'td' is a object of a cell.
{
 var r1=img.width/img.height;
 var r2=td.width/td.height;
 
 if (img.width>td.width && r1>r2)
 {
  img.width=td.width;
  img.height=img.width/r1;
 }
 if (img.height>td.height && r1<r2)
 {
  img.height=td.height;
  img.width=img.height*r1;
 }
 }


//----->

//----The End of Funoral

//*********************************************************************//
// Copyright (C) 1998-2008 Jiangxi Jinchen Decorate Design Co,.Ltd //
//                      www.jinchen.org                                                               //
//*********************************************************************//
