function showExitPopup(){
	openHTML('caaRegPopup.asp', 'SpecialOffer', '850', '800', '0');
	}


function openHTML(pageToLoad, winname, width, height, center) {
		self.name = "winMain";
		xposition=0; yposition=0;
		if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
			xposition = (screen.width - width) / 2;
			yposition = (screen.height - height) / 2;
		}
		args = 'width=' + width + ',height=' + height + ',location=0,menubar=0,resizable=1,';
		args = args + 'scrollbars=1,status=0,titlebar=0,toolbar=0,hotkeys=0,screenx=' + xposition + ',';
		args = args + 'screeny=' + yposition + ',left=' + xposition + ',top=' + yposition;
	
		window.open( pageToLoad,winname,args);
}


//Bookmark
function addBookmark(strURL) {
	bookmarkurl="http://www.lawcash.com"
	bookmarktitle="LawCash.com"
	if (document.all)
	window.external.AddFavorite(strURL,bookmarktitle);
}

function addBookmarkExtended(title,url) {
if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true;
}
}

// show something
function changeClassShow(ShowID) 
	{
		identityShow=document.getElementById(ShowID);
		identityShow.className='showBlock'; 
	}

// hide something
function changeClassHide(HideID) 
	{
		identityShow=document.getElementById(HideID);
		identityShow.className='hideBlock'; 
	}

//Form submissions and validations
//-----------------------------------------------------------------------------

// check all checkboxes
function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
	
	
}

//uncheck all checkboxes
function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}




// check all checkboxes with a unique set of array values
function checkAllUnique(field)
{
	for (i = 0; i < field.length ; i++)
	{	
		checkbox=document.getElementById(field[i]);
		checkbox.checked = true ;
	}	
}

//uncheck all checkboxes with a unique set of array values
function uncheckAllUnique(field)
{
	for (i = 0; i <  field.length; i++)
	{
		checkbox=document.getElementById(field[i]);	
		checkbox.checked = false;
	}
}




function submitSignUpForm(){document.frmSignUp.submit();}

function validateSignUpForm(frmSignUp)
{		
		//empty field check
		if(""==document.forms.frmSignUp.strEmailAddress.value)
			{
			alert("Please enter your E-Mail Address.");
			document.forms.frmSignUp.strEmailAddress.focus();
			return false;
			}
			
		if(""==document.forms.frmSignUp.strZipCode.value)
			{
			alert("Please enter your Zip Code.");
			document.forms.frmSignUp.strZipCode.focus();
			return false;
			}
			
		var thezipcode;
		
		thezipcode = document.forms.frmSignUp.strZipCode.value
		
		if(thezipcode.length < 5)
			{
			alert("Please enter a five digit Zip Code.");
			document.forms.frmSignUp.strZipCode.focus();
			return false;
		}

		if (!IsNumeric(frmSignUp.strZipCode.value)) 
	   { 
	      alert('Please enter only numbers for the zip code.') 
	      frmSignUp.strZipCode.focus(); 
	      return false; 
	    } 
		

}


function Login(){document.frmMemberLogin.submit();}

function validateLoginForm(frmMemberLogin)
{		
		//empty field check
		if(""==document.forms.frmMemberLogin.email.value)
			{
			alert("Please enter your E-Mail Address.");
			document.forms.frmMemberLogin.email.focus();
			return false;
			}
			
		if(""==document.forms.frmMemberLogin.password.value)
			{
			alert("Please enter your password.");
			document.forms.frmMemberLogin.password.focus();
			return false;
			}
			
		var thePassword;
		
		thePassword = document.forms.frmMemberLogin.password.value
		
		if(thePassword.length < 6)
			{
			alert("Your password at least six characters long.");
			document.forms.frmMemberLogin.password.focus();
			return false;
		}

}




//create complaint
function submitComplaintForm(){document.frmCreateComplaint.submit();}
	
function validateCreateComplaintForm(frmCreateComplaint)
{		

	
	//empty field check
	if(""==document.forms.frmCreateComplaint.strComplaintDefendant.value)
	{
		alert("Please enter who you want to sue.");
		document.forms.frmCreateComplaint.strComplaintDefendant.focus();
		return false;
	}
	
	if(""==document.forms.frmCreateComplaint.strComplaintTitle.value)
	{
		alert("Please enter a title for your complaint.");
		document.forms.frmCreateComplaint.strComplaintTitle.focus();
		return false;
	}
	
     if(document.forms.frmCreateComplaint.intTopic.value=="0")
	{
		alert("Please choose a topic.");
		document.forms.frmCreateComplaint.intTopic.focus();
		return false;	
	}
	
	if(document.forms.frmCreateComplaint.strCategory.value=="")
	{
		alert("Please choose a category.");
		document.forms.frmCreateComplaint.strCategory.focus();
		return false;	
	}
	
	
	if(window.document.citystate.document.forms[0].elements[0].value=="")
	{
		alert("Please choose a state.");
		window.document.citystate.document.forms[0].elements[0].focus();
		return false;	
	}
		
	if(window.document.citystate.document.forms[0].elements[1].value=="")
	{
		alert("Please choose a city.");
		window.document.citystate.document.forms[0].elements[1].focus();
		return false;	
	}
	
	if(document.forms.frmCreateComplaint.isInternet[0].checked == false && document.forms.frmCreateComplaint.isInternet[1].checked == false)
	{
		alert('Please select whether or not the company has a website.');
		document.forms.frmCreateComplaint.isInternet[0].focus()
		return false;
	}	
	
	if(document.forms.frmCreateComplaint.isNationwide[0].checked == false && document.forms.frmCreateComplaint.isNationwide[1].checked == false)
	{
		alert('Please select whether or not the company operates nationwide.');
		document.forms.frmCreateComplaint.isNationwide[0].focus()
		return false;
	}

	if(""==document.forms.frmCreateComplaint.strComplaint.value)
	{
		alert("Please enter your complaint.");
		document.forms.frmCreateComplaint.strComplaint.focus();
		return false;
	}
	
}

//edit complaint

function submitUpdateComplaintForm(){
	document.frmUpdateComplaint.submit();
}

function selectLastStateAndCity(stateCode, city)
	{	
	window.document.citystate.document.forms[2].elements[0].value=stateCode;
	window.document.citystate.document.forms[2].elements[1].value=city;
	window.document.citystate.document.frmSaveCity.submit();
	//the page focus was sometimes shifting to the iframe, so just incase.
	document.forms.frmUpdateComplaint.strComplaintDefendant.focus();
}



function validateUpdateComplaintForm(frmUpdateComplaint)
{		
	//empty field check
	if(""==document.forms.frmUpdateComplaint.strComplaintDefendant.value)
	{
		alert("Please enter who you want to sue.");
		document.forms.frmUpdateComplaint.strComplaintDefendant.focus();
		return false;
	}
	
	if(""==document.forms.frmUpdateComplaint.strComplaintTitle.value)
	{
		alert("Please enter a title for your complaint.");
		document.forms.frmUpdateComplaint.strComplaintTitle.focus();
		return false;
	}
	
     if(document.forms.frmUpdateComplaint.intTopic.value=="0")
	{
		alert("Please choose a topic.");
		document.forms.frmUpdateComplaint.intTopic.focus();
		return false;	
	}
	
	if(document.forms.frmUpdateComplaint.strCategory.value=="")
	{
		alert("Please choose a category.");
		document.forms.frmUpdateComplaint.strCategory.focus();
		return false;	
	}
	
	
	if(window.document.citystate.document.forms[0].elements[0].value=="")
	{
		alert("Please choose a state.");
		window.document.citystate.document.forms[0].elements[0].focus();
		return false;	
	}

		
	if(window.document.citystate.document.forms[0].elements[1].value=="")
	{
		alert("Please choose a city.");
		window.document.citystate.document.forms[0].elements[1].focus();
		return false;	
	}
	
	if(""==document.forms.frmUpdateComplaint.strComplaint.value)
	{
		alert("Please enter your complaint.");
		document.forms.frmUpdateComplaint.strComplaint.focus();
		return false;
	}
	
}



//create Response
function submitResponseForm(){document.frmCreateResponse.submit();}

function validateCreateResponseForm(frmCreateResponse)
{		
	//empty field check
	if(""==document.forms.frmCreateResponse.strResponseTitle.value)
	{
		alert("Please enter the title of your response.");
		document.forms.frmCreateResponse.strResponseTitle.focus();
		return false;
	}
	

	
     if(document.forms.frmCreateResponse.intResponseTypeID.value=="0")
	{
		alert("Please tell us who you are responding as.");
		document.forms.frmCreateResponse.intResponseTypeID.focus();
		return false;	
	}
	
	if(document.forms.frmCreateResponse.strResponse.value=="")
	{
		alert("Please enter your response.");
		document.forms.frmCreateResponse.strResponse.focus();
		return false;	
	}

}




//called functions for validation

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
   }
   
//so textareas can have a maxlength attribute
function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
} 
   

function search() {
	var searchType
	searchtype = document.frmSearchBox.selSearchType.options[document.frmSearchBox.selSearchType.selectedIndex].value
	if (searchtype == 0) {
		document.frmSearchBox.action = '/search/searchResults.asp';
	}
	
	if (searchtype == 1) {
		document.frmSearchBox.action = '/search/searchCases.asp';
	}
	if (searchtype == 2) {
	      document.frmSearchBox.action = '/search/searchRecalls.asp';
	}
	if (searchtype == 3) {
	      document.frmSearchBox.action = '/search/searchComplaints.asp';
	}
	
	if (document.frmSearchBox.searchTerm.value == '')
	{
		alert('LawCash.com Search Error\nPlease enter some search text.');
		document.frmSearchBox.searchTerm.focus();
	}
	else
	{
		document.frmSearchBox.submit();
	}
}


function filterlist(selectobj) {

  // VARIABLES

  // HTML SELECT object
  this.selectobj = selectobj;

  // Flags for regexp matching.
  // "i" = ignore case; "" = do not ignore case
  this.flags = "i";

  // Make a copy of the options array
  this.optionscopy = new Array();
  for (var i=0; i < selectobj.options.length; i++) {
    this.optionscopy[i] = new Option();
    this.optionscopy[i].text = selectobj.options[i].text;
    this.optionscopy[i].value = selectobj.options[i].value;
  }

  //==================================================
  // METHODS
  //==================================================

  //--------------------------------------------------
  this.reset = function() {
  // This method resets the select list to the original state.
  // It also unselects all of the options.

    this.set("");
  }

  //--------------------------------------------------
  this.set = function(pattern) {
  // This method removes all of the options from the select list,
  // then adds only the options that match the pattern regexp.
  // It also unselects all of the options.
  // In case of a regexp error, returns false

    var loop=0, index=0, regexp, e;

    // Clear the select list so nothing is displayed
    this.selectobj.options.length = 0;

    // Set up the regular expression
    try {
      regexp = new RegExp(pattern, this.flags);
    } catch(e) {
      return;
    }

    // Loop through the entire select list
    for (loop=0; loop < this.optionscopy.length; loop++) {

      // Check if we have a match
      if (regexp.test(this.optionscopy[loop].text)) {

        // We have a match, so add this option to the select list
        this.selectobj.options.length = index + 1;
        this.selectobj.options[index].text = this.optionscopy[loop].text;
        this.selectobj.options[index].value = this.optionscopy[loop].value;
        this.selectobj.options[index].selected = false;

        // Increment the index
        index++;
      }
    }
  }

  //--------------------------------------------------
  this.set_ignore_case = function(value) {
  // This method sets the regexp flags.
  // If value is true, sets the flags to "i".
  // If value is false, sets the flags to "".

    if (value) {
      this.flags = "i";
    } else {
      this.flags = "";
    }
  }

}

