
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 100;
		yOffset = 50;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
        $("body").append("<p id='preview'><img src='"+ this.t +"' alt='Image preview' /></p>");							 
		$("#preview")
			.css("top",(e.pageY - xOffset)* 0 + "px")
			.css("left",(e.pageX + yOffset)* 0 + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

this.radioToggleDisable = function(groupName, boolDisabled) {
    
    $("input[name='options["+groupName+"]']").each(function() {
        if(boolDisabled) {
            $(this).attr("disabled", "diabled");
        } else {
            $(this).attr("disabled", "");
        }
        
    });
    
    
}

$(document).ready(function(){
	$("a[rel='gallery']").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic'		
	});
    
  imagePreview();
  
  if($("input[name='options[frame]']").length > 0) {
      radioToggleDisable('frame-sur', true);
      radioToggleDisable('frame-thick', true);
  } 
  
  $("input[name='options[frame]']").each(function() {
    var selected;
    $(this).change(function() {
        radioToggleDisable("frame-sur", false);
        radioToggleDisable("frame-thick", false);
    });
  }); 
});
