
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 validateEmanuelForm( frm )
{
	if( frm.first_name.value == "" ||
	    frm.last_name.value == "" ||
	    frm.email.value == "" ||
	    frm.law_school.value == "")
	{
	    alert( "Please enter your First Name, Last Name, E-Mail Address and select Law School." );
	    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 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()
String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};

function validateBarExamFeedbackForm( frm )
{
	if( frm.First_Name.value.trim() == "" ||
	    frm.Last_Name.value.trim() == "" ||
	    frm.Email.value.trim() == "" ||
	    frm.BarExam_Taken.value.trim() == "" )
	{
	    alert( "Please enter first, last name, e-mail address and Bar Exam Taken fields." );
	    return false;
	}
	else
	{
	    return true;
	}
} // validateBarExamFeedbackForm()
function ValidateMaxLength(objId)
{
	var txtNotes;  
	txtNotes=document.getElementById(objId);  
	var strNotes=txtNotes.innerHTML;
	var blnValid;
	if(strNotes.length>500){
		blnValid=false;
		txtNotes.value=strNotes.substring(0,500);
		document.getElementById(objId).focus();
	}
	else{
		blnValid=true;
	}
	return blnValid;
}
