$(document).ready(function() {
	try { // add target blank to non image links that link to external sites
		$('a').not(":has(img)").not(".pdf").filter(function() {
			//.not(":has(img)")
			//.not(:has(".pdf"))
			return this.hostname && (this.hostname).split(":")[0] !== (location.hostname).split(":")[0];
		}).attr('target','_blank');
	} catch(e) {
		alert(e.message);
	}
	try { // add target blank to advert images that link to external sites
		$('.advert a').filter(function() {
			return this.hostname && (this.hostname).split(":")[0] !== (location.hostname).split(":")[0];
		}).attr('target','_blank');
	} catch(e) {
		alert(e.message);
	}
	try { // add image pop up to jpg adverts
		$('.advert a').filter(function() {
			var file = this.toString();
			//alert(file.split('.').pop().toLowerCase());
			return file.split('.').pop().toLowerCase() == 'jpg';
		}).attr('rel','lightbox');
	} catch(e) {
		alert(e.message);
	}
	try {
		$("select#jumpto").msDropDown();
	} catch(e) {
		alert(e.message);
	}
	try {
		$('input[placeholder], textarea[placeholder]').placeholder();
	} catch(e) {
		alert(e.message);
	}
	try {
   		$("ul.dropdown li").hover(function(){
    		$(this).addClass("hover");
        	$('ul:first',this).css('visibility', 'visible');
    	}, function(){
    		$(this).removeClass("hover");
        	$('ul:first',this).css('visibility', 'hidden');
    	});
	} catch(e) {
		alert(e.message);
	}
	try {
		$("li:last-child").addClass("last-child");
	} catch(e) {
		alert(e.message);
	}
	try {
		$("tr:last-child").addClass("last-child");
	} catch(e) {
		alert(e.message);
	}
});
$.fn.toggleCheckbox = function() {
    this.attr('checked', !this.attr('checked'));
}
$.fn.disableCheckbox = function() {
    this.attr('disabled', !this.attr('disabled'));
}
