﻿$(document).ready(function()
{
	$("#fnc_page .fndList ul > li").mouseover(function(){
		var nameItem=$(this).attr("id").substr(6);
		$("#fnc_page .fndList ul > li").removeClass("fn01_select fn02_select fn03_select fn04_select fn05_select");
		$(this).addClass("fn0"+nameItem+"_select");
		$(".fndDescriptionContent > span").hide();
		$("#fundDetails0"+nameItem).show();
	});
});

var _hiddenElements = null;
var _openedToolTip = null;

function __customPostBack(eventTarget, eventArgument, submitButtonId)
{
	if (!theForm.onsubmit || (theForm.onsubmit() != false))
	{
		theForm.__EVENTTARGET.value = eventTarget;
		theForm.__EVENTARGUMENT.value = eventArgument;
		var submitButton = document.getElementById(submitButtonId);
		if (submitButton != null)
		{
			if (submitButton.style.display != 'none')
			{
				submitButton.focus();
			}
			submitButton.click();
		}
	}
}

var sliderMapping = [];
function SearchSliderPostback(id,lv,rv) {
	document.getElementById(sliderMapping[id].min).value = lv;
	document.getElementById(sliderMapping[id].max).value = rv;
	__doPostBack(sliderMapping[id].max, '');
}

// Registers a onHide method for a modalpopup panel to avoid flickering when exiting a page
function RegisterOnModalPopupHide(behaviourID) {
  $find(behaviourID).add_hidden(function(source, args)
  {
		obj = document.getElementById(source._PopupControlID);
		if (obj)
		  obj.style.display = 'none';
  });
}

// Toggles multiple checkboxes for given name, depending on the checked state of the given object
var toggleMultipleCheckboxes = function (obj, name) {
	$("input[name='"+name+"']").attr("checked", obj.checked);
}

/* Find the position of an element */
function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do 
		{
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function setInvisible(elementID) 
{
	obj = document.getElementById(elementID);
	obj.style.visibility = 'hidden';
	popupClose();
}

function setCollapsed(elementID) 
{
	obj = document.getElementById(elementID);
	if (obj)
		obj.style.display = 'none';
}


// sets a given object in the dom visible/invisible. 
function toggleVisible(elementID, anchorElementID)
{
	var curleft = curtop = 0;
	
	var anchor = document.getElementById(anchorElementID);
	if (anchor.offsetParent) {
		do 
		{
				curleft += anchor.offsetLeft;
				curtop += anchor.offsetTop;
		} while (anchor = anchor.offsetParent);
	}
	
	obj = document.getElementById(elementID);
	obj.style.top = curtop + 'px';
	obj.style.left= (curleft + 20) + 'px';
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
	
	if(_openedToolTip != null && _openedToolTip != obj)
		_openedToolTip.style.visibility = "hidden";
	
	if(obj.style.visibility == 'visible')
	{
		popupOpen(obj);
	}
	else
	{
		popupClose();
	}
	
	_openedToolTip = obj;
}

function toggleVisibleUp(elementID, anchorElementID)
{
	var curleft = curtop = 0;
	
	var anchor = document.getElementById(anchorElementID);
	if (anchor.offsetParent) {
		do 
		{
				curleft += anchor.offsetLeft;
				curtop += anchor.offsetTop;
		} while (anchor = anchor.offsetParent);
	}

	obj = document.getElementById(elementID);
	obj.style.top = (curtop - obj.offsetHeight) + 'px';
	obj.style.left= (curleft) + 'px';
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
	
	if(_openedToolTip != null && _openedToolTip != obj)
		_openedToolTip.style.visibility = "hidden";
	
	if(obj.style.visibility == 'visible')
	{
		popupOpen(obj);
	}
	else
	{
		popupClose();
	}
	
		_openedToolTip = obj;
}

function CallPrint(strid)
{
	var prtContent = document.getElementById(strid);
	var WinPrint =
	window.open('', '', 'left=2,top=2,width=350,height=200,toolbar=0,scrollbars=1,status=0');
	var txthtml = prtContent.innerHTML;
	var txtcss1 = '<link rel="stylesheet" href="/css/print.css" media="all" /></head><body>';
	var txtinit = '<html><head>';
	var txtend = '</body></html>';
	WinPrint.document.write(txtinit + txtcss1 +  txthtml + txtend );
	WinPrint.document.close();
	WinPrint.focus();
	WinPrint.print();
	WinPrint.close();
}

function popupOpen(popup) {
	if(!isIE6)
		return;
		
	if(_hiddenSelectboxes != null) {
		// show hidden selectboxes
		menuShowHiddenSelectBoxes();
	}
	
	if(_hiddenElements != null)
	{	
		for(var i = 0; i < _hiddenElements.length; i++) 
		{
			_hiddenElements[i].style.visibility = "visible";
		}
	}
	
	
	// get all direct submenu items
	var subItems = popup.getElementsByTagName("div");
	
	// get all select boxes on the page
	var selectboxes = document.getElementsByTagName("select");
	
	// check if any of this selectboxes if overlapped by a 
	// submenu item.
	_hiddenElements = new Array();
	for(var i = 0; i < selectboxes.length; i++) {
		var selectBox = selectboxes[i];
		
		for(var k = 0; k < subItems.length; k++) {
			var li = subItems[k];
			
			if(elementOverlapsObject(li, selectBox)) {
				_hiddenElements.push(selectBox);
				break;
			}
		}
	}
	
	// hide all dropdown boxes
	//_hiddenSelectboxes = selectboxes;
	
	// hide all overlapped dropdown boxes
	for(var i = 0; i < _hiddenElements.length; i++) {
		_hiddenElements[i].style.visibility = "hidden";
	}
}

function popupClose()
{
	if(_hiddenElements == null)
		return;
		
	for(var i = 0; i < _hiddenElements.length; i++) 
	{
		_hiddenElements[i].style.visibility = "visible";
	}
		
	_hiddenElements = null;
}

function JPMeetingOnLoad(iframe)
{
//	if(iframe.contentDocument)
//		iframe.style.height = '1350px';
//	else
//		iframe.style.height = '1350px';
}