
/* Remove functions that you do not need before any deployments !! */




function ClearSearch() {
	try {
		var element = window.document.getElementById('SearchKeywords');
		if(element.value=='Search Our Website'){
			element.value='';
		}else{}
	} catch(e) {}
}

function WriteSearch() {
	try {
		var element = window.document.getElementById('SearchKeywords');
		if(element.value==''){
			element.value='Search Our Website';
		}else{}
	} catch(e) {}
}


ReplaceSearch = function() {
	try {
		var elements = window.document.getElementById('SearchKeywords');
		if(window.addEventListener){	
			elements.addEventListener('focus', ClearSearch, true);
			elements.addEventListener('blur', WriteSearch, true);	
		}else{
			elements.attachEvent("onfocus",ClearSearch);
			elements.attachEvent("onblur",WriteSearch);
		}
	} catch(e) {}
}


if(window.addEventListener) window.addEventListener('load', ReplaceSearch, false); // gecko, safari, konqueror and standard
else if(document.addEventListener) document.addEventListener('load', ReplaceSearch, false); // opera 7
else if(window.attachEvent) { // win/ie
	window.attachEvent('onload', ReplaceSearch);
} else { // mac/ie5
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			ReplaceSearch();
		}
	} else {
		window.onload = function() {
			ReplaceSearch();
		}
	}
}






function WriteFlash(SWFPath,SWFWidth,SWFHeight,SWFParams) {
	try {
		var str = '\n';
		var NewParams = '';
		str+='	<object type="application\/x-shockwave-flash" data="' + SWFPath + '" width="' + SWFWidth + '" height="' + SWFHeight + '" title="">\n';
		str+='		<param name="wmode" value="transparent">\n';
		str+='		<param name="movie" value="' + SWFPath + '">\n';
		if(typeof(SWFParams) != "undefined"){
			var SWFParamsArray = SWFParams.split(';');
			for (var i=0; i<SWFParamsArray.length; i++) {
				var EachParam = SWFParamsArray[i].split(',');
				NewParams+='		<param name="' + EachParam[0] + '" VALUE="' + EachParam[1] + '">\n';
			}
			str+=NewParams;
		}
		str+='	<\/object>\n';
		document.write(str);
	} catch(e) {}
}







/* These aren't in the onload attach event above */




/* From Architectural Resources */
function Highlight(ElementID){

	// get the old element and set it to nothing
	try{
		var obj = document.getElementById(currentElementID);
		obj.className="";
	}
	catch(e){}

	// set the new element border and color
	try{
		var obj = document.getElementById(ElementID);
		obj.className="Sel";
	}
	catch(e) {}

	// make the new element the current element
	try{
		currentElementID = ElementID
		document.getElementById('current').value = ElementID;
	}
	catch(e){}
}

function SwapImg(ElementID,strSrc){
	// swap img src
	try{
		var obj = document.getElementById(ElementID);
		obj.src=strSrc;
	}
	catch(e) {}
}


AttachFunction = function() {
	try{
		if(document.getElementById('Image1')) {
			Highlight('Image1');
		}
	}
	catch(e){}
}

if(window.addEventListener) window.addEventListener('load', AttachFunction, false); // gecko, safari, konqueror and standard
else if(document.addEventListener) document.addEventListener('load', AttachFunction, false); // opera 7
else if(window.attachEvent) { // win/ie
	window.attachEvent('onload', AttachFunction);
} else { // mac/ie5
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			AttachFunction();
		}
	} else {
		window.onload = function() {
			AttachFunction();
		}
	}
}







/* Attaching an alert to all form textarea's */
//function EmailAlert() {
//	return confirm('These materials have been prepared for informational purposes and are not legal advice. The information is not intended to create, and receipt of does not constitute, a lawyer-client relationship.\n\nBy sending an e-mail to our firm you do not become a client. Please do not provide any confidential information in your e-mail inquiries.\n\nPlease click the "OK" button if you understand and accept the foregoing statement and wish to proceed.');
//}

//function CommentAlert() {
//	alert('Submission of this form is not intended to create, and our receipt of it does not constitute, a lawyer-client relationship.\n\nAny information provided to us in this form is not protected from disclosure. By completing this form you do not become a client. Please do not provide any confidential information in the "Comments" field.');
//}

//AttachAlert = function() {
//	var elements = document.getElementsByTagName('A');
//	
//	for (i=0;i<elements.length;i++){
//		if(elements[i].href.substring(0,7) == 'mailto:') {
//			elements[i].onclick=function(){return EmailAlert();}
//			elements[i].title = "These materials have been prepared by Jaeckle Fleischmann & Mugel, LLP for informational purposes and are not legal advice. The information is not intended to create, and receipt of does not constitute, a lawyer-client relationship. By sending an e-mail to our firm you do not become a client. Please do not provide any confidential information in your e-mail inquiries.";
//		} else {}
//	}
//}


//function TextAreaAlert() {
//		// Attach to the change check JS to all TEXTAREA elements...
//		var elements = window.document.getElementsByTagName('TEXTAREA');
//		for (i=0; i <  elements.length; i++){ 
//			if(window.addEventListener){	
//			  window.addEventListener('blur', CommentAlert, true);	
//			}else{
//			  elements[i].attachEvent("onblur",CommentAlert);

//			}
//		}
//}


//if(window.addEventListener) window.addEventListener('load', AttachAlert, false); // gecko, safari, konqueror and standard
//else if(document.addEventListener) document.addEventListener('load', AttachAlert, false); // opera 7
//else if(window.attachEvent) { // win/ie
//	window.attachEvent('onload', AttachAlert);
//	window.attachEvent('onload', TextAreaAlert);
//} else { // mac/ie5
//	if(typeof window.onload == 'function') {
//		var existing = onload;
//		window.onload = function() {
//			existing();
//			AttachAlert();
//			TextAreaAlert();
//		}
//	} else {
//		window.onload = function() {
//			AttachAlert();
//			TextAreaAlert();
//		}
//	}
//}




/* North American Health Plans */

// Use this function to jump user to another page

function JumpRedirect(strAddress) {
	try {
		if (strAddress != "") {
			//alert(strAddress);
			window.location.href=strAddress;
		}
	} catch(e) {}
}





// Use this function for resizing embedded iframes

function getElementPosition(elemID) {
   	try {	
		var offsetTrail = document.getElementById(elemID);
		var offsetLeft = 0;
		var offsetTop = 0;
		while (offsetTrail) {
			offsetLeft += offsetTrail.offsetLeft;
			offsetTop += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
		}
		if (navigator.userAgent.indexOf("Mac") != -1 && 
			typeof document.body.leftMargin != "undefined") {
			offsetLeft += document.body.leftMargin;
			offsetTop += document.body.topMargin;
		}
		return {left:offsetLeft, top:offsetTop};
	}catch(e){
	   return {left:0, top:0};
	}
    //return "left:" + offsetLeft + ", " + "top:" + offsetTop;
}




// Add jump menu script -- uses JumpRedirect()

AttachJump = function() {
	try {
		var element = document.getElementById('JumpMenu');
		element.onchange = function(){JumpRedirect(element.value);}
	} catch(e) {}
}





// Resize home page news scrolling div

AttachResize = function() {
	try {
		var ScrollElement = document.getElementById('HomeNewsScroll');
		var ContentElement = document.getElementById('HomeAuthorContent');
		//alert(ContentElement.clientHeight - 18);
		ScrollElement.style.height = ContentElement.clientHeight - 18 + 'px';
	} catch(e) {}
}



if(window.addEventListener) { // gecko, safari, konqueror and standard
	window.addEventListener('load', AttachJump, false);
	window.addEventListener('load', AttachResize, false);
	window.addEventListener('resize', AttachResize, false);
} else if(document.addEventListener) {  // opera 7
	document.addEventListener('load', AttachJump, false);
	document.addEventListener('load', AttachResize, false);
	document.addEventListener('resize', AttachResize, false);
} else if(window.attachEvent) { // win/ie
	window.attachEvent('onload', AttachJump);
	window.attachEvent('onload', AttachResize);
	window.attachEvent('onresize', AttachResize);
} else { // mac/ie5
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			AttachJump();
			AttachResize();
		}
	} else {
		window.onload = function() {
			AttachJump();
			AttachResize();
		}
	}
}



// Controls height of iframes

function ResizeToHeight(BoxElementID, offsetBottom) {
	var ElementHeight;
	try {
		if (BoxElementID== 'FrameWrapper') {
			if(document.body.clientHeight > 0){
				ElementHeight = document.body.clientHeight - 2 - getElementPosition(BoxElementID).top ;
			}
		} else {
		
			if(document.body.clientHeight > 0){
				ElementHeight = document.body.clientHeight - 1 - getElementPosition(BoxElementID).top ;
			}
		}
		
		if (offsetBottom){
			 ElementHeight = ElementHeight - offsetBottom; 
		}
		ElementHeight = ElementHeight + "px";

		document.getElementById(BoxElementID).style.height=ElementHeight;
	
	}catch(e){}
}






// Manage display and hide of Email to Friend app and Bookmarks app


function CloseSelf(ElementID) {
	try {
		var obj = document.getElementById(ElementID);
		obj.style.display='none';
	}
	catch(e){}
}

function DisplayElement(ElementID) {
	try {
		var obj = document.getElementById(ElementID);
		obj.style.display='inline';
	}
	catch(e){}
}

function AttachHelpClass(ElementID) {
	try {
		var obj = document.getElementById(ElementID);
		obj.className='HelpBox';
	}
	catch(e){}
}

function AttachHelpClose(ElementID,CloserElementID) {
	try {
		// Attach to the element
		var obj = document.getElementById(CloserElementID);
		obj.onclick=function(){CloseSelf(ElementID);}
	}
	catch(e){}
}

function getElementPosition(elemID) {
   	try {
		var offsetTrail = document.getElementById(elemID);
		var offsetLeft = 0;
		var offsetTop = 0;
		while (offsetTrail) {
			offsetLeft += offsetTrail.offsetLeft;
			offsetTop += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
		}
		if (navigator.userAgent.indexOf("Mac") != -1 && 
			typeof document.body.leftMargin != "undefined") {
			offsetLeft += document.body.leftMargin;
			offsetTop += document.body.topMargin;
		}
		//alert("left:" + offsetLeft + ", " + "top:" + offsetTop);
		return {left:offsetLeft, top:offsetTop};
	}catch(e){
		return {left:100, top:100};
	}

	//return "left:" + offsetLeft + ", " + "top:" + offsetTop;
}

function ShowHelp(ElementID,CallerID,strWidth,strOffsetTop,strOffsetLeft) {
	try {
		var CallerTop = getElementPosition(CallerID).top;
		var CallerLeft = getElementPosition(CallerID).left;
		var obj = document.getElementById(ElementID);
		var ParentTop = CallerTop + strOffsetTop;
		var ParentLeft = CallerLeft - strOffsetLeft;
		obj.style.display = 'block';
		obj.style.width = strWidth + 'px';
		if(CallerLeft == 0){
			obj.style.left = '45%';
		}else{
			obj.style.left = ParentLeft + 'px';
		}
		if(CallerTop == 0){
			obj.style.top = '35%';
		}else{
			obj.style.top = ParentTop + 'px';
		}
	}
	catch(e){}
}

function InitializeHelpBox(strBoxId,strLinkID,strCloser) {
	try {
		AttachHelpClose(strBoxId,strCloser);
		AttachHelpClass(strBoxId);
		DisplayElement(strLinkID);
	}
	catch(e){}
}






// Basic validation for Email to Friend Application, can be used on other forms



function generateError(elemID,errMsg) {
	try {
		var obj = document.getElementById(elemID);
		obj.className="error";
		try{
			var obj2 = document.getElementById('lbl'+elemID);
			obj2.className="error";
		}catch(e){}
		putFocusOnElement(elemID);
		//alert(errMsg);
	}catch(e){}
}


function putFocusOnElement(elemID){
	// Put focus on an element by passing its ident
	try{
		document.getElementById(elemID).focus();
	}
	catch(e){}
}

function ValidateBasic(elemID,errMsg,bolRequired){
	var strError = false;
	// Initiate basic validation, at least for required fields
	try{
		if(document.getElementById(elemID).value == '' && bolRequired == 1){
			strError = 1;
			generateError(elemID,errMsg);
			CollectErrors(errMsg);
			return strError;
		}else{
			strError = false;
			var obj = document.getElementById(elemID);
			obj.className="";
			try{
				var obj2 = document.getElementById('lbl'+elemID);
				obj2.className="";
			}catch(e){}
			return 0;
		}
	}
	catch(e){}
}

function ValidateEmail(elemID,errMsg,bolRequired){
	var strError = false;
	var obj = document.getElementById(elemID);
	// Initiate basic validation, at least for required fields
	try{
		// is it blank and required?
		if(obj.value == '' && bolRequired == 1){
			strError = 1;
			generateError(elemID,errMsg);
			CollectErrors(errMsg);
			return strError;
		// is it formatted as an email address?
		} else if(((obj.value.indexOf(".") < 3) || (obj.value.indexOf("@") < 2)) && obj.value != ''){
			strError = 1;
			generateError(elemID,errMsg);
			CollectErrors(errMsg);
			return strError;
		}else{
			strError = false;
			obj.className="";
			try{
				var obj2 = document.getElementById('lbl'+elemID);
				obj2.className="";
			}catch(e){}
			return 0;
		}
	}
	catch(e){}
}



function CollectErrors(errMsg){
	var errorText;
	var ErrBox = document.getElementById('ErrMsg');
	ErrBox.innerText = errMsg + '\n' + ErrBox.innerText;
	//alert(ErrBox.innerText);
}


function CheckFields() {
	try {
		var ErrBox = document.getElementById('ErrMsg');
		var strError = 0
		strError = strError + Validations();

		if((ErrBox.innerText != '') && (strError > 0)){
			alert(ErrBox.innerText);
			ErrBox.innerText = '';
		}

		//alert(strError);
		if(strError < 1){
		}else{
			//if(IsSubmit == "true"){
				//stop the submit
				return false;
			//}
		}

	}catch(e){}
}







// Pop-up window at 500x400
function PopWin500x400(url) {
	newWindow = window.open(url,"","toolbar=no,location=no,scrollbars=yes,width=500,height=400");
}

// Generic Pop-up window where you pass width and height
function PopWin(url,strWidth,strHeight) {
	newWindow = window.open(url,"","toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight);
}





// cookie functions

function createCookie(name,value,days) {
	try {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	} catch(e) {}
}

function readCookie(name) {
	try {
		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;
	} catch(e) {}
}

function eraseCookie(name) {
	try {
		createCookie(name,"",-1);
	} catch(e) {}
}
