﻿// JScript File

//printer friendly function
function PrintPage() {
	window.print();
}

//Traveler middle name confirmation
$(document).ready(function() {

	$("[id$='ConfirmBtn']").click(function() {
		if (!($("input[id$='VerifyCheckCtl']").is(":checked"))) {
			$("label[id$='VerifyCheckLbl']").css('color', 'red'); 
			return false;
		}
	});

	$("input[id$='VerifyCheckCtl']").click(function() {
		if (($("input[id$='VerifyCheckCtl']").is(":checked"))) {
			$("label[id$='VerifyCheckLbl']").css('color', '#666666');
		}
	});

});

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openwindow()
{
	window.open('/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 regExp1,result1,regExp2,result2;
	var usrname  = document.getElementById("ctl00_ContentPlaceHolder1_RegUserName").value;
	var pwdCtrl = document.getElementById("ctl00_ContentPlaceHolder1_RegPassword");    
	var pwdval = pwdCtrl.value;
	
	regExp1 = new RegExp("^\\w*(?=\\w*\\d)(?=\\w*[a-zA-Z])\\w*$","i");
	regExp2 = new RegExp("^([a-zA-Z][0-9]){3}$","i");
	result1 = pwdval.match(regExp1)
	result2 = pwdval.match(regExp2)
	
	if(result1 == null || result1 == ",\*" ||pwdval.length < 6 || pwdval.length >16 || result2 != null || usrname.toLowerCase() == pwdval.toLowerCase() )
	{
		pwdCtrl.focus();
		args.IsValid = false;
	}
}


function ValidatePassword(source, args)
{
	var regExp1,result1,regExp2,result2;
	var pwdCtrl = document.getElementById("ctl00_ctl00_ContentPlaceHolder1_CenterContent_NewPassword");    
	var pwdval = pwdCtrl.value;
	
	regExp1 = new RegExp("^\\w*(?=\\w*\\d)(?=\\w*[a-zA-Z])\\w*$","i");
	regExp2 = new RegExp("^([a-zA-Z][0-9]){3}$","i");
	result1 = pwdval.match(regExp1)
	result2 = pwdval.match(regExp2)
	
	if(result1 == null || result1 == ",\*" ||pwdval.length < 6 || pwdval.length >16 || result2 != null)
	{
		pwdCtrl.focus();
		args.IsValid = false;
	}
}


function setHeightForDivs(){
  window.onload=function(){
  runSetHeightForDivs()
}};




function runSetHeightForDivs()
		{
			

var browser=navigator.appName;
var val;
if (browser=="Microsoft Internet Explorer")
{
val = 0
}
else if (browser =="Opera") {

val = 0

}
else
{
val = 15
}
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
   { 
   }


}

var EF = {
	/* Short hand to return object in global */
	$_script: function () {
		return this.Global.ScriptHandler
	},
	$_util: function () {
		return this.Global.Utilities
	},
	/* -- Global */
	Global: {
		Utilities: {
			CookieManager: {
				/* Create cookie */
				Bake: function (name, value, days) {
					var date = new Date();
					days = days || 1
					document.cookie = name + "=" + value + "; Max-Age=" + (60 * 60 * 24 * days) + "; path=/;domain=.eftours.ca;";
				},
				/* Create session cookie */
				Session: function (name, value) {
					document.cookie = name + "=" + value + "; path=/";
				},
				Consume: function (name, key) {
					var arr = this._Check(name);
					var condition = undefined;
					if (arr) {
						arr = unescape(arr).split("&");
						for (var i = 0; i < arr.length; i++) {
							var t = arr[i].split("|");
							for (var g = 0; g < t.length; g++) {
								t[g] = t[g].split("=");
							}
							for (var counter = 0; counter < t.length; counter++) {
								if (unescape(t[counter][0]) == key) {
									condition = t[counter][1];
									break;
								}
							}
						}
						return condition;
					} else {
						return condition;
					}
				},
				/* Checks for key or key/value pair in cookie - hacked together for leadform*/
				Check: function (name, key, value) {
					var arr = this._Check(name);
					var condition = false;
					if (arr) {
						arr = unescape(arr).split("&");
						for (var i = 0; i < arr.length; i++) {
							var t = arr[i].split("|");
							for (var g = 0; g < t.length; g++) {
								t[g] = t[g].split("=");
							}
							for (var counter = 0; counter < t.length; counter++) {
								if (arguments.length == 2) {
									if (unescape(t[counter][0]) == key) {
										condition = true;
										break;
									}
								} else {
									if (unescape(t[counter][0]) == key & unescape(t[counter][1]) == value) {
										condition = true;
										break;
									}
								}
							}
						}
						return condition;
					} else {
						return condition;
					}
				},
				/* Helper - returns value of specified cookie */
				_Check: function (name) {
					var s = document.cookie.split(';');
					for (var i = 0, l = s.length; i < l; i++) {
						var c = s[i].toString(), f, r;
						f = c.substring(0, c.indexOf("="))
						r = c.substring(c.indexOf("=") + 1, c.length)
						while (f.charAt(0) == " ") f = f.substring(1, f.length)
						if (f == name) return r;
					}
				}
			},
			GetDimensions: function (Width_Height_or_Both) {
				Width_Height_or_Both = Width_Height_or_Both.toLowerCase()
				switch (Width_Height_or_Both) {
					case "width":
						return { "width": width() }
						break;
					case "height":
						return { "height": height() }
						break;
					case "both":
						return { "width": width(), "height": height() }
						break;
					// If nothing, just return both...     
					default:
						return { "width": width(), "height": height() }
						break;
						window.location
				}
				function height() {
					return Math.max(
			Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
			Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
			Math.max(document.body.clientHeight, document.documentElement.clientHeight)
		  );
				}
				function width() {
					return Math.max(
			Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
			Math.max(document.body.offsetWidth, document.documentElement.offsetWidth),
			Math.max(document.body.clientWidth, document.documentElement.clientWidth)
		  );
				}
			}
		}
	},
	/* -- Teachers */
	Teachers: {
		/* Start - Liveball Marketing */
		LiveBall: {
			Private: function () {
				var playing = new Boolean();
				return function setter(condition) {
					if (arguments.length == 0) return playing;
					playing = condition;
					if (playing == "true") {
						EF.Teachers.LiveBall.killTimer(EF.Teachers.LiveBall.Private._timer);
						return playing;
					} else if (playing == "false") {
						EF.Teachers.LiveBall.setTimer();
						return playing;
					}
				}
			},
			showModal: function () {
				/* Load ColorBox for pop-in -- Will eventually replace nryo and ThickBox */
				if (typeof $.fn.colorbox != "undefined") {
					$.fn.colorbox({
						href: EF.Teachers.LiveBall.Private._liveball,
						iframe: true,
						overlayClose: false,
						innerWidth: EF.Teachers.LiveBall.Private._width,
						innerHeight: EF.Teachers.LiveBall.Private._height,
						opacity: 0.3,
						onLoad: function () {
							$("select").css("display", "none");
							$("html").css("overflow-x", "hidden");
							var dimensions = EF.$_util().GetDimensions('both');
							$("#cboxOverlay").css({
								"height": dimensions['height'],
								"width": dimensions['width']
							})
						},
						onCleanup: function () {
							$("#cboxClose").css("display", "none")
							$("select").css("display", "inline");
							$("html").css("overflow-x", "auto");
						},
						onClosed: function () {
							/* Create EFLD cookie */
							EF.Global.Utilities.CookieManager.Session("EFLD", escape("Viewed=True"));

							/* Increment counter */
							var _count = parseInt(EF.Global.Utilities.CookieManager.Consume("EFFEDCK", "Count")) + 1;
							EF.Global.Utilities.CookieManager.Bake("EFFEDCK", "Count=" + _count, "180");
						}
					})
				}
			},
			setTimer: function () {
				EF.Teachers.LiveBall.Private._timer = setTimeout('EF.Teachers.LiveBall.showModal()', EF.Teachers.LiveBall.Private._timeout);
			},
			killTimer: function (timer) {
				try {
					clearTimeout(timer)
				} catch (err) { }
			},
			Init: function (url, timeout, width, height, iframe) {
				/* Create counter cookie, if nec. */
				if (!EF.Global.Utilities.CookieManager.Check("EFFEDCK", "Count")) {
					EF.Global.Utilities.CookieManager.Bake("EFFEDCK", "Count=0", "180");
				}

				if (EF.Global.Utilities.CookieManager.Check("EFLD", "Viewed", "True") || EF.Global.Utilities.CookieManager.Check("EFFEDCK", "Count", "2")) return /*silently*/;

				EF.Teachers.LiveBall.Private._liveball = url;
				EF.Teachers.LiveBall.Private._timeout = timeout || 30000;
				EF.Teachers.LiveBall.Private._width = width || 400;
				EF.Teachers.LiveBall.Private._height = height || 690;
				this.setTimer();
			},
			FlashInit: function () {
				return EF.Teachers.LiveBall.Private._temp = new this.Private()
			}
		}
	}
}
