﻿// JScript File
function validateInputField(objName, objValue, strError)
{
    var charpos = objValue.search("[^A-Za-z0-9\-_\s,.^:/%@$ ]"); 
	if (objValue.length > 0 && charpos >= 0)
	{	
		strError += objName + ": Invalid input value.  Characters allowed are A-Z,a-z,0-9,- and _. Re-enter please.\n [Error character position " + eval(charpos+1) + "]\n\n";
	}
	return strError;
}

function isEnterKey(evt)
{
    evt = (evt) ? evt : (window.event) ? window.event : "";
    var theKey;
    if (evt) {
        theKey = (evt.which) ? evt.which : evt.keyCode;
    }
    return (theKey == 13);
}

function ProcessOnEnter(fld, evt)
{
    if (isEnterKey(evt)) {
        DoSubmitCWSSearch(fld);
        return false;
    }
    return true;    
}
function DoSubmitCWSSearch(fld)
{
    var url="/Content/Listing.aspx?Search="
    
    if (fld != null)
    {
		// needs to escape the string first to avoid invalid characters to get through the search field.
        url = url + escape(fld.value);
    }
	window.location.href=url;  
    return;
}
function SubmitCWSSearch()
{
    DoSubmitCWSSearch( document.getElementById('ctl00_Main_TextBox_Search') );
}
function SubmitTopCWSSearch()
{
    DoSubmitCWSSearch( document.getElementById('ctl00_TextBox_Search_Top') );
}
function SubmitForumTopCWSSearch()
{
    DoSubmitCWSSearch( document.getElementById('ctl00_ctl00_TextBox_Search_Top') );
}
function onTopSearchMouseDown( textBox )
{
    if( textBox.spliceState == null )
    {
        textBox.spliceState = "changed";
        textBox.value = "";
        textBox.className = "cws_search_input_top_normal";
    }
}