function doSearch() {
	searchText=document.getElementById("input_search").value;
	document.location.href="/pages/programmes/search?term="+searchText;
}
			
function NewWindow(mypage, myname, w, h, scroller, formname, dayfield, monthfield, yearfield) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroller+',resizable'
win = window.open(mypage+'?form='+formname+'&dayfield='+dayfield+'&monthfield='+monthfield+'&yearfield='+yearfield, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function NewWindowStd(mypage, myname, w, h) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=Yes,resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function fnOpenWindowImage(strURL, strName, iWidth, iHeight){
	var objWin = window.open(strURL, strName, 'toolbar=false,status=false,width='+iWidth+',height='+iHeight+',resizable=false,left=100,top=100');
	/*objWin.document.write('<table cellpadding="0" cellspacing="0" style="border:0; height:100%; width:100%;"><tr><td style="text-align:center; vertical-align:middle;">');
	objWin.document.write('<img src="' + strURL + '" alt="" />');
	objWin.document.write('</td></tr></table>');*/
	objWin.focus();
}

function fnPSKEpisodeChange(sMID) {
	var objEpi = document.getElementById("selEpisode");

	if (objEpi.options[objEpi.selectedIndex].value == 0) {
		window.location.href = 'programmes-publicity?MID=' + sMID;
	}
	else
	{
		window.location.href = 'programmes-publicity?MID=' + sMID + '&epi=' + objEpi.options[objEpi.selectedIndex].value;
	}
}

function setSessionTimeout()
{
var t=setTimeout("alertTimeout()",1200000);
}
function alertTimeout()
{
alert("You have been logged out of the site as you have been inactive for longer than 20 minutes. Please log back in to continue browsing.");
document.forms["formLogin"].submit();
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=600,left = 660,top = 305');");
}

var dwDefaults = new Class({
	//implements
	Implements: [Options],

	//options
	options: {
		collection: $$('input[type=text]')
	},
	
	//initialization
	initialize: function(options) {
		//set options
		this.setOptions(options);
		this.defaults();
	},
	
	//a method that does whatever you want
	defaults: function() {
		this.options.collection.each(function(el) {
			el.set('value',el.get('rel'));
			el.addEvent('focus', function() { if(el.get('value') == el.get('rel')) { el.set('value',''); } });
			el.addEvent('blur', function() { if(el.get('value') == '') { el.set('value',el.get('rel')); } });
		});
	}
	
});

window.addEvent('domready', function() {

	SqueezeBox.initialize();

	SqueezeBox.assign($$('a[rel=boxed][href^=#]'), {
		//size: {x: 600, y: 400},
		//onShow: function() {firstChild.style.visibility = 'visible';return false;}
		onOpen: function() {document.getElementById('sbox-content').firstChild.style.display = 'block';var tabs = new SimpleTabs('sbox-content', {selector: 'h2'});tabs.select(0);return false;}//,
		//onClose: function() {firstChild.style.visibility = 'hidden';return false;}
	});  
	
	//SqueezeBox.initialize();

	SqueezeBox.assign($$('a[rel=boxed2][href^=#]'), {
		//size: {x: 600, y: 400},
		//onShow: function() {firstChild.style.visibility = 'visible';return false;}
		onOpen: function() {document.getElementById('sbox-content').firstChild.style.display = 'block';var tabs = new SimpleTabs('sbox-content', {selector: 'h2'});tabs.select(2);return false;}//,
		//onClose: function() {firstChild.style.visibility = 'hidden';return false;}
	});  
	
	try {
	document.getElementById('box2login').style.display = 'none';
	document.getElementById('moologinbutton').style.display = 'block';
	}catch(e){}
	
	try {
	var accordion = new Accordion($$('.toggler'),$$('.epiGroupGroupage'), {
		opacity: true,
		onActive: function(toggler) { toggler.setStyle('color', '#0D5491');toggler.setStyle('font-weight', 'bold'); },
		onBackground: function(toggler) { toggler.setStyle('color', '#000000');toggler.setStyle('font-weight', 'normal'); }
	});
	}catch(e){}
	
	var defs = new dwDefaults({
		collection: $$('input.defs')
	});
	
	new FormCheck('formregister');
	
	try{
		var toggletSearch2Content = new Fx.Slide('tSearch2Content');
			if (location.href.indexOf('/pages/programmes/search') == -1)
			{
				toggletSearch2Content.hide();
			}
			
			$('tSearch2').addEvent('click', function(e){
				e.stop();
				toggletSearch2Content.toggle();
			})}catch(e){};  
});	
