window.addEvent('domready', function(){
	
	$$('.minister-button').each( function(el,i){
	el.addClass('cursoractive');	
	});
	
	$$('input.datehere').each( function(el){
		new SlimPicker(el);
	});
	
	// Rounded Corners
	var flikrRoundedCorners = new RoundedCorners('.homerightcol .flickr ul li a img');
	var quoteRoundedCorners = new RoundedCorners('.home2col .homeleftcol .quotemain img');
	var promoRoundedCorners = new RoundedCorners('.home2col .homeleftcol .promomain img');
	var listnewsRoundedCorners = new RoundedCorners('.home2col .homerightcol .listnews ul li img');
	var relatedlinksRoundedCorners = new RoundedCorners('.relatedlinks ul li img');
 	var listinfoRoundedCorners = new RoundedCorners('.home2col .homeleftcol .listinfo img');
	var newslist = new RoundedCorners('.newslist ul li a img');
	
	//external links
	$$('a[rel=external]').set('target', '_blank');
	
	var drawer = new Drawers('div.drawer-content', 'div.job_form h3', 
	{
		toggleClass: "open",
		//toggleText: "Hide",
		openDrawer: 1
	});
	
	var ministerDrawers = new Drawers('div.minister-content', 'h2.minister-button', 
	{
		toggleClass: "open",
		autoClose: true
	});
	

	// Adds access to enhanced region selector if JS enabled.
	if(!(navigator.userAgent.toLowerCase().indexOf('msie 6') != -1))
	{
		if($$('.headeroptions ul li.changeregion a')[0])
		{
			$$('.headeroptions ul li.changeregion a')[0].set(
				{
					'class' : 'mb',
					'rel' : 'width:600,height:510',
					'href' : '/selectregion.htm'
				});
		}
	}
	
	var languageSelector = new LanguageSelector('li.language', 'ul', 'li');

	var cover = new overlay();
	var box = new multiBox('mb', 
	{
		overlay: cover,
		showControls: false 		
	}); 
	
	//tooltips
	$$('.tooltip').setStyle('display','block');
	var myTips = new Tips('.tooltip');

	//search results table remove
	var searchResults = $$('.searchResults table');
	if(searchResults){
	    searchResults.each(function(el){el.destroy();});
	}

	
});

// Message box to ask if they really want to submit the job application.
function JobApplicationCheck()
{
	var response = confirm('Submit this Job Application?');
	if (response)
	{
		$('SubmitForm').value = 'true';
	}
	else
	{
		$('SubmitForm').value = 'false';
	}
}

// IE Properties sIFR error correction.
function resetZoom()
{
	if($('content'))
	{
		//alert("fire zoom");
		$('content').setStyle('zoom', 1);
	}
}

// sIFR

var FSAlbertBold = { src: '/flash/FSAlbertBold.swf' };

sIFR.activate(FSAlbertBold);

sIFR.replace(FSAlbertBold, {
  selector: 'h1.grey span.title-text',
  css: '.sIFR-root { color: #54534A; }',
  wmode: 'transparent',
  cursor: 'pointer'
});


sIFR.replace(FSAlbertBold, {
  selector: 'h2.grey span.title-text',
  css: '.sIFR-root { color: #54534A; }',
  wmode: 'transparent',
  cursor: 'pointer'
});
sIFR.replace(FSAlbertBold, {
  selector: 'p.grey span.title-text',
  css: '.sIFR-root { color: #54534A; }',
  wmode: 'transparent',
  cursor: 'pointer'
});
sIFR.replace(FSAlbertBold, {
  selector: 'h2.white span.title-text',
  css: '.sIFR-root { color: #FFFFFF; }',
  wmode: 'transparent',
  cursor: 'pointer'
});

sIFR.replace(FSAlbertBold, {
  selector: 'h3.white span.title-text',
  css: '.sIFR-root { color: #FFFFFF; }',
  wmode: 'transparent',
  cursor: 'pointer'
});

sIFR.replace(FSAlbertBold, {
  selector: 'h3.grey span.title-text',
  css: '.sIFR-root { color: #54534A; }',
  wmode: 'transparent',
  cursor: 'pointer'
});

sIFR.replace(FSAlbertBold, {
  selector: 'h3.blue span.title-text',
  css: '.sIFR-root { color: #00A0AF; }',
  wmode: 'transparent',
  cursor: 'pointer'
});

sIFR.replace(FSAlbertBold, {
  selector: 'h3.white span.title-text',
  css: '.sIFR-root { color: #FFFFFF; }',
  wmode: 'transparent',
  cursor: 'pointer'
});

function checkMaxLength(e,el)
{
	switch(e.keyCode){
	case 37: // left
	return true;
	case 38: // up
	return true;
	case 39: // right
	return true;
	case 40: // down
	return true;
	case 8: // backspace
	return true;
	case 46: // delete
	return true;
	case 27: // escape
	el.value='';
	return true
	}
	return (el.value.length<el.getAttribute("MaxLength"));
}
