// Form Scripts

	function form_submit(form, e){
		
		var key_code;
		
		if(window.event) key_code = window.event.keyCode;
		else if (e) key_code = e.which;
		else return true;
		
		if(key_code == 13){
			form.submit();
			return false;
		} else {
			return true;	
		}
		
	}
	
	function smart_field(element, default_text, class_name){
		
		$(element).focus(function(){
			if(this.value == default_text){
				this.value = '';
				this.className = class_name;
				this.focus();
			} else {
				this.select();
			}
		})
		.blur(function(){
			if(this.value == ''){
				this.value = default_text;
				this.className = class_name + '_blur';
			}
		});
		
		if ($(element).val() == default_text){
			$(element).removeClass().addClass(class_name + '_blur');
		}
	}


// Live Chat

	function live_chat(){
		window.open("http://www.websitealive8.com/1273/rRouter.asp?groupid=1273&websiteid=0&departmentid=1453&javascriptok=false", 'websitealive', 'width=1,height=1');
	}
	
// Quick View Scripts

function quickview_init(){
$(document).ready(function(){ 

	quickview = function(id_item){
		$.fancybox({
			'width'				:	'100%',
			'height'			:	560,
			'top'				:	200,
			'padding'			:	0,
			'margin'			:	0,
			'opacity'			:	true,
			'autoScale'			:	false,
			'centerOnScroll'	:	true,
			'changeSpeed'		:	100,
			'showCloseButton'	:	true,
			'transitionIn'		:	'fade',
			'transitionOut'		:	'none',
			'titleShow'			:	false,
			'type'				:	'iframe',
			'href'				:	'/item/quick-view/?id='+id_item
		});
	};
	
	
	$('[quickview]').mouseover(function(){
		
		q = $(this).attr('quickview')
		$('.quickview_button').each(function(){
			if($(this).attr('id') != q)	$(this).remove();
		});
		
		if ($('.quickview_button[id=' + $(this).attr('quickview') + ']').length == 0){
			
			css_top = ($(this).height() + 20) + 'px';
			
			quickview_button = $('<div></div>')
							.attr('id', $(this).attr('quickview'))
							.click(function(){
								quickview(q);
								$(this).remove();
							})
							.html('<img src="/images/quick-view.png"><br>')
							.css({ top: css_top })

							.addClass('quickview_button')
							.addClass('over')
												
							.mouseover(function(){
								$(this).addClass('over');
							}).mouseout(function(){
								$(this).removeClass('over');
							});
			
			if($(this).height() < 250){
				css_top = Math.round($(this).height() - 20) + 'px';
				$(quickview_button).addClass('small')
								   .html('<img src="/images/quick-view.small.png">')
								   .css({ top: css_top });
			}
			
			container = $(this).parent();
			if ($(container).attr('href'))	container = $(container).parent();
			$(container).prepend(quickview_button);
			$(quickview_button).show();

		}
		
	}).mouseout(function(){
		
		$('.quickview_button[id=' + $(this).attr('quickview') + ']').removeClass('over');
		q = $(this).attr('quickview');
		setTimeout(function(){
			remove_quickview(q);
		}, 100);
				
	});
	
	remove_quickview = function(q){
		if(!$('.quickview_button[id=' + q + ']').hasClass('over')) $('.quickview_button[id=' + q + ']').remove();
	}
	
});	
}
