$(document).ready(function(){
	// add class to links depending on extension
	$("a[@href$=pdf]").addClass("pdf").attr('target','_blank');
	$("a[@href$=zip]").addClass("zip");
	$("a[@href$=doc]").addClass("doc");
	$("a[@href$=xls]").addClass("xls");
	$("a[@href$=psd]").addClass("psd");
	
	// automatically create external link class and open in new window if link is not local or ID anchor
	$("a[@href^='http']").not("[@href*=http://skin:8888]").not("[@href*=http://www.destinationskin.com]").not("[@href*=http://destinationskin.com]").not("[href^=#]").addClass("external").attr('target','_blank');

	$("input").clearField();
	$('ul.sf-menu').superfish({ 
		delay:0,
		speed:'fast',
		autoArrows:false,
		dropShadows:false
	});
	$('ul#nav_primary li').hover(function(){
		$(this).find('a:first').addClass('active');
	},
	function(){
		$(this).find('a:first').removeClass('active');
	});
	$('ul#nav_primary2 li').hover(function(){
		$(this).find('a:first').addClass('active');
	},
	function(){
		$(this).find('a:first').removeClass('active');
	});

	if($.browser.msie && parseInt($.browser.version) <= 6){
	}
	else{	
		$('#preferred_date_1').datepicker({  
			dateFormat: 'dd/mm/yy',  
			buttonImage: '/interface/images/layout/date.gif', 
			buttonImageOnly: true,
			showOn: 'both'
		});
		$('#preferred_date_2').datepicker({  
			dateFormat: 'dd/mm/yy',  
			buttonImage: '/interface/images/layout/date.gif', 
			buttonImageOnly: true,
			showOn: 'both'
		});
	}

	//$(document).pngFix();
});

$.fn.clearField = function(){
	return this.focus(function() {
		if( this.value == this.defaultValue){
			this.value = "";
		}
	}).blur(function(){
		if( !this.value.length){
			this.value = this.defaultValue;
		}
	});
};