document.write('<script type="text/javascript" src="http://www.in.gov/ai/rightnow/syndication_widget/arss.js"></script>');
document.write('<script type="text/javascript" src="http://iot.widget.custhelp.com/euf/rightnow/RightNow.Client.js"></script>');

/*
CUSTOM FORM ELEMENTS
www.ryanfait.com
The only things you may need to change in this file are the following
variables: checkboxHeight, radioHeight and selectWidth (lines 24, 25, 26)
The numbers you set for checkboxHeight and radioHeight should be one quarter
of the total height of the image want to use for checkboxes and radio
buttons. Both images should contain the four stages of both inputs stacked
on top of each other in this order: unchecked, unchecked-clicked, checked,
checked-clicked.
You may need to adjust your images a bit if there is a slight vertical
movement during the different stages of the button activation.
The value of selectWidth should be the width of your select list image.
Visit http://ryanfait.com/ for more information.
*/
var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "85";

/* No need to change anything after this */

document.write('<style type="text/css">#cse-search-box input.styled { display: none; } #cse-search-box select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; padding:0; height: 25px; } #cse-search-box .disabled { opacity: 0.5; filter: alpha(opacity=50); }</style>');
var Custom = {
    init: function() {
        var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
        for(a = 0; a < inputs.length; a++) {
            if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
                span[a] = document.createElement("span");
                span[a].className = inputs[a].type;
                if(inputs[a].checked == true) {
                    if(inputs[a].type == "checkbox") {
                        position = "0 -" + (checkboxHeight*2) + "px";
                        span[a].style.backgroundPosition = position;
                    } else {
                        position = "0 -" + (radioHeight*2) + "px";
                        span[a].style.backgroundPosition = position;
                    }
                }
                inputs[a].parentNode.insertBefore(span[a], inputs[a]);
                inputs[a].onchange = Custom.clear;
                if(!inputs[a].getAttribute("disabled")) {
                    span[a].onmousedown = Custom.pushed;
                    span[a].onmouseup = Custom.check;
                } else {
                    span[a].className = span[a].className += " disabled";
                }
            }
        }
        inputs = document.getElementsByTagName("select");
        for(a = 0; a < inputs.length; a++) {
            if(inputs[a].className == "styled") {
                option = inputs[a].getElementsByTagName("option");
                active = option[0].childNodes[0].nodeValue;
                textnode = document.createTextNode(active);
                for(b = 0; b < option.length; b++) {
                    if(option[b].selected == true) {
                        textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
                    }
                }
                span[a] = document.createElement("span");
                span[a].className = "select";
                span[a].id = "select" + inputs[a].name;
                span[a].appendChild(textnode);
                inputs[a].parentNode.insertBefore(span[a], inputs[a]);
                if(!inputs[a].getAttribute("disabled")) {
                    inputs[a].onchange = Custom.choose;
                } else {
                    inputs[a].previousSibling.className = inputs[a].previousSibling.className += " disabled";
                }
            }
        }
        document.onmouseup = Custom.clear;
    },
    pushed: function() {
        element = this.nextSibling;
        if(element.checked == true && element.type == "checkbox") {
            this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
        } else if(element.checked == true && element.type == "radio") {
            this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
        } else if(element.checked != true && element.type == "checkbox") {
            this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
        } else {
            this.style.backgroundPosition = "0 -" + radioHeight + "px";
        }
    },
    check: function() {
        element = this.nextSibling;
        if(element.checked == true && element.type == "checkbox") {
            this.style.backgroundPosition = "0 0";
            element.checked = false;
        } else {
            if(element.type == "checkbox") {
                this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
            } else {
                this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
                group = this.nextSibling.name;
                inputs = document.getElementsByTagName("input");
                for(a = 0; a < inputs.length; a++) {
                    if(inputs[a].name == group && inputs[a] != this.nextSibling) {
                        inputs[a].previousSibling.style.backgroundPosition = "0 0";
                    }
                }
            }
            element.checked = true;
        }
    },
    clear: function() {
        inputs = document.getElementsByTagName("input");
        for(var b = 0; b < inputs.length; b++) {
            if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
                inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
            } else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
                inputs[b].previousSibling.style.backgroundPosition = "0 0";
            } else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
                inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
            } else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
                inputs[b].previousSibling.style.backgroundPosition = "0 0";
            }
        }
    },
    choose: function() {
        option = this.getElementsByTagName("option");
        for(d = 0; d < option.length; d++) {
            if(option[d].selected == true) {
                document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
                setSearch(option[d].value); //CV: Added in order to set the site search variable for the form.
            }
        }
    }
}


//Script for Find a Agency page.
/***********************************************
* Advanced Gallery script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice must stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var tickspeed=100 //ticker speed in miliseconds (2000=2 seconds)
var displaymode="manual" //displaymode ("auto" or "manual")
if (document.getElementById){
    document.write('<style type="text/css">\n')
    document.write('.gallerycontent{display:none;}\n')
    document.write('</style>\n')
}
var selectedDiv=0
var totalDivs=0
function getElementbyClass(classname) {
    partscollect=new Array()
    var inc=0
    var alltags=document.all? document.all.tags("DIV") : document.getElementsByTagName("*")
    for (i=0; i<alltags.length; i++) {
        if (alltags[i].className==classname)
        partscollect[inc++]=alltags[i]
    }
}
function contractall(){
    var inc=0
    while (partscollect[inc]){
        partscollect[inc].style.display="none"
        inc++
    }
}
function populatemenu(){
    temp=document.gallerycontrol.menu
    for (m=temp.options.length-1;m>0;m--)
    temp.options[m]=null
    for (i=0;i<totalDivs;i++){
        var thesubject=partscollect[i].getAttribute("subject")
        thesubject=(thesubject=="" || thesubject==null)? "HTML Content "+(i+1) : thesubject
        temp.options[i]=new Option(thesubject,"")
    }
    temp.options[0].selected=true
}
function expandone(){
    var selectedDivObj=partscollect[selectedDiv]
    contractall()
    if (document.gallerycontrol){
    selectedDivObj.style.display="block"
    }
    if (document.gallerycontrol)
    temp.options[selectedDiv].selected=true
    selectedDiv=(selectedDiv<totalDivs-1)? selectedDiv+1 : 0
    if (displaymode=="auto")
    autocontrolvar=setTimeout("expandone()",tickspeed)
}
function manualcontrol(menuobj){
    if (displaymode=="manual"){
        selectedDiv=menuobj
        expandone()
    }
}
function preparemode(themode){
    displaymode=themode
    if (typeof autocontrolvar!="undefined")
    clearTimeout(autocontrolvar)
    if (themode=="auto"){
        document.gallerycontrol.menu.disabled=true
        autocontrolvar=setTimeout("expandone()",tickspeed)
        }
    else
    document.gallerycontrol.menu.disabled=false
}
function startgallery(){
    if (document.getElementById("controldiv")) //if it exists
    document.getElementById("controldiv").style.display="block"
    getElementbyClass("gallerycontent")
    totalDivs=partscollect.length
    if (document.gallerycontrol){
        populatemenu()
        if (document.gallerycontrol.mode){
            for (i=0; i<document.gallerycontrol.mode.length; i++){
                if (document.gallerycontrol.mode[i].checked)
                displaymode=document.gallerycontrol.mode[i].value
            }
        }
    }
    if (displaymode=="auto" && document.gallerycontrol)
    document.gallerycontrol.menu.disabled=true
    expandone()
}
if (window.addEventListener) window.addEventListener("load", startgallery, false)
else if (window.attachEvent) window.attachEvent("onload", startgallery)
else if (document.getElementById) window.onload=startgallery
 
//Script for Options iframe pages.
function dropdown(mySel)
{
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
if(myVal)
{
if(mySel.form.target)myWin = parent[mySel.form.target];
else myWin = window;
if (! myWin) return true;
myWin.location = myVal;
}
return false;
}

function togglePageOption(x) {
if (document.getElementById("col2")){
if(x=='email') { document.getElementById("col2").style.display = 'none';
document.getElementById("rateIframe").style.display = 'none';
document.getElementById("suggestIframe").style.display = 'none';
document.getElementById("emailIframe").style.display = 'block'; }
}
if (document.getElementById("col2full")){
if(x=='email') { document.getElementById("col2full").style.display = 'none';
document.getElementById("rateIframe").style.display = 'none';
document.getElementById("suggestIframe").style.display = 'none';
document.getElementById("emailIframe").style.display = 'block'; }
}
if (document.getElementById("col2")){
if(x=='rate') { document.getElementById("col2").style.display = 'none';
document.getElementById("emailIframe").style.display = 'none';
document.getElementById("suggestIframe").style.display = 'none';
document.getElementById("rateIframe").style.display = 'block'; }
}
if (document.getElementById("col2full")){
if(x=='rate') { document.getElementById("col2full").style.display = 'none';
document.getElementById("emailIframe").style.display = 'none';
document.getElementById("suggestIframe").style.display = 'none';
document.getElementById("rateIframe").style.display = 'block'; }
}
if (document.getElementById("col2")){
if(x=='suggest') { document.getElementById("col2").style.display = 'none';
document.getElementById("emailIframe").style.display = 'none';
document.getElementById("rateIframe").style.display = 'none';
document.getElementById("suggestIframe").style.display = 'block'; }
}
if (document.getElementById("col2full")){
if(x=='suggest') { document.getElementById("col2full").style.display = 'none';
document.getElementById("emailIframe").style.display = 'none';
document.getElementById("rateIframe").style.display = 'none';
document.getElementById("suggestIframe").style.display = 'block'; }
}
if(x=='print') { document.getElementById("emailIframe").style.display = 'none';
document.getElementById("rateIframe").style.display = 'none';
document.getElementById("suggestIframe").style.display = 'none';
if (document.getElementById("col2")){
document.getElementById("col2").style.display = 'block';
}
if (document.getElementById("col2full")){
document.getElementById("col2full").style.display = 'block';} }
}
 
function saveSelections(frm) {
        var setvalue;
        var fieldType;
        var index;
        var formname = frm.name;
        // Expire cookie in 999 days.
        var today = new Date();
        var exp   = new Date(today.getTime()+999*24*60*60*1000);
        var string = "formname=" + formname + "|";
        var cookieName = formname;
        //alert(exp);
        //alert(formname);
        var n = frm.length;
        for (i = 0; i < n; i++)
        {
            e         = frm[i].name;
            fieldValue  = frm[i].value;
            fieldType   = frm[i].type;
            //alert(e);
            //alert(fieldType);
            //alert(fieldValue);
            //
            // RADIO BUTTON
            //
            if (fieldType == "radio") {
            //alert(frm.elements[e].length);
                for (x=0; x < frm.elements[e].length; x++) {
                    if (frm.elements[e][x].checked)
                    {
                    index = x
                    }
                }
            string = string + index + "\|";
            }
            //
            // TEXT, TEXTAREA, and DROPDOWN
            //
            if ((fieldType == "text") ||
                (fieldType == "textarea") ||
                (fieldType == "select-one"))
            {
                string = string + frm.elements[e].value + "\|";
                //alert("text");
            }
            //
            // CHECKBOX
            //
            if (fieldType == "checkbox")
            {
                if (frm.elements[e].checked==true) {
                    var setvalue = "1";
                    }
                if (frm.elements[e].checked==false) {
                    var setvalue = "0";
                    }
            string = string + setvalue + "\|";
            //alert("checkbox");
            }
            //
            // HIDDEN field
            //
            if (fieldType == "hidden")
            {
                string = string + frm.elements[e].value + "\|";
                //alert("text");
            }
        }
//alert(string);
setCookie(cookieName, string, exp); }
//
// LOAD FORM FIELD SELECTIONS FROM SAVED COOKIES
//
function loadSelections(frm) {
var e;
var z;
var x;
var cookieName;
var fieldArray;
var fieldValues;
var fieldValue;
var formname = frm.id;
// Retrieve form elements from cookie and split into array.
cookieName  = formname;
fieldValues = getCookie(cookieName);
fieldArray  = fieldValues.split("\|");
//alert(fieldArray);
//alert(fieldArray[0]);
//alert(fieldArray[1]);
//alert(fieldArray[2]);
//alert(fieldArray[3]);
        var n = frm.length;
        for (i = 0; i < n; i++) {
            e = frm[i].name;
            z = i;
            z++;
            var fieldType  = frm[i].type;
            var fieldValue = fieldArray[z];
            //
            // TEXT, TEXTAREA, and DROPDOWN
            //
            if ((fieldType == "text") ||
                (fieldType == "textarea") ||
                (fieldType == "select-one"))
            {
                frm.elements[e].value = fieldValue;
                //alert(e);
                //alert(fieldValue);
            }
            // CHECKBOX
            //
            if (fieldType == "checkbox")
            {
                fld_checkbox = fieldValue;
                if (fld_checkbox == "1") {
                    frm.elements[e].checked = true;
                }
            }
            // RADIO BUTTON
            //
            if (fieldType == "radio") {
                x = fieldValue;
                //alert(x);
                frm.elements[e][x].checked = true;
            }
            //
            // HIDDEN field
            //
            if (fieldType == "hidden")
            {
                frm.elements[e].value = fieldValue;
                }
        }
}
/// COOKIE FUNCTIONS
function setCookie(name, value, expires, path, domain, secure) {
document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return "null";
} else {
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
return unescape(dc.substring(begin + prefix.length, end));
}
 
//un-embed for flash
function flashload(urlflash,imagenoflash){
        document.write('<div id="image">');
        document.write('<object type="application/x-shockwave-flash" data="' + urlflash + '" width="566" height="253">');
        document.write('<param name="movie" value="' + urlflash + '" />');
        document.write('' + imagenoflash + '');
        document.write('</object>');
        document.write('</div>');
}
//E-MAIL VALIDATION
var results
function checkemail(){
var str=document.govcontact.email.value
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
results=true
else{
document.getElementById('stoplayer').style.display = 'block';
results=false
}
return (results)
}
function validatemail(){
if (document.layers||document.getElementById||document.all)
return checkemail()
else
return true
}
//USE THE FOLLOWING CODE FOR E-MAIL VALIDATION
//<input name="email" type="text" id="email" size="40" onBlur="if (this.value=='') document.getElementById('stoplayer').style.display = 'none'; else validatemail();" onFocus="document.getElementById('stoplayer').style.display = 'none';">
//<div id="stoplayer" style="display: none; color: Red;"> 
//<p style="margin-bottom: 5px;"><strong>Please enter a valid email format</strong> (me@myemail.com).</p> 
//</div>
function closeAll() {
var navRoot = document.getElementById("leftnavul");
 for (i=0; i<navRoot.childNodes.length; i++) {
  var node = navRoot.childNodes[i];
  if (node.nodeName=="LI") { node.className=node.className.replace("navClick",""); }
 }
}
function startList() {
var navRoot = document.getElementById("leftnavul");
var navRootULs = navRoot.getElementsByTagName("UL");
for (i=0; i<navRootULs.length; i++) { navRootULs[i].style.display = 'none'; }
 for (i=0; i<navRoot.childNodes.length; i++) {
  var node = navRoot.childNodes[i];
     if(node.nodeName=="LI" && node.firstChild.getAttribute("HREF").charAt(node.firstChild.getAttribute("HREF").length-1) == "#") {
   node.className = 'navMore';
   node.onclick=function() {
    closeAll();
    this.className += " navClick"; }
   node.firstChild.onclick=function() { return false; }
   }
  }
}
function emailPage() {
 var appURL
 appURL = "http://www.in.gov/apps/options/email.aspx?url="
 newURL = appURL + location.href;
 window.open(newURL, "email","scrollbars=1,width=583,height=520")
}
function ratePage() {
 var appURL
 appURL = "http://www.in.gov/apps/options/rate.aspx?url="
 newURL = appURL + location.href;
 window.open(newURL,"rate","scrollbars=1,width=583,height=525")
}
function suggestPage() {
 var appURL
 appURL = "http://www.in.gov/apps/options/suggestion.aspx?url="
 newURL = appURL + location.href;
 window.open(newURL, "rate","scrollbars=1,width=583,height=525")
}
function qrCode() {
var appURL
var tempURL
tempURL=escape(location.href)
tempURL=location.href
appURL="http://chart.googleapis.com/chart?chs=250x100&cht=qr&choe=UTF-8&chl="
appURL="http://ii-vapp9-test:8080/ii-portal-qr/qr_input.action?url_string="
appURL="http://www.in.gov/core/qr/QR.html?page1="
appURL = appURL + tempURL
window.open(appURL,"QR","toolbar=0,location=0,width=300,height=300")
}
function populateElementIdInnerHTML(element_id)
{
    
    if (opener)
    {
        var update_html = opener.document.transfer_html.popup_html.value;
        if (update_html)
        {
            document.getElementById(element_id).innerHTML = update_html;
        }
    }
    else
    {
        document.getElementById(element_id).innerHTML ="<p><b>Sorry, unable to locate the parent page</b></p>";
    }
}
function populateElementIdInnerHTML_oc1(element_id)
{
    
    if (opener)
    {
        var update2_html = opener.document.transfer2_html.popup2_html.value;
        if (update2_html)
        {
            document.getElementById(element_id).innerHTML = update2_html;
        }
    }
    else
    {
        document.getElementById(element_id).innerHTML ="<p><b>Sorry, unable to locate the parent page</b></p>";
    }
}
function populateElementIdInnerHTML_oc2(element_id)
{
    
    if (opener)
    {
        var update3_html = opener.document.transfer3_html.popup3_html.value;
        if (update3_html)
        {            document.getElementById(element_id).innerHTML = update3_html;
        }
    }
    else
    {
        document.getElementById(element_id).innerHTML ="<p><b>Sorry, unable to locate the parent page</b></p>";
    }
}
function populateElementIdInnerHTML_Hdr(element_id)
{
    
    if (opener)
    {
        var updateHdr_html = opener.document.transferHdr_html.popupHdr_html.value;
        if (updateHdr_html)
        {            document.getElementById(element_id).innerHTML = updateHdr_html;
        }
    }
    else
    {
        document.getElementById(element_id).innerHTML ="<p><b>Sorry, unable to locate the parent page</b></p>";
    }
}
 
function linkdis(qwerty){
    document.getElementById("disclaim").style.display='block';
    document.getElementById("sc_links").action=qwerty;
}
function hideDis(){
document.getElementById("disclaim").style.display='none';
}
 

/* This funtion is called from a body onload and starts the external link check within the element you define (divid) and also passes the context of what you want to do for any external links found (context).  */
function linkCheck (divid,context){
var divLinks=document.getElementById(divid);
var links=divLinks.getElementsByTagName("a");
for(i=0;i<links.length;i++)
    {
    var currentLink = links[i].getAttribute("href");
    var newLink = "javascript:extLinkCheck('" + currentLink + "'," + context + ");";
    links[i].setAttribute('href',newLink);
    }
}
/*This function checks for internal links.  If a link is not internal, it does 'something'.  that something is defined in separate functions, and is choses based on the 'context' variable*/
function extLinkCheck(y,context){
    var linkArray = y.split( '/' );
    var q = 0;
    for(i=0;i<linkArray.length;i++)
        {
            /*checks if first character of the link is /, hense is internal */
            if(linkArray[0].length==0)
            {
                q=1;
            }
            /*checks for in.gov or test.ai.org somewhere in the link path*/
            else if(linkArray[i].match("test.ai.org")!=null || linkArray[i].match("in.gov")!=null || linkArray[i].match("IN.gov")!=null || linkArray[i].match("IN.GOV")!=null )
            {
                q=1;
            }
            /*checks to see if the link only has one element (index.htm for example), hense is internal */
            else if(linkArray.length==1)
            {
                q=1;
            }        
        }
    if(q==1)
    {
    window.location.href=y;
    }
    else{
        if (context==0)
        {
            stayConnectExtLink(y);
        }
        else if (context==null)
        {
            stayConnectExtLink(y);
        }
    }
}

function stayConnectExtLink(externalLink){
linkdis(externalLink);
}
