// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function refreshSideCart() {
		new Ajax.Updater('cart-contents-refresh-container','/store/refresh_cart_contents');
		jQuery('div.package').remove();
}
function toggleExpiration() {
	$('ccard_input').toggle();
	$('bulldog_bucks_input').toggle();
}
function warnBuckPurchase() {
	var returning = false;
	var decision = confirm("Purchasing Bucks will clear all items in your cart.  Do you wish to continue?");
	if (decision == true) {
		returning = true;
	}
	return returning;
}
function warnBucksExist() {
	alert("You may not purchase regular items while 'Bucks' are in your cart.\nPlease purchase 'Bucks' or empty cart to continue.\nWe apologize for any inconvenience.");
	return false;
}
// functions opacity and changeOpac are used for fading elements
function itemNotifyCustomer(){
	new Ajax.Updater("item_notifier_element","/store/refresh_item_notifier");
	opacity("floatdiv", 100, 0, 3000);	
}
function opacity(id, opacStart, opacEnd, millisec, item) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
    //determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
	    for(i = opacStart; i >= opacEnd; i--) {
	        setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
	        timer++;
	    }
	} else if(opacStart < opacEnd) {
	    for(i = opacStart; i <= opacEnd; i++)
	        {
	        setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
	        timer++;
	    }
	}
} 
//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 101);
    object.MozOpacity = (opacity / 101);
    object.KhtmlOpacity = (opacity / 101);
    object.filter = "alpha(opacity=" + opacity + ")";
}
function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
}
