// JavaScript Document
 

$(document).ready(function(){
 

navidobj =  $('[name="NavID"]');
 

if (navidobj !=null ) { 
 navidVal = navidobj.val();
if (navidVal .indexOf('_') >0 ){
 
var mySplit = navidVal .split("_")
var myMenu = '.' + mySplit[0];
var myId = '#' + mySplit[0];
var dropDown = '#' + navidVal ;


$(myMenu).css('display', 'block');
$(myId).addClass('active');
$(dropDown).addClass('active');
 
}
 
}
//used further down to apply styles dependent on whether or not we are on a 1024 resolution
var screen1024
if ((screen.width>=1024) && (screen.height>=768)) { 
screen1024= true
} 
else  { 
screen1024 = false
}

if (screen1024) { 
$('.greenfly').addClass('green1024')
$('.redfly').addClass('red1024')
} 
else  { 
$('.greenfly').addClass('greenless1024')
$('.redfly').addClass('redless1024')
}


//this is to correct a funny of Lotus Notes.  In sections it did not give a href attribute to the section to be extended but it did give it an anchor link and it went off to a random page.  This gives it an internal anchor link in the page
$("a").each(function() {

if ($(this).attr('href')) {
// attribute exists
} else {
var id = $(this).closest("div").attr("id");
$(this).attr('href', '#' + id)
}
}); 


//for bulletin prod/web/common filepath needs to be changed to prod/internet/common.nsf

if(window.location.href.indexOf("bulletin") > 0 ) {
$("a").each(function() {
this.href = this.href.replace("/prod/web", "/prod/internet");
}); 


$("img").each(function() {
this.src = this.src.replace("/prod/web", "/prod/internet");
});

$("div").each(function() { 
var url = $(this).css("backgroundImage").replace("/prod/web", "/prod/internet"); 
$(this).css("backgroundImage", url); }); 

}

else {
$("a").each(function() {
this.href = this.href.replace("/prod/internet", "/prod/web");
}); 


$("img").each(function() {
this.src = this.src.replace("/prod/internet", "/prod/web");
});

$("div").each(function() { 
var url = $(this).css("backgroundImage").replace("/prod/internet", "/prod/web"); 
$(this).css("backgroundImage", url); }); 

}
 
 // right aligned images margins

$(".bodyText img").filter(function (index) { 
return $(this).attr("align") == "right";
}).css("margin", "0px 0px 0px 20px");


 
// Legislative Assembly Left Navigation
 
$('#LA1, #LA2, #LA3, #LA4, #LA5, #LA6, #LA7, #LA8, #LA9, #LA10').click(function () {
$('ul.greenSubnav li ul').slideUp('fast');
});


 
 
 
// Legislative Council Left Navigation
 
$('#LC1, #LC2, #LC3, #LC4, #LC5, #LC6, #LC7, #LC8, #LC9, #LC10, #LC11, #LC12, #LC13, #LC14, #LC15, #LC16').click(function () {
$('ul.redSubnav li ul').slideUp('fast');
 });

 
 
 
 
// Engaging Left Navigation
 
$('#EN1, #EN2, #EN3, #EN4, #EN5, #EN6, #EN7').click(function () {
$('ul.enSubnav li ul').slideUp('fast');
});
 

// tables hide show
 
$("h4 ").click(function(){
 
$(".table").css('display', 'none');
$(this).next(".table").css('display', 'block' );
   
$(".tablearrow").attr('src', '/prod/web/common.nsf/key/img/$file/blueArrow_up.png');
$(this).find("img").attr('src', '/prod/web/common.nsf/key/img/$file/blueArrow_down.png');
 
});
 
 
 
//research
 
$('.research') 
   .click(function(){ window.location.href = '/prod/parlment/publications.nsf/V3ListRPSubject'; return false;});
   
// members
   
$('.members')
.mouseover(function(){$('.bluefly1').css('display', 'block')})
.mouseout(function(){$('.bluefly1').css('display', 'none')});
$('.members')
.click(function(){$('.bluefly1').css('display', 'block')});

$('.bluefly1')
.mouseover(function(){$('.bluefly1').css('display', 'block')})
.mouseout(function(){$('.bluefly1').css('display', 'none')});
   
   
 

//Bills
   
$('.bluefly2')
.mouseover(function(){$('.bluefly2').css('display', 'block')})
.mouseout(function(){$('.bluefly2').css('display', 'none')});

$('.bills')
.mouseover(function(){$('.bluefly2').css('display', 'block')})
.mouseout(function(){$('.bluefly2').css('display', 'none')});

$('.bills')
.click(function(){$('.bluefly2').css('display', 'block')});

 
 
 
// committees
   
$('.bluefly3')
.mouseover(function(){$('.bluefly3').css('display', 'block')})
.mouseout(function(){$('.bluefly3').css('display', 'none')});

$('.committees')
.mouseover(function(){$('.bluefly3').css('display', 'block')})
.mouseout(function(){$('.bluefly3').css('display', 'none')});

$('.committees')
.click(function(){$('.bluefly3').css('display', 'block')});


// hansard
   
$('.bluefly4')
.mouseover(function(){$('.bluefly4').css('display', 'block')})
.mouseout(function(){$('.bluefly4').css('display', 'none')});

$('.hansard')
.mouseover(function(){$('.bluefly4').css('display', 'block')})
.mouseout(function(){$('.bluefly4').css('display', 'none')});

$('.hansard')
.click(function(){$('.bluefly4').css('display', 'block')});
  
 
// LC
$('.redfly').hover(function(){
 

$('.redfly').css('display', 'block');},
function(){ 
$('.redfly').css('display', 'none')
});

 

$('#Lvl1redNav a') 
.mouseover(function(){$('.redfly').css('display', 'block')})
.mouseout(function(){$('.redfly').css('display', 'none')});

$('#Lvl1redNav a')
.click(function(){$('.redfly').css('display', 'block')
});



$('.redfly ul li.redArrow').hover(function(){
$(this).find('ul').css('display', 'block'); },
function(){
$(this).find('ul').css('display', 'none');
});
 
// LA
$('.greenfly').hover(function(){
$('.greenfly').css('display', 'block');},
function(){ 
$('.greenfly').css('display', 'none')
});

 
$('#Lvl1greenNav a')
.mouseover(function(){$('.greenfly').css('display', 'block')})
.mouseout(function(){$('.greenfly').css('display', 'none')});

$('#Lvl1greenNav a')
.click(function(){$('.greenfly').css('display', 'block')
});

     
$('.greenfly ul li.greenArrow').hover(function(){
 
$(this).find('ul').css('display', 'block'); },
function(){
$(this).find('ul').css('display', 'none');

   });
 
 
 
// Engaging with Parliament
$('.bluefly6').hover(function(){
 

$('.bluefly6').css('display', 'block');},
function(){ 
$('.bluefly6').css('display', 'none')
});

 
 
 
$('#Lvl1blueNav .engaging')
.mouseover(function(){$('.bluefly6').css('display', 'block')})
.mouseout(function(){$('.bluefly6').css('display', 'none')});

$('#Lvl1blueNav .engaging')
.click(function(){ window.location.href = '/prod/web/common.nsf/V3HomeEngaging'; return false;});
 

 
$('.bluefly6 ul li.blueArrow').hover(function(){
 
$(this).find('ul').css('display', 'block'); },
function(){
$(this).find('ul').css('display', 'none');
});

});
 
 function submitenter(myfield,e)
{
 
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
 
if (keycode == 13)
{
siteSearch();
return false;
}
else {
return true;
}
} 

function siteSearch() {
 
d2 = document.forms['googlesrch']; 
$('[name="q"]').val ( $('[name="IW_FIELD_INPUT_GOOGLE"]').val() ); 
d2.submit(); return false;
 
}




