// registration.js - routines to enable class registration from
// ncacademyofrealestate.com, using IMS.
// 03/18/2008, 05/16/2008, 08/07/2008, 09/29/2010

// ClassLink - Links to the URL to view the policy, while sending the selected Class ID.
function ClassLink($ClassCode) {
   $classreg ='http://www.ncacademyofrealestate.com/bulletin_ims.html'
	+ '?ClassID='
	+ $ClassCode;
   SaveCurrentLocation();
   location.href = $classreg;
}

// LoadCourse creates and executes the href link to register for the class.
function LoadCourse($ClassCode) {
   $classreg ='https://www.internetmemberservices.com/scripts/mgrqispi.dll'
	+ '?APPNAME=IMS'
	+ '&PRGNAME=IMSMemberLoginCookie'
	+ '&ARGUMENTS=-ANCAR'
	+ '&SessionType=N'
	+ '&ServiceName=REGE'
	+ '&ClassID='
	+ $ClassCode;
   location.href = $classreg;
}

// Regclass - loads the url to register for the class
function RegClass() {
	var IDCode = gup("ClassID");
	LoadCourse(IDCode);
}

// gup - "Get URL Parameter" - returns the value for the specified URL string parameter
function gup( name ){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return results;
  else
    return results[1];
}

// LinkTo - 09/29/2010 - Creates and executes the URL to view the policy,
// 	    then register for the class.
function LinkTo($ClassCode, $policy) {
   if (typeof $policy == 'undefined')
      LoadCourse($ClassCode);
   $classreg ='http://www.ncacademyofrealestate.com/policies/'
	+ $policy
	+ '.html'
	+ '?sl='
	+ $policy
	+ '&ClassID='
	+ $ClassCode;
   location.href = $classreg;
}

