
function InvokeSearch()
{
	var strParam="";
	var bReturn;
	var sCategory = "";
	var sTopic = "";
	var sCategoryTitle = "";
	var sTopicTitle = "";
	var sSearchOpt;
	
	/*if (window.document.SearchForm.ByTitle.checked) 
		sSearchOpt=window.document.SearchForm.ByTitle.value;
	else
		sSearchOpt=window.document.SearchForm.ByISBN.value;*/
	
	strParam=replEscapeChar(window.document.SearchForm.searchCriteria.value);

	bReturn = IsSpaceOnly(strParam);

	if (bReturn) 
	{
		strParam= trimit(window.document.SearchForm.searchCriteria.value);
	}
	
	//if ((strParam=="" ) && ((window.document.SearchForm.topic[window.document.SearchForm.topic.selectedIndex].value==0) || (window.document.SearchForm.topic[window.document.SearchForm.topic.selectedIndex].value==null)))
	if (strParam=="" )
	{
			alert('Please enter your search criteria (may be a title, author, ISBN, or keyword).');
			return false;
	}		
	else if (strParam!="" ) 
	{			
			window.document.SearchForm.target = "resource window";
			window.document.SearchForm.action ="http://www.aspenpublishers.com/search.asp?Mode=SEARCH&keyword=" + escape(strParam)  + "&ISBN=&Author=&Sort=DEFAULT&profitcenter=30"
			window.document.SearchForm.submit();		
			return true;
	}

	
	/*if ((strParam!="" ) && (window.document.SearchForm.topic[window.document.SearchForm.topic.selectedIndex].value!=0) && (window.document.SearchForm.topic[window.document.SearchForm.topic.selectedIndex].value!=null))

		{		
			//sCategory = window.document.SearchForm.category.options[window.document.SearchForm.category.selectedIndex].value;
			//sTopic = window.document.SearchForm.topic[window.document.SearchForm.topic.selectedIndex].value;
			
			//sCategoryTitle =window.document.SearchForm.category.options[window.document.SearchForm.category.selectedIndex].text;
			//sTopicTitle =window.document.SearchForm.topic.options[window.document.SearchForm.topic.selectedIndex].text;
			//window.document.SearchForm.action ="search.asp?Mode=SEARCH&keyword=" + escape(strParam) + "&Category=" + escape(sCategory) + "&Topic=" + escape(sTopic) + "&CategoryTitle=" + escape(sCategoryTitle) + "&TopicTitle=" + escape(sTopicTitle) + "&ISBN=&Author=&Sort=DEFAULT"
			window.document.SearchForm.action ="search.asp?Mode=SEARCH&keyword=" + escape(strParam) + "&Category=" + escape(sCategory) + "&Topic=" + escape(sTopic) + "&CategoryTitle=" + escape(sCategoryTitle) + "&TopicTitle=" + escape(sTopicTitle) + "&ISBN=&Author=&Sort=DEFAULT"
			window.document.SearchForm.submit();		
			return true;
		}
	*/
	//if ((strParam!="" ) && ((window.document.SearchForm.topic[window.document.SearchForm.topic.selectedIndex].value==0)||(window.document.SearchForm.topic[window.document.SearchForm.topic.selectedIndex].value==null)))
	/*
	else if ((strParam=="" ) && (window.document.SearchForm.topic[window.document.SearchForm.topic.selectedIndex].value!=0) && (window.document.SearchForm.topic[window.document.SearchForm.topic.selectedIndex].value!=null))
		{
			sCategory = window.document.SearchForm.category.options[window.document.SearchForm.category.selectedIndex].value;
			sTopic = window.document.SearchForm.topic[window.document.SearchForm.topic.selectedIndex].value;
			
			sCategoryTitle =window.document.SearchForm.category.options[window.document.SearchForm.category.selectedIndex].text;
			sTopicTitle =window.document.SearchForm.topic.options[window.document.SearchForm.topic.selectedIndex].text;

			window.document.SearchForm.action ="search.asp?Mode=BROWSE&Category=" + escape(sCategory) + "&Topic=" + escape(sTopic) + "&CategoryTitle=" + escape(sCategoryTitle) + "&TopicTitle=" + escape(sTopicTitle) + "&Sort=TITLE"
			window.document.SearchForm.submit();
			return true;
		}
	else	
		{
			if (!((window.document.SearchForm.category[window.document.SearchForm.category.selectedIndex].value==null) || (window.document.SearchForm.category[window.document.SearchForm.category.selectedIndex].value==0) || (window.document.SearchForm.category.value.indexOf("Choose")==0)))
				{
				alert("Please select the subcategory");
				}
			else
				{
				alert("Please enter a search string...");
				}
			return false;
		} 
	*/
}
function replEscapeChar(strKeyword)	{
	if (strKeyword.indexOf("+")>0)
		//replace the + sign with the some other character and parse it back in the posted asp page.
		return strKeyword.replace("+","~");
	else
		return strKeyword;
}
	
function IsSpaceOnly(s) 
{
	var i;
	for(i=0; i<=s.length-1; i++)	{
		if ((s.charAt(i) != ' ')) {
			return false;
		}
	}
	return true;	
}
function trimit(s)
{
	
	while (s.length!=0)
	{
		s = s.replace(" ","");	
	}
	return s;
}

function popWindow( url, width, height )
{
	var wnd = window.open( url,
			       '_blank', 
			       'height=' + height + ',width=' + width + ',location=no,menubar=no,scrollbars=yes,resizable=no,toolbar=no'
			       );
	wnd.focus();	
} // popWindow

function popupTimeline()
{
    return popWindow( '../law_students/timeline.asp', 600, 315 );
} // popTimeline()

function validateSignupForm( frm )
{
	if( frm.first_name.value == "" ||
	    frm.last_name.value == "" ||
	    frm.email.value == "" )
	{
	    alert( "Please enter your first and last name, and your e-mail address." );
	    return false;
	}
	else
	{
	    return true;
	}
} // validateSignupForm()

function validateSignupForm( frm )
{
	if( frm.first_name.value == "" ||
	    frm.last_name.value == "" ||
	    frm.email.value == "" )
	{
	    alert( "Please enter your first and last name, and your e-mail address." );
	    return false;
	}
	else
	{
	    return true;
	}
} // validateSignupForm()

function validateRequestForm( frm )
{
	if( frm.first_name.value == "" ||
	    frm.last_name.value == "" )
	{
	    alert( "Please enter your first and last name." );
	    return false;
	}
	else
	{
	    return true;
	}
} // validateRequestForm()

// by Paul@YellowPencil.com and Scott@YellowPencil.com
// feel free to delete all comments except for the above credit

function addLoadEvent(func) {
	var oldonload = window.onload;

	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else 
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

function setTall() {
	if (document.getElementById) {
		if (document.getElementById('left') && document.getElementById('contentContainer')) {
			var divs = new Array(document.getElementById('left'), document.getElementById('contentContainer'));
			
			var maxHeight = 0;
			for (var i = 0; i < divs.length; i++) {
				if (divs[i]) {
					if (divs[i].offsetHeight > maxHeight) maxHeight = divs[i].offsetHeight;
				}
			}

			if (maxHeight < 900) {
				maxHeight = 900;
			}

			for (var i = 0; i < divs.length; i++) {
				if (divs[i]) {
					divs[i].style.height = maxHeight + 'px';
		
					if (divs[i].offsetHeight > maxHeight) {
						divs[i].style.height = (maxHeight - (divs[i].offsetHeight - maxHeight)) + 'px';
					}
				}
			}
		} 
	} 		
}

addLoadEvent(setTall);

window.onresize = function() {
	setTall();
}
