// ************************************************
// Begin Project 7 Functions
// ************************************************
function P7_swapClass(){ //v1.4 by PVII
 var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
 if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}
function P7_writeStyles(a){ //v1.1 by PVII
 var tS="<sty"+"le type=\"text/css\">";
 tS+="\n"+a+"\n<"+"/sty"+"le>";document.write(tS);
}

//P7_writeStyles('.closed ul{display:none;}.open ul{display:block;}.closed2 div{display:none;}.open2 div{display:block;}.closed3 div{display:none;}.open3 div{display:block;}');

P7_writeStyles('.closedSmall ul{display:none;}.closed ul{display:none;}.openSmall ul{display:block;}.open ul{display:block;}.closed2 ul,.closed2 div{display:none;}.open2 ul,.open2 div{display:block;}.closed3 ul,.closed3 div{display:none;}.open3 ul,.open3 div{display:block;}');

// ************************************************
// Swaping Functions
// ************************************************
function swapClass(elementId,newClassName){ // Finds element by id then gives it the new class name
	document.getElementById(elementId).className = newClassName;
}
function swapChildId(elementId,newIdName){ // Finds element by id then gives it the new class name
	document.getElementById(elementId).firstChild.id = newIdName;
}

// ************************************************
//	Change and Track Font Functions
// ************************************************
function setActiveStyleSheet(title) {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			document.getElementById(a.getAttribute("title")).className="";
			if(a.getAttribute("title") == title){
				a.disabled = false;
				document.getElementById(title).className="atFont";
			}
		}
	}
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  return ('medium');
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
  setNavState();
}

window.onunload = function(e) {
  title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
if (title == 'null') {
  title = getPreferredStyleSheet();
}

/*setActiveStyleSheet(title);*/

 /*code for validation */

/* search validation */

function isBlank(testStr){
	if (testStr.length==0)  // nothing entered
		return true
	for (var i = 0; i <= testStr.length-1; i++)  // all spaces?
		if (testStr.charAt(i) != " ")
			return false
	return true
}

function search_submit() {
	if (isBlank(document.searchForm.searchCriteria.value)){
		alert("Please enter Search Criteria");
		return false;
		}
	//document.searchForm.submit();
}

function search_submit_href() {
	
	if (isBlank(document.searchForm.searchCriteria.value)){
		alert("Please enter Search Criteria");
		return false;
		}
		
	window.location="searchremote.asp?searchCriteria="+document.searchForm.searchCriteria.value;
}

function checkEnter(e){ /*e is event object passed from function invocation var characterCode literal character code will be stored in this variable*/
	if(e && e.which){ /*if which property of event object is supported (NN4)*/
		e = e;
		characterCode = e.which /*character code is contained in NN4's which property*/
	}else{
		e = event
		characterCode = e.keyCode /*character code is contained in IE's keyCode property*/
	}
	return characterCode;
}

function checkEnter_Search(e){
	charCode = checkEnter(e);
	if(charCode == 13 ){ /*if generated character code is equal to ascii 13 (if enter key)*/
		search_submit(); //submit the form
		return false; 
	}else{
		return true; 
	}
	
}



function checkEnter_Login(e){ 
	charCode =checkEnter(e) ;
	if(charCode == 13 ){ /*if generated character code is equal to ascii 13 (if enter key)*/
		form1_submit(); //call the login validation
	return false; 
	}else{
		return true; 
	}

}
var flag = true;
function lookup_Forms() {
		if(!document.Lookup.optRadio[0].checked){
		alert("You cannot continue without accepting the license agreement");
		return false;
		}
		if(isBlank(document.Lookup.LenderAccessCode.value)){
		alert("Please enter your Lender Access Code");
		return false;
		}
return true;
}


/*code ends here*/

