﻿// JScript File
var viccacWin = 'viccacWin';

function WindowOpenEmail(aType,aUser,aDomainOrSubject,aBody,aSubject)
{
    var Form = rootPath() + "Email/Email.aspx";
    if (aType == 0)  Form += "?User="+aUser+"&Sub="+aDomainOrSubject+"&Body="+aBody;
    else Form += "?User="+aUser+"&Domain="+aDomainOrSubject+"&Body="+aBody+"&Sub="+aSubject; 
    window.open(Form,'myWin','toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,width=700,height=580');
}

function WindowOpen(aForm)
{
    var rp = rootPath();
    window.open(rootPath()+aForm,viccacWin,'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1');
}

function WindowOpenSource(aSource)
{
    window.open(aSource,viccacWin,'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1');
}

function currentPath() {
    return window.location.href.substring(0, window.location.href.lastIndexOf("/")+1);
}

function rootPath() {
//    var port;
//    port = window.location.port;
//    if (port == '' || port == 80) {
//        return '/';
//    }
//    else {
//        var root;
//        root = window.location.href.substring(window.location.href.indexOf('//')+2);
//        root = root.substr(root.indexOf('/')+1);
//        root = root.substr(0,root.indexOf('/'));
//        return "/"+root+"/";
//    }

    var root;
    if (window.location.hostname.toLowerCase() == 'localhost')
    {
        root = window.location.href.substring(window.location.href.indexOf('//')+2);
        root = root.substr(root.indexOf('/')+1);
        root = root.substr(0,root.indexOf('/'));
        return "/"+root+"/";
    }
    else
    {
        return '/';
    }
}

//Start Media Player
function MediaPlayer_Class(p_tblBody)
{
	var m_tblMediaPlayerBody = document.getElementById(p_tblBody)
	this.SetTableBody = SetTableBody;
	this.MediaPlayerClick = MediaPlayer_Click;
	this.writeWMPlayer = writeWMPlayer;
	
	function SetTableBody(p_tblBody)
	{
		m_tblMediaPlayerBody = document.getElementById(p_tblBody);
	}

	function MediaPlayer_Click(p_MovieClip) 
	{
		var movie = 'Clips/vcac30Anniversary.wmv';
		if (typeof p_MovieClip != "undefined") movie = p_MovieClip;
		
		oTR = m_tblMediaPlayerBody.insertRow(0);
		//Populate Cells
		oTD = populateCell(oTR, writeWMPlayer(true,movie,true));
		oTD.align="center";
		oTD.style.Align="center";

		deleteTableRows(m_tblMediaPlayerBody,1);

	}

	// populate cell
	function populateCell(tr,col) {
		td = tr.insertCell(0);
		td.innerHTML = col;
		return td;
	}
									
	//Clear the table
	function deleteTableRows(objTableBody,p_row){
		var rowCount = 0;
		if (typeof p_row != "undefined") rowCount = p_row;
		while (rowCount < objTableBody.rows.length){
			objTableBody.deleteRow(rowCount);
		}
	}									
			
	function checkWMP7()
	{
		var WMP7;
		try {
		if(window.ActiveXObject)
		{	
				// Windows Media Player 7 Code
				WMP7 = new ActiveXObject("WMPlayer.OCX.7");
			}
			else if (window.GeckoActiveXObject)
			{
				// Windows Media Player 7 Code
				WMP7 = new GeckoActiveXObject("WMPlayer.OCX.7");
			}
		}
		catch(e)
		{
			// Handle error -- no WMP 7 or 9 control
			// Can use WMP 6 also if necessary, but this is legacy software nowadays
			WMP7 = false;
		}
		return WMP7;
	}

	function writeWMPlayer(p_autoStart,p_MovieClip,p_text)
	{
		var WMP7 = checkWMP7();
		var movie = new String('Clips/vcac30Anniversary.wmv');
		if (typeof p_MovieClip != "undefined") movie = p_MovieClip;
		var retText = false;
		var ret = new String();
		if (typeof p_text != "undefined") retText = p_text;
		
		// Windows Media Player 7 Code
		if ( WMP7 )
		{
			if (retText) {
				ret += '<OBJECT ID=MediaPlayer width="400" height="300" runat="server" '; 
				ret += ' CLASSID=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6';
				ret += ' standby="Loading Microsoft Windows Media Player components..."';
				ret += ' TYPE="application/x-oleobject" >';
				ret += '<PARAM NAME="url" VALUE="' + movie + '">';
				if (p_autoStart) ret += '<PARAM NAME="AutoStart" VALUE="true">';
				else ret += '<PARAM NAME="AutoStart" VALUE="false">';
				ret += '<PARAM NAME="ClickToPlay" VALUE="true">';
				ret += '<PARAM NAME="ShowControls" VALUE="true">';
				ret += '<PARAM NAME="uiMode" VALUE="full">';
				
				ret += '</OBJECT>';
			}
			else {
				document.write ('<OBJECT ID=MediaPlayer width="400" height="300" runat="server" ');
				document.write (' CLASSID=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6');
				document.write (' standby="Loading Microsoft Windows Media Player components..."');
				document.write (' TYPE="application/x-oleobject" >');
				document.write ('<PARAM NAME="url" VALUE="' + movie + '">');
				if (p_autoStart) document.write ('<PARAM NAME="AutoStart" VALUE="true">');
				else document.write ('<PARAM NAME="AutoStart" VALUE="false">');
				ret += '<PARAM NAME="ClickToPlay" VALUE="true">';
				document.write ('<PARAM NAME="ShowControls" VALUE="true">');
				document.write ('<PARAM NAME="uiMode" VALUE="full">');
				document.write ('</OBJECT>');
			}
		}

		// Windows Media Player 6.4 Code
		else
		{
			//IE Code
			if (retText) {
				ret += '<OBJECT ID=MediaPlayer runat="server" ';
				ret += 'CLASSID=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 ';
				ret += 'CODEBASE=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ';
				ret += 'standby="Loading Microsoft Windows Media Player components..." ';
				ret += 'TYPE="application/x-oleobject" width="400" height="300" VIEWASTEXT>';
				ret += '<PARAM NAME="FileName" VALUE="' + movie + '">';
				if (p_autoStart) ret += '<PARAM NAME="AutoStart" VALUE="true">';
				else ret += '<PARAM NAME="AutoStart" VALUE="false">';
				ret += '<PARAM NAME="ClickToPlay" VALUE="true">';
				ret += '<PARAM NAME="ShowControls" VALUE="true">';

				//Netscape code
				ret += '    <Embed type="application/x-mplayer2" id="MediaPlayer"';
				ret += '        pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"';
				ret += '        src="' + movie + '"';
				ret += '        Name="MediaPlayer"';
				if (p_autoStart) ret += '        AutoStart="1"';
				else ret += '        AutoStart="0"';
				ret += '        ShowControls="1"';
				//document.write ('        ShowDisplay="1"');
				ret += '        ShowStatusBar="1"';
				ret += '        width="400"';
				ret += '        height="300">';
				ret += '    </embed>';
				ret += '</OBJECT>';
			}
			else {
				document.write ('<OBJECT ID=MediaPlayer runat="server"');
				document.write ('CLASSID=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 ');
				document.write ('CODEBASE=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ');
				document.write ('standby="Loading Microsoft Windows Media Player components..." ');
				document.write ('TYPE="application/x-oleobject" width="400" height="300" VIEWASTEXT>');
				document.write ('<PARAM NAME="FileName" VALUE="' + movie + '">');
				if (p_autoStart) document.write ('<PARAM NAME="AutoStart" VALUE="true">');
				else document.write ('<PARAM NAME="AutoStart" VALUE="false">');
				document.write ('<PARAM NAME="ShowControls" VALUE="1">');

				//Netscape code
				document.write ('    <Embed type="application/x-mplayer2" id="MediaPlayer"');
				document.write ('        pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"');
				document.write ('        src="' + movie + '"');
				document.write ('        Name="MediaPlayer"');
				if (p_autoStart) document.write ('        AutoStart="1"');
				else document.write ('        AutoStart="0"');
				document.write ('        ShowControls="1"');
				//document.write ('        ShowDisplay="1"');
				document.write ('        ShowStatusBar="1"');
				document.write ('        width="400"');
				document.write ('        height="300">');
				document.write ('    </embed>');

				document.write ('</OBJECT>');
			}
		}
		return ret;
	}

}

//End Media Player