function doSubmit(val)
{
  var ret = true;
  var theVal = readCookie("QCaccessRestrictedPage");
  var theForm = document.getElementById("clickThroughForm");
  if(theForm) {
     theForm.action = unescape(theVal);
     document.getElementById("processAgreement").value = "true";
  
     if(val == 1) {
        document.getElementById("restrictAgree").value = "true"; 
     } else {
        document.getElementById("restrictAgree").value = "false"; 
        document.location = "/index.html";
        ret = false;
     }
  }
  return ret;
}

///////////////////////////////////////////////////////////
// Read a cookie by the given name
// param name - Cookie name
//////////////////////////////////////////////////////////
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
//		while (c.charAt(0)==' ') c = c.substring(1,c.length);
    c = trim(c);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

//////////////////////////////////////////////////////////
// If the user is from the U.S. then
// hide any RESTRICTED elements.
//////////////////////////////////////////////////////////
function hideRestrictedContent()
{
     var cookie = readCookie("usercc");
//     alert("cookie="+cookie);
     if(cookie != null && cookie == "US")
     {
       var elems = document.getElementsByName("RESTRICTED");
       for(i=0;i<elems.length;i++)
       {
           elems[i].style.display = "none";
       }
     }
}

/////////////////////////////////////////////////////////
// Trim the indciated string of spaces at front and end.
/////////////////////////////////////////////////////////
  function trim(inp)
  {
     var str = inp;
     str = str.replace(/^\s*(.*)/, '$1');
     str = str.replace(/(.*?)\s*$/, '$1');

     return str;
  }
