// jQuery slideDown Toggle function -  apply class jq-toggle to any next sibling element will slide up and down
$(function() {
	$(".jq-toggle").next().hide();
	
	$(".jq-toggle").css("cursor", "pointer");
	$(".jq-toggle").prepend("+ ");
	
	$(".jq-toggle").click(function() {
		$(this).next().slideToggle(1000);
		
		var v = $(this).html().substring( 0, 1 );
		if ( v == "+" )
			$(this).html( "-" + $(this).html().substring( 1 ) );
		else if ( v == "-" )
			$(this).html( "+" + $(this).html().substring( 1 ) );
	});
});


// jQuery tooltip function - apply class .tooltip to any elemant and will take title attribute as parameter
this.tooltip = function(){	
			
		xOffset = 10;
		yOffset = 20;		
		
	$(".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");
	});			
};

$(document).ready(function(){
	tooltip();
});



//// Outputs colorbox subscriber form for floorplan
$(document).ready(function(){
				$(".floorplan").colorbox();
				$(".colorbox-profile").colorbox({scrolling: false});
			});

//// colorbox for exhibitors
$(document).ready(function(){
				$(".exhib-profiles").colorbox({width:"500px", height:"300px", iframe:true});
				$(".youtube").colorbox({width:"420px", height:"315px", iframe:true});
				});

// Columnzier initialiser - add class mcol2 to any ul
jQuery(document).ready(function($){
	$('.mcol2').makeacolumnlists({cols: 4, colWidth: 0, equalHeight: 'li', startN: 1});
});

$(function () {
	var apex = new Date(); 
	apex = new Date(apex.getFullYear(), 10 - 1, 4, 16); 
	
	$('#home-countdown').countdown({
		until: apex,
		timezone: +2,
		compact: true,
		format: 'dhMS',
		timeSeparator: '',
		compactLabels: ['', '', '', ''],
		layout: '<div class="count-days">{dnnn}</div>' + 
						'<div class="count-hours">{hnn}</div>' + 
						'<div class="count-mins">{mnn}</div>' + 
						'<div class="count-secs">{snn}</div>',
		serverSync: serverTime						
	}); 

	function serverTime() { 
    var time = null; 
    $.ajax({url: '/includes/time.php', 
        async: false, dataType: 'text', 
        success: function(text) { 
            time = new Date(text); 
        }, error: function(http, message, exc) { 
            time = new Date(); 
    }}); 
    return time; 
}
	
});

// gallery
$(function() {

$(".gallery").scrollable();

$(".gallery .items img").click(function() {

	if ($(this).hasClass("active")) { return; }

	var url = $(this).attr("src");

	var wrap = $("#image_wrap").fadeTo("medium", 0.9);

	var img = new Image();


	img.onload = function() {

		wrap.fadeTo("slow", 1);

		wrap.find("img").attr("src", url);

	};

	img.src = url;

	$(".items img").removeClass("active");
	$(this).addClass("active");
}).filter(":first").click();
});


//scrollto smooth
$(function(){

    $('a[href*=#]').click(function() {
    
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
        
            var $target = $(this.hash);
            
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            
            if ($target.length) {
            
                var targetOffset = $target.offset().top;
                
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                    
                return false;
                
            }
            
        }
        
    });
    
});

////top nav drop down div for left button UNCOMMENT TO ACTIVATE

//$(document).ready(function(){
//$("#top-nav-button-left").hover(function () {
//if ($("#top-nav-button-left-div").is(":hidden")) {
//$("#top-nav-button-left-div").slideDown(600);
//} else {
//$("#top-nav-button-left-div").hide();
//}
//});
//});

