function VID() {
	var popUp = false;
	var publisher;
	var pub_width = 555, pub_height = 380;
	var player_width = 440, player_height = 440;
	var popUpColor = 'white';

	var winW = 630, winH = 460;
	var offsetY;

	this.select_videopath = null;
	this.select_videoplay = null;
  this.display_comments = true;
  this.display_title = true;

	var VID_Player = document.getElementById('VID_Player');
	var VID_Links = document.getElementById('VID_Links');
	
	var viewed_pub = false;
	
	this.watermark_url = IMAGE_URL+"/video/video_watermark_trans.png";
	this.getVideoVars = function(vars) {

		/* Variables and descriptions taken from VE_api 1.4
		 * Even though VideoEgg has its own defaults for these variables,
		 * here we can set defaults specific to our site.
		 */

		/* file (string: default empty): The path to the video. This is the only required
		parameter.
		 */
		vars['file'] = vars['file'] || '';

		/* width (number: default 440): The width of the Player in pixels. The height is
		extrapolated from the width using a 4:3 ratio. The width must be at least 400
		pixels to show ads correctly.
		 */
		//MYB: Make sure width is an integer, default to 350.
		if (isNaN(parseInt(vars['width']))) vars['width'] = 350;

		/* autoPlay (boolean: default false): Defines if the Player should start playing
		immediately when the page is loaded.
		 */
		//MYB: Make sure autoplay is a boolean, default to true.
		if (vars['autoPlay']) vars['autoplay'] = true;

		/* showAd (boolean: default true): Defines if VideoEgg can insert ads into the
		video stream.
		 */
		//MYB: Make sure showAd is a boolean, default to true.
		if (vars['showAd']) vars['showAd'] = true;

		/* adVars (string: default empty): See the Step 8 section for the complete details.
		 */
		if (vars['advars']) vars['adVars'] = vars['advars'];
		vars['adVars'] = vars['adVars'] || {site:SITEURL, area:'gallery', channel:'videos', vl:'null', vg:'null', va:'null'};

		/* wmode (string: default â€świndowâ€?): Specifies the window mode passed to the
		Flash Player. In almost all cases, this should be â€świndowâ€?. In special cases, you
		can pass â€śopaqueâ€? or â€śtransparentâ€? to change the Flash window mode but this
		will disable full-screen viewing of the video.
		 */
		//MYB: Make sure wmode is a valid string (noted above), default to 'window'.
		if (vars['wmode']!='opaque' && vars['wmode']!='transparent') vars['wmode'] = 'window';

		/* allowGrabcode (boolean: default false): Displays HTML code that allows users
		the ability to embed the video onto their own site if they click the Menu button.
		 */
		//MYB: Make sure allowGrabcode is a boolean, default to false.
		if (vars['allowGrabcode']) vars['allowGrabcode'] = true;

		/* allowRecommendations (boolean: default false): Displays thumbnails of
		suggested movies if the users click the Menu button. Recommendations will only
		be displayed if allowGrabCode is also set to â€śtrueâ€?.
		 */
		//MYB: Make sure allowRecommendations is a boolean, default to false.
		if (vars['allowRecommendations']) vars['allowRecommendations'] = true;

		/* watermark (string: default empty): The URL of an image that will be overlaid on
		the video while itâ€™s played. The image must be a GIF or PNG that is less than 60
		pixels high and 125 pixels wide and should have a transparent background. A
		watermark is not displayed unless this parameter is specified.
		 */
		vars['watermark'] = vars['watermark'] || VID.watermark_url;

		/* watermarkLocation (string: default â€śbottomleftâ€?): Defines the placement of
		the watermark. Parameters include â€śbottomleftâ€?, â€śbottomrightâ€?, â€śtopleftâ€?,
		â€śtoprightâ€?.
		 */
		//MYB: Make sure watermarkLocation is a valid string (noted above), default to 'bottomright'.
		if (vars['watermarkLocation']!='topleft' && vars['watermarkLocation']!='topright' && vars['watermarkLocation']!='bottomleft') vars['watermarkLocation'] = 'bottomright';

		/* clickurl (string: default empty): If user clicks in the video player window the
		specified URL loads in browser. If this parameter is not specified the browser will
		remain on the video if clicked upon.
		 */
		vars['clickurl'] = vars['clickurl'] || '';

		/* clickurl_openinnewwindow (boolean: default false): Defines if the specified
		URL should open in a browser window.
		 */
		//MYB: Make sure clickurl_openinnewwindow is a boolean, default to false.
		if (vars['clickurl_openinnewwindow']) vars['clickurl_openinnewwindow'] = true;

		return vars;

	}
	
	this.displayRating = function(val, out) {

		if (out) {
			document.getElementById("ratingText").innerHTML = 'Rating:';
		} else {
			document.getElementById("ratingText").innerHTML = 'Rate this video:';
		}
		for (i=1; i<=5; i++) {
			if (i<=val) {
				document.getElementById('star'+i).src = document.getElementById('star'+i).src.replace('empty', 'full');
			} else {
				document.getElementById('star'+i).src = document.getElementById('star'+i).src.replace('full', 'empty');
			}
		}

	}
	
	this.displayPrivacy = function(p) {
		if (p==0) {
			document.getElementById("privacyDescription").innerHTML='"Private" videos may only be viewed by you.  They do not appear in your Video Playlist.';
		} else if (p==1) {
			document.getElementById("privacyDescription").innerHTML='"Friends Only" videos may be viewed by you and your friends.  You and your friends will see them in your Video Playlist, but no one else.';
		} else if (p==2) {
			document.getElementById("privacyDescription").innerHTML='"Public" videos may be viewed by anyone.  They will appear in your Video Playlist.';
		}
	}
	
	this.sendRating = function(id, r) {
		document.getElementById('ratingText').innerHTML = 'please wait...';
		if (r>=1 && r<=5 && id && id!='') {
			aj = new AJAX(0,'VID.returnRating');
			aj.makeRequest('/ajax/video/ajax_rate_video.php?&videoid='+id+'&r='+r);
		}
	}
	
	this.returnRating = function(x) {
		if (x!='error') {
			document.getElementById('ratingText').style.color='#FF0000';
			document.getElementById('ratingText').innerHTML = '<strong>Rating sent!</strong>&nbsp;&nbsp;';
			for (i=1; i<=5; i++) {
				document.getElementById('ratingStars').innerHTML = x;
			}
		} else {
			document.getElementById('ratingText').innerHTML = 'Error.';
		}
	}
	
	this.addToFavs = function(videoid) {
		if (document.getElementById('addToFavs')) {
			document.getElementById('addToFavs').style.color = '#000000';
			document.getElementById('addToFavs').innerHTML = 'please wait...';
		}
		if (parseInt(videoid)!='') {
			aj = new AJAX(0,'VID.returnFavs')
				aj.makeRequest('/ajax/video/ajax_add_favs.php?&videoid='+videoid);
		}
	}
	
	this.returnFavs = function(x) {
		if (document.getElementById('addToFavs')) {
			document.getElementById('addToFavs').style.color = '#FF0000';
			if (x!='error') {
				document.getElementById('addToFavs').innerHTML = '<strong>Added to Favorites!</strong>';
			} else {
				document.getElementById('addToFavs').innerHTML = '<strong>Error</strong>';
			}
		}
	}

	this.addToPlaylist = function(videoid) {
		if (document.getElementById('addToPlaylist_video')) {
			document.getElementById('addToPlaylist_video').style.color = '#000000';
			document.getElementById('addToPlaylist_video').innerHTML = 'please wait...';
		}
		if (parseInt(videoid)!='') {
			aj = new AJAX(0,'VID.returnPlaylist');
			aj.makeRequest('/ajax/video/ajax_add_pl.php?&videoid='+videoid);
			//VID.addToFavs(videoid);
		}
	}
	
	this.returnPlaylist = function(x) {
		if (document.getElementById('addToPlaylist_video')) {
			document.getElementById('addToPlaylist_video').style.color = '#FF0000';
		}
		if (x!='error') {
			if (document.getElementById('addToPlaylist_video')) {
				document.getElementById('addToPlaylist_video').innerHTML = '<strong>Added to Playlist!</strong>';
				VID.addToFavs(x);

			}
		}
		else {
			if (document.getElementById('addToPlaylist_video')) {
				document.getElementById('addToPlaylist_video').innerHTML = '<strong>Error</strong>';
			}
		}
	}

	this.setAutoPlay = function(a) {
		document.getElementById('setAutoPlay').innerHTML = 'please wait...';
		if (a==1) {
			aj = new AJAX(0,'VID.returnAutoPlay');
			aj.makeRequest('/ajax/video/ajax_set_autoplay.php?&autoplay=true');
		} else {
			aj = new AJAX(0,'VID.returnAutoPlay');
			aj.makeRequest('/ajax/video/ajax_set_autoplay.php');
		}
	}
	
	this.returnAutoPlay = function(x) {
		document.getElementById('setAutoPlay').style.color = '#FF0000';
		document.getElementById('setAutoPlay').innerHTML = x;
	}
	
	this.copyCode = function(field) {
		var txtfield = document.getElementById(field);
		var msg = document.getElementById('msg_copyCode');
		msg.style.color = "#FF0000";
		txtfield.select();
		if (navigator.appName == "Microsoft Internet Explorer") {
			var range = txtfield.createTextRange();
			range.execCommand("Copy");
			msg.innerHTML = "<strong style=\"color:red\">(The code was auto-copied.  Use CTRL + V to paste.)</strong>";
		} else {
			msg.innerHTML = "<strong style=\"color:red\">Use CTRL + C to copy; CTRL + V to paste.</strong>";
		}
	}
	
	this.selectVideo = function(videoid, width, area) {
		if (parseInt(videoid)!='') {
			if (!width) {
				width = 380;
			}
			if (!area) {
				area = '';
			}
			aj = new AJAX(0,'VID.returnSelectVideo');
			aj.makeRequest('/ajax/video/ajax_select_video.php?videoid='+videoid+'&width='+width+'&area='+area+'&title='+this.display_title+'&comments='+this.display_comments);
		}
	}
	
	this.returnSelectVideo = function(x) {
		document.getElementById('videoSelected').innerHTML = x;
		width = document.getElementById('videoSelectedWidth').value;
		
		if (document.getElementById('videoSelectedPlayer').innerHTML=='') {
			code = VID.getVideoEmbed( {file:VID.select_videopath, width:width, showAd:true, advars:advars, allowGrabcode:true, allowRecommendations:true} );
			document.getElementById('videoSelectedPlayer').innerHTML = code;
			path = document.getElementById('videoEmbedCode').value;
			document.getElementById('videoEmbedCode').value = VID.getVideoEmbed( {file:path} );
		}
		else {
			document.getElementById('videoEmbedCode').value = document.getElementById('videoSelectedEmbed').value;
		}
		VID.select_videoplay = true;
	}
	
	this.thumbwidth = 120;
	this.thumbheight = 90;
	this.thumboffset = 7;
	this.mybVideoServer = 'http://video.scs.myyearbook.com/'
	this.getThumbnail = function(container, src, linkpath, width, height) {
		if (!width) {
			width = VID.thumbwidth;
		}
		if (!height) {
			height = VID.thumbheight;
		}

		var size = '';
		if (width <= 60) {
			size = '_60';
		}
		else if (width <= 80) {
			size = '_80';
		}
		else if (width <= 120) {
			size = '_120';
		}
		else if (width <= 160) {
			size = '_160';
		}
		else if (width <= 176) {
			size = '_176';
		}
		hspace = 5;
		if (src.indexOf('http://') == -1) {
			src = this.mybVideoServer + src +'_thumbnail.jpg'
		}
		
		code = '<div style="width:'+(width)+'px; height:'+height+'px; overflow:hidden;">';
		code += '<a href="'+linkpath+'" class="normaltextlinkbold" title="Watch this video!">';
		code += '<img src="'+src+'" alt="" width="'+width+'" height="'+height+'" style="border:0px;">';
		code += '<img src="'+IMAGE_URL+'/video/video_thumb_overlay'+size+'.gif" alt="" width="'+width+'" height="'+height+'" style="border:0px; position:relative; top:-'+height+'px;">';
		code += '</a>';
		code += '</div>';
		container.innerHTML = code;
	}

	this.getThumbnail2 = function(container, path, linkpath, width, height) {

		if (!width) {
			width = VID.thumbwidth;
		}
		if (!height) {
			height = VID.thumbheight;
		}

		var size = '';
		if (width <= 80) {
			size = '_80';
		}else if (width <= 120) {
			size = '_120';
		}else if (width <= 160) {
			size = '_160';
		}else if (width <= 176) {
			size = '_176';
		}

		if (src.indexOf('http://') == -1) {
			src = this.mybVideoServer + src +'_thumbnail.jpg'
		}


		code = '<div style="height:'+height+'px; width:'+width+'px; overflow:hidden; background-image:url(\''+src+'\');">';
		code += '<a href="'+linkpath+'" class="normaltextlinkbold" title="Watch this video!">';
		code += '<img src="'+IMAGE_URL+'/video/video_thumb_overlay'+size+'.gif" alt="" width="'+width+'" height="'+height+'" hspace="5" style="border:0px;">';
		code += '</a>';
		code += '</div>';
		container.innerHTML = code;
	}

	this.getThumbnailEx = function(container, path, linkpath, width, height) {

		if (!width) {
			width = VID.thumbwidth;
		}
		if (!height) {
			height = VID.thumbheight;
		}

		var size = '';
		if (width <= 80) {
			size = '_80';
		}else if (width <= 120) {
			size = '_120';
		}else if (width <= 160) {
			size = '_160';
		}else if (width <= 176) {
			size = '_176';
		}
		hspace = 5;

		code = '<div style="width:'+(width)+'px; height:'+height+'px; overflow:hidden;">';
		code += '<a href="'+linkpath+'" class="normaltextlinkbold" title="Watch this video!">';
		code += '<img src="'+path+'" alt="" width="'+width+'" height="'+height+'" style="border:0px;">';
		code += '<img src="'+IMAGE_URL+'/video/video_thumb_overlay'+size+'.gif" alt="" width="'+width+'" height="'+height+'" style="border:0px; position:relative; top:-'+height+'px;">';
		code += '</a>';
		code += '</div>';
		container.innerHTML = code;

	}
}

/***********************************************
 * Textarea Maxlength script- Dynamic Drive (www.dynamicdrive.com)
 * This notice must stay intact for legal use.
 * Visit http://www.dynamicdrive.com/ for full source code
 ***********************************************/

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
		if (obj.getAttribute && obj.value.length>mlength) obj.style.border="2px solid #ff0000";
		else obj.style.border='2px solid';
}

var VID = new VID();