$(document).ready(function(){

	// pdf attachments
	$('a[rel*="attachment"]').parent().addClass('pdf-link');
	$('a[href*=".pdf"]').addClass('pdf-link');
	$('a[href*=".doc"]').addClass('doc-link');

	//
	init_swap_text_boxes();

	// WPML bug
	$('a')
		.each(function(){ 
			this.href = this.href.replace(/^http:\/\/www\.montolit\.com\/en\/en/, "http://www.montolit.com/en");
		}
	);
	
	// aggiungi indicatore agli elementi del menu categorie se hanno dei figli (solo dal secondo livello in poi)   
	$('#access ul li ul li ul.children').parent().children('a').append('<span class="floatright">&raquo;</span>');
   
})


/* ######### http://developerkarma.com/blog/andrew-m-riley/using-jquery-hide-value-text-fields-focus ######### */

var swap_text_boxes = [];

function init_swap_text_boxes(){
  //Store the default value for each box
  $('input[type=text][value].swaptextbox').each(function() {
    swap_text_boxes[$(this).attr('id')] = $(this).attr('value');
  });
  //Add focus and blur events to set or clear the value
  $('input[type=text][value].swaptextbox').bind('focus', function() {
    if($(this).val() == swap_text_boxes[$(this).attr('id')]) {
      $(this).val('');
    }
  });
  $('input[type=text][value].swaptextbox').bind('blur', function() {
    if($(this).val() == '') {
      $(this).val(swap_text_boxes[$(this).attr('id')]);
    }
  });
}


