function init() {
	if($('#sidebar').length) sideclick();
	nav();
	if($('.tooltip-target').length) tips();
	if ($('.donate').length) donate();
	if ($('a.lightbox').length) {
		//alert('hello world!');
		$('a.lightbox').colorbox();
	}
}

function setstyles() {
	$('#bg_imge').hide().fadeIn('slow');		
}

function nav() {
	var links = $('#nav ul li a');
	var unset = $('#bg_imge');

	var oldcolor = links.css('color');
		
	$('#nav a').hover(function() {
		$(this).animate('color', 'ffffff');
	}, function() {
		$(this).animate('color', oldcolor);
		
	});
	
	links.mousedown(function() {
		$('#bg_imge').fadeOut();
	});
	
}
function donate() {
	// alert('hello');
	var $radio = $('#custom-price');
	var $value = $('#custom-price-value');
	
	$value.attr('disabled', 'disabled').fadeTo('fast', 0.25);
	// $value.removeAttr("disabled");
	
	$radio.click(function() {
		// $value.removeAttr('disabled').fadeTo('fast', 1);
		$value.removeAttr('disabled').addClass('required').fadeTo('fast', 1);
	});
	
	$('label.error').hide();
	
	$("#donate").validate({
		// debug: true,
	    rules: {
           "fund": {
                required: true
            },
            "price": {
                required: true
            }
        }
    });

	$radio.click(function() {
		$value.removeAttr('disabled').addClass('required').fadeTo('fast', 1);
		// $value.removeAttr('disabled').fadeTo('fast', 1);
		// $value.rules("add", {
		// 			required: true,
		// 			number: true,
		// 			minlength: 1,
		// 			messages: {
		// 				required: "Please enter the amount of your donation.",
		// 				minlength: jQuery.format("Please enter the amount of your donation")
		// 			}
		// 		});
	});

		
	// if (document.donations.custom_amount.checked) {
	// 	document.donations.custom_donation.disabled = false;
	// 	document.donations.custom_donation.focus();
	// } else {
	// 	document.donations.custom_donation.disabled = true;
	// }
}

function sideclick() {		
	if($('sidebar').length) 
	$('#sidebar a').addEvent('mousedown', function(){
		$('bg_imge').fadeOut();
	});
}

function tips() {	
	$('.tooltip-target').ezpz_tooltip({
		//contentId:"caption",
		contentPosition: "belowRightFollow",
		showContent: function(content) { 
			content.fadeIn('slow'); 
		},
		hideContent: function(content) { 
			content.stop(true, true).fadeOut('slow'); 
		}
	});
	
} 

window.onload = function() {
	if($('#bg_imge').length) $('#bg_imge').fadeIn('slow');
};
	
$(document).ready(function() {
	if($('#bg_imge').length) $('#bg_imge').hide();
    init();    
});

// EZPZ Tooltip v1.0; Copyright (c) 2009 Mike Enriquez, http://theezpzway.com; Released under the MIT License
(function($){$.fn.ezpz_tooltip=function(options){var settings=$.extend({},$.fn.ezpz_tooltip.defaults,options);return this.each(function(){var content=$("#"+getContentId(this.id));var targetMousedOver=$(this).mouseover(function(){settings.beforeShow(content,$(this))}).mousemove(function(e){contentInfo=getElementDimensionsAndPosition(content);targetInfo=getElementDimensionsAndPosition($(this));contentInfo=$.fn.ezpz_tooltip.positions[settings.contentPosition](contentInfo,e.pageX,e.pageY,settings.offset,targetInfo);contentInfo=keepInWindow(contentInfo);content.css('top',contentInfo['top']);content.css('left',contentInfo['left']);settings.showContent(content)});if(settings.stayOnContent&&this.id!=""){$("#"+this.id+", #"+getContentId(this.id)).mouseover(function(){content.css('display','block')}).mouseout(function(){content.css('display','none');settings.afterHide()})}else{targetMousedOver.mouseout(function(){settings.hideContent(content);settings.afterHide()})}});function getContentId(targetId){if(settings.contentId==""){var name=targetId.split('-')[0];var id=targetId.split('-')[2];return name+'-content-'+id}else{return settings.contentId}};function getElementDimensionsAndPosition(element){var height=element.outerHeight(true);var width=element.outerWidth(true);var top=$(element).offset().top;var left=$(element).offset().left;var info=new Array();info['height']=height;info['width']=width;info['top']=top;info['left']=left;return info};function keepInWindow(contentInfo){var windowWidth=$(window).width();var windowTop=$(window).scrollTop();var output=new Array();output=contentInfo;if(contentInfo['top']<windowTop){output['top']=windowTop}if((contentInfo['left']+contentInfo['width'])>windowWidth){output['left']=windowWidth-contentInfo['width']}if(contentInfo['left']<0){output['left']=0}return output}};$.fn.ezpz_tooltip.positionContent=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY-offset-contentInfo['height'];contentInfo['left']=mouseX+offset;return contentInfo};$.fn.ezpz_tooltip.positions={aboveRightFollow:function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY-offset-contentInfo['height'];contentInfo['left']=mouseX+offset;return contentInfo}};$.fn.ezpz_tooltip.defaults={contentPosition:'aboveRightFollow',stayOnContent:false,offset:10,contentId:"",beforeShow:function(content){},showContent:function(content){content.show()},hideContent:function(content){content.hide()},afterHide:function(){}}})(jQuery);(function($){$.fn.ezpz_tooltip.positions.aboveFollow=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY-offset-contentInfo['height'];contentInfo['left']=mouseX-(contentInfo['width']/2);return contentInfo};$.fn.ezpz_tooltip.positions.rightFollow=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY-(contentInfo['height']/2);contentInfo['left']=mouseX+offset;return contentInfo};$.fn.ezpz_tooltip.positions.belowRightFollow=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY+offset;contentInfo['left']=mouseX+offset;return contentInfo};$.fn.ezpz_tooltip.positions.belowFollow=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=mouseY+offset;contentInfo['left']=mouseX-(contentInfo['width']/2);return contentInfo};$.fn.ezpz_tooltip.positions.aboveStatic=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=targetInfo['top']-offset-contentInfo['height'];contentInfo['left']=(targetInfo['left']+(targetInfo['width']/2))-(contentInfo['width']/2);return contentInfo};$.fn.ezpz_tooltip.positions.rightStatic=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=(targetInfo['top']+(targetInfo['height']/2))-(contentInfo['height']/2);contentInfo['left']=targetInfo['left']+targetInfo['width']+offset;return contentInfo};$.fn.ezpz_tooltip.positions.belowStatic=function(contentInfo,mouseX,mouseY,offset,targetInfo){contentInfo['top']=targetInfo['top']+targetInfo['height']+offset;contentInfo['left']=(targetInfo['left']+(targetInfo['width']/2))-(contentInfo['width']/2);return contentInfo}})(jQuery);
