	var	today =	new	Date()
	var	dateNow	 = today.getDate()
	var	monthNow = today.getMonth()
	var	arr	= new Array()

	var yesno = false;
     
    function splitString( str , separator, requiredElement )
    {
      arrayOfStrings = str.split(separator);
      if(requiredElement <= arrayOfStrings.length)
		{
		return 	arrayOfStrings[requiredElement-1];
		}
		else
		{
		return 	'';
		}
    }

// Following functions are used in displaying timer on filling course/questionnaire
//javascript clock countdown script
function Clock() {
   D = new Date();

   mm = D.getMinutes();
   ss = D.getSeconds();

// read from cookie

timevalue = GetCookie("timevalue");
if(timevalue!="Stop")	
{
	min = timevalue/60;
	sec = timevalue%60;
	curr = GetCookie("curr");

	if (sec<0 || sec==null) sec=0;
	if (min<0 || min==null) min=0;
	if (curr!=ss)
	{
		document.images["d0"].src = Url(min/10);
		document.images["d1"].src = Url(min%10);
		document.images["d2"].src = Url(sec/10);
		document.images["d3"].src = Url(sec%10);

		// decrement min:sec and write to cookie   
		if(sec==0 && min!=0) {sec=60; min=min-1;}
		if(sec>0) sec=sec-1;

		var expdate = new Date();
		expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
		
		Currsecs = Math.round(D.getTime()/1000);
		secs = GetCookie("secs");
		
		if(secs=="Nothing") {secs = Currsecs} else {
		secs = Number(GetCookie("secs")) + 2; }

		diff = (Currsecs>secs)? Currsecs - secs : 1;
		
		if(diff>timevalue) diff=timevalue;
		
		SetCookie("timevalue", timevalue - diff , expdate, "/", null, false);

		curr=ss;
		SetCookie("curr", curr, expdate, "/", null, false);
	}
	
	SetCookie("secs", Math.round(D.getTime()/1000) , expdate, "/", null, false);
	
	// set timeout for next time (half second)
	window.setTimeout("Clock()",1000);
	//window.setInterval("Clock()",500);
} //If timevalue="Stop"

} //Clock() end


// converts 4 (numeric) to "d4.gif"
function Url(num)
{
	num = Math.floor(num);
	return "/Images/Digits/d" + num + ".gif";
}

function getCookieVal (offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

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 = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

