﻿
function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_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; }
}


//



var TIMER_SLIDE = null;
var OBJ_SLIDE;
var OBJ_VIEW;
var PIX_SLIDE = 10; //this is the amount of slide/DELAY_SLIDE
var NEW_PIX_VAL;
var DELAY_SLIDE = 30; //this is the time between each call to slide
var DIV_HEIGHT = 22; //value irrelevant
var SUB_MENU_NUM =0;
var RE_INIT_OBJ = null;
var bMenu = document.getElementById("curMenu");
var MainDiv,SubDiv

//DD added code
document.write('<div id="tempcontainer" class="mainDiv" style="visibility: hidden; position: absolute"></div>')

function Init(objDiv)
{
    if (TIMER_SLIDE == null)
    {
        SUB_MENU_NUM = 0;
        MainDiv = objDiv.parentNode;
        SubDiv =  MainDiv.getElementsByTagName("DIV").item(0);
        SubDiv.onclick = SetSlide;
        
        OBJ_SLIDE = MainDiv.getElementsByTagName("DIV").item(1)
        OBJ_VIEW = OBJ_SLIDE.getElementsByTagName("DIV").item(0);

    document.getElementById("tempcontainer").innerHTML=MainDiv.getElementsByTagName("DIV").item(2).innerHTML //DD added code
    DIV_HEIGHT=document.getElementById("tempcontainer").offsetHeight //DD added code
        
        for (var i=0;i<OBJ_VIEW.childNodes.length;i++)
        {
            if (OBJ_VIEW.childNodes.item(i).tagName == "SPAN")
            {
                SUB_MENU_NUM ++;
                OBJ_VIEW.childNodes.item(i).onmouseover= ChangeStyle;
                OBJ_VIEW.childNodes.item(i).onmouseout= ChangeStyle;
            }
        }   
        
              NEW_PIX_VAL = parseInt(MainDiv.getAttribute("state")); 
    }

}
function SetSlide()
{   
   if (window.TIMER_SLIDE) clearInterval(TIMER_SLIDE) //DD added code
      if (TIMER_SLIDE == null && this.parentNode == MainDiv)
            TIMER_SLIDE = setInterval('RunSlide()', DELAY_SLIDE);
      else
      {
          RE_INIT_OBJ = this;
          setTimeout('ReInit()', 200);
      }
}

function ReInit(obj)
{
    Init(RE_INIT_OBJ);
    TIMER_SLIDE = setInterval('RunSlide()', DELAY_SLIDE);
    RE_INIT_OBJ = null;
}

function RunSlide()
{

    if (OBJ_VIEW.getAttribute("state") == 0)
    {

        NEW_PIX_VAL += PIX_SLIDE;
        OBJ_SLIDE.style.height = NEW_PIX_VAL;

        if (NEW_PIX_VAL >= DIV_HEIGHT) //DD modified code
        {
            clearInterval(TIMER_SLIDE);
            TIMER_SLIDE = null;
            OBJ_VIEW.style.display = 'inline';
            OBJ_VIEW.setAttribute("state","1")
            MainDiv.setAttribute("state",NEW_PIX_VAL);
        }
    } else
    {
        OBJ_VIEW.style.display = 'none';
        NEW_PIX_VAL -= PIX_SLIDE;
        if(NEW_PIX_VAL > 0)OBJ_SLIDE.style.height = NEW_PIX_VAL;
        if (NEW_PIX_VAL <= 0)
        {
            NEW_PIX_VAL = 0;
            OBJ_SLIDE.style.height = NEW_PIX_VAL
            clearInterval(TIMER_SLIDE);
            TIMER_SLIDE = null;
            OBJ_VIEW.setAttribute("state","0")
            MainDiv.setAttribute("state",NEW_PIX_VAL);
        }
    }
}

function ChangeStyle()
{
    if (this.className == this.getAttribute("classOut"))
        this.className = this.getAttribute("classOver");
    else
        this.className = this.getAttribute("classOut");
}
function validate()
{
 var elem1=order_form.tel.value;
 var elem2=order_form.email.value;
 //var pattern1=/(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/;
 var pattern1=/^[\d\(\)\-\+]+$/;
 //var pattern1=/^[^a-zA-Z]+$/;
 // tel
 var pemail=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
 var pattern2=/^\s*$/;
 	if (order_form.in_time.value == "")

	{
		alert("The Check-in date is not spatial!");
		order_form.in_time.focus();
		return (false);
	}
	 	if (order_form.out_time.value == "")

	{
		alert("The Check-out date is not spatial!");
		order_form.out_time.focus();
		return (false);
	}
   if (order_form.name.value == "")

	{
		alert("The name is not spatial!");
		order_form.name.focus();
		return (false);
	}
	if(!pattern1.test(elem1))
	{
   	alert("The telephone form is not correct!");
	order_form.tel.focus();
	return (false);
    }
	 if(!pemail.test(elem2))
	{
   	alert("The email form is not correct!");
	order_form.email.focus();
	return (false);
    }

    if (order_form.num.value == "")

	{
		alert("The Room_Number is not spatial!");
		order_form.num.focus();
		return (false);
	}

 }

function validate2()
{
 var elem12=order_form2.tel.value;
 var elem22=order_form2.email.value;
 //var pattern1=/(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/;
 var pattern12=/^[\d\(\)\-\+]+$/;
 //var pattern1=/^[^a-zA-Z]+$/;
 // tel
 var pemail2=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
 var pattern22=/^\s*$/;
 	if (order_form2.in_time.value == "")

	{
		alert("The Check-in date is not spatial!");
		order_form2.in_time.focus();
		return (false);
	}
	 	if (order_form2.out_time.value == "")

	{
		alert("The Check-out date is not spatial!");
		order_form2.out_time.focus();
		return (false);
	}
   if (order_form2.name.value == "")

	{
		alert("The name is not spatial!");
		order_form2.name.focus();
		return (false);
	}
	if(!pattern12.test(elem12))
	{
   	alert("The telephone form is not correct!");
	order_form2.tel.focus();
	return (false);
    }
	 if(!pemail2.test(elem22))
	{
   	alert("The email form is not correct!");
	order_form2.email.focus();
	return (false);
    }

    if (order_form2.num.value == "")

	{
		alert("The Room_Number is not spatial!");
		order_form2.num.focus();
		return (false);
	}

 }

function validate_article(j_content)
{
	// document.write(j_content);return (false);
	// rivernote: js能否调用全局变量？
	// alert(article_form.catPath.value); return (false);
	if (article_form.catPath.value == "" || article_form.catPath.value == "0,1") {
		alert("文章分类不能为空!");
		article_form.catPath.focus();
		return (false);
	}else if (article_form.title.value == "") {
		alert("文章标题不能为空!");
		article_form.title.focus();
		return (false);
	}else if (article_form.title.value.length > 50) {
		alert("文章标题长度不能超过50!目前的长度："+article_form.title.value.length);
		article_form.title.focus();
		return (false);
	}else if (article_form.postTime.value == "") {
		alert("发布时间不能为空.");
		article_form.postTime.focus();
		return (false);
	}else if (article_form.summary.value.length > 200) {
		alert("文章摘要不能超过200个字符.");
		article_form.summary.focus();
		return (false);
	}else if (j_content == "") {
	//}else if (oFCKeditor.value == "") {
		alert("文章内容不能为空.");
		article_form.message.focus();
		return (false);
	}
	
	article_form.submit();
 }


function pop_show(roomId)
{
	if (roomId) document.getElementById(roomId).selected="selected"; 
	document.getElementById('no111').className='wzsb'; 
	document.getElementById('gdni').className='wzsbxx';
	document.getElementById('naqianlai').className='wzsbxx';
	// document.getElementById('woshiliumang').className='woshiliumang';
	
}

function pop_hide()
{
	// alert(document.getElementById('no111').form);
	document.getElementById('no111').className='wzsbxx'; 
	document.getElementById('gdni').className='flash';
	document.getElementById('naqianlai').className='booking';
	// document.getElementById('woshiliumang').className='qqqqqq';
	
}

