function CenteredWindow(dest, windowName, w, h, scroll,resize,tool,loc) {
	var	winl = ((screen.width - w) / 2) - 10;
	var	wint = ((screen.height - h) / 2) - 25;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resize+',toolbars='+tool+',location='+loc+'';
win = window.open(dest, windowName, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

//Stylesheet Switcher Code
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;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
    createCookie("style", title, 365);
}


function Toprint() {
window.print();
}

function openQuestion(num)
{
		for (i=1; i<10; i++)
		{
				var questionId = "question" + i;
				var answerId = "answer" + i;
				if (num == i)
				{
						document.getElementById(questionId).className = "QuestionTitleOn";
						document.getElementById(answerId).className = "QuestionAnswerOn";			
				}
				else if (num != i)
				{
						document.getElementById(questionId).className = "QuestionTitleOff";
						document.getElementById(answerId).className = "QuestionAnswerOff";
				}
		}
}

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() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}
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;
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


addLoadEvent(function() {
  if (document.getElementById) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
	}
});

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var browser=navigator.appName;
if (document.layers) {
//  onresize = function() { location.reload(); }
}

else if (document.all && browser != "Microsoft Internet Explorer") onresize = function() {
			 window.location.reload(); 
}

// ACTIVE CONTENT WORKAROUNG SCRIPT
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function validateForm(theForm)

{
	/*
    if (theForm.TextFirstName.value == "") 
		{
	    	alert("Please provide your first name.");
    		theForm.TextFirstName.focus();
       		return false;
        
		} 
    if (theForm.TextLastName.value == "")  
		{
	    	alert("Please provide your last name.");
    		theForm.TextLastName.focus();
        	return false;
		} 
    if (theForm.TextAddress.value == "")  
		{
	    	alert("Please provide your address.");
    		theForm.TextAddress.focus();
        	return false;
		} 
    if (theForm.TextCity.value == "")  
		{
	    	alert("Please provide your city.");
    		theForm.TextCity.focus();
        	return false;
		} 
    if (theForm.DropState.value == "")  
		{
	    	alert("Please select your State from the list.");
    		theForm.DropState.focus();
            return false;
		} 
	var InString = theForm.TextZip.value
	if (InString.length==0) 
		{
	    	alert("Please provide your ZIP Code.");
    		theForm.TextZip.focus();
			return false;
		}
	if ((InString.length!=5) && (InString.length!=10))
		{
	    	alert("Please provide a valid ZIP Code.");
    		theForm.TextZip.focus();
		    return false;
		}
	RefString="1234567890-";
	for (Count=0; Count < InString.length; Count++)  
		{
			TempChar= InString.substring (Count, Count+1);
			if (RefString.indexOf (TempChar, 0)==-1) 
				{
	    			alert("Please provide a valid ZIP Code.");
    				theForm.PostalCode.focus();
				    return false;
				}
		}

		if((theForm.travatanzphone != null && theForm.travatanzphone.checked == true) || theForm.phoneRequired != null)
			{	
				var strMessage = "";
				if (theForm.travatanzphone != null && theForm.travatanzphone.checked == true)
					{
						strMessage = "Thank you for signing up to receive communications via phone.  ";
					}
				var TextAreaCodeString = theForm.TextAreaCode.value;
				if (TextAreaCodeString.length==0) 
					{
						strMessage += "Please enter your area code.";
						alert(strMessage);
						theForm.TextAreaCode.focus();
						return (false);
					}
				if (TextAreaCodeString.length<3)
					{
						strMessage += "Please provide a valid area code.";
						alert(strMessage);
						theForm.TextAreaCode.focus();
						return (false);
					}
				RefString="1234567890-";
				for (Count=0; Count < TextAreaCodeString.length; Count++)  
					{
						TempChar= TextAreaCodeString.substring (Count, Count+1);
						if (RefString.indexOf (TempChar, 0)==-1) 
							{
								strMessage += "Please provide a valid area code.";
								alert(strMessage);
								theForm.TextAreaCode.focus();
								return false; 
							}
					}
				var Phone1String = theForm.TextPhone1.value
				if (Phone1String.length==0) 
					{
						strMessage += "Please enter your phone number.";
						alert(strMessage);
						theForm.TextPhone1.focus();
						return (false);
					}
				if (Phone1String.length<3)
					{
						strMessage += "Please provide a valid phone number.";
						alert(strMessage);
						theForm.TextPhone1.focus();
						return (false);
					}
				RefString="1234567890-";
				for (Count=0; Count < Phone1String.length; Count++)  
					{
						TempChar= Phone1String.substring (Count, Count+1);
						if (RefString.indexOf (TempChar, 0)==-1) 
							{
								strMessage += "Please provide a valid phone number.";
								alert(strMessage);
								theForm.TextPhone1.focus();
								return false; 
							}
					}	
				var Phone2String = theForm.TextPhone2.value
				if (Phone2String.length==0) 
					{
						strMessage += "Please enter your phone number.";
						alert(strMessage);
						theForm.TextPhone2.focus();
						return (false);
					}
				if (Phone2String.length<4)
					{
						strMessage += "Please provide a valid phone number.";
						alert(strMessage);
						theForm.TextPhone2.focus();
						return (false);
					}
				RefString="1234567890-";
				for (Count=0; Count < Phone2String.length; Count++)  
					{
						TempChar= Phone2String.substring (Count, Count+1);
						if (RefString.indexOf (TempChar, 0)==-1) 
							{
								strMessage += "Please provide a valid phone number.";
								alert(strMessage);
								theForm.TextPhone2.focus();
								return false; 
							}
					}		
			}
			*/
        var strMessage = "";
        var blnRtn = true;
        var ctrl;

        if (theForm.TextEmailAddress.value == "" ) 
        {
            strMessage += "Please enter your email address.";
            ctrl = theForm.TextEmailAddress;
            blnRtn = false; 
        } 
        else 
        {
            // check validity of email
            if (!checkEmail(theForm.TextEmailAddress)) 
            {
                strMessage += "Please enter a valid email address.";
                ctrl = theForm.TextEmailAddress;
                blnRtn = false; 
            } 
            else 
            {
                    if ((theForm.TextEmailAddress2 != null) && (theForm.TextEmailAddress.value != theForm.TextEmailAddress2.value)) {
                        strMessage += "The email addresses do not match.";
                        ctrl = theForm.TextEmailAddress2;
                        blnRtn = false; 
                    }
            }
        }     
       
        if (strMessage != "") {
            alert(strMessage);
            ctrl.focus(); 
        } 

        return blnRtn;    			
		
} 
function checkEmail(email)  		
{
	var goodEmail = email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
	if (goodEmail)
    {
		return true;
	} 
	else
	{
		return false;
	}		
}


