﻿    
    
    function AddToLstName()
    {
      var strText = "تكرار الحجز كل يوم ←" + document.getElementById("DdlWeeks").value + " لمدة " + document.getElementById("TxtWeeks").value + " اسبوع";
      var strId = "تكرار الحجز كل يوم ←" + document.getElementById("DdlWeeks").value;
      if(GetItemIndex(document.getElementById("LstRepeat"), strId) < 0)
        AddItem(document.getElementById("LstRepeat"), strText, strId);
    }
    
    
    
    function AddItem(objListBox, strText, strId)
    {
      var newOpt;
      newOpt = document.createElement("OPTION");
      newOpt = new Option(strText,strText);
      newOpt.id = strId;
      objListBox.add(newOpt);
    }
    
    function DoRemove(LstName)
    {
      RemoveItem(document.getElementById(LstName));
    }
        
    function RemoveItem(selectbox)
    {
      var i;
      for(i=selectbox.options.length-1;i>=0;i--)
        if(selectbox.options[i].selected)
           selectbox.remove(i);
    }

    function GetItemIndex(objListBox, strId)
    {
      for (var i = 0; i < objListBox.children.length; i++)
      {
        var strCurrentValueId = objListBox.children[i].id;
        if (strId == strCurrentValueId)
        {
          return i;
        }
      }
     return -1;
    }
    
    function SetHfieldRepeat()
    {
      FormReservations.HfieldRepeat.value = "";
      if(document.getElementById("ChkRepeatDays").checked)
        FormReservations.HfieldRepeat.value += "تكرار الحجز كل يوم لمدة " + document.getElementById("TxtDays").value + " أيام\n"; 
      if(document.getElementById("ChkRepeatWeeks").checked && document.getElementById("LstRepeat").children.length)
      {
        var objListBox = document.getElementById("LstRepeat");
        for (var i = 0; i < objListBox.children.length; i++)
          FormReservations.HfieldRepeat.value += objListBox.children[i].value + "\n";
      }
      
    }
    
    function ChkRepeatDaysChanged()
    {
       var TableRepeatDetails = document.getElementById("TableRepeatDetails");
       var ChkRepeatDays = document.getElementById("ChkRepeatDays").checked;
       TableRepeatDetails.rows[3].cells[1].disabled = !ChkRepeatDays;
       TableRepeatDetails.rows[3].cells[2].disabled = !ChkRepeatDays;
       TableRepeatDetails.rows[3].cells[3].disabled = !ChkRepeatDays;
       
    }
    
    function ChkRepeatWeeksChanged()
    {
        var TableRepeatDetails = document.getElementById("TableRepeatDetails");
        var ChkRepeatWeeks = document.getElementById("ChkRepeatWeeks").checked;
        TableRepeatDetails.rows[4].cells[1].disabled = !ChkRepeatWeeks;
        TableRepeatDetails.rows[4].cells[2].disabled = !ChkRepeatWeeks;
        TableRepeatDetails.rows[4].cells[3].disabled = !ChkRepeatWeeks;
        TableRepeatDetails.rows[5].disabled = !ChkRepeatWeeks;
    }
    
    function SetReservationDetails()
    {
    var Temp = "";
    var TbMain = document.getElementById("TableRooms");
    if (TbMain == null)
        {
            alert('عليك اختيار تاريخ');
            return false;
        }
    for (var x = 0; x < TbMain.rows.length; x++)
        for (var y = 0; y < TbMain.rows[x].cells.length; y++) {
            var table = document.getElementById("Table" + (x + 1).toString() + (y + 1).toString());
            for (var z = 1; z < table.rows.length; z++) {
                var IsSelected = table.rows[z].cells[0].firstChild.checked;
                if (IsSelected == true)
                Temp += table.rows[z].cells[0].firstChild.id + "\n";
            }
        }
        document.getElementById("HfResDetails").value = Temp;
        if (Temp == "")
        {
            alert('عليك اختيار اوقات');
            return false;
        }
        else
        return true;
    }
    
    function GetTimingDescription(TheTime)
    {
        var Time1;var Time2;
        var TimeFrom;var TimeTo;
        if(TheTime > 11) Time1 =  'مساءا'; else Time1 = 'صباحا ';
        if(parseInt(TheTime) + 1 > 11) Time2 = 'مساءا'; else Time2 = 'صباحا';
        if(parseInt(TheTime) > 12) TimeFrom = (parseInt(TheTime) - 12).toString(); else TimeFrom = TheTime;
        if(parseInt(TheTime) + 1 > 12) TimeTo = (parseInt(TheTime) - 11).toString();else TimeTo = parseInt(TheTime) + 1;
        return 'من ' + TimeFrom + ' ' + Time1 + ' الى ' + TimeTo + ' ' + Time2;
    }
    






/***********************************************
* Bottom slide tooltip- by Ron Grafe (mailto:grafer@REMOVETHIScolumbus.rr.com)
* Website URL: http://www.gdevresources.com
* Script modified by and available at Dynamic Drive: http://www.dynamicdrive.com/
***********************************************/

//SET TOOLTIP DESCRIPTIONS BELOW
//Extend or contract array as needed
var description=new Array()
description[0]='This is tool-tip description 1'
description[1]='<b>This is tool-tip descrition 2'
description[2]='<i>This is tool-tip description 3'

//Do not edit below here

iens6=document.all||document.getElementById
ns4=document.layers

var thename
var theobj
var thetext
var winHeight
var winPositionFromTop
var winWidth
var startH=2
var openTimer
<!--END GLOBAL VARIABLES-->

<!--GLOBAL FUNCTIONS-->

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function setObj(text,theswitch,inwidth,inheight) {
	thetext=text
	if(iens6){
		thename = "viewer"
		theobj=document.getElementById? document.getElementById(thename):document.all.thename
		winHeight=100
			if(iens6&&document.all) {
				winPositionFromTop=!window.opera? ietruebody().clientHeight : document.body.clientHeight
				winWidth=(ietruebody().clientWidth-ietruebody().leftMargin)
			}
			if(iens6&&!document.all) {
				winPositionFromTop=window.innerHeight
				winWidth=(window.innerWidth-(ietruebody().offsetLeft+30))
			}
			if(theswitch=="override") {
				winWidth=inwidth
				winHeight=inheight
			}
		theobj.style.width=winWidth+"px"
		theobj.style.height=startH+"px"
			if(iens6&&document.all) {
				theobj.style.top=ietruebody().scrollTop+winPositionFromTop+"px"
				//window.status=winPositionFromTop
				theobj.innerHTML = ""
				theobj.insertAdjacentHTML("BeforeEnd","<table cellspacing=0 width="+winWidth+" height="+winHeight+" border=1><tr><td width=100% valign=top><font type='times' size='2' style='color:black;font-weight:normal'>"+thetext+"</font></td></tr></table>")
			}
			if(iens6&&!document.all) {
				theobj.style.top=window.pageYOffset+winPositionFromTop+"px"
				theobj.innerHTML = ""
				theobj.innerHTML="<table cellspacing=0 width="+winWidth+" height="+winHeight+" border=1><tr><td width=100% valign=top><font type='times' size='2' style='color:black;font-weight:normal'>"+thetext+"</font></td></tr></table>"
			}
	}
	if(ns4){
		thename = "nsviewer"
		theobj = eval("document."+thename)
		winPositionFromTop=window.innerHeight
		winWidth=window.innerWidth
		winHeight=100
			if(theswitch=="override") {
				winWidth=inwidth
				winHeight=inheight
			}
		theobj.moveTo(0,eval(window.pageYOffset+winPositionFromTop))
		theobj.width=winWidth
		theobj.clip.width=winWidth
		theobj.document.write("<table cellspacing=0 width="+winWidth+" height="+winHeight+" border=1><tr><td width=100% valign=top><font type='times' size='2' style='color:black;font-weight:normal'>"+thetext+"</font></td></tr></table>")
		theobj.document.close()
	}
	viewIt()
}

function viewIt() {
	if(startH<=winHeight) {
		if(iens6) {
			theobj.style.visibility="visible"
				if(iens6&&document.all) {
					theobj.style.top=(ietruebody().scrollTop+winPositionFromTop)-startH+"px"
				}
				if(iens6&&!document.all) {
					theobj.style.top=(window.pageYOffset+winPositionFromTop)-startH+"px"
				}
			theobj.style.height=startH+"px"
			startH+=2
			openTimer=setTimeout("viewIt()",10)
		}
		if(ns4) {
			theobj.visibility = "visible"
			theobj.moveTo(0,(eval(window.pageYOffset+winPositionFromTop)-startH))
			theobj.height=startH
			theobj.clip.height=(startH)
			startH+=2
			openTimer=setTimeout("viewIt()",10)
		}
	}else{
		clearTimeout(openTimer)
	}
}

function stopIt() {
	if(iens6) {
		theobj.innerHTML = ""
		theobj.style.visibility="hidden"
		startH=2
	}
	if(ns4) {
		theobj.document.write("")
		theobj.document.close()
		theobj.visibility="hidden"
		theobj.width=0
		theobj.height=0
		theobj.clip.width=0
		theobj.clip.height=0
		startH=2
	}
}

