﻿var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;
var imgLoading = new Image(); imgLoading.src = "/img/loading.gif";

var strTR_Show_State = "block";
if(navigator.userAgent.indexOf("Firefox")!=-1)
	strTR_Show_State = "table-row";
else
	strTR_Show_State = "block";



// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }


//**********general functions*******
function GetObjectByIdValue(strObjectName)
{ 
	if (document.getElementById)
	{ 
		// DOM3 = IE5, NS6 
		return document.getElementById(strObjectName); 
	} 
	else 
	{ 
		if (document.layers) 
		{ 
			// Netscape 4 
			eval("return document.layers['" + strObjectName + "']");
		} 
		else 
		{ 
			// IE 4 
			eval("return document.all['" + strObjectName + "']");
		} 
	}
	return null;
}
function ShowHideObj(objName, swState, otherState)
{
	objDiv = GetObjectByIdValue(objName);
	if (!objDiv)
	{
		return;
	}
	var state = (swState ? "block" : "none");
	if(otherState && state=="block")
	{
		state = "inline-block";
	}
	
	if (document.getElementById)
	{ 
		// DOM3 = IE5, NS6 
		objDiv.style.display = state; 
	} 
	else 
	{ 
		if (document.layers) 
		{ 
			// Netscape 4 
			objDiv.display = state; 
		} 
		else 
		{ 
			// IE 4
			objDiv.style.display = state;
		} 
	}
}
function hideObj(objName)
{
	ShowHideObj(objName, false);
}
function showObj(objName)
{
	ShowHideObj(objName, true);
}
function showObjBlock(objName)
{
	ShowHideObj(objName, true, "inline-block");
}
function toggleDisplay(divName)
{
	var tempDiv = GetObjectByIdValue(divName);
	if (!tempDiv)
	{
		return;
	}  
	
	if (tempDiv.style.display=="none" || tempDiv.style.display=="")
	{
		tempDiv.style.display="block";
	}
	else if (tempDiv.style.display=="block")
	{
		tempDiv.style.display="none";
	}
}
function CheckIsInteger(strValue)
{
	if(isNaN(strValue) || String(parseInt(strValue)) != strValue)
		return false;
	else
		return true;
}
function CheckIsNumber(strValue)
{
	if(isNaN(strValue) || String(parseFloat(strValue)) != Number(strValue))
		return false;
	else
		return true;
}
function PutNumber(strNumber, swIsInteger)
{
	if(strNumber=="" || isNaN(strNumber))
	{
		return "";
	}
	else
	{
		if(!swIsInteger)
		{
			return parseFloat(strNumber).toFixed(2);
		}
		else
		{
			return parseInt(strNumber);
		}
	}
}
function FillCombiWithItems(objList, attr_list, SelectedItemID, strTextColumn, strValueColumn, swAddEmptyValue)
{
	var i=0; var j = 0;
	for (i = objList.options.length; i >= 0; i--) objList.options[i] = null;
	if(swAddEmptyValue)
	{
		objList.options[0] = new Option("   "); objList.options[0].value = "0"; objList.options[0].selected = true;
		j=1;
	}
	for(i=0; i<attr_list.length; i++)
	{
		objList.options[j] = new Option(attr_list.item(i).attributes.getNamedItem(strTextColumn).value, attr_list.item(i).attributes.getNamedItem(strValueColumn).value);
		if(SelectedItemID == attr_list.item(i).attributes.getNamedItem(strValueColumn).value)
			objList.options[j].selected = true;
		j++;
	}
}
function OpenWin(strUrl, winName, winWidth, winHeight, strWindowProperties)
{
	var ie=document.all &&!window.opera;
	var dom=document.getElementById;
	var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body; //create reference to common "body" across doctypes
	var scroll_top=(ie)? standardbody.scrollTop : window.pageYOffset;
	var scroll_left=(ie)? standardbody.scrollLeft : window.pageXOffset;
	var docwidth= (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	var docheight=(ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
	var docheightcomplete=(standardbody.offsetHeight>standardbody.scrollHeight)? standardbody.offsetHeight : standardbody.scrollHeight;
	var objwidth=winWidth;
	var objheight=winHeight; //docheight-50;
	var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2 : scroll_top+10;
	var w_left=docwidth/2-objwidth/2;
	var w_top=Math.floor(parseInt(topposition));
	if(strWindowProperties!=null)
	{
		return window.open(strUrl,winName,'width='+objwidth+',height='+objheight+',left='+w_left+',top='+w_top+',screenX='+w_left+',screenY='+w_top+',' + strWindowProperties);
	}
	else
	{
		window.open(strUrl,winName,'width='+objwidth+',height='+objheight+',left='+w_left+',top='+w_top+',screenX='+w_left+',screenY='+w_top+',toolbar=yes, location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes');
	}
}




















//**********sort functions*******
function Sort(list_name, onWhat, how)
{
	var strFormContainerName = "frm_" + list_name; var objFormContainer = document.forms[strFormContainerName];
	objFormContainer.act_type.value = "list";
	objFormContainer.p_nr.value = "1";
	objFormContainer.sort_on.value = String(onWhat);
	objFormContainer.sort_order.value = String(how);
	Form_Action("list");
}
function GetPage(list_name, pageNumber)
{
	var strFormContainerName = "frm_" + list_name; var objFormContainer = document.forms[strFormContainerName];
	objFormContainer.act_type.value = "list";
	objFormContainer.p_nr.value = pageNumber;
	Form_Action("list");
}
function GoFilter(list_name)
{
	var strFormContainerName = "frm_" + list_name; var objFormContainer = document.forms[strFormContainerName];
	objFormContainer.act_type.value = "filter";
	Form_Action("filter");
}
function HideFilterButton(objForm, strFilterButton)
{
	var objFilterButton = GetObjectByIdValue(strFilterButton);
	if(objFilterButton)
	{
		objFilterButton.style.display = "none";
		objFilterButton.parentNode.appendChild(imgLoading);
	}
}




/************general functions******************/
function SubmitWithoutViewState(objForm, objSubmitButton)
{
	objSubmitButton.disabled = true;
	try{objForm.removeChild(objForm.__VIEWSTATE);}catch(e){}
	try{objForm.removeChild(objForm.__EVENTVALIDATION);}catch(e){}
	objForm.submit();
}
function getPageSize()
{
	//Returns array with page width, height and window width, height
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function CenterObject(obj)
{
	var ie=document.all &&!window.opera;
	var dom=document.getElementById;
	var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body; //create reference to common "body" across doctypes
	var scroll_top=(ie)? standardbody.scrollTop : window.pageYOffset;
	var scroll_left=(ie)? standardbody.scrollLeft : window.pageXOffset;
	var docwidth= (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	var docheight=(ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
	var docheightcomplete=(standardbody.offsetHeight>standardbody.scrollHeight)? standardbody.offsetHeight : standardbody.scrollHeight;
	var objwidth=obj.offsetWidth;
	var objheight=obj.offsetHeight;
	var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px";
	obj.style.left=docwidth/2-objwidth/2+"px";
	obj.style.top=Math.floor(parseInt(topposition))+"px";
	obj.style.visibility="visible";
}
function UpdatePriceFromSAP(objButton, intPID, strSapCode, strCurrencyCode, intCurrencyID)
{
	objButton.disabled = true;
	showObj(String("p_load_" + String(intPID)))
	var objDivInfo = GetObjectByIdValue(String("p_i_" + String(intPID)))
	var myURL = "/common/user_controls/for_product/get_product_price_from_SAP.aspx?rnd=" + Math.random() + "&PID=" + String(intPID) + "&SAPCODE=" + strSapCode + "&CC=" + strCurrencyCode + "&CID=" + intCurrencyID;
	getUrlXMLResponseAndFillDiv(myURL, objDivInfo, null);
}












/***********product list*****************/
function line_select(objChildNode)
{
	var objLine = objChildNode.parentNode;
	if(objLastActiveLine) objLastActiveLine.id="";
	objLine.id="activ_tr";
	objLastActiveLine = objLine;
		
	var intTemp = 0;
	var intID = new Number(objLine.attributes.getNamedItem("tr_id").value);
	var objInfo = GetObjectByIdValue(String("info_" + intID));
	if(objInfo.style.display == strTR_Show_State)
	{
		objInfo.style.display = "none";
	}
	else
	{
		intTemp = intID;
		objInfo.style.display = strTR_Show_State;
		if(objInfo.getAttribute("isloaded") == "false")
		{
			var objDivInfo = GetObjectByIdValue(String("div_info_" + intID))
			var myURL = "/common/user_controls/for_product/get_product_details.aspx?rnd=" + Math.random() + "&PID="+String(intID);
			this.line_select_finish = line_select_finish;
			this.objDivInfo = objDivInfo;
			this.objInfo = objInfo;
			this.intID = intID;
			this.swOnlyOptional = GetObjectByIdValue ("chk_only_opt").checked ? 1 : 0;
			getUrlXMLResponse(myURL, null, self.line_select_finish);
		}
	}
	if(intLastActiveInfo!=0)
		GetObjectByIdValue(String("info_" + intLastActiveInfo)).style.display = "none";
	intLastActiveInfo = intTemp;	
}
function line_select_finish(xmlHttpRequest)
{
	this.objDivInfo.innerHTML = xmlHttpRequest.responseText;
	this.objInfo.setAttribute("isloaded", "true");
	LoadOptProd(1,this.intID, this.swOnlyOptional);
}
function LoadOptProd(intPage, intPID, isOnlyOptional)
{
	var objDivInfo = GetObjectByIdValue("div_opt_"+intPID);
	var myURL = "/common/user_controls/for_product/options_search.aspx?rnd=" + Math.random() + "&PID=" + intPID + "&p_nr=" + String(intPage) + "&onlyopt=" + isOnlyOptional;
	getUrlXMLResponseAndFillDiv(myURL, objDivInfo, null);
}
function AddToBasket(strButton, strFormName, intRestoreThisValue)
{
	var objButton = GetObjectByIdValue(strButton);
	if(objButton){objButton.disabled = true;}
	var objDivInfo = GetObjectByIdValue("left_basket_content");
	var objForm = GetObjectByIdValue(strFormName);
	var myURL = "/common/user_controls/add_to_basket.aspx?rnd=" + Math.random();
	if(objForm)
	{
		for(i=0; i<objForm.length; i++)
			if(objForm[i].id.substring(4,0)=="buy_")
				if(Number(objForm[i].value)!=0)
					myURL += "&" + objForm[i].id + "=" + objForm[i].value;
		
		getUrlXMLResponseAndFillDivSync(myURL, objDivInfo, null);
		
		for(i=0; i<objForm.length; i++)
			if(objForm[i].id.substring(4,0)=="buy_")
				if(Number(objForm[i].value)!=0)
					objForm[i].value = intRestoreThisValue;
	}
	
	if(objButton){objButton.disabled = false;}
}
function CheckProductForBuy(objForm)
{
	var swHaveProductsForBuy = false;
	if(objForm)
		for(i=0; i<objForm.length; i++)
			if(objForm[i].id.substring(4,0)=="buy_")
				if(Number(objForm[i].value)!=0)
				{
					swHaveProductsForBuy = true;
					break;
				}
	if(swHaveProductsForBuy && confirm("Adaugati produsele in cos?"))
	{
		AddToBasket('btnAddToBasket', 'frm_product', 0);
	}
	return true;
}
function get_all_attr(intPID)
{
	var objDivInfo = GetObjectByIdValue(String("all_p_i_" + String(intPID)))
	var myURL = "/common/user_controls/for_product/get_product_all_attributes.aspx?rnd=" + Math.random() + "&PID=" + String(intPID);
	getUrlXMLResponseAndFillDiv(myURL, objDivInfo, null);
}
function AddSpinControls(arrProductList, strInputName, intMinValue, intMaxValue)
{
	var objDivInfo = null;
	var spinCtrl = null;
	for (i = 0; i < arrProductList.length; i++)
	{
		objDivInfo = GetObjectByIdValue("spin_" + arrProductList[i].PID);
		spinCtrl = new SpinControl(strInputName + arrProductList[i].PID);
		spinCtrl.SetMinValue(intMinValue);
		spinCtrl.SetMaxValue(intMaxValue);
		spinCtrl.SetCurrentValue(0);
		objDivInfo.appendChild(spinCtrl.GetContainer());
		spinCtrl.StartListening();
	}
}
function AddSpinControlsAndSetValue(arrProductList, strInputName, intMinValue, intMaxValue)
{
	var objDivInfo = null;
	var spinCtrl = null;
	for (i = 0; i < arrProductList.length; i++)
	{
		objDivInfo = GetObjectByIdValue("spin_" + arrProductList[i].PID);
		spinCtrl = new SpinControl(strInputName + arrProductList[i].PID);
		spinCtrl.SetMinValue(intMinValue);
		spinCtrl.SetMaxValue(intMaxValue);
		spinCtrl.SetCurrentValue(arrProductList[i].QTY);
		objDivInfo.appendChild(spinCtrl.GetContainer());
		spinCtrl.StartListening();
	}
}










/*****iframe actions******/
function i_action(act_type, act)
{
	var objIframe;
	var strUrl = new String("");
	
	if(act_type=="login")
	{
		objIframe = GetObjectByIdValue("ifrm_login");
		strUrl = "login.aspx?rnd=" + Math.random();
	}
	
	ShowHideBackLayer("over_page");
	CenterObject(objIframe);
	objIframe.style.visibility = "visible";
	objIframe.src = strUrl;
}
function ShowHideBackLayer(strDiv)
{
	var arrayPageSize = getPageSize();
	objDiv = GetObjectByIdValue(strDiv);
	var visibility_state = objDiv.style.visibility;
	if(visibility_state=="hidden")
		visibility_state = "visible";
	else
		visibility_state = "hidden";
	objDiv.style.width = arrayPageSize[0];
	objDiv.style.height = arrayPageSize[1];
	objDiv.style.visibility = visibility_state;
}








/*************XmlHttp functions*************/
function CreatXmlHttpRequest(){var httpRequest=null;try{httpRequest = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{httpRequest=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){httpRequest=null;}}if(!httpRequest && typeof XMLHttpRequest!="undefined"){httpRequest=new XMLHttpRequest();}return httpRequest;}
function getUrlSync(url){return getUrl(url, false, null);}
function getUrlAsync(url, handleStateChange){return getUrl(url, true, handleStateChange);}
function getUrl(url, async, handleStateChange) {var xmlHttpReq = CreatXmlHttpRequest();	if (!xmlHttpReq) return; if (handleStateChange) {xmlHttpReq.onreadystatechange = function()	{handleStateChange(xmlHttpReq);	};}else{xmlHttpReq.onreadystatechange = function() {;}}	xmlHttpReq.open("GET", url, async); xmlHttpReq.send(null);}
function postUrl(url, data, async, stateChangeCallback){var xmlHttpReq = CreatXmlHttpRequest(); if (!xmlHttpReq)return; xmlHttpReq.open("POST", url, async); xmlHttpReq.onreadystatechange = function() {stateChangeCallback(xmlHttpReq);};	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttpReq.send(data); }
function urlEncodeDict(dict){var result = "";for (var i=0; i<dict.length; i++) {result += "&" + encodeURIComponent(dict[i].name) + "=" + encodeURIComponent(dict[i].value);}return result;}
function execOnSuccess(stateChangeCallback){return function(xmlHttpReq)	{if (xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200){stateChangeCallback(xmlHttpReq);}};}
function postFormByForm(form, async, successCallback) {var formVars = new Array();for (var i = 0; i < form.elements.length; i++){var formElement = form.elements[i];if(formElement.type=='checkbox' && !formElement.checked){continue;} var v=new Object; v.name=formElement.name; v.value=formElement.value; formVars.push(v);}postUrl(form.action, urlEncodeDict(formVars), async, execOnSuccess(successCallback));}
function postForm(formName, async, successCallback){var form = document.forms[formName];return postFormByForm(form, async, successCallback);}


function getUrlXMLResponseCallbackFillDiv(xmlHttpReq)
{
	this.div_id.innerHTML = xmlHttpReq.responseText;
	if(this.successCallback)
	{
		//alert(this.successCallback);
		//this.successCallback;
	}
}
function getNodeValue(obj,tag)
{
	node=obj.getElementsByTagName(tag);
	if(node!=null && node.length>0) {
		return node[0].firstChild.nodeValue;
	} else {
		return null;
	}
}
function getRootNode(xmlHttpReq) {return xmlHttpReq.responseXML.getElementsByTagName('root')[0];}
function getUrlXMLResponse(url, successCallback, responseCallback) {
	this.successCallback = successCallback;
	this.urlResponseCallback = responseCallback;
	getUrl(url, true, execOnSuccess(this.urlResponseCallback)) 
}
function getUrlXMLResponseAndFillDiv(url, div_id, successCallback) {
	self.successCallback = successCallback;
	this.urlResponseCallback = getUrlXMLResponseCallbackFillDiv;
	this.div_id = div_id;
	getUrl(url, true, execOnSuccess(this.urlResponseCallback)) 
}
function getUrlXMLResponseAndFillDivSync(url, div_id, successCallback) {
	this.successCallback = successCallback;
	this.urlResponseCallback = getUrlXMLResponseCallbackFillDiv;
	this.div_id = div_id;
	getUrl(url, false, execOnSuccess(this.urlResponseCallback)) 
}
function postUrlXMLResponse(url, data, successCallback) {
	this.successCallback = successCallback;
	this.urlResponseCallback = getUrlXMLResponseCallback;
	postUrl(url, data, true, execOnSuccess(this.urlResponseCallback))
}
function confirmAndPostUrlXMLResponse(url, confirmMessage, data, successCallback) {
	if (confirm(confirmMessage)) {
		postUrlXMLResponse(url, data, successCallback);
	}
}
function postFormXMLResponse(formName, successCallback) {
	this.successCallback = successCallback;
	postForm(formName, true, execOnSuccess(getUrlXMLResponseCallback))
}





//**********for list************
function tr_onMOv(obj)
{
obj.className = "tr_on";
//obj.style.backgroundColor="#eeeeee";
}
function tr_onMOu(obj){obj.style.backgroundColor="#fffdf4";}
function news_line_select_by_id(strLineID, line_type)
{
	var objLine = GetObjectByIdValue(strLineID);
	news_line_select(objLine, line_type);
}
function news_line_select(objLine, line_type)
{
	if(objLastActiveLine) objLastActiveLine.className="";
	objLine.className="news_content_selected";
	objLastActiveLine = objLine;
		
	var intTemp = 0;
	var intID = new Number(objLine.attributes.getNamedItem("tr_id").value);
	var objInfo = GetObjectByIdValue(String("info_" + intID));
	if(objInfo.style.display == strTR_Show_State)
	{
		objInfo.style.display = "none";
	}
	else
	{
		intTemp = intID;
		objInfo.style.display = strTR_Show_State;
		if(objInfo.getAttribute("isloaded") == "false")
		{
			var objDivInfo = GetObjectByIdValue(String("div_info_" + intID))
			var myURL = "";
			if(line_type==1)
			{
				myURL = "/common/user_controls/for_render/get_news_details.aspx?rnd=" + Math.random() + "&NID="+String(intID);
			}
			getUrlXMLResponseAndFillDiv(myURL, objDivInfo, null);
			objInfo.setAttribute("isloaded", "true");
		}
	}
	if(intLastActiveInfo!=0)
		GetObjectByIdValue(String("info_" + intLastActiveInfo)).style.display = "none";
	intLastActiveInfo = intTemp;	
}
function careers_line_select(objLine, line_type, intID)
{
	//if(objLastActiveLine) objLastActiveLine.id="";
	//objLine.id="activ_tr";
	objLastActiveLine = objLine;
		
	var intTemp = 0;
	var objInfo = GetObjectByIdValue(String("info_" + intID));
	if(objInfo.style.display == strTR_Show_State)
	{
		objInfo.style.display = "none";
	}
	else
	{
		intTemp = intID;
		objInfo.style.display = strTR_Show_State;
		if(objInfo.getAttribute("isloaded") == "false")
		{
			var objDivInfo = GetObjectByIdValue(String("div_info_" + intID))
			var myURL = "";
			if(line_type==1)
			{
				myURL = "/common/user_controls/for_render/get_careers_details.aspx?rnd=" + Math.random() + "&CID="+String(intID);
			}
			getUrlXMLResponseAndFillDiv(myURL, objDivInfo, null);
			objInfo.setAttribute("isloaded", "true");
		}
	}
	if(intLastActiveInfo!=0)
		GetObjectByIdValue(String("info_" + intLastActiveInfo)).style.display = "none";
	intLastActiveInfo = intTemp;	
}


/****language selector*******/
function showLanguages ()
{
	hideObj("current_language");
	showObj("language_selector");
}
function hideLanguages ()
{
	hideObj("language_selector");
	showObj("current_language");
}




/*pentru slide-show*/
function ActionTabContent(selected_tab)
{
}


/* pentru fereastra de chat a clientului  */
function ShowClientChatDialog()
{
	if (chatwindow && !chatwindow.closed)
	{
		alert("Fereastra de chat este deschisa deja!");
	}
	else
	{
		var strURL = "/ClientChat.aspx?rnd=" + Math.random();
		chatwindow = OpenWin(strURL, "Client_Chat", 650, 450, "toolbar=no, location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no");
	}
}



function showGlossary(GlossaryID, inputObj)
{
	var glossary_tooltip = GetObjectByIdValue ('glossary_tooltip_' + GlossaryID);
	
	if (!glossary_tooltip)
	{
		glossary_tooltip = document.createElement('div');
		
		glossary_tooltip.style.position = 'absolute';
		glossary_tooltip.style.border = '1px solid #FFBF4F';
		glossary_tooltip.style.background = '#FFFABF';
		glossary_tooltip.style.padding = '5px';
		glossary_tooltip.id = 'glossary_tooltip_' + GlossaryID;
		
		getUrlXMLResponseAndFillDiv('/get_glossary.aspx?GID=' + GlossaryID, glossary_tooltip);
		
		document.body.appendChild(glossary_tooltip);
	}	
	
	glossary_tooltip.style.display = 'block';
	positionGlossary(glossary_tooltip, inputObj);
}

function hideGlossary(GlossaryID)
{
	var glossary_tooltip = GetObjectByIdValue ('glossary_tooltip_' + GlossaryID);
	
	if (glossary_tooltip)
	{
		glossary_tooltip.style.display = 'none';
	}
}

function positionGlossary(GlossaryObj, inputObj)
{
	var leftPos = (get_object_left_pos(inputObj) + inputObj.offsetWidth);
	var topPos = get_object_top_pos(inputObj);
	
	GlossaryObj.style.left = leftPos + 'px';
	GlossaryObj.style.top = topPos + 'px';	
	
}

function get_object_left_pos (inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}

function get_object_top_pos (inputObj)
{
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}


//**********start page************
var timer = "";
var chatwindow = null;
onLoadFunctionList = new Array();
function performOnLoadFunctions()
{
	for (var i in onLoadFunctionList)
	{
		onLoadFunctionList[i]();
	}
}
function KeepAlive()
{
	var myhttp = CreatXmlHttpRequest();
	myhttp.open("GET", "/KeepAlive.aspx", false);	
	myhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	myhttp.send(null);
}
function set_KeepAlive()
{
	timer = setInterval("KeepAlive()", (1000 * 60 * 6));
}
function WindowOnload(oNewOnloadFunction) 
{
    var oPreviousOnloadFunction = window.onload;
    window.onload = function()
    {
        if (oPreviousOnloadFunction) 
		{ 
			oPreviousOnloadFunction(); 
		}
        oNewOnloadFunction();
    }
}	
function myInitFunction() 
{
    set_KeepAlive();
}
WindowOnload(performOnLoadFunctions);
onLoadFunctionList.push(function() { myInitFunction(); });
onLoadFunctionList.push(function() { mladdevents(); });