the_selected_id = "none";
var already_clicked = false;

function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
	var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
	var int_windowTop = (screen.height - a_int_windowHeight) / 2;
	var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
	var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties);
	if (parseInt(navigator.appVersion) >= 4) {
		obj_window.window.focus();
	}
}
		
//checks for a valid zip code
function CheckValidZip(thefield) {
	var filter = /^([0-9]{5})+$/;
	if (!filter.test(thefield.value)) {
		alert ("Please enter a valid zip code");
		//$("#signupalert").html("Please enter a valid zip code"); 
		return false; }
	else if (thefield.value==null || thefield.value==""){
		alert ("Please enter a zip code");
		//$("#signupalert").html("Please enter a zip code");
		return false;
	}
	return true;					
}

//checks for a valid email address   
function CheckEmailAddr(thefield) {
	var filter  = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	alert ("Im checkling email address");
	if (!filter.test(thefield.value)) {
		alert ("Please enter a valid email address");
		//$("#signupalert").html("Please enter a valid email address");
		return false; }
	else if (thefield.value==null||thefield.value==""){
		alert ("Please enter an email address!");
		//$("#signupalert").html("Please enter an email address!");
		return false;
	}
	return true;		
}

function calcage(secs, num1, num2) {
	s = ((Math.floor(secs/num1))%num2).toString();
	//if (s.length < 2) s = "0" + s;
  return s;
}




$(document).ready(function() {

	$("#sectionnav a").prepend("&raquo;&nbsp;");

	$("#signupsubmit").hover( function() {
		$(this).addClass("submithover");
	}, function() {
		$(this).removeClass("submithover");
	});

	$("#signup form input").focus(function() {
 		if ($(this).val() == "email address" || $(this).val() == "zip") $(this).val("");
 	});

 	$("#addme").submit(function() {
 		
 		$("#homelink").hide();
 		
		if (!CheckEmailAddr($("#email").val()) || !CheckValidZip($("#zipcode").val())) {
			$("#signup #mesg").fadeOut("fast", function(){
				$("#signup #mesg").html("Please enter a valid email address and/or zip code!");
				$("#signup #mesg").fadeIn("normal");
			});

			
		} else {
	
		//else, do ajax thing
//		$.post("/ajax/signup.php", { email:$("#email").val(), zipcode:$("#zipcode").val(), submitted:"yes", set_sbm:"t", set_ea:"t" }, function(data) {
//			if (data == "1") {
//				$("#signup #mesg").fadeOut("fast", function(){
//					$("#addme").fadeOut("fast");
//					$("#signup").css("background-color","#eee");
//					$("#signup #mesg").html("<b>Thanks for signing up for updates from StopBigMedia.com!</b> We've added you to our email list. (Don't forget to review <a href=\"http://www.freepress.net\">our privacy policy</a>)");
//					$("#signup #mesg").fadeIn("normal");
//				});	
//			} else {
//				$("#signup #mesg").fadeOut("fast", function(){
//					$("#signup #mesg").html("Sorry, an error occurred. Please try again!");
//					$("#signup #mesg").fadeIn("normal");
//				});
//			}}	
//		);
		} //end else
		
	});
	
//	$(".actbox").hover(function(){
//		$(this).addClass("acthover");
//	},function(){
//		$(this).removeClass("acthover");
//	});
	
//	$(".actbox").click(function(){
//		window.location = $(this).children("a:first").attr("href");
//	});
	
//	$("#sbm_logo").click(function(){
//		window.location = "http://www.freedom2speak.org/";
//	});
	
//	$('#navbar img').hover(function(){
//		if ($(this).attr('id') != the_selected_id) $(this).attr('src','http://www.stopbigmedia.com/graphics/n_'+$(this).attr('id')+"_h.gif");
// 	}, function() {
//		if ($(this).attr('id') != the_selected_id) $(this).attr('src','http://www.stopbigmedia.com/graphics/n_'+$(this).attr('id')+".gif");
// 	});	

//	$('#threelinks img').hover(function(){
//		$(this).attr('src','http://www.stopbigmedia.com/graphics/'+$(this).attr('id')+"_o.gif");
// 	}, function() {
//		$(this).attr('src','http://www.stopbigmedia.com/graphics/'+$(this).attr('id')+".gif");
// 	});	

	$("a#minoritydetails").click(function() {
		$("#explanation").fadeIn("normal");
	});

	$("#explanation").click(function() {
		$("#explanation").fadeOut("fast");
	});
	
	$("#tracklist a:even").addClass("dark");
	
	//SBM_CountDown();
});

/*
$(window).load(function() {
	setTimeout('$("#sectionnav table").fadeIn("slow")',1000);
});
*/