

function changeLanguage(ob) {
	var preLang = $(ob).val();
	var url = "http://"+window.location.host+"/csp/cms/sites/DTI/Home/index.csp";

	if(preLang == "French"){
		var lang = "/FR"
	}if(preLang == "Spanish"){
		var lang = "/ES"
	}if(preLang == "German"){
		var lang = "/DE"
	}if(preLang == "US English"){
		var lang = ""
	}
	
	re = new RegExp("(?:/FR|ES|DE)")
	if(url.search("/FR") != -1 || url.search("/DE") != -1 || url.search("/ES") != -1){
		url = url.replace(re,"");
	}
	
	if(url.search("/Home") != -1){
		window.location.href = url.replace("/Home","/Home" + lang);
	}
}

$(function() {
	/* A special transparent pseudo-select box for selecting a language */
	$('#headerCountrySelect').selectbox({onChange:changeLanguage });
		
	/* Add a class to the first <li> tag in the footer element (so that we don't show a | ) */
	$('#footer ul li:first').addClass('first');
		
	/* We need to absolutely position the close quotes so that the browser
	   can re-adjust the line height of the final line of text.  
	   (The quote is taller than the text.)
	   	   
	   In every browser but safari we can do this right in the css.  Safari, however, seems like to
	   lay out the page before we switch the quote to absolute positioning 
	*/	
	$('.right-quote').css( { 'position': 'absolute', 'margin-top':'3px'  } );	    
	
	/* Add a dynamic hover handler to any image with a css "hover" class 
	
		Image suffixes must be:
			_off.gif
			_on.gif
			_roll.gif
			
		For example:
			technologies_on.gif
			technologies_off.gif
			technologies_roll.gif
	*/
	
	$('.hover img, img.hover').filter(':not(.no-roll)').hover(
		function() {					
			$(this).data("old",this.src);
			this.src=this.src.replace( /_off|_on/, '_roll' )
		},
		function () {
			this.src=$(this).data("old");
		}
	);
	
	/*
		Dynamically add <li class="spacer"> to the secondary nav menu where appropriate.
		
		This allows us to have semantically correct html and still show an attractive 
		spacer border when the page actually loads. 
	*/
	
	$('#secondary-nav-sidebar > ul > li')
		.addClass('no-border')
		.not(':last')
			.after('<li class="spacer">');		
	
	/* Use "superfish" menus for the second level submenus and beyond */
	$(function() {		
		$('ul.sf-menu').superfish();
	});
	
	
});

