

function grabObj(id) {
	if (document.getElementById(id)) return document.getElementById(id);
	return false;
}



function inputFocus(el,str) {
	if (el.value == str) {
		el.value	= '';
	}
}
function inputBlur(el,str) {
	if (el.value == '') {
		el.value	= str;
	}
}


var menuTimer;
function init_menu() {
// Only for IE6
	if (navigator.appVersion.indexOf('MSIE 6.0')<0) return;
	for(var i=1; grabObj('menu_'+i) ;i++) {
		if (grabObj('menu_'+i+'_content')) {
			grabObj('menu_'+i).onmouseout=function() {
				hideMenu(this);
			}
			grabObj('menu_'+i).onmouseover=function() {
				openMenu(this);
			}
			grabObj('menu_'+i+'_content').onmouseover=function() {
				clearMenuTimer();
//				alert(this.id);
			}
			grabObj('menu_'+i+'_content').onmouseout=function() {
				menuTimer=window.setTimeout("closeMenus()",500);
//				alert(this.id);
			}
		}
	}
}
function clearMenuTimer() {
	clearTimeout(menuTimer);
}
function hideMenu() {
	menuTimer=window.setTimeout("closeMenus()",500);
}
function closeMenus() {
	for(var i=1; grabObj('menu_'+i) ;i++) {
		if (grabObj('menu_'+i+'_content')) {
			grabObj('menu_'+i+'_content').style.display	= '';
		}
	}
}
function openMenu(el) {
	id=el.id+'_content';
	for(var i=1; grabObj('menu_'+i) ;i++) {
		if (grabObj('menu_'+i+'_content')) {
			grabObj('menu_'+i+'_content').style.display	= '';
		}
	}
	grabObj(id).style.display	= 'block';
}

var minPopUpHeight	= 350;
function popUpInfo(el) {
	if (posFixedSupport()!==true) return true;	// will allow link to open as normal if fixed Positioning is not supported
	var popUpInfo=grabObj('popUpInfo');
	if (!popUpInfo) {
		var popUpInfoBG=document.createElement('div');
		popUpInfoBG.id='popUpInfoBG';
		popUpInfoBG.onclick=closePopUpInfo;
		var popUpInfoW=document.createElement('div');
		popUpInfoW.id='popUpInfoW';
		popUpInfoW.onclick=closePopUpInfo;
		var popUpInfo=document.createElement('div');
		popUpInfo.id='popUpInfo';
		popUpInfoW.appendChild(popUpInfo);
	}
	iFrame=document.createElement('iframe');
	iFrame.src=el.href+'?contentonly=1'
	iFrame.frameBorder='no';
	iFrame.style.border='none';
	iFrame.style.width='100%';
	iFrame.style.height='100%';
	popUpInfo.innerHTML='';

/* 30-11-10; LJB
	var popUpInfoClose=document.createElement('div');
	popUpInfoClose.appendChild(document.createTextNode('X'));*/
	var popUpInfoClose	= new Image();
	popUpInfoClose.id='closePopUp';
	popUpInfoClose.title='Close PopUp';
	popUpInfoClose.onclick=closePopUpInfo;
	popUpInfoClose.src=baseurl+'images/buttons/close.png';
	popUpInfo.appendChild(popUpInfoClose);

	popUpInfo.appendChild(iFrame);
	document.body.appendChild(popUpInfoBG);
// prevents the window from being too small
	if (parseFloat(popUpInfoBG.offsetHeight) < minPopUpHeight) return true;
	document.body.appendChild(popUpInfoW);

	popUpInfo.style.height=(parseFloat(popUpInfo.offsetHeight)-160)+'px';
	return false;
}
function closePopUpInfo(e) {
	grabObj('popUpInfoBG').parentNode.removeChild(grabObj('popUpInfoBG'));
	grabObj('popUpInfoW').parentNode.removeChild(grabObj('popUpInfoW'));
	try {
		window.event.cancelBubble = true;
	} catch (er) {
		e.stopPropagation();
	}
}



var videoObj;
/*
*/function initVid(vidCode,vidText) {
// changed to play automatically when started (pause:"0")
//	var videoVars={clip_id:vidCode,player_color1:"#c8c8c8",player_color:"#a6a6a6",transparent:"false",pause:"1",repeat:"",bg_color:"#FFFFFF",fs_mode:"2",no_fullscreen:"0",no_controls:"",start_img:"1",start_volume:"100",close_button:"",brand_new_window:"1",auto_hide:"",prebuffer:"",stretch_video:"",player_align:"NONE",offset_x:"",offset_y:"",bg_transp:"",player_color_ratio:0.6};
	if (vidText!='') {
		var testStr=vidText.toLowerCase();
		if (testStr.indexOf('<p')==-1) vidText='<p>'+vidText+'</p>';
		grabObj('vidText').innerHTML=vidText;
		var playVideo=false;
	} else {
		var playVideo=true;
	}
// removed rid as this was causing errors with new play() being run after opening the video box
//	var videoVars={clip_id:vidCode,player_color1:"#c8c8c8",player_color:"#a6a6a6",transparent:"true",pause:"1",repeat:"",bg_color:"#FFFFFF",fs_mode:"2",no_fullscreen:"0",no_controls:"",start_img:"1",start_volume:"100",close_button:"",brand_new_window:"1",auto_hide:"",prebuffer:"",stretch_video:"",player_align:"NONE",offset_x:"",offset_y:"",bg_transp:"",player_color_ratio:0.6,rid:"vidPlayer"};
	var videoVars={clip_id:vidCode,player_color1:"#c8c8c8",player_color:"#a6a6a6",transparent:"true",pause:"1",repeat:"",bg_color:"#FFFFFF",fs_mode:"2",no_fullscreen:"0",no_controls:"",start_img:"1",start_volume:"100",close_button:"",brand_new_window:"1",auto_hide:"",prebuffer:"",stretch_video:"",player_align:"NONE",offset_x:"",offset_y:"",bg_transp:"",player_color_ratio:0.6};
	videoObj=new SVPDynamicPlayer("vidPlayer", "", "640", "379", {use_div:"vidPlayer",skin:"2"}, videoVars);
	videoObj.execute();
	var fixedPos=posFixedSupport();
	grabObj('fullScreen').onclick=closeVideo;
	if (fixedPos===true) {
		grabObj('fullScreen').style.display='block';
	} else {
		grabObj('fullScreen').style.width=fixedPos['widthX']+'px';
		grabObj('fullScreen').style.height=fixedPos['widthY']+'px';
		grabObj('videoBoxWrapper').style.top=fixedPos['offsetY']+'px';
		grabObj('fullScreen').style.display='block';
	}
	grabObj('videoBoxWrapper').style.display='block';
	if (playVideo) openVideo();
}
function openVideo() {
	grabObj('playVideo').style.display='none';
	setTimeout("$('#vidPlayerWrapper').animate({'height' : ($('#vidPlayer').height())},'slow',null,playVideo)",10);
}
function playVideo() {
//	alert('Play Video Code should go in here!!!');
	videoObj.play('');
}
function closeVideo() {
	videoObj.destroy();
	grabObj('fullScreen').onclick='';
	grabObj('videoBoxWrapper').style.display='';
	grabObj('playVideo').style.display='';
	grabObj('fullScreen').style.display='';
	grabObj('vidPlayerWrapper').style.height='';
}

/* Test if fixed Position is Supported (taken from
											http://tadhg.com/wp/2007/03/29/checking-for-positionfixed-support/
											http://javascriptkit.com/javatutors/static3.shtml
										),
	if not supported then return client window data as Array
	arr[widthX]
	arr[widthY]
	arr[offsetX]
	arr[offsetY]
*/function posFixedSupport() {
	var testDiv = document.createElement("div");
	testDiv.id = "testingPositionFixed";
	testDiv.style.position = "fixed";
	testDiv.style.top = "0px";
	testDiv.style.right = "0px";
	document.body.appendChild(testDiv);
	var offset = 1;
	var supported = false;
	if (typeof testDiv.offsetTop == "number") {
		if (testDiv.offsetTop != null) {
			if (testDiv.offsetTop != "undefined") {
				offset = parseInt(testDiv.offsetTop);
			}
		}
	}
	if (offset === 0) {
		supported = true;
	}
	if (supported) return supported;
	var arr=Array();

	if (window.innerWidth) {
		arr['widthX']=window.innerWidth;
	} else if (document.body.clientWidth) {
		arr['widthX']=document.body.clientWidth;
	}

	if (window.innerHeight) {
		arr['widthY']=window.innerHeight;
	} else if (document.body.clientHeight) {
		arr['widthY']=document.body.clientHeight;
	}

var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
	arr['offsetX']=document.all? iebody.scrollLeft : pageXOffset;
	arr['offsetY']=document.all? iebody.scrollTop : pageYOffset
	return arr;
}


var altImgTimeout;
function altImg(state,img) {
	if (state=='over') {
		clearTimeout(altImgTimeout);
		grabObj('mainImg').src=img;
	} else {
// prevents flicker when moving between two images next to one another with a small gap
		altImgTimeout=setTimeout('altImgDefault()',100);
	}
	return
}
function altImgDefault() {
	grabObj('mainImg').src=defaultImg;
}

function printPopUp() {
	window.print();
	return false;
}

function chkSelect(int) {
	if (grabObj('selectdropdwn_'+int).options[grabObj('selectdropdwn_'+int).selectedIndex].value=='') {
		alert('Please select an option before continuing.');
		return false;
	}
	return true;
}

