

//tndc video control sctipts

videoWindowWidth  = 439;
videoWindowHeight = 520;
	
	function openVideoWindow(theVideoFile, theName, theTitle, theContent){
		//name the parent window
		self.name = 'tndc_main';
		
		//theConnectionSpeed = readCookie('videoConnectionSpeed');
		theConnectionSpeed = "";
		// test to see if there is a coookie that contains the connection speed
		if (theConnectionSpeed == ""){
			//videoWindow = window.open( 'video/video_speed.html', 'videoWindow', 'location=no,resizable=no,toolbar=no,status=no,width=' + videoWindowWidth + ',height=' + videoWindowHeight + ',scrollbars=no');
			videoWindow = window.open( '', 'videoWindow', 'location=no,resizable=no,toolbar=no,status=no,width=' + videoWindowWidth + ',height=' + videoWindowHeight + ',scrollbars=no');
			writeConnectionSpeedWindow(theVideoFile, theName, theTitle, theContent);
			videoWindow.focus();
		}else{


			if(theConnectionSpeed == "dialup"){
				theFileName = theVideoFile + "_sml.wmv";
			}else{
				theFileName = theVideoFile + "_lrg.wmv";
			}
			
			if(gPathtoImageDir == '../images/'){
				rootPath = '../'
			}else if(gPathtoImageDir == '../../images/'){
				rootPath = '../../'
			}else{
				rootPath = ''
			}

			videoWindow = window.open( '', 'videoWindow', 'location=no,resizable=no,toolbar=no,status=no,width=' + videoWindowWidth + ',height=' + videoWindowHeight + ',scrollbars=no');						
			writeVideoWindow(theFileName, theName, theTitle, rootPath);
			videoWindow.focus();
		}
	}

	
	
		
	function playVideo(){
		if (document.videoProfile.PlayState < 3){
			document.videoProfile.Play();
		}
	}
	function pauseVideo(){
		if (document.videoProfile.PlayState == 2){
			document.videoProfile.Pause();
		}
	}
	function stopVideo(){
			document.videoProfile.Stop();
	}



	function selectSpeed(connectionSpeed, theVideoFile, theName, theTitle, theContent){
			
		theConnectionSpeed = connectionSpeed;
		if(theConnectionSpeed == "dialup"){
			theFileName = theVideoFile + "_sml.wmv";
			//writeCookie("videoConnectionSpeed", "dialup", 24);
		}else{
			theFileName = theVideoFile + "_lrg.wmv";
			//writeCookie("videoConnectionSpeed", "broadband", 24);
		}
			
		writeVideoWindow(theFileName, theName, theTitle, theContent);
	
	}



	function writeConnectionSpeedWindow(theVideoFile, theName, theTitle, theContent){	
	
		if(gPathtoImageDir == '../images/'){
			rootPath = '../'
		}else if(gPathtoImageDir == '../../images/'){
			rootPath = '../../'
		}else{
			rootPath = ''
		}
		
		var newContent = '<html>\n<head> \n'
		newContent += '<link href="' + rootPath + 'scripts/tndc_styles.css" rel="stylesheet" type="text/css"> \n'
		newContent += '<scr' + 'ipt language=JavaScript src="' + rootPath + 'scripts/video_control.js"></scr' + 'ipt> \n'
		newContent += '<title>TNDC Video Profile : Choose Connection Speed</title>\n</head> \n'
		newContent += '<body leftmargin=0 topmargin=0 marginheight=0 marginwidth=0 bgcolor=#FFFFFF> \n'
		newContent += '<table width=439 height=520 cellpadding=0 cellspacing=0 border=0 background="' + rootPath + 'images/interface/video_background.jpg"> \n'
		newContent += '<tr align=left valign=top><td width=28 height=80>&nbsp;</td><td width=320>&nbsp;</td><td width=91>&nbsp;</td></tr> \n'
		newContent += '<tr align=left valign=top><td width=28 height=62>&nbsp;</td><td width=320> \n'
		newContent += '<div class=videoWindowTitle>TNDC Video</div> \n <div class=videoWindowText>Choose your connection speed:</div> \n'
		newContent += '</td><td width=91>&nbsp;</td></tr> \n'
		newContent += '<tr align=left valign=top><td width=28 height=290>&nbsp;</td><td width=320 class=contentPagesText> \n'
		newContent += '<img src="' + rootPath + 'images/interface/spacer.gif" width=320 height=25 border=0><br> \n'
		newContent += '<a href="javaScript:selectSpeed(\'dialup\', \'' + theVideoFile + '\', \'' + theName + '\', \''+ theTitle + '\', \'' + rootPath +'\');"><img src="' + rootPath + 'images/interface/dialup_button.gif" border=0></a> &nbsp; \n'
		newContent += '<a href="javaScript:selectSpeed(\'broadband\', \'' + theVideoFile + '\', \'' + theName + '\', \''+ theTitle + '\', \'' + rootPath +'\');"><img src="' + rootPath + 'images/interface/broadband_button.gif" border=0></a> &nbsp; \n'
		newContent += '<img src="' + rootPath + 'images/interface/spacer.gif" width=320 height=75 border=0><br> \n'
		newContent += 'TNDC Videos require Windows Media Player<br>Series 9 or greater to view.<br> \n'
		newContent += '<a href="http://windowsmedia.com/download" target="_blank"><img src="http://www.microsoft.com/windows/windowsmedia/images/Download_88x31_static.gif" width=88 height=31 vspace=7 border=0 alt="Get Windows Media Player"></a> \n'
		newContent += '</td><td width=91>&nbsp; \n </td></tr> \n'		
		newContent += '<tr align=left valign=top><td width=28 height=88>&nbsp;</td><td width=320>&nbsp;</td><td width=91><a href="/give/donate_redirect.html" target="_blank"><img src="' + rootPath + 'images/interface/video_quickdonate.gif" border="0"></a></td></tr> \n'
		newContent += '</table>\n</body>\n</html>'

		videoWindow.document.write(newContent);
		videoWindow.document.close();
		
	}


	function writeVideoWindow(theFileName, theName, theTitle, theContent){	
	
		rootPath = theContent;	
		
		var newContent = '<html>\n<head> \n'
		newContent += '<link href="' + rootPath + 'scripts/tndc_styles.css" rel="stylesheet" type="text/css"> \n'
		newContent += '<scr' + 'ipt language=JavaScript src="' + rootPath + 'scripts/video_control.js"></scr' + 'ipt> \n'
		newContent += '<title>TNDC Video Profile : ' + theName + '</title>\n</head> \n'
		newContent += '<body leftmargin=0 topmargin=0 marginheight=0 marginwidth=0 bgcolor=#FFFFFF> \n'
		newContent += '<table width=439 height=520 cellpadding=0 cellspacing=0 border=0 background="' + rootPath + 'images/interface/video_background.jpg"> \n'
		newContent += '<tr align=left valign=top><td width=28 height=80><img src="' + rootPath + 'images/interface/spacer.gif" width=28 height=80 border=0></td><td width=320>&nbsp;</td><td width=91>&nbsp;</td></tr> \n'
		newContent += '<tr align=left valign=top><td width=28 height=62>&nbsp;</td><td width=320> \n'
		newContent += '<div class=videoWindowTitle>' + theName + '</div> \n <div class=videoWindowText>' + theTitle + '</div> \n'
		newContent += '</td><td width=91>&nbsp;</td></tr> \n'
		newContent += '<tr align=left valign=top><td width=28 height=290>&nbsp;</td><td width=320> \n'
		newContent += '<object id="videoProfile" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" \n'
		newContent += 'classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" \n'
		newContent += 'standby="Loading Microsoft Media Player components..." \n'
		newContent += 'type="application/x-oleobject" \n'
		newContent += 'background=black \n color=black \n bgcolor=black \n width=320 \n height=264> \n'
		newContent += '<param name=FileName value="' + rootPath + 'video/' + theFileName + '"> \n'
		newContent += '<param name=ShowControls value=0> \n'
		newContent += '<param name=ShowAudioControls value=0> \n'
		newContent += '<param name=ShowPositionControls value=0> \n'
		newContent += '<param name=ShowTracker value=0> \n'
		newContent += '<param name=ShowStatusBar value=1> \n'
		newContent += '<param name=ShowGotoBar value=0> \n'
		newContent += '<param name=AutoStart value=1> \n'
		newContent += '<param name=autosize value=0> \n'
		newContent += '<param name=AllowChangeDisplaySize value=0> \n'
		newContent += '<param name=EnableContextMenu value=0> \n'
		newContent += '<param name=showDisplay value=0> \n'
		newContent += '<param name=SendPlayStateChangeEvents value=1> \n'
		newContent += '<param name=EnableFullScreenControls value=0> \n'
		newContent += '<param name=TransparentAtStart value=0> \n'
		newContent += '<param name=AnimationAtStart value=0> \n'
		newContent += '</object> \n </td><td width=91> \n <table cellpadding=0 cellspacing=0 border=0><tr><td width=15></td><td> \n'
		newContent += '<img src="' + rootPath + 'images/interface/spacer.gif" width=77 height=53 border=0><br> \n'
		newContent += '<a href="#"><img onClick="playVideo()" src="' + rootPath + 'images/interface/video_play.gif" width=35 height=35 border=0></a><br> \n'
		newContent += '<img src="' + rootPath + 'images/interface/spacer.gif" width=77 height=11 border=0><br> \n'
		newContent += '<a href="#"><img onClick="pauseVideo()" src="' + rootPath + 'images/interface/video_pause.gif" width=35 height=35 border=0></a><br> \n'
		newContent += '<img src="' + rootPath + 'images/interface/spacer.gif" width=77 height=11 border=0><br> \n'
		newContent += '<a href="#"><img onClick="stopVideo()" src="' + rootPath + 'images/interface/video_stop.gif" width=35 height=35 border=0></a><br> \n'
		newContent += '</td></tr></table> \n'
		newContent += '</td><td width=91>&nbsp; \n </td></tr> \n'		
		newContent += '<tr align=left valign=top><td width=28 height=88>&nbsp;</td><td width=320>&nbsp;</td><td width=91><a href="/give/donate_redirect.html" target="_blank"><img src="' + rootPath + 'images/interface/video_quickdonate.gif" border="0"></a></td></tr> \n'
		newContent += '</table>\n</body>\n</html>'

		document.write(newContent);
		document.close();
		
	}

// connection speed cookie scripts


// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}


// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

	