$(document).ready(function() { 
	
	$(".shorten_string_text").tooltip({
		showURL: false, 
		bodyHandler: function() {
			return $(this).next(".shorten_string_hidden_text").val();
		}
	});	
	
	
	$("#navigation_inactive_search_box, #navigation_inactive_your_unidog_box").tooltip({
		showURL: false, 		
		bodyHandler: function() {
			return $("#navigation_visitor_hidden_text").val();
		}
	});

	$("ul.sf-menu").superfish();	

	$("#partners_carousel").jCarouselLite({
		auto: 4000,
		speed: 5000,
		visible: 4
	}); 

	
	 $(".activities").removeClass("invisible_thing");  	 	
	
	 $("#activitiy_carousel").jCarouselLite({  
		 vertical: true, 
		 visible: 1,  
		 auto: 3000,
		 speed: 1000
    });  	
	
	
	$("#logout_button").click(function () {
		submitLogoutForm();
		return null;
	});								


	$(".login_button").click(function () {
						
		submitLoginForm($(this).parents('.login_form'));
		return null;
	});
	
						
	$(".login_form").keypress(function (event) {
		if(event.which == 13) {
				
			submitLoginForm(this);
			return null;
		}
	});
	
	$(".replace_location_element").click(function() {
		
		var url = ($(this).next('.replace_location_url').val());		
		replaceLocation(url);
	});
	
	$("#clicker3").click(function() {
	
		$.scrollTo('#universities_search_box',
				1000,
				{easing:'elasout'}
		);	
	});
	
	$.easing.elasout = function(x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	};
	
	
	ieSwfCorrect();
});


//--------------------------------------------------------
function openNewWindow(destinationUrl, destinationTitle, destinationWidth, destinationHeight, destinationToolbar, destinationDirectories, destinationStatus, destinationScrollbars, destinationResize, destinationMenubar) {

	var options = "toolbar="+destinationToolbar+",width="+destinationWidth+",height="+destinationHeight+",directories="+destinationDirectories+",status="+destinationStatus+",scrollbars="+destinationScrollbars+",resizable="+destinationResize+",menubar="+destinationMenubar;
	
	msgWindow=window.open(destinationUrl,destinationTitle, options);
	
	return msgWindow;
}

// --------------------------------------------------------
function ieSwfCorrect() {
	theObjects = document.getElementsByTagName("object"); 
	
	for (var i = 0; i < theObjects.length; i++) { 
		
		theObjects[i].outerHTML = theObjects[i].outerHTML; 
	} 
} 

// --------------------------------------------------------
function printMailAddress(address) {
	
	var address = address.replace('(->)','@');
	var outputString = '<a href="mailto: '+ address + '">'+ address + '</a>';
	document.write(outputString);
}

// --------------------------------------------------------
function submitLoginForm(loginForm) {
	
	$("#registration_button").fadeOut('slow');
	$(".login_button").fadeOut('slow');
	$("#lost_logindata_box").fadeOut('slow');
	
	showAjaxLoadingBox();
	
	$(loginForm).submit();								
}

// --------------------------------------------------------
function submitLogoutForm() {

	$("#logout_button").fadeOut('slow');
	
	showAjaxLoadingBox();
	
	$("#logout_form").submit();									
}

// --------------------------------------------------------
function replaceLocation(newLocation) {
	
	location.replace(newLocation);
}

//--------------------------------------------------------
function trim (input) {

	return input.replace (/^\s+/, '').replace (/\s+$/, '');
}

// --------------------------------------------------------
function showAjaxLoadingBox() {
	
	$("#loading_box").css("visibility","visible");
	$("#loading_box").css("display","block");
}

// --------------------------------------------------------
function hideAjaxLoadingBox() {
	
	$("#loading_box").css("visibility","hidden");
	$("#loading_box").css("display","none");
}