﻿// JScript File
var IE = document.all?true:false;
var FF = document.getElementById&&!document.all;

var _ScrollY = 0;
var _ScrollX = 0;

var _OffsetChildNode = IE ? 0 : 1;
var _SelectedItem = "";

/*
$(objId) - 
replacement for
document.getElementById
*/
function $(objId)
{
    return(document.getElementById(objId));
}


function DisplayModal(htmlContent, innerWidth, innerHeight, objToAlignTo)
{
    document.getElementById("Body").className = "Blurred";
    var modalBody = document.getElementById("ModalBody");
    modalBody.innerHTML = htmlContent;
    if (typeof(innerWidth) != 'undefined')
    {
        modalBody.style.width = innerWidth + "px";
    }
    if (typeof(innerHeight) != 'undefined')
    {
        modalBody.style.height = innerHeight + "px";
    }
    var divModal = document.getElementById("Modal");
    ShowElement(divModal.id);
    if (typeof(objToAlignTo) != 'undefined')
    {
        SetObjectPosition(divModal, FindPosX(objToAlignTo), FindPosY(objToAlignTo), 0, 10)
    }
    else
    {
        _ScrollY = FindScrollY();
        _ScrollX = FindScrollX();
        SetObjectPosition(divModal, _ScrollX, 15 + _ScrollY, 0, 0);
    }
}
function DisplayPopUp(htmlContent, innerWidth, innerHeight, objToAlignTo)
{
    var modalBody = document.getElementById("ModalBody");
    modalBody.innerHTML = htmlContent;
    if (typeof(innerWidth) != 'undefined')
    {
        modalBody.style.width = innerWidth + "px";
    }
    if (typeof(innerHeight) != 'undefined')
    {
        modalBody.style.height = innerHeight + "px";
    }
    var divModal = document.getElementById("Modal");
    ShowElement(divModal.id);
    _ScrollY = FindScrollY();
    _ScrollX = FindScrollX();
    if (typeof(objToAlignTo) != 'undefined')
    {
        SetObjectPosition(divModal, FindPosX(objToAlignTo), FindPosY(objToAlignTo), 0, 20)
    }
    else
    {
        SetObjectPosition(divModal, _ScrollX, 120 + _ScrollY, 0, 0);
    }
}
function CloseModal()
{
    HideElement("Modal");
    document.getElementById("Body").className = "centerDesign";
    window.scrollTo(_ScrollX,_ScrollY);
}
function FindScrollX()
{
    var scrOfX = 0;
    if( typeof( window.pageYOffset ) == 'number' ) 
    {
        //Netscape compliant
        scrOfX = window.pageXOffset;
    } 
    else if( document.body && ( document.body.scrollLeft ) ) {
        //DOM compliant
        scrOfX = document.body.scrollLeft;
    } 
    else if( document.documentElement && ( document.documentElement.scrollLeft ) ) 
    {
        //IE6 standards compliant mode
        scrOfX = document.documentElement.scrollLeft;
    }
    return scrOfX;
}

function FindScrollY() 
{
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) 
  {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } 
  else if( document.body && ( document.body.scrollTop ) ) 
  {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } 
  else if( document.documentElement && ( document.documentElement.scrollTop ) ) 
  {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}

// Set object position
function SetObjectPosition(obj, x, y, offsetX, offsetY)
{
    try
    {
        if (typeof(offsetX) == 'undefined')
        {
            offsetX = 0;
        }
        if (typeof(offsetY) == 'undefined')
        {
            offsetY = 0;
        }
        obj.x = x;
        obj.y = y;
        obj.style.left = x + offsetX + "px";
        obj.style.top = y + offsetY + "px";
        obj.style.display = "block";
    }
    catch(e)
    {
        alert(e);
    }
}
function SetObjectRelativePosition(objId, objToAlignTo, offsetX, offsetY)
{
    try
    {
        if (typeof(offsetX) == 'undefined')
        {
            offsetX = 0;
        }
        if (typeof(offsetY) == 'undefined')
        {
            offsetY = 0;
        }
        var obj = document.getElementById(objId);
        var x = FindPosX(objToAlignTo);// + FindScrollX();
        var y = FindPosY(objToAlignTo);// + FindScrollY();
        SetObjectPosition(obj, x, y, offsetX, offsetY);
        //alert("x=" + x + " y=" + y)
    }
    catch(e)
    {
        //alert(e);
    }
}

function HideElement(elementId)
{
    var element = document.getElementById(elementId);
    if (element)
    {
        element.style.display = "none";
    }
    if (elementId == 'contactTop')
        document.getElementById('divSponsorshipBox').style.height= '112px';
}
function ShowElement(elementId)
{
    var element = document.getElementById(elementId);
    if (element)
    {
        element.style.display = "block";
    }
}
function ShowHideElement(elementId)
{
    var element = document.getElementById(elementId);
    if (element.style.display == "none") 
    {
        element.style.display = "";
    }
    else 
    {
        element.style.display = "none";
    }
}

function FindPosX(obj) 
{
    var curleft = 0;

    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else
    {
        if (obj.offsetLeft) { curleft += obj.offsetLeft; }
        alert(obj.offsetLeft)
    }
    return curleft;
}

function FindPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else
    {
        if (obj.offsetTop) { curtop += obj.offsetTop; }
    }
    return curtop;
}
// Scroll to the element's position
function ScrollToElement(objId)
{
    var obj = document.getElementById(objId);
    var posY = FindPosY(obj);
    window.scrollTo(0, posY);
}
// Set the object dimensions
function SetObjDimensions(objToResize, objToMeasure)
{
    if (!window.opera && !document.mimeType && document.all && document.getElementById)
    {
        objToResize.style.height = objToMeasure.offsetHeight+"px";
    }
    else if(document.getElementById) 
    {
        objToResize.style.height = objToMeasure.scrollHeight+"px"
    }
}

// Clear text box on click
var _FirstClick = true;
function SearchTextClick(txtID)
{
    if (_FirstClick)
    {
        _FirstClick = false;
        
        var txtObj = document.getElementById(txtID);
        txtObj.value = "";
        txtObj.className = "on";
    }
}
// Get email address
function GetEmail(part1,part2,part3)
{
    var email = part2 + "@" + part1 + "." + part3;
    return email;
}
function ContactByMail(part1, part2, part3, linkId, sSubject, sBody, sMailtoText, sTitle, width)
{
    var email = GetEmail(part1, part2, part3);
    var mailTo = email;
    if (sSubject != "")
    {
        mailTo += "?subject=" + sSubject
    }
    if (sBody != "")
    {
        mailTo += "&body=" + sBody
    }
    if (sMailtoText == "")
    {
        sMailtoText = email;
    }
    var popUpContent = "<h1>" + sTitle + "</h1>"
        + "<br/><a href=\"mailto:" + mailTo + "\" onclick=\"top.CloseModal();\">" + sMailtoText + "</a>";
    var html = CreatePopUpHtml(popUpContent);
    DisplayPopUp(html, width, 70, document.getElementById(linkId));
}
// pop up HTML
function CreatePopUpHtml(innerContent)
{
    var html = "<div id=\"popup\">"
        + "<div class=\"popupLogo\">"
        + "<div class=\"closeLink\"><a href=\"javascript:top.CloseModal();\">close</a></div>"
        + "</div>"
        + "<div class=\"popupContent\">" + innerContent + "</div"
        + "</div";
    return html;
}
// Change pictures
var _PicIndex = 0;
var _ArrImagePaths = new Array();
var _MainPicID = "";
function ChangePic(value)
{
    var mainPic = document.getElementById(_MainPicID);
    _PicIndex += value;
    if (_PicIndex < 0)
    {
        _PicIndex = _ArrImagePaths.length-1;
    }
    else if (_PicIndex == _ArrImagePaths.length)
    {
        _PicIndex = 0;
    }
    mainPic.src = _ArrImagePaths[_PicIndex];
}

function GetCities()
{
    var pnlStates = document.getElementById(BV_PnlStatesID);
    var selectedCountry = document.getElementById(BV_SelCountriesID).value;
    if (selectedCountry != "")
    {
        var selectedState = "";
        
        if (selectedCountry.toLowerCase() == "usa")
        {
            pnlStates.style.display = "block";
            var searchEvents = document.getElementById(BV_RadioSearchEventsID).checked;
            if (searchEvents)
            {
                pnlStates.className = "statesevents";
            }
            else
            {
                pnlStates.className = "statesvenues";
            }
            selectedState = document.getElementById(BV_SelStatesID).value;
        }
        else
        {
            document.getElementById(BV_SelStatesID).value = "";
            pnlStates.style.display = "none";
        }
        
        // Get the cities
        CallService("CitiesService.aspx", "country=" + selectedCountry + "&state=" + selectedState, "SetCities(xhr.responseText)");  
    }
    else
    {
        document.getElementById(BV_SelStatesID).selectedIndex = 0;
        document.getElementById(BV_SelCitiesID).selectedIndex = 0;
    }
}
function SetCities(listCities)
{
    var selCities = document.getElementById(BV_SelCitiesID);
    var arrCities = listCities.split(",");
    selCities.length = arrCities.length+1;
    for (var i = 0 ; i < arrCities.length ; i++)
    {
        if (arrCities[i] != "")
        {
            selCities.options[i+1].text = arrCities[i];
            selCities.options[i+1].value = arrCities[i].toLowerCase().replace(/ /g, "-");
        }
    }
    selCities.selectedIndex = 0;
}
function CallService(serviceName, postData, responseFunction)
{ 
    var xhr; 
    try {xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {xhr = new ActiveXObject('Microsoft.XMLHTTP');}
        catch (e2) 
        {
          try { xhr = new XMLHttpRequest(); }
          catch (e3) { xhr = false; }
        }
    }
    xhr.onreadystatechange = function()
    { 
         if(xhr.readyState == 4)
         {
              if(xhr.status == 200)               
                  eval(responseFunction); 
         }
    }; 
    
    xhr.open("POST", "/WebServices/" + serviceName, true); 
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
    xhr.send(postData); 
} 

// Doctors search box
//var _SelSpecialty = "ddlSpeciality";
//var _SelSubSpecialty = "ddlSubSpeciality";
var _SelSpecialty = "ddlDoctorSpecialty";
var _SelSubSpecialty = "ddlDoctorSubSpecialty";

function SetSpecialties()
{
    var specialtySel = document.getElementById(_SelSpecialty);
    specialtySel.length = _ArrSpecialty.length+1;
    specialtySel.options[0].text = "-- בחר התמחות --";
    specialtySel.options[0].value = "";
    for (var i = 0 ; i < _ArrSpecialty.length ; i++)
    {
        if (_ArrSpecialty[i] != "")
        {
            var specialtyValues = _ArrSpecialty[i].split("|");
            specialtySel.options[i+1].text = specialtyValues[0];
            specialtySel.options[i+1].value = specialtyValues[1];
        }
    }
    specialtySel.selectedIndex = 0;
}
function GetSubSpecialties()
{
    var selectedSpecialty = document.getElementById(_SelSpecialty).value;
    if (selectedSpecialty != "")
    {
        // Get the sub-specialties
        CallService("SpecialtiesService.aspx", "parent=" + selectedSpecialty, "SetSubSpecialities(xhr.responseText)");  
    }
    else
    {
        document.getElementById(_SelSubSpecialty).selectedIndex = 0;
    }
}
function SetSubSpecialities(listSubSpecialities)
{
    var selSubCat = document.getElementById(_SelSubSpecialty);
    var arrSubSpec = listSubSpecialities.split("~");
    selSubCat.length = arrSubSpec.length+1;
    for (var i = 0 ; i < arrSubSpec.length ; i++)
    {
        if (arrSubSpec[i] != "")
        {
            var subSpecValues = arrSubSpec[i].split("|");
            selSubCat.options[i+1].text = subSpecValues[0];
            selSubCat.options[i+1].value = subSpecValues[1];
        }
    }
    selSubCat.selectedIndex = 0;
}

function SearchDoctors()
{
    var searchFilter = "";
    var searchType = "";

    var specialtySel = document.getElementById(_SelSpecialty);
    var subSpecSelect = document.getElementById(_SelSubSpecialty);

    if (specialtySel.value != "") 
    { 
        searchFilter += specialtySel.value; 
    }
    if (subSpecSelect.value != "-1") 
    { 
       searchFilter += "%3b" + subSpecSelect.value; 
    }

    if (searchFilter == "") { alert("אנא בחרו התמחות"); return;}

    if (subSpecSelect.value != "-1") 
    { 
        searchType = "3";
    }
    else if (specialtySel.value != "") 
    { 
        searchType = "2";
    }
    location.href = "/resultsexperts.aspx?o=1&t=" + searchType + "&k=" + searchFilter;
}

function invokeDoctorSearch(doctorSpecialty,doctorSubSpeciality,doctorArea,doctorName)
{
    var searchFilter = "";
    var searchType = "";

    
    //search by name 
    if ($(doctorName).value != "") 
    { 
        //searchFilter += $(doctorName).value; 
        searchFilter += $(doctorName).value; 
        searchType = 1;
        location.href = "/resultsexperts.aspx?o=1&a=" + $(doctorArea).value + "t=" + searchType + "&k=" + searchFilter;
        return;
    }

    //if this is not a name searh, search by specialty and sub specialty
    if ($(doctorSpecialty).value != "") 
    { 
        searchFilter += $(doctorSpecialty).value; 
    }
    if ($(doctorSubSpeciality).value != "-1") 
    { 
       searchFilter += "%3b" + $(doctorSubSpeciality).value; 
    }

    if (searchFilter == "") { alert(" אנא בחרו התמחות ותת התמחות, אזור או שם"); return;}

    if ($(doctorSubSpeciality).value != "-1") 
    { 
        searchType = "3";
    }
    else if ($(doctorSpecialty).value != "") 
    { 
        searchType = "2";
    }
    location.href = "/resultsexperts.aspx?o=1&a=" + $(doctorArea).value + "&t=" + searchType + "&k=" + searchFilter;
}


function SetSelectedSubSpecialty(specialty)
{
    var subSpecSelect = document.getElementById(_SelSubSpecialty);
    subSpecSelect.value = specialty;
}

function SetSelectedSpecialty(specialty)
{
    var specialtySel = document.getElementById(_SelSpecialty);
    specialtySel.value = ddlCat;
    
    if (specialty != "") { GetSubSpecialties(); }
}
var _TimeOutHideCategories = "";
var _TimeOutExaminations = "";
var _OffsetYForMenu = IE ? 27 : 26;
function DisplayCategories()
{
    clearTimeout(_TimeOutHideCategories);
    window.setTimeout('SetObjectRelativePosition("menuCategories", document.getElementById("btnCategories"), 0, _OffsetYForMenu); ShowElement("menuCategories");', 0);
}
function HideCategories()
{
     _TimeOutHideCategories = window.setTimeout('HideElement("menuCategories")', 500);
}
function DisplayExaminations()
{
    clearTimeout(_TimeOutExaminations);
    window.setTimeout('SetObjectRelativePosition("menuExaminations", document.getElementById("btnExaminations"), 0, _OffsetYForMenu); ShowElement("menuExaminations");', 0);
}
function HideExaminations()
{
    _TimeOutExaminations = window.setTimeout('HideElement("menuExaminations")', 500);
}

//*----- Calendar -----*//
function positionInfo(object) {

    var p_elm = object;

    this.getElementLeft = getElementLeft;
    function getElementLeft() {
    var x = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      x+= elm.offsetLeft;
      elm = elm.offsetParent;
    }
    return parseInt(x);
}

this.getElementWidth = getElementWidth;
function getElementWidth(){
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetWidth);
}

this.getElementRight = getElementRight;
function getElementRight(){
    return getElementLeft(p_elm) + getElementWidth(p_elm);
}

this.getElementTop = getElementTop;
function getElementTop() {
    var y = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      y+= elm.offsetTop;
      elm = elm.offsetParent;
    }
    return parseInt(y);
}

this.getElementHeight = getElementHeight;
function getElementHeight(){
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetHeight);
    }

    this.getElementBottom = getElementBottom;
    function getElementBottom(){
    return getElementTop(p_elm) + getElementHeight(p_elm);
    }
}

function CalendarControl() {

    var calendarId = 'CalendarControl';
    var currentYear = 0;
    var currentMonth = 0;
    var currentDay = 0;

    var selectedYear = 0;
    var selectedMonth = 0;
    var selectedDay = 0;

    var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
    var dateField = null;

    function getProperty(p_property){
    var p_elm = calendarId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if (elm != null){
      if(elm.style){
        elm = elm.style;
        if(elm[p_property]){
          return elm[p_property];
        } else {
          return null;
        }
      } else {
        return null;
      }
    }
    }

    function setElementProperty(p_property, p_value, p_elmId){
    var p_elm = p_elmId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if((elm != null) && (elm.style != null)){
      elm = elm.style;
      elm[ p_property ] = p_value;
    }
    }

    function setProperty(p_property, p_value) {
    setElementProperty(p_property, p_value, calendarId);
    }

    function getDaysInMonth(year, month) {
    return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
    }

    function getDayOfWeek(year, month, day) {
    var date = new Date(year,month-1,day)
    return date.getDay();
    }

    this.clearDate = clearDate;
    function clearDate() {
    dateField.value = '';
    hide();
    }

    this.setDate = setDate;
    function setDate(year, month, day) {
    if (dateField) {
      if (month < 10) {month = "0" + month;}
      if (day < 10) {day = "0" + day;}

      var dateString = day+"/"+month+"/"+year;
      dateField.value = dateString;
      hide();
    }
    return;
    }

    this.changeMonth = changeMonth;
    function changeMonth(change) {
    currentMonth += change;
    currentDay = 0;
    if(currentMonth > 12) {
      currentMonth = 1;
      currentYear++;
    } else if(currentMonth < 1) {
      currentMonth = 12;
      currentYear--;
    }

    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
    }

    this.changeYear = changeYear;
    function changeYear(change) {
    currentYear += change;
    currentDay = 0;
    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
    }

    function getCurrentYear() {
    var year = new Date().getYear();
    if(year < 1900) year += 1900;
    return year;
    }

    function getCurrentMonth() {
    return new Date().getMonth() + 1;
    } 

    function getCurrentDay() {
    return new Date().getDate();
    }

    function calendarDrawTable() {

    var dayOfMonth = 1;
    var validDay = 0;
    var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
    var daysInMonth = getDaysInMonth(currentYear, currentMonth);
    var css_class = null; //CSS class for each day

    var table = "<table cellspacing='0' cellpadding='0' border='0'>";
    table = table + "<tr class='header'>";
    table = table + "  <td colspan='2' class='previous'><a href='javascript:changeCalendarControlMonth(-1);'>&lt;</a> <a href='javascript:changeCalendarControlYear(-1);'>&laquo;</a></td>";
    table = table + "  <td colspan='3' class='title'>" + months[currentMonth-1] + "<br>" + currentYear + "</td>";
    table = table + "  <td colspan='2' class='next'><a href='javascript:changeCalendarControlYear(1);'>&raquo;</a> <a href='javascript:changeCalendarControlMonth(1);'>&gt;</a></td>";
    table = table + "</tr>";
    table = table + "<tr><th align='center'>Sun</th><th align='center'>Mon</th><th align='center'>Tue</th><th align='center'>Wed</th><th align='center'>Thu</th><th align='center'>Fri</th><th align='center'>Sat</th></tr>";

    for(var week=0; week < 6; week++) {
      table = table + "<tr>";
      for(var dayOfWeek=0; dayOfWeek < 7; dayOfWeek++) {
        if(week == 0 && startDayOfWeek == dayOfWeek) {
          validDay = 1;
        } else if (validDay == 1 && dayOfMonth > daysInMonth) {
          validDay = 0;
        }

        if(validDay) {
          if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
            css_class = 'current';
          } else if (dayOfWeek == 6) {
            css_class = 'weekend';
          } else {
            css_class = 'weekday';
          }

          table = table + "<td><a class='"+css_class+"' href=\"javascript:setCalendarControlDate("+currentYear+","+currentMonth+","+dayOfMonth+")\">"+dayOfMonth+"</a></td>";
          dayOfMonth++;
        } else {
          table = table + "<td class='empty'>&nbsp;</td>";
        }
      }
      table = table + "</tr>";
    }

    table = table + "<tr class='header'><th colspan='7' style='padding: 3px;' align='center'><a href='javascript:hideCalendarControl();'>Close</a></td></tr>";
    table = table + "</table>";

    return table;
    }

    this.show = show;
    function show(field) {
    can_hide = 0;

    // If the calendar is visible and associated with
    // this field do not do anything.
    if (dateField == field) {
      return;
    } else {
      dateField = field;
    }

    if(dateField) {
      try {
        var dateString = new String(dateField.value);
        var dateParts = dateString.split("/");
        
        selectedDay = parseInt(dateParts[0],10);
        selectedMonth = parseInt(dateParts[1],10);
        selectedYear = parseInt(dateParts[2],10);
      } catch(e) {}
    }

    if (!(selectedYear && selectedMonth && selectedDay)) {
      selectedMonth = getCurrentMonth();
      selectedDay = getCurrentDay();
      selectedYear = getCurrentYear();
    }

    currentMonth = selectedMonth;
    currentDay = selectedDay;
    currentYear = selectedYear;

    if(document.getElementById){

      calendar = document.getElementById(calendarId);
      calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);

      setProperty('display', 'block');

      var fieldPos = new positionInfo(dateField);
      var calendarPos = new positionInfo(calendarId);

      var x = fieldPos.getElementLeft();
      var y = fieldPos.getElementBottom();

      setProperty('left', x + "px");
      setProperty('top', y + "px");

      if (document.all) {
        setElementProperty('display', 'block', 'CalendarControlIFrame');
        setElementProperty('left', x + "px", 'CalendarControlIFrame');
        setElementProperty('top', y + "px", 'CalendarControlIFrame');
        setElementProperty('width', calendarPos.getElementWidth() + "px", 'CalendarControlIFrame');
        setElementProperty('height', calendarPos.getElementHeight() + "px", 'CalendarControlIFrame');
      }
    }
    }

    this.hide = hide;
    function hide() {
    if(dateField) {
      setProperty('display', 'none');
      setElementProperty('display', 'none', 'CalendarControlIFrame');
      dateField = null;
    }
    }

    this.visible = visible;
    function visible() {
    return dateField
    }

    this.can_hide = can_hide;
    var can_hide = 0;
}

var calendarControl = new CalendarControl();

function showCalendarControl(textField) {
    // textField.onblur = hideCalendarControl;
    calendarControl.show(textField);
}

function clearCalendarControl() {
    calendarControl.clearDate();
}

function hideCalendarControl() {
    if (calendarControl.visible()) {
    calendarControl.hide();
    }
}

function setCalendarControlDate(year, month, day) {
    calendarControl.setDate(year, month, day);
}

function changeCalendarControlYear(change) {
    calendarControl.changeYear(change);
}

function changeCalendarControlMonth(change) {
    calendarControl.changeMonth(change);
}

document.write("<iframe id='CalendarControlIFrame' src='javascript:false;' frameBorder='0' scrolling='no' style=display:none;'></iframe>");
document.write("<div id='CalendarControl'></div>");
//*----- End Calendar -----*//

/*----- Stats -----*/
function StatsEvent(sFor, sType, sId)
{
    CallService("StatsService.aspx", "for=" + sFor + "&type=" + sType + "&id=" + sId, "");  
}

var google_adnum = 0;
google_ad_channel = "4789422729";
google_ad_client = "pub-9661251648440059"; // substitute your client_id (pub-#)

/*----- AJAX -----*/

function getHttpRequestObj() 
{
	var xmlhttp;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}


function loadCities(citySelectObj, areaId, selectedCityName)
{
    if (citySelectObj == null || typeof(citySelectObj) == 'undefined')
    {
        return;
    }
    
    areaId = escape(areaId);
    var pageURL = "/WebServices/getCitiesByArea.aspx?areaId=" + areaId;
    
    //location.href=pageURL;
    var xObj = getHttpRequestObj();
    xObj.onreadystatechange =  function () 
	        {
			    if(xObj.readyState==4)
			    {

			      var valsArr = xObj.responseText.split('|');
			      var i = 0;
			      
                  citySelectObj.options.length = 0
                  var isSelected = false;
                  citySelectObj.options[0] = new Option("- חיפוש לפי ישוב -", "", false, false);
			      for(i = 0 ; i < valsArr.length; i++)
			      {

                    if(valsArr[i] != "")
                    {
                        var tmpStr = valsArr[i];
                        var cityName = tmpStr.split('~')[1];
                        cityName = cityName.replace(/&quot;/, "\"");
                        var cityId = tmpStr.split('~')[0];  
                        isSelected = false; 
                        if(selectedCityName)
                        {
                            if(selectedCityName == cityName)
                            {
                                isSelected = true;
                            }
                        }
			            citySelectObj.options[i + 1] = new Option(cityName, cityId, false, isSelected)
			            if (cityName.indexOf("--") == 0)
			            {
			                citySelectObj.options[i + 1].style.fontWeight = "bold";
			            }
			        }

			      }
                }
		    };

	    xObj.open ("get", pageURL ,true);
	    xObj.send(null);
}
/*----- End AJAX -----*/
function ContactExpert(expertID)
{
    ShowElement("frameContactContainer");
    document.getElementById("frameContact").src = "/ContactExpertMini.aspx?exp=" + expertID;
}
function ContactInstitute(instituteID)
{
    ShowElement("frameContactContainer");
    document.getElementById("frameContact").src = "/ContactInstituteMini.aspx?ins=" + instituteID;
}
// Clear phone box on click
var _FirstClickPhone = true;
function ClearPhoneOnClick(txtObj)
{
    if (_FirstClickPhone)
    {
        _FirstClickPhone = false;
        
        txtObj.value = "";
        //txtObj.className = "on";
    }
}
// Clear email box on click
var _FirstClickEmail = true;
function ClearEmailOnClick(txtObj)
{
    if (_FirstClickEmail)
    {
        _FirstClickEmail = false;
        
        txtObj.value = "";
        //txtObj.className = "on";
    }
}
// Clear name box on click
var _FirstClickName = true;
function ClearNameOnClick(txtObj)
{
    if (_FirstClickName)
    {
        _FirstClickName = false;
        
        txtObj.value = "";
        //txtObj.className = "on";
    }
}



function showSubMenu(mIndex)
{
    document.getElementById("s" + mIndex).className = "topMenuOn";
    document.getElementById("f" + mIndex).className = "on";
    
    document.getElementById("f" + mIndex).style.height = "280px";
    
    if(mIndex == 3)
    {
        document.getElementById("f" + mIndex).style.width = "420px";
    }
    else
    {
        document.getElementById("f" + mIndex).style.width = "320px";
    }
    
}

function hideSubMenu(mIndex)
{
    document.getElementById("s" + mIndex).className = "topMenuOff";
    document.getElementById("f" + mIndex).className = "off";
    document.getElementById("f" + mIndex).style.height = "0";
    document.getElementById("f" + mIndex).style.width = "0";
}




/////////////////////////////////////////////////////
// Stats Functions by Uri Sittan 20/01/2010
function SaveStat(StatEntityId, StatEntityType, StatType)
{
    CallService("saveStat.aspx", "StatEntityId=" + StatEntityId + "&StatEntityType=" + StatEntityType + "&StatType=" + StatType , "");  
   
}

