function toggle(div_id, vidname, tog) {

	var el = document.getElementById(div_id);
	var sP = '';

	if ( el.style.display == 'none' || !tog ) 
		{	el.style.display = 'block';
			sP = sP + '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="352" height="280" id="hwa" align="middle">';
			sP = sP + '<param name="allowScriptAccess" value="sameDomain" />';
			sP = sP + '<param name="FlashVars" value="videoURL=/Videos/FLV/' + vidname +'" />';
			sP = sP + '<param name="movie" value="hwa.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
			sP = sP + '<embed src="hwa.swf" quality="high" bgcolor="#ffffff" width="352" height="280" name="hwa" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="videoURL=/Videos/FLV/' + vidname +'" />';
			sP = sP + '</object>';
			
			document.getElementById('vHolder').innerHTML = sP;
			}
	else 
		{el.style.display = 'none'; 
			document.getElementById('vHolder').innerHTML='';}

}

function blanket_size(popUpDivVar) {

	if (typeof window.innerWidth != 'undefined') {

		viewportheight = window.innerHeight;

	} else {

		viewportheight = document.documentElement.clientHeight;

	}
	
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {

		blanket_height = viewportheight;

	} else {

	
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {

			blanket_height = document.body.parentNode.clientHeight;

		} else {

			blanket_height = document.body.parentNode.scrollHeight;

		}

	}

	var blanket = document.getElementById('blanket');

	blanket.style.height = blanket_height + 'px';

	var popUpDiv = document.getElementById(popUpDivVar);

	popUpDiv_height=blanket_height/2-285;//half popup height

	window.scroll(0, 0);
	//popUpDiv.style.top = popUpDiv_height + 'px';
	popUpDiv.style.top = '120px';

}

function window_pos(popUpDivVar) {

	if (typeof window.innerWidth != 'undefined') {

		viewportwidth = window.innerHeight;

	} else {

		viewportwidth = document.documentElement.clientHeight;

	}

	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {

		window_width = viewportwidth;

	} else {

		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {

			window_width = document.body.parentNode.clientWidth;

		} else {

			window_width = document.body.parentNode.scrollWidth;

		}

	}

	var popUpDiv = document.getElementById(popUpDivVar);

	window_width=window_width/2-180;//150 is half popups width

	popUpDiv.style.left = window_width + 'px';

}


function setDivItems(sPg, sNm, sId, vLs) {
	var vLsStr = '';
	var aLs = vLs.split('|');
	
	if (document.getElementById('blanket')) {
		document.getElementById('spkName').innerHTML = sNm;
		document.getElementById('spkName').href = '/speaker/'+sPg+'?Spea_ID='+sId;
		document.getElementById('spkPgVidLk').href = '/speaker/'+sPg+'?Spea_ID='+sId;
		//
		//
		for (i=0; i < aLs.length; i++) {
			aVid = aLs[i].split('+');
			
			vLsStr = vLsStr + '&middot; <a href="javascript:void(0);" onclick="setDivItems(\'' + sPg + '\', \'' + sNm + '\', \'' + sId + '\', \'' + vLs + '\'); popup(\'popUpDiv\', \'' + aVid[1] + '\', \'nohide\')">' + aVid[0] + '</a><br />';
		}
		document.getElementById('vList').innerHTML = vLsStr;
		document.getElementById('vLinksHeader').innerHTML = 'All videos with ' + sNm;
	}
}

function popup(windowname, vidname) {
	
	var tog = true;
	if (arguments.length > 2 && arguments[2]=='nohide') {
		tog = false;
	}

	blanket_size(windowname);

	window_pos(windowname);

	toggle('blanket', vidname, tog);

	toggle(windowname, vidname, tog);		

}


function VideoPop(url) {
	if (window.innerWidth != null) {
		theight = window.innerHeight - 50;
		twidth = window.innerWidth - 50;
	} else if (document.compatMode == 'CSS1Compat') {
		theight = document.documentElement.clientHeight - 50;
		twidth = document.documentElement.clientWidth - 50;
	} else {
		theight = document.body.clientHeight - 50;
		twidth = document.body.clientWidth - 50;
	}
	if (window.pausePlayer) {pausePlayer()}
	var theWin = window.open(url, 'VideoPlayer', 'height=600,width=500,menubar=0,scrollbars=1,resizable=1');
	if(!theWin || theWin.closed || typeof theWin == 'undefined' || typeof theWin.closed=='undefined')
	{
		alert('You may have a popup blocker preventing the video window from opening.');
	} else {
		theWin.moveTo(twidth/2 - 250,200);
		theWin.focus();	
	}
}

