/* Copyright 2008
 * title	 : vanderbilt js
 * built for : row 27 studios
 * reference : functions for vanderbilt
 * author	 : Calvin Lai
 */

//check for duplicates in the comment updater so that the same comment won't appear twice
function checkDupe(prev, last) {
	if (last.constructor == Object)	return (prev.html() == last.html()); //if HTML is same, return true, else false
	else return 0;
}

//add a comment into the database using ajax
function addComment(name, comment){
	if(name == '' || comment == ''){
		alert('Please fill in both fields!');
		return;
	}
	var pars = 'action=add_comment&name='+escape(name)+'&comment='+escape(comment)+'';
	new Ajax.Request('ajax_updater.php', { method: 'post', parameters:pars, onSuccess: function(){alert('Your comment has been submitted. Please allow up to 24 hours for your comment to show up.');} });
}

function loadSection(section, id){	
	var pars = 'action=load_videos&section='+section+'&id='+id+'';
	new Ajax.Updater('vid_area', 'ajax_updater.php', { 
		method: 'post', 
		evalScripts: true,
		//onLoading: function(){ $('videos').innerHTML = '<div style="background:transparent; margin:150px; font:bold 11px Arial; color:white; text-align:center;">Loading...</div>'; },
		parameters: pars,
		onComplete: function(){
						new Effect.SlideDown('videos', {duration:0.8});
					}
	}); 
}

function loadVideo(v, name, filename, thumb){
	var s = new SWFObject("player/player.swf","ply"+v+"","350","200","8");
	s.addParam("allowfullscreen","true");
	s.addParam("allowfullscreen","true");
	s.addParam("wmode","opaque");
	s.addParam("allowscriptaccess","always");
	s.addParam("flashvars","file="+videoDir+filename+"&image=videos/thumbs/"+thumb+"&controlbar=off&width=350&height=200&autostart=true");
	s.write("video"+v+"");
	$('video'+v+'').insert('<div class="name_title">'+name+'</div>');
	//player = getPlayer('ply'+v+'');
}

function loadIntro(){
	myLightWindow.activateWindow({
		href: introVideo, 
		height: '337px',
		width: '600px',
		fileTypes : {
			page : ['asp', 'aspx', 'cgi', 'htm', 'html', 'pl', 'php4', 'php3', 'php', 'php5', 'phtml', 'rhtml', 'shtml', 'txt', 'vbs', 'rb'],
			media : ['aif', 'aiff', 'asf', 'avi', 'divx', 'm1v', 'm2a', 'm2v', 'm3u', 'mid', 'midi', 'mov', 'moov', 'movie', 'mp2', 'mp3', 'mpa', 'mpa', 'mpe', 'mpeg', 'mpg', 'mpg', 'mpga', 'pps', 'qt', 'rm', 'ram', 'swf', 'viv', 'vivo', 'wav'],
			image : ['bmp', 'gif', 'jpg', 'png', 'tiff']
		}
	});
}