/* date-modified : 2009-10-27 */


function checkTermsAndConditionsAgreement() {
	if ( document.MembershipForm.terms_and_agreement_checkbox.checked ) {
		return true;
	} else {
		alert("You must agree to the Terms and Conditions to purchase your ABN membership");
		return false;
	} 
}

function update_enews_state_value() {
	var state_name_obj = document.getElementById('enews_state_popup');
	var state_name_value = state_name_obj.options[state_name_obj.selectedIndex].innerHTML;
	document.getElementById('enews_state_editfield').value= state_name_value;

}

function change_enews_state()
{
	if (document.getElementById('enews_country_list').selectedIndex == 0 ) {
		document.getElementById('enews_state_popup').style.display='inline';
		document.getElementById('enews_state_popup').disabled=false;
		document.getElementById('enews_state_editfield').style.display='none';
		document.getElementById('enews_state_editfield').disabled=true;
	} else {
		document.getElementById('enews_state_editfield').style.display='inline';
		document.getElementById('enews_state_popup').style.display='none';
		document.getElementById('enews_state_editfield').disabled=false;
		document.getElementById('enews_state_popup').disabled=true;
	}
}
function change_postal_address_state()
{
	if (document.getElementById('postal_country_list').selectedIndex == 0 ) {
		document.getElementById('postal_state_editfield').style.display='none';
		document.getElementById('postal_state_editfield').disabled=true;
		document.getElementById('postal_state_popup').style.display='inline';
		document.getElementById('postal_state_popup').disabled=false;
	} else {
		document.getElementById('postal_state_editfield').style.display='inline';
		document.getElementById('postal_state_editfield').disabled=false;
		document.getElementById('postal_state_popup').style.display='none';
		document.getElementById('postal_state_popup').disabled=true;
	}
}
function change_delivery_address_state()
{
	if (document.getElementById('delivery_country_list').selectedIndex == 0 ) {
		document.getElementById('delivery_state_popup').style.display='inline';
		document.getElementById('delivery_state_popup').disabled=false;
		document.getElementById('delivery_state_editfield').style.display='none';
		document.getElementById('delivery_state_editfield').disabled=true;
	} else {
		document.getElementById('delivery_state_editfield').style.display='inline';
		document.getElementById('delivery_state_editfield').disabled=false;
		document.getElementById('delivery_state_popup').style.display='none';
		document.getElementById('delivery_state_popup').disabled=true;
	}
}
function change_member_address_state()
{
	if (document.getElementById('member_country_list').selectedIndex == 0 ) {
		document.getElementById('member_state_editfield').style.display='none';
		document.getElementById('member_state_editfield').disabled=true;
		document.getElementById('member_state_popup').style.display='inline';
		document.getElementById('member_state_popup').disabled=false;
	} else {
		document.getElementById('member_state_editfield').style.display='inline';
		document.getElementById('member_state_editfield').disabled=false;
		document.getElementById('member_state_popup').style.display='none';
		document.getElementById('member_state_popup').disabled=true;
	}
}
function change_billing_address_state()
{
	if (document.getElementById('billing_country_list').selectedIndex == 0 ) {
		document.getElementById('billing_state_editfield').style.display='none';
		document.getElementById('billing_state_editfield').disabled=true;
		document.getElementById('billing_state_popup').style.display='inline';
		document.getElementById('billing_state_popup').disabled=false;
	} else {
		document.getElementById('billing_state_editfield').style.display='inline';
		document.getElementById('billing_state_editfield').disabled=false;
		document.getElementById('billing_state_popup').style.display='none';
		document.getElementById('billing_state_popup').disabled=true;
	}
}




//  code to rotate banners
	var banner_index = 1;
	var links = new Array();
	banner1= new Image();
	banner1.src = "/abn_promo/images/090714_banner_membership.jpg";
	banner2 = new Image();
	banner2.src = "/abn_promo/images/090714_banner_directory.jpg";
	links[1] = "/site/becomeAMember", "_blank"
	links[2] = "/site/memberDirectory", "_blank"
	this_description = new Array()
	this_description[1] = "Membership"
	this_description[2] = "Directory"

function startTime(){

	var time= new Date();
	hours= time.getHours();
	mins= time.getMinutes();
	secs= time.getSeconds();
	closeTime=hours*3600+mins*60+secs;
	closeTime+=6;
	Timer(0);
}

function Timer(time_period){
	var banner = document.banner;
	var time= new Date();
	hours= time.getHours();
	mins= time.getMinutes();
	secs= time.getSeconds();
	curTime=hours*3600+mins*60+secs
	
	if (curTime>=closeTime) {
		if (banner_index < 2) {
			banner_index++;
		} else{
			banner_index = 1;
		}
		banner.src = eval("banner" + banner_index + ".src");
		startTime();
	} else {
		window.setTimeout("Timer()",1000);
	}
}
function clickLink(){
	top.location = links[banner_index];
}
function descript(){
	window.status = this_description[banner_index];
}

		$(document).ready(function(){	  
			console.log('checking member profile page');
			if ( $('#MemberProfilePage').size()== 1) {
				console.log('found MemberProfilePage');
				$('.MemberSearchPageHeader, .MemberSearchPageTitle, .MemberSearchPageFooter').hide();
			} else {
				console.log('not MemberProfilePage');
			}
		});


