﻿function initPage()
{
     menu("menu");
    menu("nav-video");
    menu("nav-photo");
    tabs("tabs_container","tabs");
    var submit=document.getElementsByTagName("input");
    if(submit)
    {
        for (var i = 0; i < submit.length; i++)
        {
            if (submit[i].className == 'submit'){
                submit[i].onmouseover = function ()
                {
                    this.className += " hover";
                }
                submit[i].onmouseout = function ()
                 {
                      this.className = this.className.replace("hover", "");
                 }
            }
        }
    }
}
function tabs(tabs_container_id, tabs_id) 
{
    var tabs_container = document.getElementById(tabs_container_id);
    if(tabs_container)
    {
        var tabs = document.getElementById(tabs_id);
        if(tabs)
        {
            var link = tabs.getElementsByTagName("a");
            for (var i = 0; i < link.length; i++)
            {
                if(link[i].rel != "")
                {
                    var tab_content = document.getElementById(link[i].rel);
                    if(tab_content)
                    {
                        if(link[i].parentNode.className != 'active')
                        {
                            tab_content.style.display = "none";
                        }
                    }
                    link[i].onclick = function() {
                        var tab_contents = this.parentNode.parentNode.parentNode.getElementsByTagName("ul");
                        for (var j = 0; j < tab_contents.length; j++)
                        {
                            if(tab_contents[j].id == tabs_id)
                            {
                                var tab_li = this.parentNode.parentNode.getElementsByTagName("li");
                                for (var k = 0; k < tab_li.length; k++)
                                {
                                    tab_li[k].className = "";
                                }
                            }
                            else
                            {
                                tab_contents[j].style.display = "none";
                            }
                        }
                        var tab_content = document.getElementById(this.rel);
                        if(tab_content)
                        {
                            tab_content.style.display = "block";
                        }
                        this.parentNode.className = "active";
                        return false;
                    }
                }
            }    
        }
    }
}
function menu(id){
    var nav = document.getElementById(id);
    if (nav)
    {    
        var nodes = nav.getElementsByTagName("li");
        for (var i = 0; i < nodes.length; i++)
            {
            if (nodes[i].parentNode.id == id)
            {
             nodes[i].onmouseover = function () 
             {
              this.className += " hover";
             }
             nodes[i].onmouseout = function ()
             {
              this.className = this.className.replace("hover", "");
             }
            }
        }
        
        var links = nav.getElementsByTagName('a');    
        if(links)
        {
            for (var j = 0; j < links.length; j++){
                var link_width = links[j].parentNode.parentNode.offsetWidth;
                if(links[j].parentNode.parentNode.parentNode.parentNode.id == id)
                {
                    links[j].parentNode.style.width = link_width+"px";
                    links[j].parentNode.parentNode.style.width = link_width+"px";
                    links[j].style.width = link_width-20+"px";
                }
            }
        }
    }
}
/* common */
var browsers = 'all';
var currentState = {};
var opera = window.opera;
var safari = navigator.appVersion.indexOf("Safari") != -1;
var ie = document.all && !window.opera;
var ff = navigator.userAgent.indexOf("Firefox") != -1;
var addEvent = function(browsers,event,initMethod)
{
    if (opera && (browsers.match(/Opera/) || browsers.match(/all/))) {
        window.addEventListener(event, initMethod, false);
    } else if (safari && (browsers.match(/Safari/) || browsers.match(/all/))) {
        window.addEventListener(event, initMethod, false);
    } else if (ie && (browsers.match(/IE/) || browsers.match(/all/))) {
        window.attachEvent("on" + event, initMethod);
    } else if (ff && (browsers.match(/FF/) || browsers.match(/all/))) {
        window.addEventListener(event, initMethod, false);
    } else if (!ie && !ff && !safari && !opera) {
        if (window.addEventListener){
            window.addEventListener(event, initMethod, false);
        }
        else if (window.attachEvent){
            window.attachEvent("on" + event, initMethod);
        }
    } 
}
addEvent(browsers,'load',initPage);

//un-embed for flash
function flashload(urlflash){
    
document.write('<object data="http://www.in.gov/legislative/house_republicans/flash/cdt_main.swf" type="application/x-shockwave-flash" width="560" height="169">');
document.write('<param name="movie" value="http://www.in.gov/legislative/house_republicans/flash/cdt_main.swf" />');
document.write('<param name="base" value="." />');
document.write('<param name="flashvars" value="');
      document.write('&timer=1&');
      document.write('&time_template=3:ss;2:mm;1:hh;0:dd&');
      document.write('&time_color=0x000000&');
      document.write('&label_color=0x000000&');
      document.write('&background_color=0xFFFFFF&');
      document.write('&flare_view=true&');
      document.write('&time_label=d:DAYS;h:HOURS;m:MIN;s:SEC&');
      document.write('&time_zone=(GMT -05:00) Eastern Time (US & Canada)&');
      document.write('&event_time=year:2009;month:4;day:16;hour:0;minute:0;seconds:0&');
      document.write('&event_duration=year:1;month:1;day:1;hour:1;minute:0;seconds:0&');
      document.write('&event_recursion=no&');
      document.write('&onpress_url=-&');
      document.write('&event_onpress_url=-&');
      document.write('&title=Time Left to Vote on Property Tax Caps&');
      document.write('&event_title=Time Left to Vote on Property Tax Caps&');
      document.write('&sound_file=-&');
      document.write('&event_sound_file=-&');
      document.write('&transparent=true&');
document.write('" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="wmode" value="transparent" />');
document.write('<param name="scale" value="noscale" />');
document.write('<param name="salign" value="lt" />');
document.write('</object>');
}
