function mycarousel_initCallback(carousel)
{
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};

$(document).ready(function (){

	if($('#maincontent').height()>$('#sidebar').height()){
		$('#sidebar').height($('#maincontent').height()+20);
	}

	$('#featured').cycle({
		fx: 'fade',
		pause: 1,
		speed: 2500,
		speedIn: 1,
		speedOut: 1000,
		timeout: 6500,
		sync: 0
	});
	$('#lawyerquotes').cycle({
	    fx: 'fade',
		pause: 1,
		speed: 2500,
		speedIn: 1,
		speedOut: 1000,
		timeout: 8000,
		sync: 0
	});
	/*
	$('#newsmarquee').jcarousel({
		vertical: true,
        scroll: 1,
        auto: 3,
        wrap: 'circular',
        initCallback: mycarousel_initCallback
	});
	*/
	
	$("#newsmarquee .items").simplyScroll({
		className: 'vert',
		horizontal: false,
		autoMode: 'loop',
		pauseOnHover: true,
		frameRate: 26,
		speed: 1
	});
	
	$("#topnav li").hover(
		function(){
			$(this).addClass("over");
			$(this).children(".menu").animate({opacity:'show'},200);
		},function(){
			$(this).removeClass("over");
			$(this).children(".menu").delay(300).animate({opacity:'hide'},200);
		}
	);

	resizeWindow();
	//If the User resizes the window, adjust the #horizon margin
	$(window).bind("resize", resizeWindow);

});



function resizeWindow( e ) {
	var newWindowHeight = $(window).height();
	
	if(newWindowHeight < 698) { 
	
		$("#content").addClass("nobg");
	}
	else { 
		$("#content").removeClass("nobg");
	}
	
	
}


/*
Cufon.replace('#topnav .mainlink,.featured-text p,h1,h2,h3, .bigbullet strong, .hp_alert', {
	fontFamily: 'AvenirLT'
});
Cufon.replace('.bigintro, #sidebar.home h3,.featured-text .byline', {
	fontFamily: 'Constantia'
});
Cufon.replace('#sidebar.home h3', {
	fontFamily: 'Clarendon'
});
*/

var xmlHttp

function popUp2(message) {

var x = 20;
var y = 20;

	var windowparam = "width=" + 500 + ",height=" + 700 + ",scrollbars=yes,menubar=no,left="+x+",top="+y+",screenX="+x+",screenY="+y;
	popwin = window.open(message, "popwin", windowparam)
	popwin.opener = self;
	popwin.focus()
}

function GetXmlHttpObject() { 
	var objXMLHttp=null
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}


function validate_email(field,alerttxt) {
	with (field) { 
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) {alert(alerttxt);return false;}
		else { return true; }
	}
}

function validate_form(thisform,fieldtovalidate)
{
	with (thisform)
	{
	if (validate_email(fieldtovalidate,"Not a valid e-mail address!")==false)
	  {
	  	return false;
	  }
	var goahead=confirm("NOTICE: Unless you are an existing client, before communicating with Hausfeld, LLP by e-mail (or otherwise), please read the Disclaimer referenced by this link. (The Disclaimer is also accessible from the opening page of this Website). As noted therein, until you have received from us a written statement that we represent you in a particular matter (an “engagement letter”) you should not send to us any confidential information about any such matter. After we have undertaken representation of you concerning a matter, you will be our client, and we may thereafter exchange confidential information freely.")
	if (goahead)
	  {
	  	return true;
	  } else {
	  	return false;
	  }
	}
}
function clearout(x) { 
	//alert(x);
	document.getElementById(x).style.background="white";
}


mainNav = function() {
	$("#topnav li").bind("mouseenter",function(){
                this.className += " over";
				
	}).bind("mouseleave",function(){
                this.className = this.className.replace(" over", "");
	});
}

newsNav = function() {
	$(".dropdown").bind("mouseenter",function(){
                this.className += " over";
	}).bind("mouseleave",function(){
                this.className = this.className.replace(" over", "");
	});
}
