﻿// JScript File

if(gup('email') != null && gup('email') != '' && gup('email') == 'yes')
{
    var x = createCookie('US','YES',0);
}



function $d(elem){
  return document.getElementById(elem);
}

function $a(elem){
 //alert(elem);   //turn this on for debugging
 return(true);    //turn this off for debugging
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function setCookie(txtAnswer, rurl) {
	if (txtAnswer=="yes") {
		var x = createCookie('US','YES',0);
    //change this page url to the proper current page url
		document.location.href=rurl;
	} else {
		createCookie('US','NO',0);
		document.location.href=rurl;
	}
}

function checkCookie() {
  $a(readCookie('US'));
  $a($d('divHcp1').style.display);

	if ( readCookie('US') != 'YES') {
    
    $d('divHcp1').style.display = 'block';
    $d('divHcp2').style.display = 'none'; 
	}
  else {
    $d('divHcp1').style.display = 'none';
    $d('divHcp2').style.display = 'block';     
  }
}

function showErrorMsg(){
  $d('err').style.display = 'block';
  //  urchinTracker('/abilifyredesignhcp/areyouanhcp_popup');
}

function hideErrorMsg(){
  $d('err').style.display = 'none';

}

function validateCheckboxes() {

  //clear error msg
  $d('err').style.display = 'none';
  
  if ($d('btn_y').checked == true) {
    setCookie('yes',$d('rUrl').value);
  }
  if ($d('btn_n').checked == true) {
    setCookie('no','/');
  }
  //show error msg
  if ($d('btn_y').checked == false && $d('btn_n').checked == false){
    showErrorMsg();
  }
}

