function setBBTextArea(d,a){
	if(a){
		document.getElementById(d).style.display='block';
	}else{
		document.getElementById(d).style.display='none';
	}
	return false;
}
function validBBDate(d){
	var indate=d;
	var sdate = indate.split("/");
	var chkDate=new Date(Date.parse(indate));
	var cmpDate=(chkDate.getMonth()+1)+"/"+(chkDate.getDate())+"/"+chkDate.getFullYear();
	var indate2=(Math.abs(sdate[0]))+"/"+(Math.abs(sdate[1]))+"/"+(Math.abs(sdate[2]))
	if (indate2!=cmpDate){
		return 0;
	}
	if (cmpDate=="NaN/NaN/NaN"){
		return 0;
	}
	if (Math.abs(sdate[2])<2000) {
		return 0;
	}
	return 1;
}
function copyBBaddress(a,b) {
	var f=new Array('address1','address2','city','stateid','postalcode','country');
	for(var i=0;i<f.length;i++){
		var e=document.getElementById(a+f[i]);
		if(e.type=='text'){
			document.getElementById(b+f[i]).value=document.getElementById(a+f[i]).value;
		}else{
			document.getElementById(b+f[i]).selectedIndex=document.getElementById(a+f[i]).selectedIndex;
		}
	
	}
	return false;		
}
function trim(strValue){
	return strValue.replace(/^\s+/,'').replace(/\s+$/,'');
}
function bb_loginValidation(e){
	var m='';	
	var y=document.getElementById('bb_username_new')?'username':'password';
	switch(y){
		case 'username':
			if(document.getElementById('bb_username')){
				if(trim(document.getElementById('bb_username').value).length==0){
					m+='You must enter your current email/username.\n';
				}
			}
			var s=document.getElementById('bb_username_new').value;
			var t=document.getElementById('bb_username_confirm').value;
			if(!validEmail(s)){
				m+='Invalid email address.\n';
			}else{
				if(s!=t){
					m+='Email addresses do not match.\n';
				}
			}
			break;
		case 'password':
			if(document.getElementById('bb_username')){
				if(trim(document.getElementById('bb_password').value).length==0){
					m+='You must enter your current password.\n';
				}
			}
			var s=document.getElementById('bb_password_new').value;
			var t=document.getElementById('bb_password_confirm').value;
			if(trim(document.getElementById('bb_password_new').value).length<6){
				m+='You must enter a password of at least 6 characters.\n';
			}else{
				if(trim(document.getElementById('bb_password_confirm').value)!=trim(document.getElementById('bb_password_new').value)){
					m+='Your Password and your Confirm Password must match.\n';			
				}
			}
			break;
	}	
		
	if(m.length){
		alert (m);		
		if(e && e.preventDefault){
				e.preventDefault(); 
		}
		return false;
	}
}
function validEmail(s){
 	emailpat = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
 	if(!emailpat.test(s)) {
		return false;
	}
 	return true;
}


