
var vidlink = new Array();

function in_array(needle, haystack) { /* {{{ */

	if (needle == '') {
		return false;
	} else {
		var i;
		for (i = 0; i < haystack.length; i++) {
			if (haystack[i] == needle) {
				return true;
			}
		}

		return false;
	}
} /* }}} */
function vidlink_go(vidname) { /* {{{ */
	
	var html = '\n<!-- vidlink_go() wrote this -->\n';
	
	var arr_windows_proprietary = ['wma','wmv','asf'];
	
	var type = vidlink[vidname]['type'];
	
	var str_wmode = 'opaque';
	
	if (vidlink[vidname]['wmode']) {
		str_wmode = vidlink[vidname]['wmode'];
	}
	//###CorpTicket:45426 - Cannot select edit pencil after uploading video- changed by chinmay on Oct 21, 2008
	var brType = new  browserCheck(); 
	if(brType.agent.indexOf('msie')!=-1){
	  var str_object_wmode = 'wmode="transparent"';
	  var str_param_wmode = '<param name="wmode" value="transparent">';
	}
	else{
		 var str_object_wmode = '';
		 var str_param_wmode = '';
	}
	//###-----------------------------------------
	//SC.console.log('type',type);
	// EJF:2007.02.07 - having classid or codebase attributes in the object tag
	// works only in IE on windows and renders the object tag useless for all
	// other browsers
	// so our object tag below is only being recognized by IE on windows
	// the object tag is also not supported in safari prior to version 1.3
	// ETA of deprecating the embed tag in favor of the object tag = 2008
	// it is expected that by this time the majority of mac users are expected
	// to have upgraded past OSX 10.2
	// EJF:2007.03.21 - thanks to the GeckoActiveXObject this is not a concern
	// Firefox plays nice now with clsids for media, not sure how it handles
	// the codebase attribute, but seems to no longer be a problem
	// More research is needed to determine what changed, this did not work
	// with Firefox 1.0.7
	
	if (type == 'swf') {
		
		html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' + vidlink[vidname]['w'] + '" height="' + vidlink[vidname]['h'] + '" id="SCFlash_' + vidlink[vidname]['softFile'] + '" align="middle" style="z-index: 1;">\n';
		html += '<param name="allowScriptAccess" value="sameDomain" />\n';
		html += '<param name="movie" value="' + vidlink[vidname]['softFile'] + '" />\n';
		html += '<param name="loop" value="true" />\n';
		//html += '<param name="wmode" value="opaque" />\n';
		html += '<param name="wmode" value="' +  str_wmode + '" />\n';
		html += '<param name="autoplay" value="false" />\n';
		html += '<param name="quality" value="high" />\n';
		html += '<param name="bgcolor" value="#' + vidlink[vidname]['swf_bgcolor'] + '" />';
		html += '<embed src="' + vidlink[vidname]['softFile'] + '" wmode="' + str_wmode + '" quality="high" loop="true" bgcolor="#' + vidlink[vidname]['swf_bgcolor'] + '" width="' + vidlink[vidname]['w'] + '" height="' + vidlink[vidname]['h'] + '" name="SCFlash_' + vidlink[vidname]['softFile'] + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n';
		html += '</object>\n';
	} else if (type == 'mpeg') {
		//###CorpTicket:45426 - Cannot select edit pencil after uploading video- changed by chinmay on Oct 21, 2008
        html += '<object '+str_object_wmode+' classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'  + vidlink[vidname]['w'] + '" height="' + vidlink[vidname]['h'] + '" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" style="z-index: 1;">\n';
        html += '    <param name="type" value="video/quicktime">\n';
        html += '    <param name="autoplay" value="false">\n';
        html += '    '+str_param_wmode+'\n';//###CorpTicket:45426 - Cannot select edit pencil after uploading video- changed by chinmay on Oct 21, 2008
        html += '    <param name="target" value="myself">\n';
        html += '    <param name="src" value="' + vidlink[vidname]['softFile'] + '">\n';
        html += '    <param name="pluginspage" value="http://www.apple.com/quicktime/download/indext.html">\n';
        html += '    <embed width="' + vidlink[vidname]['w'] + '" autoplay="false" height="' + vidlink[vidname]['h'] + '" src="' + vidlink[vidname]['softFile'] + '" type="video/quicktime" target="myself" border="0" pluginspage="http://www.apple.com/quicktime/download/indext.html"></embed>\n';
		html += '</object>\n';
	} else if (type == 'quicktime') {

		var str_dims = '';
		if (vidlink[vidname]['w']) {
			str_dims += ' width="' + vidlink[vidname]['w'] + '" ';
		}

		if (vidlink[vidname]['h']) {
			str_dims += ' height="' + vidlink[vidname]['h'] + '" ';
		}

        //html += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="' + vidlink[vidname]['w'] +'" height="' + vidlink[vidname]['h'] + '" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" style="z-index: 1;">\n';
        //###CorpTicket:45426 - Cannot select edit pencil after uploading video- changed by chinmay on Oct 21, 2008
		html += '<object '+str_object_wmode+' classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ' + str_dims + ' codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" style="z-index: 1;">\n';
        html += '    <param name="type" value="video/quicktime">\n';
        html += '    <param name="autoplay" value="false">\n';
        html += '    '+str_param_wmode+'\n';//###CorpTicket:45426 - Cannot select edit pencil after uploading video- changed by chinmay on Oct 21, 2008
        html += '    <param name="target" value="myself">\n';
        html += '    <param name="src" value="' + vidlink[vidname]['softFile'] + '">\n';
        html += '    <param name="pluginspage" value="http://www.apple.com/quicktime/download">\n';
        //html += '    <embed width="' + vidlink[vidname]['w'] + '" autoplay="false" height="' + vidlink[vidname]['h'] + '" src="' + vidlink[vidname]['softFile'] + '" type="video/quicktime" target="myself" border="0" pluginspage="http://www.apple.com/quicktime/download/indext.html"></embed>\n';
        html += '    <embed ' + str_dims + ' autoplay="false" src="' + vidlink[vidname]['softFile'] + '" type="video/quicktime" target="myself" border="0" pluginspage="http://www.apple.com/quicktime/download/indext.html"></embed>\n';
        html += '</object>\n'; 
	} else if (type == 'impatica') {
        html += '<object>\n';
        html += '  <param name="code" value="com.impatica.v300.ImPlayerConsole.class" />\n';
        html += '  <param name="archive" value="' + vidlink[vidname]['archive'] + '" />\n';
        html += '  <param name="type" value="application/x-java-applet">\n';
        html += '  <param name="color0" value="000066" />\n';
        html += '  <param name="color1" value="ccccff" />\n';
        html += '  <param name="file" value="' + vidlink[vidname]['softFile'] + '" />\n';
        html += '  <param name="bgcolor" value="ffffff" />\n';
        html += '  <embed autoplay="false" archive="' + vidlink[vidname]['archive'] + '" code="com.impatica.v300.ImPlayerConsole.class" file="' + vidlink[vidname]['softFile'] + '" type="application/x-java-applet" target="myself" border="0"></embed>\n';
        html += '</object>\n';
	} else if (type == 'applet') { 
		html += '<applet code="' + vidlink[vidname]['code'] + '" archive="' + vidlink[vidname]['archive'] + '" width="' + vidlink[vidname]['w'] +'" height="' + vidlink[vidname]['h'] + '" alt="Please enable \'active content\' and/or Java plugins.">\n';
		html += vidlink[vidname]['params'];
		html += '  Your browser is not compatible with SchoolCenter\'s Java Mode Multiple File Upload Manager.\n';
		html += '</applet>\n';
	} else if (arr_windows_proprietary.inArray(type)) { // handles windows proprietary formats
		
		// api does not allow you to turn off video so we must resize the interface to hide it
		var str_extension     = vidlink[vidname]['softFile'].split('.').reverse()[0];
		var arr_audio_formats = ['wma','m4a','aac','aiff'];
		var int_player_height = arr_audio_formats.inArray(str_extension) ? 45 : 280;
		
		html += '<object';
		html += ' id="audio_plugin_wmp"';
		html += ' width="320"';
		html += ' height="' + int_player_height + '"';
		html += ' standby="Loading Media"';
		html += ' type="application/x-oleobject"';
		html += ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"';
		//html += ' classid="clsid:22D6f312-B0F6-11D0-94AB-0080C74C7E95"'; // 6.4
		html += ' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"'; // 7 & 9
		html += '>\n';
		html += '    <param name="bgcolor" value="#' + vidlink[vidname]['bgcolor'] + '">\n';
		html += '    <param name="width" value="320">\n';
		html += '    <param name="height" value="' + int_player_height + '">\n';
		html += '    <param name="loop" value="false">\n';
		html += '    <param name="alt" value="">\n';
		html += '    <param name="volume" value="30">\n';
		html += '    <param name="target" value="myself">\n';
		html += '	 <param name="wmode" value="opaque">';
		if (vidlink[vidname]['hidden']) {
			html += '    <param name="hidden" value="1">\n';
		}
		html += '    <param name="name" value="audio_plugin_windowsmediaplayer">\n';
		html += '    <param name="type" value="application/x-mplayer2">\n';
		html += '    <param name="pluginspage" value="http://gohere.com">\n';
		html += '    <param name="url" value="' + vidlink[vidname]['softFile'] + '">\n';
		html += '    <param name="ShowControls" value="false">\n';
		vidlink[vidname]['AutoStart'] = true;
		html += '    <param name="AutoStart" value="' + vidlink[vidname]['AutoStart'] + '">\n';
		html += '	 <param name="uiMode" value="mini">'; // invisible, none, mini, full
		html += '	 <param name="enableContextMenu" value="false">';
		html += '	 <param name="enabled" value="true">'; // whether controls are enabled or not
		
		// CorpTicket:43864 - put an embed in the object so firefox can run wmv and asf  - changed by BIrons on Oct  9, 2008
		if ((vidlink[vidname]['br_type'] != 'ie') && (type == 'wmv' || type == 'asf' )) {
		
			html += '    <embed';
			html += ' src="' + vidlink[vidname]['softFile'] + '"';
			if (vidlink[vidname]['hidden']) {
				html += ' hidden="1"';
			}
			html += ' bgcolor="#' + vidlink[vidname]['bgcolor'] + '"';
			html += ' align="center"';
			html += ' width="320"';
			html += ' height="' + int_player_height + '"';
			html += ' target="myself"';
			html += ' border="0"';
			html += ' uiMode="none"'; // invisible, none, mini, full
			html += ' enabled="true"'; // whether controls are enabled or not
			html += ' enableContextMenu="false"';
			html += ' AutoSize="false"';
			html += ' DisplaySize="false"';
			html += ' ShowControls="true"';
			html += ' ShowStatusBar="true"';
			html += ' TransparentAtStart="true"';
			html += ' AnimationAtStart="true"';
			html += ' SendPlayStateChangeEvents="true"';
			html += ' AutoStart="' + vidlink[vidname]['AutoStart'] + '"';
			html += ' type="video/x-ms-asf"';
			//html += ' type="application/x-mplayer2"';
			html += ' pluginspage=""';
			html += '></embed>\n';
		}
		 
		if (int_user_id > 0) {
			html += 'Your operating system does not have the required player installed to play this file format.\n';
		}
		html += '</object>\n';
	} else if ((type == 'avi') || (type == 'divx') || (type == 'xvid')) { 
		// No handler
		html += '<embed src="' + vidlink[vidname]['softFile'] + '"></embed>';
	} else { // quicktime handles 'mp3','midi','wav','ac3','riff' (audio only)
		html += '<object';
		html += ' id="audio_plugin_qt"';
		html += ' width="250"';
		html += ' height="16"';
		html += ' standby="Loading Media"';
		html += ' type="video/quicktime"';
		html += ' codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"';
		//html += ' codebase="http://www.apple.com/qtactivex/qtplugin.cab"';

		html += ' classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
		html += '>\n';
		html += '    <param name="bgcolor" value="#' + vidlink[vidname]['bgcolor'] + '">\n';
		html += '    <param name="width" value="250">\n';
		html += '    <param name="height" value="16">\n';
		html += '    <param name="loop" value="false">\n';
		html += '    <param name="alt" value="">\n';
		html += '    <param name="volume" value="30">';
		html += '    <param name="target" value="myself">\n';
		
		if (vidlink[vidname]["hidden"]) {
			html += '    <param name="hidden" value="1">\n';
		}
		html += '    <param name="name" value="audio_plugin_quicktime">\n';
		html += '    <param name="type" value="video/quicktime">\n';
		html += '    <param name="pluginspage" value="http://www.apple.com/quicktime/download/indext.html">\n';
		html += '    <param name="src" value="' + vidlink[vidname]['softFile'] + '">\n';
		html += '    <param name="autoplay" value="' + vidlink[vidname]['autostart'] + '">\n';
		
		if (vidlink[vidname]["br_type"] != 'ie') {
			html += '    <embed';
			html += ' src="' + vidlink[vidname]['softFile'] + '"';
			
			if (vidlink[vidname]['hidden']) {
				html += ' hidden="1"';
			}
			html += ' bgcolor="#' + vidlink[vidname]['bgcolor'] + '"';
			html += ' align="center"';
			html += ' height="16"';
			html += ' width="250"';
			html += ' target="myself"';
			html += ' border="0"';
			html += ' autoplay="' + vidlink[vidname]['autostart'] + '"';
			html += ' type="video/quicktime"';
			html += ' pluginspage="http://www.apple.com/quicktime/download/indext.html"';
			html += '></embed>\n';
		}
		
		html += '</object>\n';
	}
	html += '<!-- vidlink_go() end -->\n';
	
	document.write(html);
	
} /* }}} */
function createFlashPlayer(str_video_location, str_container, bit_allow_fullscreen) { /* {{{ */
	var obj_swf = new SWFObject();
	var obj_flash_version = deconcept.SWFObjectUtil.getPlayerVersion();
	var int_flash_version = obj_flash_version['major'];

/*
	var obj_swf = new SWFObject(str_path_root + "page/mediaplayer.swf","mediaplayer","450","300","8");

	obj_swf.addParam("allowfullscreen","true");
	obj_swf.addVariable("width","450");
	obj_swf.addVariable("height","300");
	obj_swf.addVariable("file", str_video_location);
	obj_swf.addVariable("image", str_video_location + '.jpg');
	obj_swf.addVariable("autostart","false");
	obj_swf.addVariable("showstop","true");
	obj_swf.addVariable("wmode","opaque");

	//obj_sqf.addVariable("linkfromdisplay","true");
	//obj_sqf.addVariable("shownavigation ","true");
	//obj_sqf.addVariable("captions","2");

	obj_swf.write(str_container);
	return 0;
*/
	var html = '';

	var str_player = str_path_root + "page/mediaplayer.swf";

	/*
	html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="450"  height="300" id="SCFlash_' + str_video_location + '" align="middle" style="z-index: 1;">\n';
	html += '<param name="allowScriptAccess" value="sameDomain" />\n';
	html += '<param name="loop" value="true" />\n';
	//html += '<param name="wmode" value="opaque" />\n';
	html += '<param name="wmode" value="opaque" />\n';
	html += '<param name="autoplay" value="false" />\n';
	html += '<param name="quality" value="high" />\n';
	html += '<param name="quality" value="high" />\n';
	*/
	if (bit_allow_fullscreen) {		
		html += '<embed src="' + str_player + '" wmode="opaque" file="' + str_video_location + '" quality="high" id="mediaplayer" allowfullscreen="true" loop="true" width="320" height="240" name="SCFlash_' + str_video_location + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="file=' + str_video_location + '&amp;image=' + str_video_location + '.jpg&amp;showstop=true&amp;autostart=false&amp;showstop=true&amp;wmode=opaque"/>\n';
	} else {
		// removes wmode
		html += '<embed src="' + str_player + '"  file="' + str_video_location + '" quality="high" id="mediaplayer" loop="true" width="320" height="240" name="SCFlash_' + str_video_location + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="file=' + str_video_location + '&amp;image=' + str_video_location + '.jpg&amp;showstop=true&amp;autostart=false&amp;showstop=true&amp;wmode=opaque"/>\n';
	}

	//html = '<embed src="' + str_player + '"  file="' + str_video_location + '" quality="high" id="mediaplayer" allowfullscreen="true" loop="true" width="450" height="300" name="SCFlash_' + str_video_location + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="width=450&amp;height=300&amp;file=/images/pageitems/13275/p646703592_1343.flv&amp;image=/images/pageitems/13275/p646703592_1343.flv.jpg&amp;autostart=false&amp;showstop=true&amp;wmode=opaque"/>\n';

	//html = '<embed type="application/x-shockwave-flash" src="/education/page/mediaplayer.swf" style="" id="mediaplayer" name="mediaplayer" quality="high" allowfullscreen="true" flashvars="width=450&amp;height=300&amp;file=/images/pageitems/13275/p646703592_1343.flv&amp;image=/images/pageitems/13275/p646703592_1343.flv.jpg&amp;autostart=false&amp;showstop=true&amp;wmode=opaque" height="300" width="450">\n';

	//html += '</object>\n';
	if (int_flash_version >= 8) {
		$(str_container).innerHTML = html;
	}

} /* }}} */


