/*
 JavaScript Init File
 Author: Dave Buchholz - I-CRE8
 Version: 1.0
 Date: 28th June 2010
*/

document.documentElement.className += 'js hide';

// Initialise Standard jQuery Stuff
$(function() {
	// open external links in a new window
	$('a[rel=external]').click(function(e){
		open(this.href);
		e.preventDefault();
		});
	// Animate anchor links
	//$.localScroll();
	$.localScroll.hash({ queue:true });
	// Top of Page add &#8593; to link
	$('a.toTop').prepend('&#8593;&nbsp;');
	// offensive check
	$('a.checkThis').click( function(e) {																 
		
		var toBeChecked = this.href;
		
		if(toBeChecked.indexOf('offensive') > -1) {
			e.preventDefault();
			$.blockUI({ message: $('#question'), css: { border: '5px solid #1a1a1a', left: '30%',  padding: '6px', width: 'auto' }, overlayCSS: { opacity: .95 },  baseZ: 99999999 });
			
			$('#yes').click(function() {  
				// unblock when remote call returns 
				$.unblockUI();
				window.location.href = toBeChecked;
			}); 
			
			$('#no').click(function() {
				$.unblockUI();
				return false;
			});			
		}
	});
	// Show Number of Records Select List
	$('#change').hide();
	$('#change1').hide();	
	$('#change2').hide();
	$('#change3').hide();
	var COOKIE_NAME = 'recordPaging';
	var COOKIE_NAME1 = 'sortBy';
	$("#paging").change(function() {
		var pagingValue = $(':selected', this).val();
		var date = new Date();
		date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));
		$.cookie(COOKIE_NAME, pagingValue, { path: '/', expires: date });
		$(this).parents('form').submit();
	});
	$("#paging1").change(function() {
		var pagingValue = $(':selected', this).val();
		var date = new Date();
		date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));
		$.cookie(COOKIE_NAME, pagingValue, { path: '/', expires: date });
		$(this).parents('form').submit();
	});
	$("#sortby").change(function() {
		var sortBy = $(':selected', this).val();
		var date = new Date();
		date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));
		$.cookie(COOKIE_NAME1, sortBy, { path: '/', expires: date });
		$(this).parents('form').submit();
	});
	$("#sortby1").change(function() {
		var sortBy = $(':selected', this).val();
		var date = new Date();
		date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));
		$.cookie(COOKIE_NAME1, sortBy, { path: '/', expires: date });
		$(this).parents('form').submit();
	});
	// colorbox image viewer
	$('a.colorbox').colorbox();
	// color box cvv info viewer	
	$('a.cvv').colorbox({width:"50%"});
});

