var isSafari = /safari/i.test(navigator.userAgent);

function getPopMeasures(pW, pH) {
	if (isSafari) {
		pW += 0;
		pH += 1;
	}
	
	return 'width=' + pW +',' + 'height=' + pH;
}


function getExternalLinks() {
	$$('#wrapper a.external').each ( function(link) {
		link.onclick = function() {
			window.open(this.href);
			return false;
		}	
	} );
}

//News-Detail
function openNewsDetail(pID, pLang) {
	var newswin = self.open("/news-detail.php?newsID=" + pID + "&lang=" + pLang, "", "width=670, height=720 scrollbars=0, toolbars=0, resizable=0, status=1");
	newswin.focus();
}

function openSailZoomImage() {
	//$('zoomImage').onclick();
	Shadowbox.open( $('zoomImage') );
}

function openSailActionImage(num){
	//$('actionImage-' + num).onclick();
	Shadowbox.open( $('actionImage-' + num) );
}

//Team-Video
function openTeamVideo(pID) {

	if (Prototype.Browser.IE) {
		return openIETeamVideo(pID)
	}

	var url = '/video_detail.php';	
	var params = 'id=' + pID + '&ajax=1';
	new Ajax.Request(
		url,
		{
			method		:	'get',
			parameters	:	params,
			onComplete	:	showVideoPlayer
		}
	);

}

//Tech-Video
function openIETeamVideo(pID) {
	var vid = self.open('/video_detail.php?id=' + pID, 'vidwin','width=400, height=320, scrollbars=0, toolbar=0, status=0, resizable=0, location=0, top=50, left=50');
	vid.focus();
}

function showVideoPlayer(originalRequest) {
	if ( $('vp') ) {
		hideVideoPlayer();
	}
	new Insertion.Top( 'wrapper', originalRequest.responseText.strip() );
}

function hideVideoPlayer() {
	document.qt.Stop();
	$('wrapper').removeChild( $('vp') );
}

function openSoundPlayer() {
	var sp = window.open('/northtunes/', 'nt', 'width=160,height=200,scrollbars=0,toolbar=0,resizable=0,location=0');
	sp.focus();
}

function initShadowbox() {
	return;
	Shadowbox.init( {
		handleOversize	:	'resize',
		players			:	['img', 'html', 'swf', 'iframe']
	} );
}


function initJS() {
	getExternalLinks();
	//initSIFR();
	initShadowbox();
}

function initSIFR() {
	
	
	if(typeof sIFR == "function"){
		//alert('SIFR');
		
	    sIFR.replaceElement(
			"h2", 
			named( {
				sFlashSrc	: "/media/global/sIFR/h2.swf", 
				sColor		: "#222222",
				sCase		: 'upper',
				sWmode		: 'transparent'
			} )
		);
		
	}

}

var prevOnLoad = window.onload || function() {};

window.onload = function() {
	prevOnLoad();
	initJS();
}

