﻿// document ready
$(function() {
	$(".labeler").labeler();
	$(".afalc").afalc();
	$("#content").moveClass("body");
	$("#content input").typeClass("input_type");
	$(".odd").oddEven();
	$(".tablestripe").oddEven({target:"tbody tr"});
	//$(".level1 ul li a").tooltiper({position:"left bottom tl", hideDelay:40, showDelay:200});
	initDatePicker();
	createTabs();
	videoPagination();
	startLeadelement1();
	startLeadelement2();
	startLeadelement3();
	startFooter();
	startVirtualtour();
	page_tools();
	$(".setNumberOfColumns3").columnise(".sublead", {numberOfColumns:3});
	$(".setNumberOfColumns2").columnise(".sublead", {numberOfColumns:2});
	$(".row").columns(".column");
	addClassToNavigation();	
   	$(".latestPodcast ul").accordion({ header: '.title', autoHeight: false });
	
});

// document load 
/*$(window).load(function() {
	$("a[href^='http://'], a[href^='www.']").oinw();
});*/

function initDatePicker() {
	// Datepickers for date input fields
	$('input.date').datepicker({ dateFormat: 'dd/mm/yy' });
}

 function page_tools() {
	$(".page_tools a").tooltiper({animateEffect:"fade", position:"center bottom",  opacity:0.7});

}
 
// Open an AJAX dialog
function openDialog(url,title,width,height) {
	// Width and height
	var w = 500;
	var h= 300;
	if(width) {
		w = width;	 
	}
	if(height) {
		h = height;	 
	}
	 // Reset the dialog
    $("#dialog").html('').dialog('destroy'); 
    // Set up dialog
    $("#dialog").dialog({
		width: w,
		height: h,
		modal: true,
		title: title,
		cache: false
    }); 
    // Fetch content
    $.ajax({
		type: "GET",
		url: url,
		data: "ajax=1",
		success: function(data){
			$("#dialog").html(data);
		}
    });
}

// Replace alrt boxes with a much nicer alternative
function ajaxAlert(msg) {
	if($('#alert').length == 0) {
		$("body").append('<div id="alert"></div>');	
	}
    $('#alert').dialog('destroy').html(msg).dialog({
		dialogClass: 'alert',
		width: 200,
		minHeight: 80,
		modal: true,
		cache: false,
		buttons: { "Ok": function() { $(this).dialog("close"); } }
    }); 
}

/* create tabs function - to allow for tabs to be called by other means */
function createTabs(){
	$(".tabs").tabber();
}

function printPage() {
    window.print();
}

function startLeadelement1() {
   $('.panel1').cycle({
        fx:      'fade',
        timeout:  0,
        pager:   '.pager1',
		timeout: 10000, 
        pagerAnchorBuilder: pagerFactory
    });

    function pagerFactory(idx, slide) {
        var s = idx > 10 ? ' style="display:none"' : '';
        return '<li'+s+'><a href="#">'+(idx+1)+'</a></li>';
    };
}

function startLeadelement2() {
   $('.panel2').cycle({
        fx:      'fade',
        timeout:  0,
        pager:   '.pager2',
		timeout: 10000, 
        pagerAnchorBuilder: pagerFactory
    });

    function pagerFactory(idx, slide) {
        var s = idx > 10 ? ' style="display:none"' : '';
        return '<li'+s+'><a href="#">'+(idx+1)+'</a></li>';
    };
}

function startLeadelement3() {
   $('.panel3').cycle({
        fx:      'fade',
        timeout:  0,
        pager:   '.pager3',
		timeout: 10000, 
        pagerAnchorBuilder: pagerFactory
    });

    function pagerFactory(idx, slide) {
        var s = idx > 10 ? ' style="display:none"' : '';
        return '<li'+s+'><a href="#">'+(idx+1)+'</a></li>';
    };
}



function startFooter() {
   $('.footer .cycle').cycle({
        fx:      'fade',
        timeout:  0,
		timeout: 6000, 
		random:  1 
       
    });

   
}


// add classes to navigation to display popup
function addClassToNavigation() {	
	$(".topnav ul li:not(div.nav_popup ul li)").hoverIntent(function() {														
		$(".topnav ul li:not(this)").removeClass("showPopup");
		$(this).addClass("showPopup");
		$(this).find("div.nav_popup").addClass("displayPopup");
	},function(){});
	
	$(".topnav ul li div.nav_popup").mouseleave(function() {
		if($(".topnav ul li div.nav_popup").hasClass("displayPopup")) {
			$(this).removeClass("displayPopup");
			$(".topnav ul li").removeClass("showPopup");
		}
		else {
			
		}
	});
	
	$("#header .inner").mouseenter(function() {
		$(this).addClass("hover");
	});
	
	$("#header .inner").mouseleave(function() {
		$(this).removeClass("hover");
	});
};


function videoPagination() {	
   $('.video_list').cycle({
        fx:      'fade',
        timeout:  0,
        prev:    '#prev',
        next:    '#next',
		timeout: 0 
    });

   
}




function startVirtualtour() {
 
	var flashvars = {};
	var params = {};
	var attributes = {};
	var width = 535;
	var height = 345;
	var base = 'http://www.venuefinder.com/vrtours/';
	var tourname1 = '11336/841.swf';
	var tourname2 = '11336/840.swf';
	var tourname3 = '11336/843.swf';
	var tourname4 = '11336/844.swf';
	var tourname5 = '11336/842.swf';
	params.play = 'true';
	params.loop = 'false';
	params.quality = 'autohigh';
	params.allowfullscreen = 'true';
	params.wmode = 'opaque';
	swfobject.embedSWF(base + tourname1, 'VirtualTourPanel1', width, height, '9.0.0',  base + '/expressInstall.swf', flashvars, params, attributes);
	swfobject.embedSWF(base + tourname2, 'VirtualTourPanel2', width, height, '9.0.0',  base + '/expressInstall.swf', flashvars, params, attributes);
	swfobject.embedSWF(base + tourname3, 'VirtualTourPanel3', width, height, '9.0.0',  base + '/expressInstall.swf', flashvars, params, attributes);
	swfobject.embedSWF(base + tourname4, 'VirtualTourPanel4', width, height, '9.0.0',  base + '/expressInstall.swf', flashvars, params, attributes);
	swfobject.embedSWF(base + tourname5, 'VirtualTourPanel5', width, height, '9.0.0',  base + '/expressInstall.swf', flashvars, params, attributes);

  
}
