
 $(window).load(function() {
	 $('.blueberry').blueberry({ pager: false, lineheight: 0, arrows: true});
 });


$(function() {

	$('input, textarea').placeholder();
	
	$( ".accordion" ).accordion({
		autoHeight: false,
		navigation: true
	});
	
	
	$( ".accordion-collapsed" ).accordion({
		active: false,
		collapsible: true,
		autoHeight: false,
		navigation: true
	});

	
	$('.modal').colorbox();
	
	$( ".tabs" ).tabs();
	
	var has_resized = false;
	
	$(window).resize(function(e) {
	
		if ($(this).width() < 997) {
			$('.menu li a').next().removeClass('dropdown_fullwidth').addClass('dropdown_1column');
			$('.menu li').removeClass('fullwidth');
			$('.nav_box').hide();
			
			$('.nav_box_links').css({marginTop: '0px', marginBottom: '0px', 'width': '105px', 'height': '230px'});
			$('.nav_box_links ul').css({margin: '-10px 0 12px 0'});
			
			has_resized = true;
			
		} else {
		
			if (has_resized) {
				$('.menu li a').next().removeClass('dropdown_1column').addClass('dropdown_fullwidth');
				$('.menu li').addClass('fullwidth');
				$('.nav_box_title').removeClass('dropdown_fullwidth');
				$('.nav_box').show();
				
				$('.nav_box_links').css({marginTop: '6px', marginBottom: '6px', 'width': '290px', 'height': '163px'});
				$('.nav_box_links ul').css({margin: '0 0 12px 0'});
				
				has_resized = false;
				
				
			}
			
		}
		
		
		$('.li_clickable li').click(function() {
			var href = $(this).find("a").attr("href");
			if (href == 'outages.html') {
				$.fn.colorbox({scrolling: false, width:730, height:510, href:href});
			} else {
				window.location = href;
			}
			return false;
		});
		
		
		$('.drop').click(function() {
		
			if (Modernizr.touch){
				return false;
			}
		
		});


		
		$(".page_item").hover(
		  function () {
		  
			if (Modernizr.webgl){
				$(this).css({'background-color': '#D1E4F3'});
			}
			
		  },
		  function () {
		  
			if (Modernizr.webgl){
				$(this).css({'background-color': '#FFF'});
			}

		  }
		);
		
		$('.simple-section-nav ul li').click(function() {
			window.location=$(this).find("a").attr("href"); return false;
		});
		



     });


	$('#feedback').keyup(function(){
		var n = $(this).val();
		if (n.split(' ').length > 4)  {
			$('#saveForm').slideDown();
		} else {
			$('#saveForm').slideUp();
		}
	});
	
	$('#form45').submit(function() {
		var n = $('#feedback').val();
		if (n.split(' ').length < 4)  {
			alert("Please enter more than four words. Thanks!");
			return false;
		}
	});
	
	
	$('.login_nppd').click(function() {
		
		ftype = $(this).attr('rel');
		
		if (ftype != '0') {

			$('#username').val($('#txtUser_' + ftype).val());
			$('#password').val($('#txtPass_' + ftype).val());
			
			if (ftype == 'mobile') {
				$('#loginMyAccount').attr('action', 'https://billpay.nppd.com/cwa/m/Login.aspx');
			}
		
		}
		
		$('#loginMyAccount').submit();
		return false;
		
	});
	
	
	
	$(window).resize();

}); //end dom ready

function resizeMenu(e) {
	
		if (e.width() < 997) {
			$('.menu li a').next().removeClass('dropdown_fullwidth').addClass('dropdown_1column');
			$('.menu li').removeClass('fullwidth');
			$('.nav_box').hide();
			
			$('.nav_box_links').css({marginTop: '0px', marginBottom: '0px', 'width': '105px', 'height': '200px'});
			$('.nav_box_links ul').css({margin: '-10px 0 12px 0'});
			
			has_resized = true;
			
		} else {
		
			if (has_resized) {
				$('.menu li a').next().removeClass('dropdown_1column').addClass('dropdown_fullwidth');
				$('.menu li').addClass('fullwidth');
				$('.nav_box').show();
				
				$('.nav_box_links').css({marginTop: '6px', marginBottom: '6px', 'width': '290px', 'height': '163px'});
				$('.nav_box_links ul').css({margin: '0 0 12px 0'});
				
				has_resized = false;
				
				
			}
			
		}
	
}

function submitFormWithEnter(myfield,e, ftype) {
	var keycode;

	if (window.event) {
		keycode = window.event.keyCode;
	} else if (e) {
		keycode = e.which;
	} else {
		return true;
	}

	if (keycode == 13) {

		if (ftype != '0') {

			$('#username').val($('#txtUser_' + ftype).val());
			$('#password').val($('#txtPass_' + ftype).val());
			
			if (ftype == 'mobile') {
				$('#loginMyAccount').attr('action', 'https://billpay.nppd.com/cwa/m/Login.aspx');
			}
		
		}
		
		myfield.form.submit();
		return false;
	} else {
		return true;
	}
}

function openpopup(url, name, options, fullscreen) {
    var fullurl = "http://learn.nppd.com" + url;
    var windowobj = window.open(fullurl, name, options);
    if (!windowobj) {
        return true;
    }
    if (fullscreen) {
        windowobj.moveTo(0, 0);
        windowobj.resizeTo(screen.availWidth, screen.availHeight);
    }
    windowobj.focus();
    return false;
}
