// wrapperType 0 = no popup, no masthead
// wrapperType 1 = popup to size, with fat masthead, navigation menubar
// wrapperType 2 = no popup, with fat masthead
//				   (changed to popup, with toolbar, no address bar to mirror type 4)
// wrapperType 3 = popup to size, no masthead, no menubars
// wrapperType 4 = no popup, with skinny masthead
//				   (changed to popup, with toolbar, no address bar)
// wrapperType 5 = popup to size, with skinny masthead, navigation menubar
// wrapperType 6 = popup to size with skinny mast head and no navigation menubar
// wrapperType 7 = no popup, with fat masthead
// wrapperType 8 = same as 3 but for video player to eliminate multiple streams

function extLink(site,wrapperType,width,height,PZN) {
	var winName = Math.round(Math.random()*100000000);
	var currDate = new Date();
	var time = currDate.getMilliseconds();
	if (PZN) {
		var pznNow = new Date;
		var pznRnd = "&rnd=" + pznNow.getMilliseconds();
		var pznImg = "http://log.btopenworld.com/pzn/fw/pixel.gif?page=";
		var pznPage = "***"+PZN+"***";
		var pznImage = new Image;
		pznImage.src = pznImg + pznPage + pznRnd;
	}
	if (wrapperType==0) {
		var newurl = site;
		document.location = newurl;
	} else if (wrapperType==2) {
		var wrapperimage = "spacer.gif";
		var popupref='scrollbars=no,width=' + width + ',height=' + height + ',resizable=yes,toolbar=yes,location=no,directories=no,status=no,menubar=no,copyhistory=no,top=100,left=100';
		var newurl="[CURL /visp1/business/wrapperframe/new]??"+wrapperimage+'??'+site;
		window.open(newurl,winName,popupref);
	} else if (wrapperType==3) {
		var newurl = site;
		var popupref = window.open(newurl, winName, 'scrollbars=no,width=' + width + ',height=' + height + ',resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,top=50,left=50');
	} else if (wrapperType==4) {
		var newurl = site;
		var popupref = window.open(newurl, winName, 'scrollbars=yes,width=' + width + ',height=' + height + ',resizable=yes,toolbar=yes,location=no,directories=no,status=no,menubar=no,copyhistory=no,top=50,left=50');
	} else if (wrapperType==6) {
		var wrapperimage = "spacer.gif";
		var popupref='scrollbars=no,width=' + width + ',height=' + height + ',resizable=yes,toolbar=yes,location=no,directories=no,status=no,menubar=no,copyhistory=no,top=100,left=100';
		var newurl="[CURL /visp1/business/wrapperframe/new]??"+wrapperimage+'??'+site;
		window.open(newurl,winName,popupref);
	} else if (wrapperType==7) {
		var newurl = '[CURL /visp1/business/wrapperframe/ "csn=[SHOW showOID0]"]?site=' + escape(site);
		document.location = newurl;
	} else if (wrapperType==8) {
		var winName = "vidFeature";
		var newurl = site;
		var popupref = window.open(newurl, winName, 'scrollbars=no,width=' + width + ',height=' + height + ',resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,top=50,left=50');
	} else if (wrapperType==9) {
		var newurl = site;
		var popupref = window.open(newurl, winName, 'scrollbars=yes,width=' + width + ',height=' + height + ',resizable=no,toolbar=yes,location=no,directories=no,status=no,menubar=no,copyhistory=no,top=50,left=50');
	} else if (wrapperType==10) {
		var newurl = site;
		var popupref = window.open(newurl, winName, 'scrollbars=yes,width=' + width + ',height=' + height + ',resizable=yes,toolbar=yes,location=yes,directories=no,status=yes,menubar=no,copyhistory=no,top=50,left=50');
	} else {
		if (wrapperType==1) {
			var newurl = '[CURL /visp1/business/wrapperframe/ "csn=[SHOW showOID0]"]?site=' + escape(site);
		} else if (wrapperType==5) {
			var newurl = '[CURL /visp1/business/wrapperframe/skinny "csn=[SHOW showOID0]"]?site=' + escape(site);
		}
		if (wrapperType==1 || wrapperType==5) {
			var iw, ih; // Set inner width and height
			if (window.innerWidth == null) {
				iw = document.body.clientWidth;
				ih = document.body.clientHeight;
			} else {
				iw = window.innerWidth;
				ih = window.innerHeight;
			}
			if (width == null) width = iw;
			if (height == null) height = ih;
			pw = 100;
			ph = 100;
			bw = 24;
			bh = 24;
			var sw = Math.round((iw - bw) * pw / 100);
			var sh = Math.round((ih - bh) * ph / 100);
			if ((width * sh) / (height * sw) < 1) sw = Math.round(width * sh / height);
			else sh = Math.round(height * sw / width);
			var popupref = window.open(newurl, winName, 'scrollbars=no,width=' + width + ',height=' + height + ',resizable=yes,toolbar=yes,location=no,directories=no,status=no,menubar=no,copyhistory=no');
			popupref.focus();
		}
	}
}


function openWrapper(WrapperType, ExternalUrl, WrapperJS)
{
	if ((WrapperType == 'IntegratedMasthead') || (WrapperType == 'IntegratedApplication'))
	{
		window.location.href = ExternalUrl;
	}
	else if (WrapperType == 'FramesetApplication')
	{

		var num = WrapperJS.indexOf('|',0);
		var isimage = WrapperJS.substring(num+1,WrapperJS.length);
		if ((num != -1) && (isimage != ""))
		{
			var wrapperimage = WrapperJS.substring(num+1,WrapperJS.length);
		}
		else
		{
			var wrapperimage = "spacer.gif";
		}
		var wrapperWin1 = window.open('[CURL /visp1/glb/skinnyframe "csn=[SHOW showOID0]"]??'+wrapperimage+'??'+ExternalUrl,'BTopenworldApplication',WrapperJS);
	}
	else if (WrapperType == 'FramesetMasthead')
	{
		var wrapperWin = window.open('[CURL /visp1/glb/fatframe "csn=[SHOW showOID0]"]?'+ExternalUrl,'BTopenworldFrameset',WrapperJS);
	}
	else
	{
		var wrapperWin = window.open(ExternalUrl,'NoWrapper',WrapperJS);
	}
}


function openWrapperPZN(WrapperType, ExternalUrl, WrapperJS, PZN)
{

		
	var pznNow = new Date;
	var pznRnd = "&rnd=" + pznNow.getMilliseconds();
	var pznImg = "http://log.btopenworld.com/pzn/esp/pixel.gif?page=";
	var pznPage = "***"+PZN+"***";
	var pznImage = new Image;
	pznImage.src = pznImg + pznPage + pznRnd;	
		

	if ((WrapperType == 'IntegratedMasthead') || (WrapperType == 'IntegratedApplication'))
	{
		window.location.href = ExternalUrl;
	}
	else if (WrapperType == 'FramesetApplication')
	{

		var num = WrapperJS.indexOf('|',0);
		var isimage = WrapperJS.substring(num+1,WrapperJS.length);
		if ((num != -1) && (isimage != ""))
		{
			var wrapperimage = WrapperJS.substring(num+1,WrapperJS.length);
		}
		else
		{
			var wrapperimage = "spacer.gif";
		}
		var wrapperWin1 = window.open('[CURL /visp1/glb/skinnyframe "csn=[SHOW showOID0]"]??'+wrapperimage+'??'+ExternalUrl,'BTopenworldApplication',WrapperJS);
	}
	else if (WrapperType == 'FramesetMasthead')
	{
		var wrapperWin = window.open('[CURL /visp1/glb/fatframe "csn=[SHOW showOID0]"]?'+ExternalUrl,'BTopenworldFrameset',WrapperJS);
	}
	else
	{
		var wrapperWin = window.open(ExternalUrl,'NoWrapper',WrapperJS);
	}
}



//service status function included...
function servicestatus(url)
{

	if (document.all) 
	{
	window.open(url, 'btconnect', 'scrollbars=yes,width=530,height=600,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,top=50,left=50').focus();
	}
	else 
	{
	window.open(url, 'btconnect', 'scrollbars=yes,width=530,height=600,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,top=50,left=50,alwaysRaised=yes');
	}

}
