// 

var gTabLoaded = new Array();

$(document).ready(function(){
	
	// Define tabs
	$("#tabs").tabs({ selected: 0});						

	// Define function for clicking on Tab
	$('#tabs').bind('tabsselect', function(event, ui) {
		
		// Only load once
		if (!gTabLoaded[ui.tab.name]) {
			var tabName = ui.tab.name;
			var url = "subpages/"+tabName+".html"
			$('#'+tabName).load(url);
			gTabLoaded[ui.tab.name] =true;
		}

	});

	// Define accordian
	$("#accordion").accordion({
		collapsible: true,
		autoHeight: false,
		active: "none"
	});

	// Define accordian
	$("#accordion2").accordion({
		collapsible: true,
		autoHeight: false, 
		active: "none"
	});

	// increase the default animation speed to exaggerate the effect
	$(function() {
		$('#dialog').dialog({
			autoOpen: false,
			bgiframe: true,
			closeText: "Close",
			width: 1000,
			show: 'blind',
			modal: true
		});
	});
	
	$(function (){ 
		$('a.changeDialog').click(function() { 
					var attr = this.name;
					var height = attr.substr(0,4); 
					if (height==0) height = 'auto';
					var width = attr.substr(4,8);
					var title = this.title;
					var url = this.href; 
					$.ajax({ 
						method: "get",
							url: url,
							cache: false,
							success: 	function(html){ 
								$('#dialog').dialog('option', 'title', title);
								$('#dialog').dialog('option', 'height', height);
								$('#dialog').dialog('option', 'width', width);
								$('#dialog').dialog('option', 'position', 'top');
								
								$('#dialog').dialog('open'); 
								$('#dialog').html(html);
										} 
					});

					//prevent the browser to follow the link 
					return false; 
		}); 
	}); 

	$('#Home').load('subpages/Home.html');
	gTabLoaded["Home"] =true;

});


function toggleDiv(div) {
	$(div).slideToggle(300);
}

function showContact() {
	$('#tabs').tabs('select', 5); 
}

function showDialog(url, title, height, width) {
	var ht = height;
	if (ht==0) ht = 'auto';

	$.ajax({ 
		method: "get",
			url: url,
			cache: false,
			success: 	function(html){ 
				$('#dialog').dialog('option', 'title', title);
				$('#dialog').dialog('option', 'height', ht);
				$('#dialog').dialog('option', 'width', width);
				$('#dialog').dialog('option', 'position', 'top');
				
				$('#dialog').dialog('open'); 
				$('#dialog').html(html);
						} 
	});
	
}

function loadClientTabs() {
	$("#tabsc").tabs({ selected: 0});						
	
	// Define function for clicking on Tab
	$('#tabsc').bind('tabsselect', function(event, ui) {
		
	});

	$('#Clients_Commercial').load("subpages/Clients_Commercial.html");
	gTabLoaded["Clients_Commercial"] =true;
}

function loadVacanciesTabs() {
	$("#tabsv").tabs({ selected: 0});						
	
	// Define function for clicking on Tab
	$('#tabsv').bind('tabsselect', function(event, ui) {
		
	});

	$('#Vacancies_Commercial').load("subpages/Vacancies_Commercial.html");
	gTabLoaded["Vacancies_Commercial"] =true;
}

function loadHomeTabs() {
	$("#tabsh").tabs({ selected: 0});						
	
	// Define function for clicking on Tab
	$('#tabsh').bind('tabsselect', function(event, ui) {
		
	});

	$('#Home_Direct').load("subpages/Home_Direct.html");
	gTabLoaded["Home_Direct"] =true;
}
