/*
(c) Mindshelf All Rights Reserved.
Web Framework
	- Balhousie Care Group Functions [v4.6.09]
No unauthorised copying or editing without permission
Author ~ Matt Barnes
*/
function showprofile(){
	if($('.plink').html().indexOf('Show')>=0){
		$('.contactprofile').slideDown('fast',function(){fixPanel();});
		$('.plink').html($('.plink').html().replace(/Show/,'Hide'));
	}else{
		$('.contactprofile').slideUp('fast',function(){fixPanel();});
		$('.plink').html($('.plink').html().replace(/Hide/,'Show'));
	}
};
function contactbcg(i){
	_prc();
	$.post('../_rsc/contact.mindshelf',{i:i},function(data){
		d=data.split("|");
		if(d[0]=='_bcg_pass'){
			$('.hr').after(d[1]);
			$('div.contact').slideDown("fast",function(){
				fixPanel();
				_prc(true);
			});
		};
	},'html');
};
$(document).ready(function(){
	contactbcg(9);
});
function subform(){
	err=false;
	a[0]=$('.content input[type="hidden"]:eq(0)').val();
	a[1]=$('.contact select:eq(0)').val();
	if(a[1]==''){
		$('.contact select:eq(0)').addClass('error');
		err=true;
	}else{
		$('.contact select:eq(0)').removeClass('error');
	}
	a[2]=$('.contact input[type="text"]:eq(0)').val();
	if(a[2]==''){
		$('.contact input[type="text"]:eq(0)').addClass('error');
		err=true;
	}else{
		$('.contact input[type="text"]:eq(0)').removeClass('error');
	}
	a[3]=$('.contact input[type="text"]:eq(1)').val();
	if(a[3]==''){
		$('.contact input[type="text"]:eq(1)').addClass('error');
		err=true;
	}else{
		$('.contact input[type="text"]:eq(1)').removeClass('error');
	}
	a[4]=$('.contact input[type="text"]:eq(2)').val();
	if(!window['emfilt'].test(a[4])){
		$('.contact input[type="text"]:eq(2)').addClass('error');
		err=true;
	}else{
		$('.contact input[type="text"]:eq(2)').removeClass('error');
	}
	a[5]=$('.contact input[type="text"]:eq(3)').val();
	a[6]=$('.contact textarea:eq(0)').val();
	a[7]=$('.contact select:eq(1)').val();
	a[8]=(($('.contact input[type="checkbox"]:eq(0)').is(':checked'))?'1':'0');
	a[10]='7';
	a[11]=$('.contact select:eq(2)').val();
	if(a[11]==''){
		err=true;
		$('.contact select:eq(2)').addClass('err');
	}else{
		$('.contact select:eq(2)').removeClass('err');
	}
	if(!err){
		$.post('../_rsc/validate.mindshelf',{a:$('.contact input[type="text"]:eq(4)').val()},function(data){
			if(data=='_bcg_pass'){
				window['__message']=a.join("|BCG_DATA|");
				_prc();
				$.post('../_rsc/contactsubmission.mindshelf',{a:window['__message']},function(data){
					d=data.split("|");
					if(d[0]=='_bcg_pass'){
						_prc(true);
						setTimeout("scrollTop();$('div.contact').html('<p>Submission Successful</p>');fixPanel();",500);
					}else{
						_prc(true);
						alert(data);
					}
				},'html');
			}else{
				_prc(true);
				_rci();
				alert('Please input the correct code in the text box provided');
			}
		},'html');
	}else{
		_prc(true);
		alert('Please check the highlighted fields and try again.');
	}
	return false;
};