this.screenshotPreview = function(){	
		xOffset = 10;
		yOffset = 30;
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='eelvaade..' />"+ c +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },

	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	

	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
// starting the script on page load
$(document).ready(function(){
    initPopup();
	//$('#search-field').focus();
	screenshotPreview();
	 $('#search-select').bind('change', function() {
		 var selected = $('#search-select').attr('value');
		 $('.search-div').hide();
		 $('#search-' + selected).show();
		 $('#search-field').focus();
	 }); 
	 
});




function initPopup() {
	$('a.poplight').click(function() {
	    var popID = $(this).attr('rel'); //Get Popup Name
	    var popURL = $(this).attr('href'); //Get Popup href to define size
	    var query= popURL.split('?');
	    var dim= query[1].split('&');
	    var popWidth = dim[0].split('=')[1]; //Gets the first query string value
	    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><snap class="btn_close">Sulge</span></a>');
	    var popMargTop = ($('#' + popID).height() + 80) / 2;
	    var popMargLeft = ($('#' + popID).width() + 80) / 2;
	    $('#' + popID).css({
	        'margin-top' : -popMargTop,
	        'margin-left' : -popMargLeft
	    });
	    $('body').append('<div id="fade"></div>');
	    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();  
	    return false;
	});
	$('a.close, #fade').live('click', function() {
	    $('#fade , .popup_block').fadeOut(function() {
	        $('#fade, a.close').remove();
	    });
	    return false;
	});	
}

