var longRef = "document.forms.form";
var searchStr = 'Search This Site';
	
addEvent(window, "load", cleanSearch, false);
addEvent(window, "load", function() {enableDropdown('utilities')}, false);
addEvent(window, "load", function() {enableDropdown('nav')}, false);

var searchStr = 'Search This Site';

function cleanSASearch() 
{
	document.search.query.onfocus = function() {if (this.value == searchStr) this.value = ''};
	document.search.query.onblur = function() {if (this.value == '') this.value = searchStr};
}

function displayOrHideFormSection(formSection)
{
	if (document.getElementById(formSection).style.display == 'block')
	{
		hideFormSection(formSection);
	}
	else
	{
		displayFormSection(formSection);
	}
}
	
	

function displayFormSection(formSection, dynamicQuestion)
{
	document.getElementById(formSection).style.display = 'block';
}


function hideFormSection(formSection, dynamicQuestion)
{
	document.getElementById(formSection).style.display = 'none';
}


/* Table Specific Hide/Show */
function displayOrHideFormRow(formRow)
{
	if ((document.getElementById(formRow).style.display == 'table-row')||(document.getElementById(formRow).style.display == ''))
	{
		hideFormRow(formRow);
	}
	else
	{
		displayFormRow(formRow);
	}
}

function displayFormRow(formRow)
{   
    // set to default for browser.
    // Mozilla will interpret this as 'table-row'
    // IE will interpret this as block 
    // (IE does not support 'table-row' as a display value)
	document.getElementById(formRow).style.display = '';
}

function hideFormRow(formRow)
{
	document.getElementById(formRow).style.display = 'none';
}


/* Begin FAQ Specific Dynamic HTML */
/* NYU-TV */
function displayOrHideFaqTV(formSection, dynamicQuestion)
{
	if (document.getElementById(formSection).style.display == 'block')
	{
		hideFaqTV(formSection, dynamicQuestion);
	}
	else
	{
		displayFaqTV(formSection, dynamicQuestion);
	}
}
	
function displayFaqTV(formSection, dynamicQuestion)
{
	document.getElementById(formSection).style.display = 'block';
	document.getElementById(dynamicQuestion).className ='activeQuestionTv';
	document.getElementById(formSection).style.borderBottomColor ='#0193d4';
	document.getElementById(formSection).style.borderBottomWidth ='1px';
	document.getElementById(formSection).style.borderBottomStyle = 'solid';
}

function hideFaqTV(formSection, dynamicQuestion)
{
	document.getElementById(formSection).style.display = 'none';
	document.getElementById(dynamicQuestion).className = 'inactiveQuestionTv';
}

/* TV Center */
function displayOrHideFaqCenter(formSection, dynamicQuestion)
{
	if (document.getElementById(formSection).style.display == 'block')
	{
		hideFaqCenter(formSection, dynamicQuestion);
	}
	else
	{
		displayFaqCenter(formSection, dynamicQuestion);
	}
}
	
function displayFaqCenter(formSection, dynamicQuestion)
{
	document.getElementById(formSection).style.display = 'block';
	document.getElementById(dynamicQuestion).className ='activeQuestionCenter';
	document.getElementById(formSection).style.borderBottomColor ='#5fae4d';
	document.getElementById(formSection).style.borderBottomWidth ='1px';
	document.getElementById(formSection).style.borderBottomStyle = 'solid';
}

function hideFaqCenter(formSection, dynamicQuestion)
{
	document.getElementById(formSection).style.display = 'none';
	document.getElementById(dynamicQuestion).className = 'inactiveQuestionCenter';
}

/* Campus Cable */
function displayOrHideFaqCable(formSection, dynamicQuestion)
{
	if (document.getElementById(formSection).style.display == 'block')
	{
		hideFaqCable(formSection, dynamicQuestion);
	}
	else
	{
		displayFaqCable(formSection, dynamicQuestion);
	}
}
	
function displayFaqCable(formSection, dynamicQuestion)
{
	document.getElementById(formSection).style.display = 'block';
	document.getElementById(dynamicQuestion).className ='activeQuestionCable';
	document.getElementById(formSection).style.borderBottomColor ='#deb406';
	document.getElementById(formSection).style.borderBottomWidth ='1px';
	document.getElementById(formSection).style.borderBottomStyle = 'solid';
}


function hideFaqCable(formSection, dynamicQuestion)
{
	document.getElementById(formSection).style.display = 'none';
	document.getElementById(dynamicQuestion).className = 'inactiveQuestionCable';
}
/* End FAQ Specific Dynamic HTML */



function changeBtn(formSection, img_id)
{
	if (document.getElementById(img_id).src == 'http://www.nyu.edu/tv.media/images/bg.expand.gif')
	{
		
	    document.getElementById(img_id).src = '../images/bg.collapse.gif';
	}
	else
	{
	    document.getElementById(img_id).src = '../images/bg.expand.gif';
	}
}

function getNavSelection(url)
{
	window.location = url;
}


/***********************************************
* Drop Down Date select script- by JavaScriptKit.com
* This notice MUST stay intact for use
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more
***********************************************/

var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];
var monthnum =['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];

function populatedropdown(dayfield, monthfield, yearfield)
{
	var today=new Date()
	var dayfield=document.getElementById(dayfield)
	var monthfield=document.getElementById(monthfield)
	var yearfield=document.getElementById(yearfield)
	
	for (var i=0; i<31; i++)
	{
		dayfield.options[i]=new Option(i+1, i+1)
	}
	dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day


	for (var m=0; m<12; m++)
	{
		monthfield.options[m]=new Option(monthtext[m], m+1)
	}
	monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthnum[today.getMonth() +1], true, true) //select today's month
	
	var thisyear=2007
	
	for (var y=0; y<7; y++)
	{
		yearfield.options[y]=new Option(thisyear, thisyear)
		thisyear++;
	}
	yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}


function showFAQ (url)
{
	window.location = url;
}

/* 
	Use to get QUERY string from url via Javascript rather than PHP 
*/

function PageQuery(q) 
{
	if(q.length > 1) 
		this.q = q.substring(1, q.length);
	else 
		this.q = null;

	this.keyValuePairs = new Array();
	
	if(q) 
	{
		for(var i=0; i < this.q.split("&").length; i++) 
		{
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() 
	{ 
		return this.keyValuePairs; 
	}
	this.getValue = function(s) 
	{
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	
	this.getParameters = function() 
	{
		var a = new Array(this.getLength());
	
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}

	this.getLength = function() 
	{ 
		return this.keyValuePairs.length; 
	}
}	


function queryString(key)
{
	var page = new PageQuery(window.location.search);
	return unescape(page.getValue(key));
}

/* Specific to Campus Cable page */
function displayItem(key1, key2)
{
	var ans = queryString(key1);
	var que = queryString(key2);
	displayFaqCable(ans, que);	
}

/* Hide/Show Function Specific to the Movie Channel Calendar */

function displayDateInfo(dateSection)
{
	//alert(dateSection);
	var dateNav = dateSection;
	var dateText = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];	
	var navText = ['mon','tue','wed','thu','fri','sat','sun'];	
	
	for (var i=0; i<7; i++)
	{
		
		if (dateText[i] == dateNav)
		{	
			document.getElementById(dateSection).style.display = 'block';
			document.getElementById(navText[i]).style.backgroundColor = '#988675';
			document.getElementById(navText[i]).style.color = '#FFF';
		}
		else
		{
			document.getElementById(dateText[i]).style.display = 'none';
			document.getElementById(navText[i]).style.backgroundColor = 'transparent';
			document.getElementById(navText[i]).style.color = '#736257';			
		}
	}
}
