

// homepage flash
/*
if(_param == false){
	//so.addVariable('home','true');
	_fla = 'tpl/northernfilm/assets/flash/social.swf';
}else{
	_fla = 'tpl/northernfilm/assets/flash/economic.swf';
}
*/
if(_fla != '' && flash) var so = new SWFObject(_fla, 'header_anim', '610', '115', '8', '#FFFFFF');

$(window).load(function()
//$(window).load(function()
{
	if(_fla != ''){
		so.write('animation');
	}

	// Open external links in new window
	var _a = document.getElementsByTagName('a');

	for(var i = 0, l = _a.length; i < l; i++)
	{
		if(_a[i].getAttribute('rel') == 'external') _a[i].onclick = openInNewWindow;
		if(_a[i].getAttribute('rel') == 'external' &&
		  _a[i].className.indexOf('locations-popup')==0)
		  	_a[i].onclick = function() {openNewWindow(this.href, 'locations-popup', 567, 567); return false;}
		else if(_a[i].getAttribute('rel') == 'image') _a[i].onclick = imageWindow;
	}
});


// Create the new window
function openInNewWindow(e)
{
	var event = !e ? window.event : e

	// Abort if a modifier key is pressed
	if(event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return true;

	else
	{
		var newWindow = window.open(this.getAttribute('href'), '_blank');

		if(newWindow)
		{
			if(newWindow.focus) newWindow.focus();
			return false;
		}

		return true;
	}
}

function setFlashHeight(id, h){
	var container = document.getElementById(id);
	container.firstChild.style.height = h + 'px';
	container.style.height = h + 'px';
}

try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

function select_all(form,mode){
	_sel = document.getElementById(form).getElementsByTagName('input');

	if(mode){
		for(var i=0;i<_sel.length;i++){
			_sel[i].checked = true;
		}
	}else{
		for(var i=0;i<_sel.length;i++){
			_sel[i].checked = false;
		}
	}
}

function openNewWindow(strURL, strType, strWidth, strHeight, strName){
	var left = (screen.width/2) - strWidth/2;
 	var top = (screen.height/2) - strHeight/2;
	var strOptions="";
	if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
	if (strType=="console-scroll") strOptions="resizable,status,scrollbars,height="+strHeight+",width="+strWidth;
	if (strType=="fixed") strOptions="height="+strHeight+",width="+strWidth;
	if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,"+"resizable,location,height="+strHeight+",width="+strWidth;
	if (strType=="locations-popup") strOptions="resizable,height="+strHeight+",width="+strWidth;
	strOptions+=',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	newWin = window.open(strURL, strName, strOptions);
	newWin.focus();
}