﻿/* This file runs on every page, every time they are loaded. Do not remove it, it's a core file. */
/* Init - runs when document is ready. All functions which require the document to be ready should be called from here */

// add page_loaded class to HTML when page is fully loaded
$(window).load(function () {
	$("a[href^='http://'], a[href^='www.']").oinw();
});

$(function() {
	$("label.labeler").labeler();
	initDatePicker();
	createTabs();
	$("div#content").moveClass({target:"body"});
	$("table.tablestripe").tableStripe();
	$(".row").columns();
	$("#content input").typeClass();
	$(".afalc").afalc();
		
	  $('.slider').anythingSlider({
				easing: "swing",       
				autoPlay: true,                
				delay: 5000,                   
				startStopped: false,            
				animationTime: 600,            
				hashTags: false,                
				buildNavigation: true,         
				pauseOnHover: true,            
				startText: "Go",             
				stopText: "Stop"
			});
	
	
	
});

function initDatePicker() {
	// Datepickers for date input fields
	$('input.date').datepicker({ dateFormat: 'dd/mm/yy' });
}
 
// 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").tabs();
}
