//####################################################
//## Function to display or hide areas contained by a div tag
//## Used on the ECBA Calendar page
//##


function showHide(shID) {
	if (document.getElementById(shID)) {
		if (document.getElementById(shID+'-show').style.display != 'none') {
			document.getElementById(shID+'-show').style.display = 'none';
			document.getElementById(shID).style.display = 'block';
		}
		else {
			document.getElementById(shID+'-show').style.display = 'inline';
			document.getElementById(shID).style.display = 'none';
		}
	}
}



//####################################################
//## This function accepts the name of a query string
//## variable and returns it's value.
//##
//## It relies on function calls to init.js which is 
//## a core Sharepoint file in the hive.
//##
//## Example: getQueryStringValue("category")
//## 

function getQueryStringValue(qsVar){
	//First we must call the EnsureSetup method
	JSRequest.EnsureSetup(); 

	//Get a query string parameter called ItemId. i.e - "page.aspx?category=parks" will return parks
	itemId = JSRequest.QueryString[qsVar];

	if(itemId != null)
	{
		return unescape(itemId);
	} else {
		return "";
	}
}

//## End function getQueryStringVar ##//
//####################################################

//## Use this function when you don't want to unescape value
//## 

function getQueryStringRawValue(qsVar){
	//First we must call the EnsureSetup method
	JSRequest.EnsureSetup(); 

	//Get a query string parameter called ItemId. i.e - "page.aspx?category=park%20place" will return park place
	itemId = JSRequest.QueryString[qsVar];

	if(itemId != null)
	{
		return (itemId);
	} else {
		return "";
	}
}

//## End function getQueryStringVar ##//
//####################################################

//## Begin functions for Interview Builder ##//
//####################################################
//The following two functions manipulate the div tags to hide or show menus based on users' actions

function appendDetails(){
	var details = $("#detailInfo");
	
	var coopName = '<strong>Cooperative Name: </strong>'+$("input[name='coop']").val();
	var positionTitle = '<strong>Position Title: </strong>'+$("input[name='title']").val();
	var jobLocation = '<strong>Job Location: </strong>'+$("input[name='location']").val();
	var interviewer = '<strong>Interviewer: </strong>'+$("input[name='interviewer']").val();
	var headerText = '<h3>Position Info:</h3><p>'+coopName+'<br/>'+positionTitle+'<br/>'+jobLocation+'<br/>'+interviewer+'</p>'
	
	$(details).append(headerText);
}

function insertQuestions(){
	var mainForm = $("#webForm");
	var displayForm = $("#resultsContainer");
	var questionArea = $("#displayQuestions");
	appendDetails();
	$("input:checked").each(function() {
		var question = $(this).val();
		if (question != "LWE"){
			$(questionArea).append("<p>"+question+"</p>");	
		}
	});
	$(mainForm).fadeOut(300);
	$(displayForm).fadeIn(1000);
}

function showFullList(){
	$("#resultsContainer").fadeOut(300);
	$("#webForm").fadeIn(1000);
	$("#detailInfo, #displayQuestions").empty();
	return false;
}

function printPartOfPage(elementId) {
	var printContent = document.getElementById(elementId);
	var windowUrl = 'about:blank';
	var uniqueName = new Date();
	var windowName = 'Print' + uniqueName.getTime();
	var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');
	
	printWindow.document.write(printContent.innerHTML);
	printWindow.document.close();
	printWindow.focus();
	printWindow.print();
	printWindow.close();
}

function hideShow(toggleObject, imageTag){
	var toggleObject = $('#'+toggleObject);
	var imageObject = $('#'+imageTag);
	if($(toggleObject).css("display")== "none"){
		$(toggleObject).fadeIn();
		$(imageObject).attr("src", "/InterestAreas/humanresources/images/minus.gif");
	}
	else{
		$(toggleObject).fadeOut();
		$(imageObject).attr("src", "/InterestAreas/humanresources/images/plus.gif");
	}	
}

//## End Interview Builder Functions ##//
//####################################################



//####################################################
//## This function expands and contracts the CRN
//## results more info section.
//##

function expandResultDetails () {
	document.getElementById("resultContent").style.display="block";
	document.getElementById("moreInfoLink").innerHTML = "<a href=\"javascript:;\" onclick=\"return contractResultDetails();\">Less information &gt;&gt;</a>";
	return false;
}

function contractResultDetails () {
	document.getElementById("resultContent").style.display="none";
	document.getElementById("moreInfoLink").innerHTML = "<a href=\"javascript:;\" onclick=\"return expandResultDetails();\">More information &gt;&gt;</a>";
	return false;
}




//## End ExpandResultDetails Functions ##//
//####################################################


//####################################################
//## This code changes the Register Now text to 
//## Event Details.
//##
//## Commented out for now.  Causes weird flash.
//_spBodyOnLoadFunctionNames.push("changeRegisterNowText");

function changeRegisterNowText() {
	if (document.getElementById("EventTableHeading")) {
	    document.getElementById("EventTableHeading").innerText = "Event Details";
	}
}
//## End Code ##//
//####################################################





