function fillDisclaimer(url, route, containerId) {
	if (document.getElementById(containerId)) {
	    var whAOpts = {
	        dataType: 'html',
	        data: {route: route},
	        complete: function(){},
	        error: function(){},
	        url: url,
	        success: function(data){ document.getElementById(containerId).innerHTML = data; }
	    };
	    $.ajax(whAOpts);
	}
}

function checkShowHidePayment() {
	var checked = $('#assessment_request_paynow')[0].checked;
	if (checked) {
		$('#payNowCCBox').show();
		$('#submitRequestButton').hide();
	}
	else {
		$('#payNowCCBox').hide();
		$('#submitRequestButton').show();
	}
}

function checkShowHideBillingAddress() {
	var checked = $('#assessment_request_useasbillingaddress')[0].checked;
	if (checked) {
		$('#billingAddressBox').hide();
	}
	else {
		$('#billingAddressBox').show();
	}
}

/**
 * Used on the press room page to flip the tabs
 * 
 * @param tab - leave empty to initialize. jQuery object to switch the tab
 */
function openTab(tab) {
//	$('#pressReleasesTab')
	if (tab) {
		var tabId = tab[0].id;
	}
	else {
		tabId = null;
	}
	
	//iterate all tabs
	$('.tab').each(function(){
		var pageId = '#'+this.id+'Page';
		
		//if no tabId was set (on initialization) show the one that already has the 'selected' class
		if (tabId == null && $(this).hasClass('selected')) {
			tabId = this.id;
		}
		
		//show the chosen one
		if (this.id == tabId) {
			$(pageId).show();
			$(this).addClass('selected');
		}
		//hide all others
		else {
			$(pageId).hide();
			$(this).removeClass('selected');
		}
	});
}

function toggleTextInput(inputElement) {
	inputElement.next('input')[0].disabled = !inputElement[0].checked;
}


$(document).ready(function() {
	
	if ($('#assessment_request_paynow').length > 0) {
		checkShowHidePayment();
		$('#assessment_request_paynow').live('click', function() {
			checkShowHidePayment();
		});
	}
	
	if ($('#assessment_request_useasbillingaddress').length > 0) {
		checkShowHideBillingAddress();
		$('#assessment_request_useasbillingaddress').live('click', function() {
			checkShowHideBillingAddress();
		});
	}
	
	//tabs on the press page
	if ($('.tab').length > 0) {
		//start with the press releases
		openTab();
		//click event for the tabs
		$('.tab').click(function() {
			openTab($(this));
			//prevent href open
			return false;
		});
	}
	
	if ($('.enableTextInput').length > 0) {
		$('.enableTextInput').each(function() {
			toggleTextInput($(this));
		});
		$('.enableTextInput').click(function() {
			toggleTextInput($(this));
		});
	}
});
function trim_str(str)
{
	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '')
}

function CTAValidate(objForm){
			var ret = false;
						
			ret = (trim_str(objForm.inq_name.value)=='');
			if(ret)
			{
				alert('Name is required.');
				return false;
			}
			
			ret = (trim_str(objForm.inq_zip.value)=='');
			if(ret)
			{
				alert('Zip Code is required.');

				return false;
			}
			
			ret = (trim_str(objForm.inq_phone.value)=='');
			if(ret)
			{
				alert('Phone is required.');
				return false;
			}
			return true;
}
function thePopupWindows(windowsname){
			var win = window.open('', windowsname,'menubar=1,resizable=1,width=1000,height=450,scrollbars=1');
			win.focus();
			return true;
}

