/* Advansys miscellaneous javascript website specific functions */
function EmbedFlash(swf, height, width){
// Main Flash animation - XHTML 1.0 compliant workaround for IE and Firefox (write as javascript rather then embed HTML))
document.write('<object type="application/x-shockwave-flash" data="'+swf+'" width="'+width+'" height="'+height+'">');
document.write('<param name="movie" value="'+swf+'"/>');
document.write('</object>');	
}
function EmbedFlashwbg(swf, height, width, bg){
// Main Flash animation - XHTML 1.0 compliant workaround for IE and Firefox (write as javascript rather then embed HTML))
document.write('<object type="application/x-shockwave-flash"  data="'+swf+'"  width="'+width+'" height="'+height+'">');
document.write('<param name="movie" value="'+swf+'"/>');
document.write('<param name="bgcolor" value="'+bg+'"/>');
document.write('<param name="scale" value="noscale" />');
document.write('<param name="salign" value="lt" />');

document.write('</object>');	
}
function ShowMap(MapURL,PostCode){
window.open(MapURL+'&pc='+PostCode,'map','width=700, height=500, scrollbars=yes, location=no, status=yes');
}
function CheckData1(form){

	if (form.a1.value=='') {
		if (!form.a1[1].checked && !form.a1[2].checked && !form.a1[3].checked && !form.a1[4].checked && !form.a1[0].checked && !form.a1[5].checked) {alert('Please select how did you hear about the Yakult ‘Self Defence’ '); form.a1[0].focus(); return false;}
	}
	
	if (!form.a2[1].checked && !form.a2[2].checked && !form.a2[3].checked && !form.a2[0].checked) {alert('Please select Title'); form.a2[0].focus(); return false;}
	if (form.a3.value=='') {alert('Please enter your first name'); form.a3.focus(); return false;}
	if (form.a4.value=='') {alert('Please enter your Surname'); form.a4.focus(); return false;}
	if (!form.a5[1].checked && !form.a5[0].checked) {alert('Please select your gender'); form.a5[0].focus(); return false;}
	if (form.a6.value=='') {alert('Please enter your Date Of Birth (DD/MM/YYYY)'); form.a6.focus(); return false;}
	if (form.a7.value=='') {alert('Please enter your email address'); form.a7.focus(); return false;}
	if (!CheckEmail(form.a7.value)) {alert('Please enter a valid email address');form.a7.focus(); return false;}
	if (form.a8.value=='') {alert('Please confirm your email address'); form.a8.focus(); return false;}
	if(form.a7.value!=form.a8.value) {alert('Email addresses do not match'); form.a7.focus(); return false;}
	if (form.a9.value=='') {alert('Please enter password'); form.a9.focus(); return false;}
	if (form.a10.value=='') {alert('Please confirm password'); form.a10.focus(); return false;}
	if(form.a9.value!=form.a10.value) {alert('Passwords do not match'); form.a9.focus(); return false;}
	if (!form.a11[1].checked && !form.a11[2].checked && !form.a11[0].checked) {alert('Please select where do you live'); form.a11[0].focus(); return false;}
	if (!form.a16[1].checked && !form.a16[2].checked && !form.a16[3].checked && !form.a16[0].checked) {alert('Please select on average, how many glasses of water have you drunk per day  in the last week?'); form.a16[0].focus(); return false;}
	if (!form.a17[1].checked && !form.a17[2].checked && !form.a17[3].checked && !form.a17[0].checked) {alert('Please select on average, how many portions of wholegrains/fibre have you had per day in the last week? E.g. wholegrain cereal, wholegrain bread etc.'); form.a17[0].focus(); return false;}
	if (!form.a18[1].checked && !form.a18[2].checked && !form.a18[3].checked && !form.a18[0].checked) {alert('Please select on average, how many exercise sessions have you done in the last week? E.g. 20 min walk, exercise class, gym session, stretching etc.'); form.a18[0].focus(); return false;}
	if (!form.a19[1].checked && !form.a19[2].checked && !form.a19[3].checked && !form.a19[0].checked) {alert('Please select how many portions of fruit and vegetables have you had per day in the last week'); form.a19[0].focus(); return false;}
	if (!form.a20[1].checked && !form.a20[2].checked && !form.a20[3].checked && !form.a20[0].checked) {alert('Please select how many units of alcohol have you had per day in the last week'); form.a20[0].focus(); return false;}
	if (!form.a21[1].checked && !form.a21[2].checked && !form.a21[3].checked && !form.a21[0].checked) {alert('Please select on average, how many sugary snacks have you had per day in the last week'); form.a21[0].focus(); return false;}
	if (!form.a22[1].checked && !form.a22[2].checked && !form.a22[3].checked && !form.a22[0].checked) {alert('Please select how has your gut health been in the last week'); form.a22[0].focus(); return false;}
	if (!form.a23[1].checked && !form.a23[2].checked && !form.a23[3].checked && !form.a23[0].checked) {alert('Please select how energetic have you felt in the last week'); form.a23[0].focus(); return false;}
	if (!form.a24[1].checked && !form.a24[2].checked && !form.a24[3].checked && !form.a24[0].checked) {alert('Please select how stressed have you felt in the last week'); form.a24[0].focus(); return false;}
	if (!form.a25[1].checked && !form.a25[2].checked && !form.a25[3].checked && !form.a25[0].checked) {alert('Please select when are you next planning on going on holiday'); form.a25[0].focus(); return false;}
	
	
	
	return true;
}

function CheckData2(form){
	if (!form.a26[1].checked && !form.a26[2].checked && !form.a26[3].checked && !form.a26[0].checked) {alert('Please select how many of Yakult probiotics have you consumed in the last week'); form.a26[0].focus(); return false;}
	if (!form.a27[1].checked && !form.a27[2].checked && !form.a27[3].checked && !form.a27[0].checked) {alert('Please select how many of Actimel probiotics have you consumed in the last week'); form.a27[0].focus(); return false;}
	if (!form.a28[1].checked && !form.a28[2].checked && !form.a28[3].checked && !form.a28[0].checked) {alert('Please select how many of Activia Yoghurt probiotics have you consumed in the last week'); form.a28[0].focus(); return false;}
	if (!form.a29[1].checked && !form.a29[2].checked && !form.a29[3].checked && !form.a29[0].checked) {alert('Please select how many of Muller Vitality probiotics have you consumed in the last week'); form.a29[0].focus(); return false;}
	if (!form.a30[1].checked && !form.a30[2].checked && !form.a30[3].checked && !form.a30[0].checked) {alert('Please select how many of Flora Omega 3 Plus probiotics have you consumed in the last week'); form.a30[0].focus(); return false;}
	if (!form.a31[1].checked && !form.a31[2].checked && !form.a31[3].checked && !form.a31[0].checked) {alert('Please select how many of Probiotic Pills probiotics have you consumed in the last week'); form.a31[0].focus(); return false;}
	if (!form.a36[1].checked && !form.a36[0].checked && !form.a36[2].checked) {alert('Please select \' Would you recommend Yakult to a friend\''); form.a36[0].focus(); return false;}
	//if (!form.a37[1].checked && !form.a37[2].checked && !form.a37[3].checked && !form.a37[4].checked && !form.a37[0].checked) {alert('Please select when do you want to start your plan'); form.a37[0].focus(); return false;}
	
	
	
	
	return true;
}

function CheckQuestionaire1(form){
	
	if (!form.a16[1].checked && !form.a16[2].checked && !form.a16[3].checked && !form.a16[0].checked) {alert('Please select on average, how many glasses of water have you drunk per day  in the last week?'); form.a16[0].focus(); return false;}
	if (!form.a17[1].checked && !form.a17[2].checked && !form.a17[3].checked && !form.a17[0].checked) {alert('Please select on average, how many portions of wholegrains/fibre have you had per day in the last week? E.g. wholegrain cereal, wholegrain bread etc.'); form.a17[0].focus(); return false;}
	if (!form.a18[1].checked && !form.a18[2].checked && !form.a18[3].checked && !form.a18[0].checked) {alert('Please select on average, how many exercise sessions have you done in the last week? E.g. 20 min walk, exercise class, gym session, stretching etc.'); form.a18[0].focus(); return false;}
	if (!form.a19[1].checked && !form.a19[2].checked && !form.a19[3].checked && !form.a19[0].checked) {alert('Please select how many portions of fruit and vegetables have you had per day in the last week'); form.a19[0].focus(); return false;}
	if (!form.a20[1].checked && !form.a20[2].checked && !form.a20[3].checked && !form.a20[0].checked) {alert('Please select how many units of alcohol have you had per day in the last week'); form.a20[0].focus(); return false;}
	if (!form.a21[1].checked && !form.a21[2].checked && !form.a21[3].checked && !form.a21[0].checked) {alert('Please select on average, how many sugary snacks have you had per day in the last week'); form.a21[0].focus(); return false;}
	if (!form.a22[1].checked && !form.a22[2].checked && !form.a22[3].checked && !form.a22[0].checked) {alert('Please select how has your gut health been in the last week'); form.a22[0].focus(); return false;}
	if (!form.a23[1].checked && !form.a23[2].checked && !form.a23[3].checked && !form.a23[0].checked) {alert('Please select how energetic have you felt in the last week'); form.a23[0].focus(); return false;}
	if (!form.a24[1].checked && !form.a24[2].checked && !form.a24[3].checked && !form.a24[0].checked) {alert('Please select how stressed have you felt in the last week'); form.a24[0].focus(); return false;}
	if (!form.a25[1].checked && !form.a25[2].checked && !form.a25[3].checked && !form.a25[0].checked) {alert('Please select when are you next planning on going on holiday'); form.a25[0].focus(); return false;}
	
	
	
	return true;
}


function CheckEmail(address) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(address)){
	return (true)
	}
	return (false)
}