/* Script to support download of the whitepaper */
function validateWhitePaper(pvar){
	var passedRequired = true;
	var notice = document.getElementById("sdConf");
	var fields = document.getElementById("wpFields");
	for (var i = 0; i < pvar.elements.length; i++){
		var element = pvar.elements[i];
		if (element.type == 'text') {
			if (element.value != undefined) {
				if (element.value.length == 0) {
					element.className = 'error';
					passedRequired = false;
				}
			}
		}
	}
	if (!passedRequired){
		alert('Please check the fields and make sure you have provided all the information requested.');
		/*if (notice != undefined || notice != null){
			notice.innerHTML = "<p>Some fields are blank.</p>";
			notice.style.display = "block";
		}*/
	}else {
		if (notice != undefined || notice != null){
			notice.className = "alert success";
			notice.innerHTML = "<p>Thank you.  Your download should be in progress.</p>";
			notice.style.display = "block";
			if (fields != undefined || fields != null) {
				fields.style.display = "none";
			}
		}	
	}
	
	return passedRequired;
}


/* Stretch the content so the footer is always at the bottom
------------------------------------*/
function resizeWindow() {
	var windowHeight = getWindowHeight();
	$("#bd .wrap .content, #bd .wrap .sidebar").css('min-height', (windowHeight - 230) + "px"); /* the rest of the pages */
	$("body.home #bd .wrap .content, body.home #bd .wrap .sidebar").css('min-height', (windowHeight - 350) + "px"); /* for the homepage with big rotating header */
}

function getWindowHeight() {
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) 
		{
			windowHeight = document.documentElement.clientHeight;
		}
		else 
		{
			if (document.body && document.body.clientHeight) 
			{
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}



/* jQuery stuff
------------------------------------- */
$(document).ready(function(){

	/* Toggle tophat dropDown menu
	----------------------------------------- */
	$('.morelinks').hover(
		function() { 
			$(this).addClass('hover');	
			$('.submenu').fadeIn(250);
		},
		function() { 
			$('.submenu', this).css('display', 'none'); 
			$(this).removeClass('hover');	
		}
	);
	
	/* Zebra stripes */
	$(".zebra tr:odd, .zebra li:odd, .zebra p:odd").addClass("odd");
	

	/* Random (homepage) Img */
	var randomImages = ['pr-lawyer-01','pr-lawyer-03'];
	var rndNum = Math.floor(Math.random() * randomImages.length);
	$("body.home #hd .wrap").css({ 
		background: "#000 url(/images/" + randomImages[rndNum] + ".jpg) 100% 100% no-repeat",
		height: "260px"
	});


	/* Tabs
	----------------------------------------- */
	//Initially hide all panes if javascript is enabled, Otherwise if javascript is disabled, all the panes will be displayed
	$(".panes .pane").css('display', 'none');
	
	// activate the tabs
	$("ul.tabs").tabs("div.panes > .pane");


	/* Initialize scripts
	----------------------------------------- */
	resizeWindow();
	$(window).resize(function() { resizeWindow(); });
});

