var str = '';
var growSpeed = 10;
var openVidInt;
var closeVidInt;
var vidwidth = 0;
var vidheight = 0;

var vidNameArr = new Array();
vidNameArr[0] = "phila_university";
vidNameArr[1] = "gsa";
vidNameArr[2] = "non_comm_med";
vidNameArr[3] = "wharton";
vidNameArr[4] = "mercersburg"; 
vidNameArr[5] = "moc";
vidNameArr[6] = "gesu";
vidNameArr[7] = "pennfac";

var vidRatioArr = new Array();
vidRatioArr[0] = "1";
vidRatioArr[1] = "1";
vidRatioArr[2] = "1";
vidRatioArr[3] = "1";
vidRatioArr[4] = "0"; 
vidRatioArr[5] = "0";
vidRatioArr[6] = "0";
vidRatioArr[7] = "0";

var vidHeightArr = new Array();
vidHeightArr[0] = "280"; 
vidHeightArr[1] = "280";
vidHeightArr[2] = "280";
vidHeightArr[3] = "280";
vidHeightArr[4] = "280";
vidHeightArr[5] = "280";
vidHeightArr[6] = "280";
vidHeightArr[7] = "280";

var vidTitleArr = new Array();
vidTitleArr[0] = "Philadelphia University";
vidTitleArr[1] = "Girl Scouts of the USA";
vidTitleArr[2] = "WXPN";
vidTitleArr[3] = "Wharton Magazine";
vidTitleArr[4] = "Mercersburg Academy";
vidTitleArr[5] = "Musicians On Call";
vidTitleArr[6] = "The Gesu School";
vidTitleArr[7] = "University of Pennsylvania";


var vidDescArr = new Array();
vidDescArr[0] = "A 4 minute video for the Industrial Design Department about a global design project with 2 other schools.";
vidDescArr[1] = "Excerpt from a 9 minute video about the Act Now program for volunteers and troop leaders.";
vidDescArr[2] = "A monthly <i>Radio-Video</i> vlog for their website: The '2010 Non Commvention' held in Philadelphia for AAA Radio Stations.";
vidDescArr[3] = "A web video for Wharton Magazine about the Wharton MBA Reunion Weekend.";
vidDescArr[4] = "An excerpt from the introduction to a 17 minute video about the school.";
vidDescArr[5] = "A 7 minute video about bringing Philadelphia musicians into local hospitals for bedside performances.";
vidDescArr[6] = "The beginning of a 6 minute video honoring a trustee of the school.";
vidDescArr[7] = "An excerpt from a 6 minute video for \"The Campaign for Penn\" for Faculty Endowment.";


function videoList()
{
	var vidList = "";
	var counter = 0;
	for(i=0;i<vidNameArr.length;i++)
	{
	    if(vidRatioArr[i] == "1")
	    {
	        picclass = 'pic_hd';
	    }
	    else
	    {
	        picclass = 'pic';
	    }
	
	    counter++;
	    if(counter == 1)
	    {
	        vidList += "<div id='pic" + i + "' class='" + picclass + "'><a href='javascript:showVideo(" + i + ");'><img src='images/vid_icons/vid_" + vidNameArr[i] + ".jpg' alt='" + vidTitleArr[i] + "' name='" + vidTitleArr[i] + "' border='0' id='" + vidTitleArr[i] + "'  class='imageborder'/></a><br/><b>" + vidTitleArr[i] + "</b></div>";
	     }
	     else
	     {
	        counter = 0;
	        vidList += "<div id='pic" + i + "' class='" + picclass + "'><a href='javascript:showVideo(" + i + ");'><img src='images/vid_icons/vid_" + vidNameArr[i] + ".jpg' alt='" + vidTitleArr[i] + "' name='" + vidTitleArr[i] + "' border='0' id='" + vidTitleArr[i] + "'  class='imageborder'/></a><br/><b>" + vidTitleArr[i] + "</b></div>";
	        vidList += "<div class='clear' style='height:15px;'><img src='images/spacer.gif' width='1' height='1' border='0'></div>";
	     }
	 }
	 return vidList;
}

function checkDirectId()
{
	if(directId != 'x' && directId != "")
	{
		if(Math.round(directId) < vidNameArr.length && Math.round(directId) >= 0)
		{
			showVideo(directId);
		}
	}
}

function showVideo(id)
{
	var flashCodeBegin = "";
	var flashCodeEnd = "";
	
	str = "";
	
	//alert(vidNameArr[id]);
	
	clearInterval(openVidInt);
	
	document.getElementById('vidplayer').style.position = "relative";
	if(vidRatioArr[id] == '1')
	{
	    vidwidth = 432;
	    vidheight = 378;
	}
	else
	{
	    vidwidth = 320;
	    vidheight = 280;
	}
	
	document.getElementById('vidplayer').style.width = + vidwidth + "px";
	
	//add-remove border
	for(i=0;i<vidNameArr.length;i++)
	{
		document.getElementById('pic' + i).style.border = "solid 2px #ffffff";
	}
	
	document.getElementById('pic' + id).style.border = "solid 2px #aec9d7";
	
	
	//alert(document.getElementById('vidplayer').offsetHeight);
	
	if(document.getElementById('vidplayer').offsetHeight < 350)
	{
		//alert("grow");
		openVidInt = setInterval(openVidPlayer,5);
	}
	flashCodeBegin = "<div id='titler'>" + vidTitleArr[id] + "</div><div id='closer'><a href='javascript: closeVid();'>Close</a></div>";
	flashCodeEnd += "<div id='desc'>" + vidDescArr[id] + "</div>";
	
	AC_FL_RunContent('codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0','width', vidwidth ,'height', vidheight , 'src', 'video/vidplayer?vid=' + vidNameArr[id] , 'quality', 'high','pluginspage', 'http://www.macromedia.com/go/getflashplayer','align','middle','play','true','loop','true','scale','showall','wmode','transparent','devicefont','false','id','mercersburg','bgcolor','#ffffff','name','mercersburg','menu','true','allowFullScreen','false','allowScriptAccess','sameDomain','movie','video/vidplayer?vid=' + vidNameArr[id],'salign','');

	document.getElementById('vidplayer').innerHTML = flashCodeBegin + "<div class='clear' style='height:1px;'><img src='images/spacer.gif' width='200' height='1'></div><div style='height:" + vidHeightArr[id] + "px;'>" + str + "</div><div class='clear' style='height:1px;'><img src='images/spacer.gif' width='200' height='1'></div>" + flashCodeEnd;
	
	document.getElementById('titler').style.width = (vidwidth - 80) + "px";
    document.getElementById('desc').style.width = (vidwidth - 20) + "px";
}

function openVidPlayer()
{
	document.getElementById('vidplayer').style.width = vidwidth + "px";
	strHeight = parseFloat(document.getElementById('vidplayer').offsetHeight);
	
	if((strHeight + growSpeed) < 375)
	{
		document.getElementById('vidplayer').style.height = (strHeight + growSpeed)+ "px";
	}
	else
	{
		clearInterval(openVidInt);
		document.getElementById('vidplayer').style.visibility = "visible";
		document.getElementById('vidplayer').style.height = "375px";
	}
}

function closeVidPlayer()
{
	strHeight = parseFloat(document.getElementById('vidplayer').offsetHeight);
	if((strHeight - growSpeed) > 1)
	{
		document.getElementById('vidplayer').style.height = (strHeight - growSpeed)+ "px";
	}
	else
	{
		clearInterval(closeVidInt);
		document.getElementById('vidplayer').style.position = "absolute";
		document.getElementById('vidplayer').style.width = "1px";
		document.getElementById('vidplayer').style.height = "1px";
	}
}

function closeVid()
{
	document.getElementById('vidplayer').style.visibility = "hidden";
	document.getElementById('vidplayer').innerHTML = "";
	clearInterval(closeVidInt);
	closeVidInt = setInterval(closeVidPlayer,5);
}

function popup(mylink, windowname)
{
	if (! window.focus)return true;
	
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else
		href=mylink.href;
		window.open(href, windowname, 'width=350,height=295,scrollbars=no');
		return false;
}

var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'name','height=293,width=335,left=400,top=400,resizeable=0,scrollbars=0,toolbar=0,menubar=0,location=0,status=0,directories=0');
	if (window.focus) {newwindow.focus()}
}

function poptasticbig(url)
{
	newwindow=window.open(url,'name','height=413,width=495,left=400,top=400,resizeable=0,scrollbars=0,toolbar=0,menubar=0,location=0,status=0,directories=0');
	if (window.focus) {newwindow.focus()}
}
