// Make IE work with HTML5 tags
document.createElement('header');
document.createElement('nav');
document.createElement('section');
document.createElement('article');
document.createElement('aside');
document.createElement('footer');

// Startup jQuery
jQuery(document).ready(function() {

	// Add a hook for every last li
	jQuery("ul li:last-child").addClass("last");
	
	// Add class to certain elements based on its index
	jQuery(".panel:odd").addClass("nth");
	jQuery("#panelsCon .panelSmall:nth-child(4n)").addClass("nth");
	jQuery("#panelsCon .panelMedium:nth-child(3n)").addClass("nth");
	jQuery("#accountCon .panelAccount:nth-child(5n)").addClass("nth");
	
	// Every fourth small panel
	//jQuery(".panelSmall").eq(3).addClass("fourth");
	//jQuery(".panelSmall:nth-child(4n)").addClass("fourth");

	// Set panels to same height
	$(".panel, .panelSmall, .panelMedium, .panelAccount").equalHeight();
	
	// Set the nav to be selected
	var url = window.location.href;
	url = url.substr(url.lastIndexOf("/") + 1);
	jQuery("nav ul, .subNav").find("a[href='./" + url + "']").parent().addClass("current");
	
	// If a sub-item is current, make the parent highlighted too
	jQuery("nav .current").parent().parent().addClass("current");
	
	// Submission form - specific to each form
	jQuery("#listings-form #formSet2, #listings-form #formSet4").hide();
	jQuery("#deals-form #formSet2, #deals-form #formSet3").hide();
	
	jQuery("#radioGroup1 :radio:eq(0)").click(function(){
		jQuery("#formSet3").show();
		jQuery("#formSet4").hide();
	});
	
	jQuery("#radioGroup1 :radio:eq(1)").click(function(){
		jQuery("#formSet3").hide();
		jQuery("#formSet4").show();
	});
	
	jQuery("#radioGroup2 :radio:eq(0)").click(function(){
		jQuery("#formSet1").show();
		jQuery("#formSet2").hide();
	});
	
	jQuery("#radioGroup2 :radio:eq(1)").click(function(){
		jQuery("#formSet1").hide();
		jQuery("#formSet2").show();
	});
	
	// Table row colouring adds class
	jQuery("tr:even").addClass("tableEven");
	jQuery("tr:odd").addClass("tableOdd");
	
	// Image gallery for properties
	jQuery("#propertyImages a").lightBox({fixedNavigation:true});

});

