(function($){

var SH = {
   ondomready: function(){
		SH.buildDonation();
		SH.buildFlare();
		SH.fixSubmit();
		SH.fixFlash();
		
		SH.fixInputs();
		
		SH.fixForm();
		
		
		setCookie("flareDisable", 1, 999);
   },
   
   
   fixForm: function() {
		$("#howhelp").submit(function() {
			if (($("#zipcode").val() != "" && $("#zipcode").val() != "Enter Zip Code...") || ($("#loc").val() != "")) {
				
				if (($("#need").val() != "" && $("#need").val() != "Select...")) {
					return true;
				} else {
					alert("Please select an Area of Need");
					return false;
				}

			} else {
				alert("Please enter a ZipCode or select a Location");
				return false;
			}
		});
   },
   
   fixInputs: function() {
		$("#s2").focus(function() {
			str = "Enter a Topic...";
			if ($(this).val() == str) {
				$(this).val("");
			}
		});
		
		$("#s2").blur(function() {
			str = "Enter a Topic...";
			if ($(this).val() == "") {
				$(this).val(str);
			}
		
		});
		$("#zipcode").focus(function() {
			str = "Enter Zip Code...";
			if ($(this).val() == str) {
				$(this).val("");
			}
		});
		
		$("#zipcode").blur(function() {
			str = "Enter Zip Code...";
			if ($(this).val() == "") {
				$(this).val(str);
			}
		
		});
   },
   
   fixFlash: function() {
	$("object").each(function() {
		$(this).append("<param name='wmode' value='transparent'/>");
	});
	
	$("embed").each(function() {
		var str = $(this).attr("outerHTML");
		if (str.length > 0) {
			str = str.replace("embed ", "embed wmode='transparent' ");
			$(this).attr("outerHTML", str);
		}
	});
   },
   
   fixSubmit: function() {
		if ($.browser.mozilla) {
			$("#sbutt").css("top", "1px");
		}
		if ($.browser.msie) {
			$("#sbutt").css("top", "-1px");
		}
   },
   
   buildDonation: function() {
		$("#donationLink").click(function(event) {
			event.preventDefault();
			$("#donationForm").submit();
		});
   },
   
   buildFlare: function() {
   
	$("#flare").pngFix();
   
   
	if ($.browser.msie) {
		if (getCookie("flareDisable") != 1 || 1==0)
		{	$("#flare").show();
			$("#flare").delay(500).animate({left: "+=75"}, 500, "linear", function() {
				$("#flare").animate({left: "+=75"}, 500, "linear", function() {
					$("#flare").hide();
				});
			});
		}	
	
	} else {
		if (getCookie("flareDisable") != 1 || 1==0)
		{	
			$("#flare").show();
			$("#flare").css("opacity", 0);
			$("#flare").delay(500).animate({left: "+=75", opacity: 100}, 500, "linear", function() {
				$("#flare").animate({left: "+=75", opacity: 0}, 500, "linear", function() {
					$("#flare").hide();
				});
			});
		}
	}
   }
   
   
}

window.SH = SH;

$(document).ready(function(){SH.ondomready();});

})(jQuery);


function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
