HELV.$(document).ready(function() {
	//show/hide default search text
 	var z = jQuery("#inpsearch").attr("value");
	var inpsearchtext = jQuery("#inpsearch").attr("value");
	jQuery("#inpsearch").focus(function() {
		if (inpsearchtext == z) {
			jQuery(this).attr('value', '');
		} else {
			jQuery(this).attr('value', inpsearchtext);
		}
		//jQuery(this).attr("value","");
	});
	jQuery("#inpsearch").blur(function() {
		jQuery(this).attr("value", inpsearchtext);
	});
	jQuery("#inpsearch").keyup(function() {
		inpsearchtext = jQuery(this).attr('value');
	});

	//show/hide default text on search result
	jQuery("#mainsearch").focus(function() {
		jQuery(this).attr("value", "");
		jQuery(this).addClass("highlighttext");
	});
	jQuery("#mainsearch").blur(function() {
		jQuery(this).removeClass("highlighttext");
	});
	 
	//display 'print this page'
	jQuery(".print").show();

	//hide overflow:scroll on simple coverflow
	jQuery("#simple_dragged_content_bg_middle").css("overflow-x","hidden");
	//show hidden simple_drag_bg
	jQuery("#simple_drag_bg").show();
	//simple coverflow custom init
	HELV.simpleCoverflow.init();
	//simple COVERFLOW
	jQuery("#simple_drag_me").draggable({
		axis: 'x',
		containment: 'parent',
		snap: '.snap_ct',
		snapMode: 'inner',
		snapTolerance: 30, //the smaller the value, the more space is left to user for dragging (before snap kicks in)
		start: function() {
			//highlight clicked handle
			jQuery("#simple_drag_me,#simple_drag_me .sdm_right").css("background-position","0 -20px");
		},
		stop: function(event,ui) {
			HELV.simpleCoverflow.snapSlot(ui.position.left);
			HELV.simpleCoverflow.processHighlighting();
			//normalize clicked handle
			jQuery("#simple_drag_me,#simple_drag_me .sdm_right").css("background-position","0 0");
		},
		drag: function(event,ui){
			//scroll contents, constraint factor is handle vs. content width
			jQuery("#simple_scroller").css("left",-ui.position.left * (HELV.simpleCoverflow.CONTENTWIDTH/HELV.simpleCoverflow.currentHandleWidth()));
		}
	});

	//coverflow custom init
	HELV.coverflow.init();
	//COVERFLOW
	jQuery("#drag_me").draggable({
		axis: 'x',
		containment: 'parent',
		snap: '.snap_ct',
		snapMode: 'inner',
		snapTolerance: 50, //the smaller the value, the more space is left to user for dragging (before snap kicks in)
		//helper: 'clone',
		start: function() {
			//highlight clicked handle
			jQuery("#drag_me").css("background-position","0 -20px");
		},
		stop: function(event,ui) {
			HELV.coverflow.snapSlot(ui.position.left);
			HELV.coverflow.processHighlighting();
			//normalize clicked handle
			jQuery("#drag_me").css("background-position","0 0");
		},
		drag: function(event,ui){
			//scroll contents, constraint factor is handle vs. content width
			jQuery("#scroller").css("left",-ui.position.left * (HELV.coverflow.CONTENTWIDTH/HELV.coverflow.HANDLEWIDTH));
		}
	});
	//tabs inside coverflow
	jQuery("#scroller .cftab").tabs();

	//popup close
	jQuery("#popup_close").click(function() {
		window.close();
		return false;
	});
});
