//Ajax methods
var subjReq = createRequestObject();
//Get unique time key
function getTimeKey() {
	var now = new Date();
	var hour = now.getHours();
	var minute = now.getMinutes();
	var second = now.getSeconds();
	var monthnumber = now.getMonth();
	var monthday = now.getDate();
	var year = now.getYear();
	return hour + "" + minute + "" + second + "" + monthnumber + "" + monthday + "" + year;
}

function sndReq(callfor, param, functionname) {
	// dummyid parameter required since the IE Browser caches the previous URL and http stuff
   	// So to say this is a new request url, dummyid being unique will help
	var urlFire = callfor + "?dummyid=" + getTimeKey() + "" + param + "&showUrl=true";
	req = createRequestObject();
	req.open("POST", urlFire);
	req.onreadystatechange = eval(functionname);
	req.send(null);
}
function sndReqSync(callfor, param, functionname) {	
	// dummyid parameter required since the IE Browser caches the previous URL and http stuff
   	// So to say this is a new request url, dummyid being unique will help
	var urlFire = callfor + "?dummyid=" + getTimeKey() + "" + param;
	req = createRequestObject();
	req.open("POST", urlFire, false);
	req.onreadystatechange = eval(functionname);
	req.send(null);
}
function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		ro = new XMLHttpRequest();
	}
	return ro;
}

function findByCat(keywords) {
	var keyVal = keywords;
	var frmObj = document.forms[0];
	if (keyVal == null) {
		keyVal = document.getElementById("keyword").value;
	}
	if (validateKeyword(keyVal)) {
		var intIndexOfMatch = keyVal.indexOf("+");
		while (intIndexOfMatch != -1) {
     		//Replace out the current instance.
			keyVal = keyVal.replace("+", "~");
			//Get the index of any next matching substring.
			intIndexOfMatch = keyVal.indexOf("+");
		}
		frmObj.method = "POST";
		frmObj.action = "/wtec/search_.htm?submitName=searchGeneral&keyword=" + escape(keyVal)//
			 + "&removekey=true&sortFlag=&searchCategory=general";
		//Must call in try catch to clear sessions page for tutor and student
		try {
			clearAllParams();
		}catch (e) {
		}
		frmObj.submit();
	} else {
		if (!validateKeyword(keyVal)) {
			return false;
		}
	}
}

function validateKeyword(keyVal) {
	var parsed = false;
	var separator = ",";
	var validchars = ",+ ";
	for (var i = 0; i < keyVal.length; i++) {
		var letter = keyVal.charAt(i);
		if (validchars.indexOf(letter) != -1) {
			separator = letter;
			parsed = true;
		}
	}
	if (keyVal.length > 0 || keyVal.length == 0) {
		parsed = true;
	}
	return parsed;
}



/*from the hiddenpopup.js for all home page popups.*/

//
var offsetfrommouse = [15, 15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
//var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var defaultDivHeight = 40;	// maximum image size.
var defaultDivWidth = 40;	// maximum image size.
var iframeHeight = "";

//var timer;
var hiddenID = "";
var onMouseOver = false;
/* DETECT BROWSER */
var bIsIE = false;
function checkIsIE() {
	try {
		if (navigator.userAgent.toUpperCase().indexOf("MSIE") >= 0) {
			bIsIE = true;
			return bIsIE;
		}
	}
	catch (e) {
		return bIsIE;
	}
	return bIsIE;
}
function checkBrw() {
	var agt = navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1) {
		return "Opera";
	}
	if (agt.indexOf("staroffice") != -1) {
		return "Star Office";
	}
	if (agt.indexOf("webtv") != -1) {
		return "WebTV";
	}
	if (agt.indexOf("beonex") != -1) {
		return "Beonex";
	}
	if (agt.indexOf("chimera") != -1) {
		return "Chimera";
	}
	if (agt.indexOf("netpositive") != -1) {
		return "NetPositive";
	}
	if (agt.indexOf("phoenix") != -1) {
		return "Phoenix";
	}
	if (agt.indexOf("firefox") != -1) {
		return "Firefox";
	}
	if (agt.indexOf("safari") != -1) {
		return "Safari";
	}
	if (agt.indexOf("skipstone") != -1) {
		return "SkipStone";
	}
	if (agt.indexOf("msie") != -1) {
		return "Internet Explorer";
	}
	if (agt.indexOf("netscape") != -1) {
		return "Netscape";
	}
	if (agt.indexOf("mozilla/5.0") != -1) {
		return "Mozilla";
	}
	if (agt.indexOf("/") != -1) {
		if (agt.substr(0, agt.indexOf("/")) != "mozilla") {
			return navigator.userAgent.substr(0, agt.indexOf("/"));
		} else {
			return "Netscape";
		}
	} else {
		if (agt.indexOf(" ") != -1) {
			return navigator.userAgent.substr(0, agt.indexOf(" "));
		} else {
			return navigator.userAgent;
		}
	}
}
function gettrailobj() {
	if (document.getElementById) {
		return document.getElementById(hiddenID).style;
	}
}
function gettrailobjnostyle() {
	if (document.getElementById) {
		return document.getElementById(hiddenID);
	}
}
function truebody() {
	if (checkBrw() == "Safari") {
		return document.body;
	} else {
		return document.documentElement;
	}
}
/*function truebody(){
return (!window.opera && document.compatMode && window.safari &&  document.compatMode!="BackCompat")? document.documentElement : document.body
}*/
function hidePopup() {
	if ((parent.document.getElementById("mask")) || (parent.document.getElementById("mask").style.display == "") || (parent.document.getElementById("mask").style.display == "block")) {
		maskWindow("closeIframe");
	}
	if ((document.getElementById("mask")) || (document.getElementById("mask").style.display == "") || (document.getElementById("mask").style.display == "block")) {
		maskWindow("closeDiv");
	}
	gettrailobj().display = "none";
	document.onmousemove = "";
	gettrailobj().left = "-500px";
	hiddenID = "";
}


function openPopup(id, width, e, onMouseOver) {
	maskWindow("open");
	if (width >= 600) {
		offsetfrommouse = [-200, 15];
	} else {
		offsetfrommouse = [15, 15];
	}
	var height = document.getElementById(id).offsetHeight;
	var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - offsetfrommouse[0];
	var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);
	if ((navigator.userAgent.indexOf("Konqueror") == -1 || navigator.userAgent.indexOf("Firefox") != -1 || (navigator.userAgent.indexOf("Opera") == -1 && navigator.appVersion.indexOf("MSIE") != -1)) && (docwidth > 650 && docheight > 500)) {
		(width == 0) ? width = defaultDivWidth : "";
		width += 0;
		if (hiddenID != "") {
			document.getElementById(hiddenID).style.display = "none";
		}
		hiddenID = id;
		gettrailobj().display = "block";
		gettrailobjnostyle().style.width = width + "px";
		height = gettrailobjnostyle().offsetHeight;
		defaultDivHeight = height;
		defaultDivWidth = width;
		if (onMouseOver == true) {
			document.onmousemove = followmouse;
		} else {
			if (checkBrw() == "Internet Explorer") {
				followmouse();
			} else {
				followmouse(e);
			}
		}
	}
}


function validi() {
	document.getElementById("validateLan").style.display = "";
}
function refreshIframe() {
	window.location.reload(true);
}
function getIframeHeight(iFrameID) {
	if (document.getElementById && !(document.all)) {
	//alert('FireFox');
		iframeHeight = document.getElementById(iFrameID).contentDocument.body.scrollHeight;
	} else {
		if (document.all) {
	//alert('IE');
			iframeHeight = document.frames(iFrameID).document.body.scrollHeight;
		}
	}
	document.getElementById(iFrameID).style.height = iframeHeight + "px";
	return iframeHeight;
}
function hideIframe(errorMessID, ifrmID, chk) {
	if (parent.document.getElementById("mask")) {
		maskWindow("closeIframe");
	}
	var errorMes = document.getElementById(errorMessID);
	if ((chk == "showError") && (errorMes.style.display != "none")) {
		var orgheight = errorMes.offsetHeight;
	//alert(parseInt(orgheight) + parseInt(parent.document.getElementById('ifrmHt').value));
		parent.gettrailobj().height = parseInt(orgheight) + parseInt(parent.document.getElementById("ifrmHt").value) + "px";
		parent.document.getElementById(ifrmID).style.height = parseInt(orgheight) + parseInt(parent.document.getElementById("ifrmHt").value) + "px";
	} else {
		parent.gettrailobj().display = "none";
		document.onmousemove = "";
		parent.gettrailobj().left = "-10000px";
		hiddenID = "";
		iframeHeight = "";
	}
	return true;
}
function doIt(iFrameID) {
//	alert(iFrameID)
	gettrailobj().display = "block";
	getIframeHeight(iFrameID);
}
function openIframeSession(id, iFrameID, width, e, refreshIfrm, url) {

	//if(hiddenID != ""){
		//if(document.getElementById("viewCalendar")){
		//activateTab();
		//}
		//document.getElementById(hiddenID).style.display="none";
		//}
	if (refreshIfrm == "refreshIfrm") {
		var ifrm = document.getElementById(iFrameID);
		ifrm.src = url;
	}
	var height = document.getElementById(id).offsetHeight;
	var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - offsetfrommouse[0];
	var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);
	if ((navigator.userAgent.indexOf("Konqueror") == -1 || navigator.userAgent.indexOf("Firefox") != -1 || (navigator.userAgent.indexOf("Opera") == -1 && navigator.appVersion.indexOf("MSIE") != -1)) && (docwidth > 650 && docheight > 500)) {
		(width == 0) ? width = defaultDivWidth : "";
		width += 0;
		if (hiddenID != "") {
			document.getElementById(hiddenID).style.display = "none";
		}
		hiddenID = id;
		gettrailobj().display = "block";
		//alert(getIframeHeight(iFrameID));
		//alert("getIframeHeight = "+getIframeHeight(iFrameID));	
		document.getElementById("ifrmHt").value = getIframeHeight(iFrameID);
		gettrailobjnostyle().style.width = width + "px";
		height = iframeHeight;
		if (hiddenID != "") {
			if (document.getElementById("viewCalendar")) {
				activateTab();
			}
			document.getElementById(hiddenID).style.display = "none";
		}
		if (refreshIfrm == "refreshIfrm") {
			var ifrm = document.getElementById(iFrameID);
			ifrm.src = url;
		}
		defaultDivHeight = height;
		defaultDivWidth = width;
		if (checkBrw() == "Internet Explorer") {
			followmouse();
		} else {
			followmouse(e);
		}
		setTimeout("doIt('" + iFrameID + "')", 500);
	}
}
function openIframeCalendar(id, iFrameID, width, e, url, listingid) {
	maskWindow("open");
	var ifrm = document.getElementById(iFrameID);
	ifrm.src = url;
	if (hiddenID != "") {
		activateTab(listingid);
		document.getElementById(hiddenID).style.display = "none";
	}
	var height = document.getElementById(id).offsetHeight;
	var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - offsetfrommouse[0];
	var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);
	if ((navigator.userAgent.indexOf("Konqueror") == -1 || navigator.userAgent.indexOf("Firefox") != -1 || (navigator.userAgent.indexOf("Opera") == -1 && navigator.appVersion.indexOf("MSIE") != -1)) && (docwidth > 650 && docheight > 500)) {
		(width == 0) ? width = defaultDivWidth : "";
		if (hiddenID != "") {
			document.getElementById(hiddenID).style.display = "none";
		}
		hiddenID = id;
		gettrailobj().display = "block";
		gettrailobjnostyle().style.width = width + "px";
		height = 491;
		defaultDivHeight = height;
		defaultDivWidth = width;
		//height = 491 + "px";
		//alert(height)
		if (checkBrw() == "Internet Explorer") {
			followmouse();
		} else {
			followmouse(e);
		}
	}
	findDivPos(id);
	defaultDivPosLt = defaultDivPosLt + "";
	if (((defaultDivPosLt).charAt(0)) == "-") {
		gettrailobjnostyle().style.left = 210 + "px";
	}
}
function followmouse(e) {
	var xcoord = offsetfrommouse[0];
	var ycoord = offsetfrommouse[1];
	var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - 15;
	var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);
	if (typeof e != "undefined") {
		if (docwidth - e.pageX < defaultDivWidth + 2 * offsetfrommouse[0]) {
			xcoord = e.pageX - xcoord - defaultDivWidth; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < defaultDivHeight + 2 * offsetfrommouse[1]) {
			ycoord += e.pageY - Math.max(0, (2 * offsetfrommouse[1] + defaultDivHeight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}
	} else {
		if (typeof window.event != "undefined") {
			if (docwidth - event.clientX < defaultDivWidth + 2 * offsetfrommouse[0]) {
				xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultDivWidth; // Move to the left side of the cursor
			} else {
				xcoord += truebody().scrollLeft + event.clientX;
			}
			if (docheight - event.clientY < (defaultDivHeight + 2 * offsetfrommouse[1])) {
				ycoord += event.clientY + truebody().scrollTop - Math.max(0, (2 * offsetfrommouse[1] + defaultDivHeight + event.clientY - docheight));
			} else {
				ycoord += truebody().scrollTop + event.clientY;
			}
		}
	}
	gettrailobj().left = xcoord + "px";
	gettrailobj().top = ycoord + "px";
}
function hidePopupexpandCollapse() {
	if (hiddenID != "") {
		gettrailobj().display = "none";
		document.onmousemove = "";
		gettrailobj().left = "-500px";
		hiddenID = "";
	}
}
function openIframe(id, iFrameID, width, e, refreshIfrm, url) {



 //if(hiddenID != ""){
  //if(document.getElementById("viewCalendar")){
  //activateTab();
  //}
  //document.getElementById(hiddenID).style.display="none";
  //}
	if (refreshIfrm == "refreshIfrm") {
		var ifrm = document.getElementById(iFrameID);
		ifrm.src = url;
	}
	var height = document.getElementById(id).offsetHeight;
	var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - offsetfrommouse[0];
	var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);
	if ((navigator.userAgent.indexOf("Konqueror") == -1 || navigator.userAgent.indexOf("Firefox") != -1 || (navigator.userAgent.indexOf("Opera") == -1 && navigator.appVersion.indexOf("MSIE") != -1)) && (docwidth > 650 && docheight > 500)) {
		(width == 0) ? width = defaultDivWidth : "";
		width += 0;
		if (hiddenID != "") {
			document.getElementById(hiddenID).style.display = "none";
		}
		hiddenID = id;
		gettrailobj().display = "block";
  //alert(getIframeHeight(iFrameID));
  //alert("getIframeHeight = "+getIframeHeight(iFrameID)); 
		document.getElementById("ifrmHt").value = getIframeHeight(iFrameID);
		gettrailobjnostyle().style.width = width + "px";
		height = iframeHeight;
		if (hiddenID != "") {
			if (document.getElementById("viewCalendar")) {
				activateTab();
			}
			document.getElementById(hiddenID).style.display = "none";
		}
		if (refreshIfrm == "refreshIfrm") {
			var ifrm = document.getElementById(iFrameID);
			ifrm.src = url;
		}
		defaultDivHeight = height;
		defaultDivWidth = width;
		if (checkBrw() == "Internet Explorer") {
			followmouse();
		} else {
			followmouse(e);
		}
		setTimeout("doIt('" + iFrameID + "')", 500);
	}
}
function openModifyIframe(id, iFrameID, width, e, refreshIfrm, url) {
	maskWindow("open");


 //if(hiddenID != ""){
  //if(document.getElementById("viewCalendar")){
  //activateTab();
  //}
  //document.getElementById(hiddenID).style.display="none";
  //}
	if (refreshIfrm == "refreshIfrm") {
		var ifrm = document.getElementById(iFrameID);
		ifrm.src = url;
	}
	var height = document.getElementById(id).offsetHeight;
	var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - offsetfrommouse[0];
	var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);
	if ((navigator.userAgent.indexOf("Konqueror") == -1 || navigator.userAgent.indexOf("Firefox") != -1 || (navigator.userAgent.indexOf("Opera") == -1 && navigator.appVersion.indexOf("MSIE") != -1)) && (docwidth > 650 && docheight > 500)) {
		(width == 0) ? width = defaultDivWidth : "";
		width += 0;
		if (hiddenID != "") {
			document.getElementById(hiddenID).style.display = "none";
		}
		hiddenID = id;
		gettrailobj().display = "block";
  //alert(getIframeHeight(iFrameID));
  //alert("getIframeHeight = "+getIframeHeight(iFrameID)); 
		document.getElementById("ifrmHt").value = getIframeHeight(iFrameID);
		gettrailobjnostyle().style.width = width + "px";
		height = iframeHeight;
		defaultDivHeight = height;
		defaultDivWidth = width;
		if (checkBrw() == "Internet Explorer") {
			followmouse();
		} else {
			followmouse(e);
		}
  //setTimeout("doIt('"+iFrameID+"')",500);
	}
}
var px = -1, py = -1, cx = -1, cy = -1;
function openHiddenIframe(id, iFrameID, width, e, refreshIfrm, url) {
	maskWindow("open");
	if (checkBrw() == "Internet Explorer") {
		px = -1;
		py = -1;
		if (typeof window.event != "undefined") {
			cx = window.event.clientX;
			cy = window.event.clientY;
		}
	} else {
		px = e.pageX;
		py = e.pageY;
		cx = -1;
		cy = -1;
	}
		//alert("px:"+px+" py:"+py+" cx:"+cx+" cy:"+cy);
	if (hiddenID != "") {
		document.getElementById(hiddenID).style.display = "none";
	}
	if (refreshIfrm == "refreshIfrm") {
		var ifrm = document.getElementById(iFrameID);
		ifrm.src = url + "&browserTime=" + escape(new Date());
	}
	mainDivID = id;
	ifrmID = iFrameID;
	//assignIdGlbVar();
	var height = document.getElementById(id).offsetHeight;
	var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - offsetfrommouse[0];
	var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);
	if ((navigator.userAgent.indexOf("Konqueror") == -1 || navigator.userAgent.indexOf("Firefox") != -1 || (navigator.userAgent.indexOf("Opera") == -1 && navigator.appVersion.indexOf("MSIE") != -1)) && (docwidth > 650 && docheight > 500)) {
		(width == 0) ? width = defaultDivWidth : "";
		hiddenID = id;
		gettrailobj().display = "block";
		gettrailobjnostyle().style.width = width + "px";
	}
}
function openSecondlevelIframe(iFrameID, url) {
	parent.document.getElementById(iFrameID).src = url;
}
function openSecondLevelPopup(iframeId,widt,url){
	var ifrmId = parent.document.getElementById(iframeId);	
	ifrmId.src = url;	
	ifrmId.style.width = widt + "px";
	parent.document.getElementById(ifrmId.parentNode.id).style.width = ifrmId.style.width;
	}

/* For Iframe */
var mainDivID = "";
var ifrmID = "";
function assignIdGlbVar() {
	document.getElementById("mainDivIDHt").value = mainDivID;
	document.getElementById("ifrmIDHt").value = ifrmID;
}
function setIfrmDivHt(ifrmId, mainDiv) {
	try {
		var ifmWrapper = document.getElementById(ifrmId);
		var mainContentDiv = document.getElementById(mainDiv);
		if (mainContentDiv) {
			if (!window.XMLHttpRequest) {
				mainContentDiv.style.width = (ifmWrapper.offsetWidth - 22) + "px";
			}
			if (ifmWrapper.offsetHeight >= 470) {
				if(mainContentDiv.offsetHeight > 450 || mainContentDiv.offsetHeight < 0) {
					mainContentDiv.style.height = 450 + "px";
				} else {
					mainContentDiv.style.height = mainContentDiv.offsetHeight + "px";
				}
			}
		}
		var ifmWrapperHt = ifmWrapper.offsetHeight;
		window.top.resizeParentElem(window.top.mainDivID, window.top.ifrmID, ifmWrapperHt);
	}
	catch (e) {
	}
}
function resizeParentElem(id, ifmHt, divHt) {
	hiddenId = id;
	var divId = document.getElementById(id);
	divId.style.height = divHt + "px";
	var ifrm = document.getElementById(ifmHt);
	ifrm.style.height = divHt + "px";
	defaultDivHeight = divId.offsetHeight;
	defaultDivWidth = divId.offsetWidth;
	//alert(defaultDivWidth);
	//document.getElementById('ifrmHt').value = divId.offsetHeight;
	followMouseIframe(px, py, cx, cy);
	findDivPos(id);
	defaultDivPosLt = defaultDivPosLt + "";
	if (((defaultDivPosLt).charAt(0)) == "-") {
		divId.style.left = 210 + "px";
	}
}
var defaultDivPosLt = "";
function findDivPos(id) {
	id = parent.document.getElementById(id);
	var curleft = curtop = 0;
	if (id.offsetParent) {
		curleft += id.offsetLeft;
		curtop += id.offsetTop;
	}
	while (id = id.offsetParent) {
	}
	defaultDivPosLt = curleft;
	 //defaultDivPosRt = curtop;
	return [curleft, curtop];
}
function followMouseIframe(pageX, pageY, clientX, clientY) {
	var xcoord = offsetfrommouse[0];
	var ycoord = offsetfrommouse[1];
	var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - 15;
	var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);
	if (pageX > -1) {
		if (docwidth - pageX < defaultDivWidth + 2 * offsetfrommouse[0]) {
			xcoord = pageX - xcoord - defaultDivWidth; // Move to the left side of the cursor
		} else {
			xcoord += pageX;
		}
		if (docheight - pageY < defaultDivHeight + 2 * offsetfrommouse[1]) {
			ycoord += pageY - Math.max(0, (2 * offsetfrommouse[1] + defaultDivHeight + pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += pageY;
		}
	} else {
		if (docwidth - cx < defaultDivWidth + 2 * offsetfrommouse[0]) {
			xcoord = cx + truebody().scrollLeft - xcoord - defaultDivWidth; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft + cx;
		}
		if (docheight - cy < (defaultDivHeight + 2 * offsetfrommouse[1])) {
			ycoord += cy + truebody().scrollTop - Math.max(0, (2 * offsetfrommouse[1] + defaultDivHeight + cy - docheight));
		} else {
			ycoord += truebody().scrollTop + cy;
		}
	}
	//alert(offsetfrommouse)
	gettrailobj().left = xcoord + "px";
	gettrailobj().top = ycoord + "px";
}
function maskWindow(flag) {
	var windowHeight = "";
	var bodyHeight = document.getElementsByTagName("body")[0].offsetHeight;
	var finalHeight = "";
	var maskDiv = document.getElementById("mask");
	if (!document.all) {
		windowHeight = window.innerHeight;
	} else {
		windowHeight = document.documentElement.clientHeight;
	}
	if (flag == "open") {
		//var wrapperHeight = document.getElementById("wrapper").offsetHeight;
		var wrapperHeight = "";
		if (document.getElementById("wrapper")) {
			wrapperHeight = document.getElementById("wrapper").offsetHeight;
		} else {
			if (document.getElementById("homeWrapper")) {//homeWrapper only for  home page
				wrapperHeight = document.getElementById("homeWrapper").offsetHeight;
			}
		}
		maskDiv.style.display = "block";
		if (bodyHeight >= windowHeight) {
			finalHeight = bodyHeight;
			maskDiv.style.height = finalHeight + "px";
		} else {
			finalHeight = windowHeight;
			maskDiv.style.height = finalHeight + "px";
		}
	} else {
		if (flag == "closeIframe") {
		//parent.maskDiv.style.display = 'none';
			parent.document.getElementById("mask").style.display = "none";
		} else {
			if (flag == "closeDiv") {
				maskDiv.style.display = "none";
			}
		}
	}
}
function remove(element) {
	if (element) {
		element.parentNode.removeChild(element);
	}
}


//Get profiles status
function updateProfilesStatus() {
	var userIdFlds = document.getElementsByName("user.id.status.check.for.chat");
	if (userIdFlds.length > 0) {
		var userIdsValArray = new Array();
		for (var i = 0; i < userIdFlds.length; i++) {
			userIdsValArray.push(userIdFlds[i].value);
		}
		var userIds = userIdsValArray.join();
		sndReq("general_chat_.htm", "&submitName=checkProfilesStatus&security=any&userIds=" + escape(userIds), "callBackUpdateProfilesStatus");
	}
}
//Update profiles status
function callBackUpdateProfilesStatus() {
	if (req.readyState == 4) { //Complete
		if (req.status == 200) { //OK response
			try {
				var availUserIds = req.responseText;
				if (availUserIds != null) {
					var availUserIdsArray = availUserIds.split(",");
					var statusAnchors = document.getElementsByName("chatStatusA");
					for (var j = 0; j < statusAnchors.length; j++) {
						statusAnchors[j].style.display = "none";
					}
					for (var i = 0; i < availUserIdsArray.length; i++) {
						for (var j = 0; j < statusAnchors.length; j++) {
							if (statusAnchors[j].id == "chatStatusA" + availUserIdsArray[i]) {
								statusAnchors[j].style.display = "";
							}
						}
					}
				}
			}
			catch (e) {
			}
		}
	}
}

function showContactUs(event) {
	openHiddenIframe("contUsDiv", "contUsIfrm", 325, event, "refreshIfrm", "/wtec/general_header.htm?submitName=showContactUs&security=any");
}

function showSupportRequest(event) {
	openHiddenIframe("contUsDiv", "contUsIfrm", 325, event, "refreshIfrm", "/wtec/general_header.htm?submitName=showSupportRequest&security=any");
}

function showReqTutor(event) {
	openHiddenIframe("reqTutDiv", "reqTutIfrm", 330, event, "refreshIfrm", "/wtec/general_header.htm?submitName=showRequestTutor&security=any");
}

function showSysReq(event) {
	openHiddenIframe("sysReqDiv", "sysReqIfrm", 610, event, "refreshIfrm", "/wtec/general_header.htm?submitName=showSysRequirments&security=any");
}