/*	iframe resizing functions
 *	set document.domain = 'ffc.dev.venus.co.uk' - this is also set on load of survey page inside iframe

document.domain = 'ffc.dev.venus.co.uk';

function iframeResize(iframeWindow) {
	var iframeElement = parent.document.getElementById(iframeWindow.name);
	if (iframeWindow.document.height)	{
		iframeElement.style.height = iframeWindow.document.height + 35 + 'px';
   }
   else if (iframeWindow.document.documentElement.scrollHeight) {
		iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + 35 + 'px';
   }
}
 */


/* suckerfish functions 

sfHover = function() {
	var sfEls = document.getElementById('TopMenu').getElementsByTagName('ul');
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].parentNode.onmouseover = function() {
			this.lastChild.className += ' pshover';
		}
		sfEls[i].parentNode.onmouseout = function() {
			this.lastChild.className = this.lastChild.className.replace(new RegExp(' pshover\\b'), '');
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
*/

/* hide the country select go button and sub menu, if we can (as then suckerfish will be working) 

hideNonJS = function() {
	var cGo = document.getElementById('CountryGo');
	if (cGo) cGo.style.display = 'none';
	var subEl = document.getElementById('SubMenu');
	if (subEl) subEl.style.display = 'none';
}
window.onload = hideNonJS;
*/

/* other functions */

function printPage() {
	window.print(); 
}

function doSelectedValue(valueField, selectField)	{
	var selObj = getObj(selectField);
	var valObj = getObj(valueField);
	valObj.value = selObj.options[selObj.selectedIndex].value;
}

function doShow(thisObj, elID, fieldID)	{
	var elObj = getObj(elID);
	elObj.style.visibility = 'visible';
	if (thisObj.checked === true) doFocus(fieldID);
}

function doHide(elID)	{
	var elObj = getObj(elID);
	elObj.style.visibility = 'hidden';
}

function doToggle(thisObj, elID, fieldID)	{
	var elObj = getObj(elID);
	if (thisObj.checked === true)	{
		elObj.style.visibility = 'visible';
		doFocus(fieldID);
	} else {
		elObj.style.visibility = 'hidden';
	}
}

function doFocus(fieldID)	{
	var fieldObj = getObj(fieldID);
	fieldObj.focus();
}

function doOpenLecture(winPath) {
	var winHeight = 560;
	var winWidth = 625;
	var openWindow = window.open(winPath, 'IBMSCongressLecture', 'location=0,toolbar=0,history=0,height=' + winHeight + ',width=' + winWidth + ',resizable=1,scrollbars=0');
	openWindow.focus();
}

function doOpenWindow(windowType) {
	var objPopup = document.getElementById('popUp' + windowType);
	var objScrim = document.getElementById('popUpScrim');
	objPopup.style.display = 'block';
	objScrim.style.display = 'block';
}

function doCloseWindow(windowType) {
	var objPopup = document.getElementById('popUp' + windowType);
	var objScrim = document.getElementById('popUpScrim');
	objPopup.style.display = 'none';
	objScrim.style.display = 'none';
}

function addBookmark(pageTitle, urlAddress)	{
	if (window.sidebar)	{
		window.sidebar.addPanel(pageTitle, urlAddress, '');
	} else if (window.external)	{
		window.external.AddFavorite(urlAddress, pageTitle);
	} else if (window.opera && window.print) {
		return true;
	}
}

function addMozillaBookmark(pageTitle, urlAddress)	{
	window.sidebar.addPanel(pageTitle, urlAddress, '');
}

function addIEBookmark(pageTitle, urlAddress)	{
	window.external.AddFavorite(urlAddress, pageTitle);
}

function addOperaBookmark()	{
	return true;
}

function doSetParam(urlParam, paramValue) {
    var hrefArray = document.location.href.split('&');
    var isReplaced = false;
    for (var i in hrefArray)	{
    	if (hrefArray[i].substr(0, urlParam.length + 1) == urlParam + '=')	{
    		hrefArray[i] = urlParam + '=' + paramValue;
    		isReplaced = true;
    		break;
    	}
    }
    if (isReplaced)	{
    	document.location.href = hrefArray.join('&');
    } else {
    	document.location.href += '&' + urlParam + '=' + paramValue;
    }
}

function doRemoveParam(urlParam) {
    var hrefArray = document.location.href.split('&');
    for (var i in hrefArray)	{
    	if (hrefArray[i].substr(0, urlParam.length + 1) == urlParam + '=')	{
    		hrefArray.splice (i, 1);
    		break;
    	}
    }
    document.location.href = hrefArray.join('&');
}

function doClearSelector(boxMax) {
    for (var i=0;i<boxMax;i++)	{
    	var theBox = getObj('PBox' + i);
		theBox.checked = false;
    }
}

function getObj(objID) {
	var theObj = document.getElementById(objID);
	if (!theObj) return false;
	return theObj;
}