// JavaScript Document


$(document).ready(
		function () {
		
			var compare_flag = false;
			//Hide assorted elements
			hideStuff();
			
			// GREY BOX
			var heebeeGeebee = {
				gbWidth: 515,
				gbHeight: 550
			};
			
			var currentYear = (new Date).getFullYear();
			$("#footer p.copy").text("DC Wireless ISP, Inc. © 2001-" + (new Date).getFullYear()); 
			
			//$('a.insideLoader').greybox(heebeeGeebee);			
			
			
			var bigLinks = '.bigLinks';
				$(bigLinks).click(
					function( ) {
						location = $(this).find('a').attr('href');
					});
			
			
			//////////////////
			/* REDUNDANCY IN THE BACKGROUND COLOR
				- it may require for no css background styling here, but only in css */
			//////////////////
			//Tabbed panels
			$('#location #roseburg span').click(
				function() {
			
						//Designates currently selected tab
						var currentTab = '.'+$(this).attr("class");
						
						$('#roseburg li').hide();
					
						$('#roseburg'+' '+currentTab+' '+'li').show();
						$('#roseburg'+' '+currentTab+' '+'li').css('font-size', '10pt');
						$('#roseburg span').css('background-color', '#133E7F');
						$('#roseburg span'+currentTab).css('background-color', '#328700');
				}
				);
			
			$('#location #medford span').click(
				function() {
			
						//Designates currently selected tab
						var currentTab = '.'+$(this).attr("class");
						
						$('#medford li').hide();
					
						$('#medford'+' '+currentTab+' '+'li').show();
						$('#medford'+' '+currentTab+' '+'li').css('font-size', '10pt');
						$('#medford span').css('background-color', '#133E7F');
						$('#medford span'+currentTab).css('background-color', '#328700');
			
				}
				);
			
			
	
			//RATES GALLERY	
			$('#gallery').cycle({
				fx: 'scrollLeft',
				timeout: 3000,
				speed: 3300,
				delay: -2000,
				pager: '#pager',
				next: '#next',
				prev: '#prev'
				
			});
			
			$('#playControl').toggle(
				function() {
					$('#gallery').cycle('pause');
					$(this).text('Play');	
				},
				function () {
					$('#gallery').cycles('resume');
					$(this).text('Pause');
				}
			);


		// Internet explorer
		//  - has problems with .click function, in regardes to assigning form values
		if ($.browser.msie) {
			run_dummy();
		}
		
		
		// All other browsers
		else {
		$('.choices').click(
			function() {
				//DOWNLAOD
				if (jQuery("#download_speed", this).attr("id") == "download_speed") {
					$("#upload_speed").attr('disabled', 'disabled');
					$("#upload_speed").val('select');
					
					$("#prices").attr('disabled', 'disabled');
					$("#prices").val('select');
					$("#download_speed").removeAttr('disabled', 'disabled');
					$("#dl").css('background-color', '#4F637A');
					$("#ul").css('background-color', '#ACD0FD');
					$("#price_list").css('background-color', '#ACD0FD');
					
					
				}
				//PRICES
				else if (jQuery("#prices", this).attr("id") == "prices") {
					$("#download_speed").attr('disabled', 'disabled');
					$("#download_speed").val('select');
					
					$("#upload_speed").attr('disabled', 'disabled');
					$("#upload_speed").val('select');
					
					jQuery("#prices", this).removeAttr('disabled');
					$("#dl").css('background-color', '#ACD0FD');
					$("#ul").css('background-color', '#ACD0FD');
					$("#price_list").css('background-color', '#4F637A');
				}
				//UPLOAD
				else if (jQuery("#upload_speed", this).attr("id") == "upload_speed") {
					$("#download_speed").attr('disabled', 'disabled');
					$("#download_speed").val('selected');
					
					$("#prices").attr('disabled', 'disabled');
					$("#prices").val('selected');
					jQuery("#upload_speed", this).removeAttr('disabled');
					$("#ul").css('background-color', '#4F637A');
					$("#dl").css('background-color', '#ACD0FD');
					$("#price_list").css('background-color', '#ACD0FD');
				}
				else {
					//do nothing
				}
				
				//COMPARE OPTIONS
				//DOWNLOAD
				if (jQuery("#download_speed2", this).attr("id") == "download_speed2") {
					$("#upload_speed2").attr('disabled', 'disabled');
					$("#upload_speed2").val('select');
					
					$("#prices2").attr('disabled', 'disabled');
					$("#prices2").val('select');
					$("#download_speed2").removeAttr('disabled', 'disabled');
					$("#dl2").css('background-color', '#008477');
					$("#ul2").css('background-color', '#85D6D0');
					$("#price_list2").css('background-color', '#85D6D0');
					
					
				}
				//PRICES
				else if (jQuery("#prices2", this).attr("id") == "prices2") {
					$("#download_speed2").attr('disabled', 'disabled');
					$("#download_speed2").val('select');
					
					$("#upload_speed2").attr('disabled', 'disabled');
					$("#upload_speed2").val('select');
					
					jQuery("#prices2", this).removeAttr('disabled');
					$("#dl2").css('background-color', '#85D6D0');
					$("#ul2").css('background-color', '#85D6D0');
					$("#price_list2").css('background-color', '#008477');
				}
				//UPLOAD
				else if (jQuery("#upload_speed2", this).attr("id") == "upload_speed2") {
					$("#download_speed2").attr('disabled', 'disabled');
					$("#download_speed2").val('selected');
					
					$("#prices2").attr('disabled', 'disabled');
					$("#prices2").val('selected');
					jQuery("#upload_speed2", this).removeAttr('disabled');
					$("#ul2").css('background-color', '#008477');
					$("#dl2").css('background-color', '#85D6D0');
					$("#price_list2").css('background-color', '#85D6D0');
				}
				else {
					//do nothing
				}
				
			});
		}
			
				
			$("#go").click ( 
				function() {
					$("#view_all").fadeIn('slow');
					var passer = 0;
					var namer = "nothing";
					//Downloads Selected
					if ($("#upload_speed").attr('disabled') && $("#prices").attr('disabled')) 
						{
							passer = $("#download_speed").val();
							namer = "download";
							
							$("#upload_speed").val('select');
							$("#prices").val('select');
					}
					//Uploads Selected
					else if ($("#download_speed").attr('disabled') && $("#prices").attr('disabled'))
						{ 
							passer = $("#upload_speed").val();
							namer = "upload";
							
							$("#download_speed").val('select');
							$("#prices").val('select');
						}
				  	//Prices Selected
					else if ($("#download_speed").attr('disabled') && $("#upload_speed").attr('disabled'))
						{
							passer = $("#prices").val();
							namer = "prices";
							
							$("#download_speed").val('select');
							$("#upload_speed").val('select');
						}
					//Nothing Selected
					else {
						$(".error").fadeIn('fast')
						return;
					}
					show_new(passer, namer);
				});
		
			$("#go2").click ( 
				function() {
					$("#view_all").fadeIn('slow');
					var passer = 0;
					var namer = "nothing";
					//Downloads Selected
					if ($("#upload_speed2").attr('disabled') && $("#prices2").attr('disabled')) 
						{
							passer = $("#download_speed2").val();
							namer = "download";
							
							$("#upload_speed2").val('select');
							$("#prices2").val('select');
					}
					//Uploads Selected
					else if ($("#download_speed2").attr('disabled') && $("#prices2").attr('disabled'))
						{ 
							passer = $("#upload_speed2").val();
							namer = "upload";
							
							$("#download_speed2").val('select');
							$("#prices2").val('select');
						}
				  	//Prices Selected
					else if ($("#download_speed2").attr('disabled') && $("#upload_speed2").attr('disabled'))
						{
							passer = $("#prices2").val();
							namer = "prices";
							
							$("#download_speed2").val('select');
							$("#upload_speed2").val('select');
						}
					//Nothing Selected
					else {
						$(".error").slideDown('medium')
						return;
					}
					compare_flag = true;
					show_new(passer, namer);
				});
		
		
		
		
		
		// HOVER FUNCTION WIP
	/*	$('#dl').hover( 
			function() {
				var ORIGINAL = $(this).closest("label").css('background-color');
				var disabler1 = $(this).closest("#dl");
				var disabler2 = $(this).closest("#ul");
				
				if ($("#download_speed").attr('disabled', 'disabled') == true) {
					alert ("working");
				}
				jQuery("label", this).css('background-color', '#4F637A');
				
			},
			function () {
				jQuery("label", this).css('background-color', ORIGINAL);
			}
			);
	*/
	
	
//FUNCTIONS		
function hideStuff () {
	$('.tab2 li').hide();
	$('.tab3 li').hide();
	$("#view_all").hide();
	$(".error").hide();
	$("#compare").hide();
	$("#comparison").hide();
}
function reset_values () {
	$("#download").removeAttr('disabled');
	$("#upload_speed").removeAttr('disabled');
	$("#prices").removeAttr('disabled');	
}
function show_plan () {
	$("#detailed_rates").fadeOut('fast');
	var targetted = $(this);
	show_new(targetted);

}
function replace_values (passer, namer) {

	var parent = "";
	
	//Identify type of plan//
	if (compare_flag == false) {
		//Light Residential
		if ((passer == 1) || (passer == .512) || (passer == 19.95)) {
			parent = "light_1A";
			
				//plan name adjustment
				$("#detailed_rates h3").html("Light Residential User Plan");
				//dl adjustment
				$("#detailed_rates .detail_download").html("1Mbs");
				//ul adjustment
				$("#detailed_rates .detail_upload").html("512Kbps");
				//price adjustment
				$("#detailed_rates .price p").html("$19.95/mo");
		
		}
		//Light Residential PLUS
		else if (((passer == 3) && namer == "download") || (passer == 1.5) || (passer == 34.95)) {
			parent = "light_1B";
			
			//plan name adjustment
				$("#detailed_rates h3").html("Light Residential User Plan PLUS+");
				//dl adjustment
				$("#detailed_rates .detail_download").html("3Mbs");
				//ul adjustment
				$("#detailed_rates .detail_upload").html("1.5Mbps");
				//price adjustment
				$("#detailed_rates .price p").html("$34.95/mo");
		}
		//Power
		else if (((passer == 6) && namer == "download") || ((passer == 3) && namer == "upload") || (passer == 54.95)) {
			parent = "power_1A";
			
			//plan name adjustment
				$("#detailed_rates h3").html("Power User Plan");
				//dl adjustment
				$("#detailed_rates .detail_download").html("6Mbs");
				//ul adjustment
				$("#detailed_rates .detail_upload").html("3Mbps");
				//price adjustment
				$("#detailed_rates .price p").html("$54.95/mo");
		}
		//Power PLUS
		else if (passer == 10 || ((passer == 4) && namer == "upload") || passer == 64.95) {
			parent = "power_1B";
			
			//plan name adjustment
				$("#detailed_rates h3").html("Power User Plan PLUS+");
				//dl adjustment
				$("#detailed_rates .detail_download").html("10Mbs");
				//ul adjustment
				$("#detailed_rates .detail_upload").html("4Mbps");
				//price adjustment
				$("#detailed_rates .price p").html("$64.95/mo");
		}
		//Business
		else if (passer == 15 || ((passer == 6) && namer == "upload") || (passer == 74.95)) {
			parent = "business_1A";
			
			//plan name adjustment
				$("#detailed_rates h3").html("Business User Plan");
				//dl adjustment
				$("#detailed_rates .detail_download").html("15Mbs");
				//ul adjustment
				$("#detailed_rates .detail_upload").html("6Mbps");
				//price adjustment
				$("#detailed_rates .price p").html("$74.95/mo");
		}
		//Business PLUS
		else {
			if (passer == "select" || passer == 0) {
				$(".error").slideDown('medium');
				return;
			}
			parent = "business_1B";
			
			//plan name adjustment
				$("#detailed_rates h3").html("Business User Plan PLUS+");
				//dl adjustment
				$("#detailed_rates .detail_download").html("20Mbs");
				//ul adjustment
				$("#detailed_rates .detail_upload").html("8Mbps");
				//price adjustment
				$("#detailed_rates .price p").html("$99.95/mo");
		}
	return;
	}
	//COMPARE PLANS
	else {
	//Light Residential
		if ((passer == 1) || ((passer == .512) && namer == "upload") || (passer == 19.95)) {
			parent = "light_1A";
			
				//plan name adjustment
				$("#detailed_rates2 h3").html("Light Residential User Plan");
				//dl adjustment
				$("#detailed_rates2 .detail_download2").html("1Mbs");
				//ul adjustment
				$("#detailed_rates2 .detail_upload2").html("512Kbps");
				//price adjustment
				$("#detailed_rates2 .price2 p").html("$19.95/mo");
				return;
		
		}
		//Light Residential PLUS
		else if (((passer == 3) && namer == "download") || ((passer == 1.5) && namer == "upload") || (passer == 34.95)) {
			parent = "light_1B";
			
			//plan name adjustment
				$("#detailed_rates2 h3").html("Light Residential User Plan PLUS+");
				//dl adjustment
				$("#detailed_rates2 .detail_download2").html("3Mbs");
				//ul adjustment
				$("#detailed_rates2 .detail_upload2").html("1.5Mbps");
				//price adjustment
				$("#detailed_rates2 .price2 p").html("$34.95/mo");
				return;
		}
		//Power
		else if (((passer == 6) && namer == "download") || ((passer == 3) && namer == "upload") || (passer == 54.95)) {
			parent = "power_1A";
			
			//plan name adjustment
				$("#detailed_rates2 h3").html("Power User Plan");
				//dl adjustment
				$("#detailed_rates2 .detail_download2").html("6Mbs");
				//ul adjustment
				$("#detailed_rates2 .detail_upload2").html("3Mbps");
				//price adjustment
				$("#detailed_rates2 .price2 p").html("$54.95/mo");
				return;
		}
		//Power PLUS
		else if (passer == 10 || ((passer == 4) && namer == "upload") || passer == 64.95) {
			parent = "power_1B";

			//plan name adjustment
				$("#detailed_rates2 h3").html("Power User Plan PLUS+");
				//dl adjustment
				$("#detailed_rates2 .detail_download2").html("10Mbs");
				//ul adjustment
				$("#detailed_rates2 .detail_upload2").html("4Mbps");
				//price adjustment
				$("#detailed_rates2 .price2 p").html("$64.95/mo");
				return;
		}
		//Business
		else if (passer == 15 || ((passer == 6) && namer == "upload") || (passer == 74.95)) {
			parent = "business_1A";
			
			//plan name adjustment
				$("#detailed_rates2 h3").html("Business User Plan");
				//dl adjustment
				$("#detailed_rates2 .detail_download2").html("15Mbs");
				//ul adjustment
				$("#detailed_rates2 .detail_upload2").html("6Mbps");
				//price adjustment
				$("#detailed_rates2 .price2 p").html("$74.95/mo");
				return;
		}
		//Business PLUS
		else {
			if (passer == "select" || passer == 0) {
				$(".error").slideDown('medium');
				$("#detailed_rates2").css('marginLeft', '200');
				return compare_flag = false;
			}
			parent = "business_1B";
			
			//plan name adjustment
				$("#detailed_rates2 h3").html("Business User Plan PLUS+");
				//dl adjustment
				$("#detailed_rates2 .detail_download2").html("20Mbs");
				//ul adjustment
				$("#detailed_rates2 .detail_upload2").html("8Mbps");
				//price adjustment
				$("#detailed_rates2 .price2 p").html("$99.95/mo");
		}
	}
	
}

function show_new (passer, namer) {
	$(".error").fadeOut('fast')
	if (compare_flag == false) {
		$("#detailed_rates").fadeOut('medium');
		$("#detailed_rates").animate(
			{
			 marginTop: "-225",
			 marginLeft: "50",
			 zIndex: "0"
			}, {
			 duration: 10,
			 complete: function() 
				{
				replace_values(passer, namer);	
				$("#detailed_rates").fadeIn('fast');
				 last_move ();
				}
								
		})
	}
	else {
		$("#detailed_rates2").fadeOut('medium');
		$("#detailed_rates2").animate(
			{
			 marginTop: "-270",
			 marginLeft: "170",
			 zIndex: "0"
			}, {
			 duration: 10,
			 complete: function() 
				{
				replace_values(passer, namer);	
				$("#detailed_rates2").fadeIn('fast');
				 last_move ();
				}
								
		})
	}
}

function last_move () {
	$("#compare").fadeIn('fast');
	$("#comparison").slideDown('medium');
	if (compare_flag == false) {
		$("#detailed_rates").animate(
		{
		 marginTop: "-225",
		 marginLeft: "75",
		 zIndex: "0"
		}, {
		 duration: 300,
		 complete: function(){}
			
		})
	}
	else {
		$("#detailed_rates2").animate(
		{
		 marginTop: "-270",
		 marginLeft: "200",
		 zIndex: "0"
		}, {
		 duration: 300,
		 complete: function(){}
		})
		return compare_flag = false		
	}
}


function run_dummy () {
	$(".choices").click(
	function() {
	var current = $(this);
	if (jQuery("#download_speed", current).attr("id") == "download_speed") {
		var trip = $(current).get(0);
		/////////currently here!
		//////  might need to make individual .click function, because
		/////    IE consider the <select> and <option> tags as part of span
		if (jQuery("#download_speed", current).attr('disabled') == 'disabled') {
			jQuery("#download_speed", current).removeAttr('disabled');
		}
		$("#prices").attr('disabled', 'disabled');
		$("#prices").val('select');
				
		$("#upload_speed").attr('disabled', 'disabled');
		$("#upload_speed").val('select');
		
		
		$("#dl").css('background-color', '#4F637A');
		$("#ul").css('background-color', '#ACD0FD');
		$("#price_list").css('background-color', '#ACD0FD');
					
		}
		//UPLOAD
	else if (jQuery("#upload_speed", current).attr("id") == "upload_speed") {
		if (jQuery("#upload_speed", current).attr('disabled') == 'disabled') {
			jQuery("#upload_speed", current).removeAttr('disabled');
		}
		$("#download_speed").attr('disabled', 'disabled');
		$("#download_speed").val('selected')
		
		$("#prices").attr('disabled', 'disabled');
		$("#prices").val('selected');
		$("#ul").css('background-color', '#4F637A');
		$("#dl").css('background-color', '#ACD0FD');
		$("#price_list").css('background-color', '#ACD0FD');
	}
	//PRICES
	else {
		if (jQuery("#prices", current).attr('disabled') == 'disabled') {
			jQuery("#prices", current).removeAttr('disabled');
		}
		$("#upload_speed").attr('disabled', 'disabled');
		$("#upload_speed").val('select');
				
		$("#download_speed").attr('disabled', 'disabled');
		$("#download_speed").val('select');
		
		$("#dl").css('background-color', '#ACD0FD');
		$("#ul").css('background-color', '#ACD0FD');
		$("#price_list").css('background-color', '#4F637A');
	}
	
	//COMPARE
	//DOWNLOAD			
	if (jQuery("#download_speed2", current).attr("id") == "download_speed2") {
			var trip = $(current).get(0);
			/////////currently here!
			//////  might need to make individual .click function, because
			/////    IE consider the <select> and <option> tags as part of span
			if (jQuery("#download_speed2", current).attr('disabled') == 'disabled') {
				jQuery("#download_speed2", current).removeAttr('disabled');
			}
			$("#prices2").attr('disabled', 'disabled');
			$("#prices2").val('select');
					
			$("#upload_speed2").attr('disabled', 'disabled');
			$("#upload_speed2").val('select');
			
			
			$("#dl2").css('background-color', '#008477');
			$("#ul2").css('background-color', '#85D6D0');
			$("#price_list2").css('background-color', '#85D6D0');
						
			}
			//UPLOAD
		else if (jQuery("#upload_speed2", current).attr("id") == "upload_speed2") {
			if (jQuery("#upload_speed2", current).attr('disabled') == 'disabled') {
				jQuery("#upload_speed2", current).removeAttr('disabled');
			}
			$("#download_speed2").attr('disabled', 'disabled');
			$("#download_speed2").val('selected')
			
			$("#prices2").attr('disabled', 'disabled');
			$("#prices2").val('selected');
			$("#ul2").css('background-color', '#008477');
			$("#dl2").css('background-color', '#85D6D0');
			$("#price_list2").css('background-color', '#85D6D0');
		}
		//DOWNLOAD
		else {
			if (jQuery("#prices2", current).attr('disabled') == 'disabled') {
				jQuery("#prices2", current).removeAttr('disabled');
			}
			$("#upload_speed2").attr('disabled', 'disabled');
			$("#upload_speed2").val('select');
					
			$("#download_speed2").attr('disabled', 'disabled');
			$("#download_speed2").val('select');
			
			$("#dl2").css('background-color', '#85D6D0');
			$("#ul2").css('background-color', '#85D6D0');
			$("#price_list2").css('background-color', '#008477');
		}
					
				
			});
	
}



		});
		
		

