function showBuyPanel(divId,other){
	$('#' + divId + 'Wrapper').slideDown(1,function(){
		$('#' + divId).slideDown('normal');		
	});/*
	$('#' + divId + 'Link').unbind('click').bind('click',function(){
		hideBuyPanel(this.rel,other);
		showBuyPanel(other,this.rel);
		return false;
	});	*/
}
function hideBuyPanel(divId,other){
	$('#' + divId).slideUp('normal', function(){
		$('#' + divId + 'Wrapper').slideUp(50);
	});	/*
	$('#' + divId + 'Link').unbind('click').bind('click',function(){
		showBuyPanel(this.rel,other);
		hideBuyPanel(other,this.rel);
		return false;		
	});*/
}

fsCheckout = {
	
	copyDetails : function(){
		
		$(".main *[name^='invoice']").each(function(){
			fieldname = $(this).attr('name').replace(/invoice/,'');
			
			if(fieldname.length > 1){

				switch ($(this).attr("tagName").toLowerCase() ){
					case "input": 
						$('.main *[name="delivery' + fieldname + '"]').val($(this).val());
					break;
		
					case "select": 
						$('.main *[name="delivery' + fieldname + '"]').selectOptions($(this).val(), true);
					break;
					
				};
			};
		
		});
		
		$('#deliveryEmail').val($('#userEmail').val());
		
	},
	
	showRefresh : function(){
		
		$('#frmBasket .proceedLink').hide();
		$('#frmBasket .updateCheckout').show();
		
	}
	
}


fsRollover = 
{
	init: function()
	{
		this.preload();
		
		$(".ro").each(function(){
		
			if(!$(this).data('isSet')){
				$(this).hover(
					function () { $(this).attr( 'src', fsRollover.newimage($(this).attr('src')) ); }, 
					function () { $(this).attr( 'src', fsRollover.oldimage($(this).attr('src')) ); }
				).data('isSet',true);
			};
			
		});
		
	},
	
	preload: function()
	{
		$(window).bind('load', function() {
			$('.ro').each( function( key, elm ) { $('<img>').attr( 'src', fsRollover.newimage( $(this).attr('src') ) ); });
		});
	},
	
	newimage: function( src )
	{ 
		return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_on' + src.match(/(\.[a-z]+)$/)[0]; 
	},
	
	oldimage: function( src )
	{ 
		return src.replace(/_on\./, '.'); 
	}
};

$(document).ready(function(){
	$('#search').bind('click',function(){
		if(this.value == 'Search Fontsmith...'){
			this.value = '';
		}
	});
	
	$('#navSearch').bind('click',function(){
		if(this.value == 'Enter keyword...'){
			this.value = '';
		}
	});
	
	fsRollover.init();
});

/**
 * Logic for copying events from one jQuery object to another.
 *
 * @private	
 * @name jQuery.events.copy
 * @param jQuery|String|DOM Element jQuery object to copy events from. Only uses the first matched element.
 * @param jQuery|String|DOM Element jQuery object to copy events to. Copies to all matched elements.
 * @type undefined
 * @cat Plugins/copyEvents
 * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 */
jQuery.event.copy = function(from, to) {
	from = (from.jquery) ? from : jQuery(from);
	to   = (to.jquery)   ? to   : jQuery(to);
	
	if (!from.size() || !from[0].events || !to.size()) return;
		
	var events = from[0].events;
	to.each(function() {
		for (var type in events)
			for (var handler in events[type])
				jQuery.event.add(this, type, events[type][handler], events[type][handler].data);
	});
};