﻿// JScript File
/* EF Object */
var EF = {
  /* Short hand to return object in global */
  $_script: function() {
    return this.Global.ScriptHandler
  },
  $_util: function() {
    return this.Global.Utilities
  },

  /* -- Global */
  Global: {
    _jqueryRequired : true,
    ScriptHandler: {
      Load: function(scriptObj) {
        var s = scriptObj.length;
        for (var i = 0, s = scriptObj.length; i < s; i++) {
          if (typeof scriptObj[i] == "string") {
            this[scriptObj[i]].Load()
          } else {
            this[scriptObj[i][0]].Load(scriptObj[i][1])
          }
        }
      },
      Coremetrics: {
        Load: function(obj) {
          if (obj['cmdata'] && obj['cmdata'] == true) EF.Global.Utilities.Write("js", "/includes/scripts/Coremetrics/cmdatatagutils.js");
          if (obj['eluminate'] && obj['eluminate'] == true) EF.Global.Utilities.Write("js", "/includes/scripts/Coremetrics/V40/eluminate.js");
          if (obj['techprops'] && obj['techprops'] == true) EF.Global.Utilities.Write("js", "/includes/scripts/Coremetrics/V40/techprops.js");
        }
      },
      jQueryCycle: {
        Load: function() {
          EF.Global.Utilities.Write("js", "/includes/scripts/jquery.cycle.all.min.js");
        }
      },
      nyroModal: {
        Load: function() {
          /* nyroModal loaded */
          EF.Global.Utilities.Write("js", "/includes/scripts/jquery.nyroModal-1.2.8.min.js");
        }
      },
      ThickBox: {
        Load: function() {
          EF.Global.Utilities.Write("css", "/includes/css/thickbox.css");
          EF.Global.Utilities.Write("js", "/includes/scripts/thickbox.js");
          EF.Global.Utilities.Write("js", "/includes/scripts/Glossary.js");
        }
      },
      sIFR: {
        Load: function() {
          EF.Global.Utilities.Write("js", "/includes/scripts/sifr.js");
        }
      }
    },
    Utilities: {
      EqualHeights: function(el1, el2) {
        if ($(el1).outerHeight() > $(el2).outerHeight()) {
          $(el2).height(($(el1).outerHeight() - $(el2).outerHeight()) + $(el2).height());
        } else {
          $(el1).height(($(el2).outerHeight() - $(el1).outerHeight()) + $(el1).height());
        }
      },
      Glossary: {
        Tooltip: function(divID, spanID, vis, shortDesc) {
          var docElement = document.getElementById(divID);
          if (docElement) {
            docElement.style.display = vis ? "inline" : "none";
            docElement.style.visibility = vis ? "visible" : "hidden";
          }
          if (shortDesc != 'Nothing') {
            document.getElementById(spanID).innerHTML = shortDesc;
          }
          return false;
        },
        showDefn: function(spanID, defnTxt) {
          var glossaryDesc;
          var temp = new Array();

          temp = defnTxt.split('%20');
          temp = temp.join(' ');
          defnTxt = temp;
          temp = defnTxt.split('%#');
          temp = temp.join('\'');
          defnTxt = temp;
          temp = defnTxt.split('%^');
          temp = temp.join('"');
          defnTxt = temp;
          temp = defnTxt.split('%(');
          temp = temp.join('<');
          defnTxt = temp;
          temp = defnTxt.split('%)');
          glossaryDesc = temp.join('>');
          document.getElementById(spanID).innerHTML = glossaryDesc;
        }
      },
      PrintPage: function(ctl) {
        $("#" + ctl).bind("click", function(e) {
          var address = location.protocol + "//" + location.hostname + $(this).attr('href');
          EF.$_util().OpenWindow({
            url: address,
            name: "PrinterFriendly",
            toolbar: "no",
            location: "no",
            height: "600",
            width: "650"
          })
          return false;
        })
      },
      OpenWindow: function(param) {
        var url = param.url
        var name = param.name || "newWindow";
        var status = param.status || 'yes';
        var toolbar = param.toolbar || 'yes';
        var location = param.location || 'yes';
        var menubar = param.menubar || 'yes';
        var resizable = param.resizable || 'yes';
        var scrollbars = param.scrollbars || 'yes';
        var height = param.height || 500;
        var width = param.width || 700;
        var features = 'status=' + status + ',toolbar=' + toolbar + ',location=' + location + ',menubar=' + menubar + ',resizable=' + resizable + ',scrollbars=' + scrollbars + ',width=' + width + ',height=' + height;
        eval("window.open('" + url + "','" + name + "','" + features + "')")
      },
      PrintWindow: function() {
        window.print()
      },
      sIFR: {
        Settings: {
          Variables: {
            Helvetica: {
              src: "/includes/flash/HelveticaNeueH2Std.swf"
            },
            ToReplace: {
              // Replaces h2 with class of tagline
              Tagline: {
                selector: "h1.tagline",
                Css: "padding:0px; margin:0px; font-size:22px; color:#FFAE00;"
              },
              // Replaces Side nav bar header
              SideNavHeader: {
                selector: ".sideNavHeader",
                Css: "color:#FFFFFF; font-size:11px; text-transform:uppercase; margin-bottom: 3px;"
              }
            }
          },
          StyleCheck: true
        },
        Activate: function(obj, swf) {
          sIFR.useStyleCheck = this.Settings.StyleCheck;
          sIFR.activate({ src: this.Settings.Variables[swf].src });
          this.sIFRize(obj, swf);
        },
        sIFRize: function(obj, swf) {
          sIFR.replace({ src: this.Settings.Variables[swf].src }, {
            selector: this.Settings.Variables.ToReplace[obj].selector,
            css: ['.sIFR-root {' + this.Settings.Variables.ToReplace[obj].Css + '}'],
            wmode: 'transparent',
            forceSingleLine: 'true',
            fixFocus: 'true'
          })
        }
      },
      SwapImage: function(ctl, url) {
        $("#" + ctl).attr('src', url);
      },
      Write: function(type, src) {
        switch (type) {
          case "js":
            var script = document.createElement("script");
            script.setAttribute("type", "text/javascript");
            script.setAttribute("src", src);
            document.getElementsByTagName("head")[0].appendChild(script);
            break;
          case "css":
            var link = document.createElement("link");
            link.setAttribute("rel", "stylesheet");
            link.setAttribute("type", "text/css");
            link.setAttribute("href", src);
            link.setAttribute("media", "screen");
            document.getElementsByTagName("head")[0].appendChild(link);
          default:
            /* did you pass in the proper type? */
            break;
        }
      }
    }
  },

  /* -- Teachers */
  Teachers: {
    /* -- Browse our tours for Non-Flash users */
    BrowseOurTours: {
      BindFlash: function() {
        $("#BrowseOurToursMap").css({ "display": "none", "visibility": "hidden" });
        swfobject.embedSWF('/includes/flash/worldMap.swf', 'flash-map', '566', '283', '9.0.0', '', flashvars, params)
      },
      Settings: {
        Variables: {
          //Hover image variables
          BrowseMapOrig: new String(),
          BrowseMapImage: new Array(),
          CurrentRegion: new String()
        },
        Link: $("#CountryList").find('a'),
        RegionCode: {
          G1: ["EuropeAfricaImg", "map_uk.gif"],
          G2: ["EuropeAfricaImg", "map_france.gif"],
          G3: ["EuropeAfricaImg", "map_italy.gif"],
          G4: ["EuropeAfricaImg", "map_spain.gif"],
          G5: ["EuropeAfricaImg", "map_greece.gif"],
          G6: ["EuropeAfricaImg", "map_germany.gif"],
          G7: ["EuropeAfricaImg", "map_scandinavia.gif"],
          G8: ["EuropeAfricaImg", "map_eastern_europe.gif"],
          C3: ["AmericasImg", "map_americas.gif"],
          C5: ["EuropeAfricaImg", "map_africa.gif"],
          C4: ["AsiaPacImg", "map_asia.gif"]
        },
        Bindings: {
          mouseOver: function() {
            $("a").mouseenter(function(e) {
              var $_var = EF.Teachers.BrowseOurTours.Settings.Variables;
              var url = $(this).attr('href');
              var regionregex = /[GC]\d/;
              $_var.CurrentRegion = regionregex.exec(url);
              try {
                var ImageSrc = $('img[id$=' + EF['Teachers']['BrowseOurTours']['Settings']['RegionCode'][$_var.CurrentRegion][0] + ']').attr('src')
                $_var.BrowseMapOrig = ImageSrc;
                $_var.BrowseMapImage[0] = ImageSrc.substring(0, ImageSrc.lastIndexOf("/") + 1);
                $_var.BrowseMapImage[1] = ImageSrc.substring(ImageSrc.lastIndexOf("/") + 1);
                $('img[id$=' + EF['Teachers']['BrowseOurTours']['Settings']['RegionCode'][$_var.CurrentRegion][0] + ']').attr('src', $_var.BrowseMapImage[0] + EF['Teachers']['BrowseOurTours']['Settings']['RegionCode'][$_var.CurrentRegion][1])
              } catch (err) { }
            })
          },
          mouseOut: function() {
            $("#CountryList").find("a").mouseleave(function() {
              var $_var = EF.Teachers.BrowseOurTours.Settings.Variables;
              try {
                $('img[id$=' + EF['Teachers']['BrowseOurTours']['Settings']['RegionCode'][$_var.CurrentRegion][0] + ']').attr('src', $_var.BrowseMapOrig)
              } catch (err) { }
            })
          }
        }
      }, /* End Settings */
      Init: function() {
        this.BindFlash();
        this.Settings.Bindings.mouseOver();
        this.Settings.Bindings.mouseOut();
      }
    }
  },

  /* -- Students */
  Students: {
    TeachersTour: {
      SetLeftPhotoLinks: function() {
        var country = document.getElementById("ctl00_body_CountryNamePhoto").value;
        var photo = document.getElementById("ctl00_body_ctl01_rptSideNav_ctl03_hlSideNavItem");

        photo.href = photo.href.substring(0, photo.href.lastIndexOf("/") + 1);
        photo.href = photo.href + country + ".aspx";
        return;
      },
      SetLeftVideoLinks: function() {
        var country = document.getElementById("ctl00_body_CountryNameVideo").value;
        var video = document.getElementById("ctl00_body_ctl01_rptSideNav_ctl02_hlSideNavItem");

        video.href = video.href.substring(0, video.href.lastIndexOf("/") + 1);
        video.href = video.href + country + ".aspx";
        return;
      },
      SetLeftGuidesLinks: function() {
        var country = document.getElementById("ctl00_body_CountryNameGuides").value;
        var countryGuide = document.getElementById("ctl00_body_ctl01_rptSideNav_ctl01_hlSideNavItem");

        countryGuide.href = countryGuide.href.substring(0, countryGuide.href.lastIndexOf("/") + 1);
        countryGuide.href = countryGuide.href + country + "/printerfriendlyversion.aspx?p=y&h=y";
        return;
      }
    }
  },
  /* -- Parents */
  Parents: {

},
/* -- About Us */
AboutUs: {

},
/* -- Contact Us */
ContactUs: {

}
}

/* GLOBAL . JS*/
function openwindow() {
  /* PARIS ORIENTATION */
  window.open('http://eftours.com/forteachers/leadinganeftour/parisorientation/VideoPopup.aspx', 'Something', 'height=300,width=340,left=420,top=340,modal=1,dialog=1,menubar=0,location=0,resizable=0,status=0,scrollbars=0,toolbar=0,directories=0');
}
//for login page to show and hide the div.

//for Left Navigations
function SetSearchKey(ctlid, key) {
  document.getElementById(ctlid).value = key;
}
function OpenPopup(url, width, height, left, top, resizeable, scrollbar, status) {
  var mywindow = window.open(url, "FAQ", "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",resizable=" + resizeable + ",scrollbars=" + scrollbar + ",status=" + status + "");
  mywindow.focus();
}
//for getstarted control in parents page
function EmptyText(id) {
  document.getElementById(id).value = "";
}
//To change the src of a control
function SwapImage(Ctrl, Url) {
  document.getElementById(Ctrl).src = Url;
}
//To show and hide the Flag Holder
function onFlag() {
  document.getElementById('divFlags').style.visibility = 'visible';
  document.getElementById('divFlags').style.display = 'inline';
}
function offFlag() {
  document.getElementById('divFlags').style.visibility = 'hidden';
  document.getElementById('divFlags').style.display = 'none';
}
//To Download Adobe Reader
function RedirectUrl() {
  var url = "http://www.adobe.com/products/reader/"
  window.open(url);
}
function Validchk(username, password, unamediv, passdiv, message) {
  var un = username;
  var uname;
  uname = document.getElementById(username).value;
  pass = document.getElementById(password).value;
  if (uname == '' && pass == '') {
    document.getElementById(unamediv).style.visibility = 'visible';
    document.getElementById(unamediv).style.display = 'block';
    document.getElementById(passdiv).style.visibility = 'visible';
    document.getElementById(passdiv).style.display = 'block';
    document.getElementById(message).style.visibility = 'visible';
    document.getElementById(message).style.display = 'block';
    return false;
  } else if (uname == '') {
    document.getElementById(unamediv).style.visibility = 'visible';
    document.getElementById(unamediv).style.display = 'block';
    document.getElementById(passdiv).style.visibility = 'hidden';
    document.getElementById(passdiv).style.display = 'none';
    document.getElementById(message).style.visibility = 'visible';
    document.getElementById(message).style.display = 'block';
    return false;
  } else if (pass == '') {
    document.getElementById(passdiv).style.visibility = 'visible';
    document.getElementById(passdiv).style.display = 'block';
    document.getElementById(unamediv).style.visibility = 'hidden';
    document.getElementById(unamediv).style.display = 'none';
    document.getElementById(message).style.visibility = 'visible';
    document.getElementById(message).style.display = 'block';
    return false;
  } else {
    document.getElementById(unamediv).style.visibility = 'hidden';
    document.getElementById(unamediv).style.display = 'none';
    document.getElementById(passdiv).style.visibility = 'hidden';
    document.getElementById(passdiv).style.display = 'none';
    document.getElementById(message).style.visibility = 'hidden';
    document.getElementById(message).style.display = 'none';
    return true;
  }
}
// Links in countDownTravelpage 
function NewWindow(url) {
  var myHeight = document.documentElement.clientHeight; //window.outerHeight();
  var myWidth = screen.availWidth - 10;
  window.open(url, "Something", "width=" + myWidth + ",height=" + myHeight + '",left=0,top=0,modal=1,dialog=1,menubar=0,location=0,resizable=0,status=0,scrollbars=1,toolbar=0,directories=0');
}
// Script for StudentGetStarted user control
function hideErrorMessage(objCtrl) {
  document.getElementById(objCtrl).style.display = "none";
  document.getElementById(objCtrl).style.visibility = "hidden";
}
//Script to validate weblogin password
function ValidatePwd(source, args) {
  var regExp, result;
  var usrname = document.getElementById("ctl00_ContentPlaceHolder1_RegUserName").value;
  var pwdCtrl = document.getElementById("ctl00_ContentPlaceHolder1_RegPassword");
  var pwdval = pwdCtrl.value;
  regExp = new RegExp("^\\w*(?=\\w*\\d)(?=\\w*[a-zA-Z])\\w*$", "i");
  result = pwdval.match(regExp)
  if (result == null || result == ",\*" || pwdval.length < 6 || pwdval.length > 16 || usrname.toLowerCase() == pwdval.toLowerCase()) {
    pwdCtrl.focus();
    args.IsValid = false;
  }
}
function ValidatePassword(source, args) {
  var regExp, result;
  var pwdCtrl = document.getElementById("ctl00_ctl00_ContentPlaceHolder1_CenterContent_NewPassword");
  var pwdval = pwdCtrl.value;
  regExp = new RegExp("^\\w*(?=\\w*\\d)(?=\\w*[a-zA-Z])\\w*$", "i");
  result = pwdval.match(regExp)
  if (result == null || result == ",\*" || pwdval.length < 6 || pwdval.length > 16) {
    pwdCtrl.focus();
    args.IsValid = false;
  }
}
function setHeightForDivs() {
  var browser = navigator.appName;
  var val;
  if (browser == "Microsoft Internet Explorer") {
    val = 0
  } else {
    val = 75
  }
  setheight(val);
}
function setheight(setvalue) {
  if ((document.getElementById('CDiv1').clientHeight > document.getElementById('CDiv3').clientHeight) && (document.getElementById('CDiv1').clientHeight > document.getElementById('CDiv2').clientHeight)) {
    document.getElementById('CDiv2').style.height = setvalue + document.getElementById('CDiv1').clientHeight + "px";
    document.getElementById('CDiv3').style.height = setvalue + document.getElementById('CDiv1').clientHeight + "px";
    document.getElementById('CDiv1').style.height = setvalue + document.getElementById('CDiv1').clientHeight + "px";
  } else if ((document.getElementById('CDiv2').clientHeight > document.getElementById('CDiv1').clientHeight) && (document.getElementById('CDiv2').clientHeight > document.getElementById('CDiv3').clientHeight)) {
    document.getElementById('CDiv1').style.height = setvalue + document.getElementById('CDiv2').clientHeight + "px";
    document.getElementById('CDiv3').style.height = setvalue + document.getElementById('CDiv2').clientHeight + "px";
    document.getElementById('CDiv2').style.height = setvalue + document.getElementById('CDiv2').clientHeight + "px";
  } else if ((document.getElementById('CDiv3').clientHeight > document.getElementById('CDiv1').clientHeight) && (document.getElementById('CDiv3').clientHeight > document.getElementById('CDiv1').clientHeight)) {
    document.getElementById('CDiv1').style.height = setvalue + document.getElementById('CDiv3').clientHeight + "px";
    document.getElementById('CDiv2').style.height = setvalue + document.getElementById('CDiv3').clientHeight + "px";
    document.getElementById('CDiv3').style.height = setvalue + document.getElementById('CDiv3').clientHeight + "px";
  } else {
  }
}
/*Importing functions.js to Global*/
function OpenWindow(url, wname, params) {
  /* FAQ LIST - Leading an EF Tour */
  var oWin = window.open(url, wname, params);
  return false;
}
function SwapImg(ctrl, img) {
  document.getElementById(ctrl).src = img;
}
function showlargemap(pageURL, title, w, h) {
  var left = (screen.width / 2) - (w / 2);
  var top = (screen.height / 2) - (h / 2);
  window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}
function closeWin() {
  window.close();
}
function printdiv() {
  window.print();
}
