var expDays = 1; // number of days the cookie should last 
var exited = 1;
function GetCookie (name) { 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) { 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) 	
			break;
	}
	return null; 
} 
function SetCookie (name, value) { 
	var argv = SetCookie.arguments; 
	var argc = SetCookie.arguments.length; 
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
} 
function DeleteCookie (name) { 
	var exp = new Date(); 
	exp.setTime (exp.getTime() - 1); 
	var cval = GetCookie (name); 
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
} 
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); 
function amt(){ 
	var count = GetCookie('count') 
	if(count == null) { 
		SetCookie('count','1') 
		return 1 
	} 
	else { 
		var newcount = parseInt(count) + 1; 
		DeleteCookie('count') 
		SetCookie('count',newcount,exp) 
		return count 
	} 
} 
function getCookieVal(offset) { 
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) 
		endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr));
} 
function checkCount() { 
//if(exited != 0) {
//	var count = GetCookie('count'); 
//	if (count == null) { 
//		count=1; 
//		SetCookie('count', count, exp);
//		survey()
//		} 
//	else { 
//		count++; 
//		SetCookie('count', count, exp);
//		} 
//	}
}
function newwindow(){
newpage = window.open('order', 'order', 'left=0, top=0, width=1024, height=768,toolbar=1,location=1,status=1,menubar=1,scrolbars=0,resizeable=1,directories=1');
newpage.focus()
}

function survey(){
 var ask= confirm("Excuse me, \nBefore you leave would you like to do a quick quiz that will assess your potential for getting back pain? \nIt will only take a couple of minutes.");
 var score= 0;
 if (ask== true)
 {
   	alert("Press \"OK\" to answer yes and \"Cancel\" to answer no")
	var one= confirm('Question 1 of 10 \nDo you have a desk job?');
	if (one== true)
	{ score++ }
	var two= confirm('Question 2 of 10 \nDo you lead a generally sedentary life?');
	if (two== true)
	{ score++ }
	var three= confirm('Question 3 of 10 \nDo you consume a lot of sugar?');
	if (three== true)
	{ score++ }
	var four= confirm('Question 4 of 10 \nDo you consume more than one drink of alcohol most days?');
	if (four== true)
	{ score++ }
	var five= confirm('Question 5 of 10 \nDo you consume either bread, pasta or rice regularly? ');
	if (five== true)
	{ score++ }
	var six= confirm('Question 6 of 10 \nDo you consume fast food two or more times a week? ');
	if (six== true)
	{ score++ }	
	var seven= confirm('Question 7 of 10 \nDo you limit your exercise to just running or walking? ');
	if (seven== true)
	{ score++ }
	var eight= confirm('Question 8 of 10 \nDid you have any significant accidents or falls whist you were growing up?');
	if (eight== true)
	{ score++ }
	var nine= confirm('Question 9 of 10 \nDo you have a short leg?');
	if (nine== true)
	{ score++ }					
	var ten= confirm('Question 10 of 10 \nAre you overweight?');
	if (ten== true)
	{ score++ }					
	if (score > 6)
	{ var choice1= confirm('With such a high number of Yes answers on the quiz you are a back problem waiting to happen, if it hasn’t already. The Bad Back Book which is available as a Free download, will give you all the information you need to understand why someone ends up with back pain and the best way to get rid of it. Or better still, how to prevent it coming in the first place. As you will read, it is all about the way you treat your body, inside and out, throughout each day.\n\nJust click the link below and provide your name and email address and you will receive instant advice on where you can download your copy of the book, immediately. Based on the answers you gave for the quiz it really is a book you need to read if your future health is important to you. Although you will also be signing up for my monthly healthletter, you are able to remove your name from my list at any time with a click of your mouse and be assured I will never, ever, share my list with any third party.\n\nClick \"OK\" to sign up for The Bad Back Book or visit www.backpain.com.au/order')
		if (choice1== true)
		{	newwindow()	}
	}
	else if (score > 3)
	{ var choice1= confirm('You have answered yes to a few more questions than is ideal so you would be what I call a borderline case. That means if you are not careful you could end up with a stubborn case of back pain, if you haven’t already. The position you are in at present means it shouldn’t be too difficult for you to make the few necessary lifestyle adjustments to keep you safe from ending up with back pain. If you do get a problem then getting rid of it won’t be nearly as difficult as it is for some.\n\nThe Bad Back Book which is available as a free download will give you a good idea of the things you need to adjust in your life to limit the chances of you ending up with a problem in the first place. If you are already a sufferer then the information it contains won’t be like anything your doctor or therapists have told you already. It will give you definite ideas on how to rid yourself of pain and stop it coming back! \n\nClick \"OK\" to sign up for The Bad Back Book or visit www.backpain.com.au/order')
		if (choice1== true)
		{	newwindow()	}
	}	
	else
	{ var choice1= confirm('You are obviously someone who is intelligent and understands what is required to keep your body healthy and strong and so are probably here as the result of an accident or because you are just interested in learning more about back pain. Either way your hunger for information will be satisfied by you obtaining a free copy of The Bad Back Book. After reading it you will understand exactly what causes most back pain. (believe it or not, most of the information in this book is something your doctors and most therapists you see will never discuss with you because most won’t know it themselves!)\n\nBecause of your healthy lifestyle any back pain you have should clear up fairly quickly once you receive the right treatment, which The Bad Back Book will fully explain for you. \n\nClick \"OK\" to sign up for The Bad Back Book or visit www.backpain.com.au/order')
		if (choice1== true)
		{	newwindow()	}
	}		
 }
}