
/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */
	//$('span.pull-quote')		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

// starting the script on page load
$(document).ready(function(){
	tooltip();
});

$(function()
   {
/*
   <td class="slotGrey" width="10" id="1290-time_0945">&nbsp;</td>
   <td class="group1a_small" width="75" bgcolor="#f1f1f1" align="center"><span id="1290-time_0945">
*/
	$("a.slotClose").click(function()
	{
	the_id = $(this).attr('id');

	$(this).parent().html("<img src='../images/spinner.gif' width='16' height='16'/>");
		$.ajax({
			type: "POST",
			data: "slotAction=close&id="+$(this).attr("id"),
			url: "slotAction.php",
			success: function(msg)
			{
				$("td#color-"+the_id).removeClass().addClass("slotGrey");
				$("span#"+the_id).html(msg);
			}
		});
	});

	$("a.slotOpen").click(function()
	{
	the_id = $(this).attr('id');

	$(this).parent().html("<img src='../images/spinner.gif' width='16' height='16'/>");
		$.ajax({
			type: "POST",
			data: "slotAction=open&id="+$(this).attr("id"),
			url: "slotAction.php",
			success: function(msg)
			{
				$("td#color-"+the_id).removeClass("slotGrey").addClass("slotGreen");
				$("span#"+the_id).html(msg);
			}
		});
	});
});
/* 
 * Cross-browser event handling, by Scott Andrew
 */
function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}

/*
 * Clear Default Text: functions for clearing and replacing default text in
 * <input> elements.
 *
 * by Ross Shannon, http://www.yourhtmlsource.com/
 */

addEvent(window, 'load', init, false);

function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.type == 'text' && theInput.className.match(/\bformAppear\b/) || theInput.type == 'password' && theInput.className.match(/\bformAppear\b/)) {  
            /* Add event handlers */          
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            
            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}

$(document).ready(function() {
	$("a.zoom").fancybox();

	$("a.zoom1").fancybox({
		'overlayOpacity'	:	0.7,
		'overlayColor'		:	'#FFF'
	});

	$("a.zoom2").fancybox({
		'zoomSpeedIn'		:	500,
		'zoomSpeedOut'		:	500
	});
});
