
var xdiff = 0;
var ydiff = 0;
var showing = '';

function view_preview(title,id,wloc,hloc)
{
	xdiff = wloc ? 290 : 0;
	ydiff = hloc ? (hloc + 20) : 0;
	//$('image_title').innerHTML = title;
	$('prev_holder').src = "resources/"+id+"_medium.jpg";
	Effect.Appear('image_preview',{duration:.1});
	showing = id;
}

function pdf_preview(path,wloc,hloc)
{
	xdiff = 0;//wloc ? 290 : 0;
	ydiff = 300;//hloc ? (hloc + 20) : 0;
	//$('image_title').innerHTML = title;
	$('prev_holder').src = "resources/"+path;
	Effect.Appear('image_preview',{duration:.1});
	showing = path;
}

function do_search(f)
{
	if(f.query.value != '' && f.query.value != 'Enter keyword') {
		location = '/home/search/'+f.query.value;
		
	}
	return false;
}


function hide_preview()
{
	showing = '';
	Element.hide('image_preview');
}

function do_follow(e)
{
	var xpos = Event.pointerX(e);
	var ypos = Event.pointerY(e);
	if($('image_preview')) 
	{
		$('image_preview').style.top = ((ypos - ydiff) + 10) +'px';
		$('image_preview').style.left = ((xpos - xdiff) + 10) +'px';
	}
	if(showing=='') Element.hide('image_preview');
}

Event.observe(document,'mousemove',do_follow,false);

document.observe("dom:loaded", function() {
	$('search_field').onfocus = function() { 
		if($(this).value == 'Enter keyword') $(this).value = '';
	}
	$('search_field').onblur = function() { 
		if($(this).value == '') $(this).value = 'Enter keyword';
	}
	$('search_button').onmouseover = function() { 
		$('search_button').src = 'images/search_on.gif';
	}
	$('search_button').onmouseout = function() { 
		$('search_button').src = 'images/search_off.gif';
	}
  }
);
