// jquery-1.4.2.min
$(document).ready(function(){
		
	findExternalLinks();
	getRidOfBlocks();
	mainNavElements();
	removeBorderTeaser();
	
	if ($.browser.msie) {
	     // ie functions: placeholder text
		inputPlaceholder();
	}


});

$(window).bind("load", function() {
   
	$("div#carousel").slideViewerPro({
		galBorderWidth: 0,  // the border width around the main images
		thumbsBorderOpacity: 1.0, // could be 0, 0.1 up to 1.0
		thumbsActiveBorderOpacity: 1.0, // could be 0, 0.1 up to 1.0
		easeTime: 750, // the time it takes a slide to move to its position
		asTimer: 4000, // if autoslide is true, this is the interval between each slide
		thumbsPercentReduction: 23, // the percentual reduction of the thumbnails in relation to the original
		thumbsVis: true, // with this option set to false, the whole UI (thumbs and buttons) are not visible
		autoslide: false, // by default the slider do not slides automatically. When set to true REQUIRES the jquery.timers plugin
		typo: false, // the typographic info of each slide. When set to true, the ALT tag content is displayed
		shuffle: false // the LI items can be shuffled (randomly mixed) when shuffle is true
	});
	
});

function removeBorderTeaser(){
	var elColAsideLastDiv = jQuery('#content div.col-aside > div:last-child');
	if(elColAsideLastDiv){
		elColAsideLastDiv.css('border-bottom', 'none');
	}
};


function mainNavElements(){
	var arrMainNavItems = jQuery('#nav>ul>li');
	
	arrMainNavItems.each(function(el, item){
		elSubNav = $(this).find('ul.submenu');
		elSubNav.parent().parent().addClass('hassub');
	});

};


function getRidOfBlocks(){
	var emptyBlock = jQuery('div.subnav div');

	emptyBlock.filter(function() {
        return $.trim($(this).text()) === ''
    })
    .remove()

};


function findExternalLinks() {
	var allExternalLinks = jQuery('a[href^="http://"]');
	var thisDomain = window.location.host;
	allExternalLinks.each(function(i) {
		if (!jQuery(this).attr('href').indexOf(thisDomain) !== -1 && !jQuery(this).hasClass('shadowbox')) {
			jQuery(this).attr('rel','external');
		}
	});
	initExternalLinks();
} 

function initExternalLinks() {
	var arrExternalLinks = jQuery('a[rel|=external]');
	if (arrExternalLinks.length > 0) {
		arrExternalLinks.each(function() {
				$(this).click(function(e) {
				window.open($(this).attr('href'));
				return false;
			});
		});	
	}
}

// ie functions

function inputPlaceholder(){
	$('input').focus(function() {
		  var input = $(this);
		  if (input.val() == input.attr('placeholder')) {
		  input.val('');
		  input.removeClass('placeholder');
	}
	}).blur(function() {
		var input = $(this);
		if (input.val() == '' || input.val() == input.attr('placeholder')) {
		input.addClass('placeholder');
		input.val(input.attr('placeholder'));
	}
	}).blur();
	$('[placeholder]').parents('form').submit(function() {
	  $(this).find('[placeholder]').each(function() {
		  var input = $(this);
		  if (input.val() == input.attr('placeholder')) {
			  input.val('');
		  }
	  });
	});
}

