//DROPDOWN MENU
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

function dropdown_open(){  
	dropdown_canceltimer();
	dropdown_close();
	ddmenuitem = $(this).find('ul').css('visibility', 'visible');
	
	//MAKES DROPDOWN SAME WIDTH AS BUTTON
	ddwidth = $(this).width() + "px";
	ddmenuitem.css('min-width', ddwidth)
}

function dropdown_close() { 
	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden'); 
}

function dropdown_timer() { closetimer = window.setTimeout(dropdown_close, timeout); }

function dropdown_canceltimer() {  
	if(closetimer) {
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
document.onclick = dropdown_close;

$(document).ready( function() {

	//DROPDOWN MENUS
	$('#dropdown > li').bind('mouseover', dropdown_open);
	$('#dropdown > li').bind('mouseout',  dropdown_timer);

	//ADD CLASS 'LAST' TO LAST ELEMENT IN LIST
	$('ul li:last-child').addClass('last');

	//CLEAR DEFAULT TEXT
	(function($){
		$.fn.clearDefault = function(){
			return this.each(function(){
				var default_value = $(this).val();
				$(this).focus(function(){
					if ($(this).val() == default_value) $(this).val("");
				});
				$(this).blur(function(){
					if ($(this).val() == "") $(this).val(default_value);
				});
			});
		};
	})(jQuery);
	$('input[type="text"]').clearDefault(); //ALL TEXT INPUTS
	
	//SIDEBAR MODAL
	$("#dailyshow").fancybox({
		'width'				: 560,
		'height'			: 340,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'titleShow'     	: false,
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.5
	});
	
	
	//SIZE BACKGROUND - MAKE SURE THIS IS THE LAST FUNCTION!
	var which_height = ( $("#left").height() > $("#right").height() ) ? $("#left").height() : $("#right").height();
	var container_height = ( which_height+ 6) + "px";
	$("#container-background").height(container_height);

});

function loadEmail() {
var u = 'https://services.myngp.com/ngponlineservices/EmailSignup.aspx?X=AAEfS9CgvYc%3d&m=dingell'; var f = document.getElementById("firstname");
if (!(f==null)){
var fv = f.value;
if (!(fv=="")){
u=u+"&f="+fv;
}
}
var l = document.getElementById("lastname");
if (!(l==null)){
var lv = l.value;
if (!(lv=="")){
u=u+"&l="+lv;
}
}
var e = document.getElementById("get-updates-email"); if (!(e==null)){ var ev = e.value; if (!(ev=="")){ u=u+"&e="+ev; } } var z = document.getElementById("get-updates-zip"); if (!(z==null)){ var zv = z.value; if (!(zv=="")){ u=u+"&z="+zv; } } document.location.href=u; }

/*
CSS Browser Selector v0.3.5 (Feb 05, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

