function getCGIURL ()
{

var cgibinURL;

// THIS IS A GLOBAL VARIABLE - EDIT THIS IF THE LOCATION
// OF THE CGI CHANGES 

cgibinURL = "/cgi-bin/reguser";

return cgibinURL;
 
}

function getEditorCGIURL ()
{

var editorCgibinURL;

// THIS IS A GLOBAL VARIABLE - EDIT THIS IF THE LOCATION
// OF THE CGI CHANGES 

editorCgibinURL = "/cgi-bin/editor";

return editorCgibinURL;

}

function getThirdPartyLocation ()
{

var thirdPartyURL;

// THIS IS A GLOBAL VARIABLE - EDIT THIS IF THE LOCATION
// OF THE CGI CHANGES 

thirdPartyURL = "/cgi-bin/thirdParty";

return thirdPartyURL;

}

function getSiteURL ()
{

var siteURL;

// THIS IS A GLOBAL VARIABLE - EDIT THIS IF THE LOCATION
// OF THE SITE URL CHANGES 

	siteURL = SITE_URL;

return siteURL;

}

function getSecureSiteURL ()
{

var secureSiteURL;

// THIS IS A GLOBAL VARIABLE - EDIT THIS IF THE LOCATION
// OF THE SECURE SITE CHANGES 

	secureSiteURL = SECURE_SITE_URL;

return secureSiteURL;

}

function getAdminSiteURL ()
{

var adminSiteURL;

// THIS IS A GLOBAL VARIABLE - EDIT THIS IF THE LOCATION
// OF THE ADMIN SITE URL CHANGES 

	adminSiteURL = ADMIN_SITE_URL;

return adminSiteURL;

}

function downloadUserNotes(courseid,user,client,allNotes,onlySharedNotes,notesType)
{
	var siteURL = getSiteURL();
	
	var windowLocation=siteURL +"/cgi-bin/reguser/downloadUserNotes.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+client+"&courseid="+courseid+"&allNotes="+allNotes+"&onlySharedNotes="+onlySharedNotes+"&showUser="+user+"&notesType="+notesType;
	window.open(windowLocation,"Notes",'status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=640,height=640,dependent=false');
 
}

function goToDownloadNotes(documentName,courseid,creator,createdDate,modifiedDate)
{
	var siteURL = getSiteURL();
	window.location=siteURL +"/cgi-bin/reguser/docxi/showDownloadReviewNotes.pl?userid="+userid+"&documentName="+documentName+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&courseid="+courseid+"&creator="+creator+"&createdDate="+createdDate+"&modifiedDate="+modifiedDate;

}

function performAction(action,state,pageType)
{
var cgibinDir = getCGIURL();
var editorCgibinDir = getEditorCGIURL ();
var siteURL = getSiteURL();
var secureSiteURL = getSecureSiteURL();
var thirdPartyLocation = getThirdPartyLocation();

if (typeof pageType == "undefined")
{
	pageType="";
}

// Start Performing the action

switch(action)
{
	case 'MAKEINSTRUCTOR':
				if (state ==1)
				{
					if (pageType == "")
					{
						pageType ="ALL";
					}
					
					var url = siteURL+"/cgi-bin/administrator/showMakeInstructor.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz +"&pageType="+pageType;
									
					if (typeOfUser == 'CLIENT_ADMINISTRATOR')
					{
						url=url+"&registeredThru="+registeredThru+"&licenseid="+licenseid+"&fromPage=2";
					}
					
					url = escape(url);
					var tempURL = siteURL + "/cgi-bin/reguser/showWaitPage.pl?url="+ url;
					alert(tempURL);
					parent.regBottomFrame.location = tempURL;
					// parent.regBottomFrame.location = url;
				}	
				break;

	case 'UPDATEINSTRUCTOR':
			// alert(state);
			
			if (state ==1)
			{
				if (pageType == "")
				{
					pageType ="ALL";
				}
				
				var url = siteURL+"/cgi-bin/administrator/showMakeInstructor.pl";
				url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz+"&pageType="+pageType;
								
				if (typeOfUser == 'CLIENT_ADMINISTRATOR')
				{
					url=url+"&registeredThru="+registeredThru+"&licenseid="+licenseid+"&fromPage=2";
				}
								
				url = escape(url);
				var tempURL = siteURL + "/cgi-bin/reguser/showWaitPage.pl?url="+ url;
				
				parent.regBottomFrame.location = tempURL;
				// parent.regBottomFrame.location = url;
			}
			break;

	case 'DELETEINSTRUCTOR':
				if (state ==1)
				{
					
					if (pageType == "")
					{
						pageType ="ALL";
					}

					var url = siteURL+"/cgi-bin/administrator/showMakeInstructor.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz + "&pageType="+pageType;
									
					if (typeOfUser == 'CLIENT_ADMINISTRATOR')
					{
						url=url+"&registeredThru="+registeredThru+"&licenseid="+licenseid+"&fromPage=2";
					}
									
					url = escape(url);
					var tempURL = siteURL + "/cgi-bin/reguser/showWaitPage.pl?url="+ url;
					
					parent.regBottomFrame.location = tempURL;
					// parent.regBottomFrame.location = url;
				}	
				break;
	case 'LISTINSTRUCTORS':
				if (state ==1)
				{
					
					var url = siteURL+"/cgi-bin/administrator/listUsers.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&actionValue="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz+"&state=" + state;
									
					if (typeOfUser == 'CLIENT_ADMINISTRATOR')
					{
						url=url+"&registeredThru="+registeredThru+"&licenseid="+licenseid+"&fromPage=2";
					}
									
					url = escape(url);
					var tempURL = siteURL + "/cgi-bin/reguser/showWaitPage.pl?url="+ url;
					
					parent.regBottomFrame.location = tempURL;
					// parent.regBottomFrame.location = url;
				}	
				break;
	case 'MANAGEVACATION':
				
				if (state ==1)
				{
					if (pageType == "")
					{
						pageType ="ALL";
					}
					
					var url = siteURL+"/cgi-bin/administrator/showMakeInstructor.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz+"&pageType="+pageType;
									
					if (typeOfUser == 'CLIENT_ADMINISTRATOR')
					{
						url=url+"&registeredThru="+registeredThru+"&licenseid="+licenseid+"&fromPage=2";
					}
									
					url = escape(url);
					var tempURL = siteURL + "/cgi-bin/reguser/showWaitPage.pl?url="+ url;
					
					parent.regBottomFrame.location = tempURL;
					// parent.regBottomFrame.location = url;
				}
				break;
	case 'PASSWORD':
		
			if (state ==2)
			{
				
				if (isPasswordFormValid())
				{
					document.forms[0].action = secureSiteURL+cgibinURL +"/updatePassword.pl";
					document.forms[0].userid.value=userid;
					document.forms[0].sessionid.value=sessionid;
					document.forms[0].loggedInFrom.value=loggedInFrom;
					if (typeof document.forms[0].isOnlyQuiz != "undefined")
					{
						document.forms[0].isOnlyQuiz.value=isOnlyQuiz;
					}
					document.forms[0].submit();
				}
			}	
			else
			{
				if (pageType == 'FIRSTTIME')
				{
					window.location= secureSiteURL+cgibinURL+"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
				}
				else
				{
					parent.regBottomFrame.location= secureSiteURL+cgibinURL+"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
				}
			}
	break;
	
	case 'REGFRAME' :
		
				window.location= siteURL+cgibinURL+"/showRegFrame.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&isOnlyQuiz="+isOnlyQuiz;
	break;
	case 'COURSE' :
	
				window.top.location= siteURL+cgibinURL+"/showRegFrame.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&isOnlyQuiz="+isOnlyQuiz+"&pageType="+pageType;
			
	break;
	
	case 'COURSELIST' :
		
				// Added by Karthik - this generates the list of all courses 
				// available to a client 
				if (state ==1)
				{
					cgibinURL ="/cgi-bin/reguser";
					window.location = siteURL+cgibinURL +"/showCourseList.pl?loggedInFrom=" + pageType + "&inout=OUT1";				
				}
				else if (state ==2)
				{
					cgibinURL ="/cgi-bin/reguser";
					window.location = siteURL+cgibinURL +"/showCourseList.pl?loggedInFrom="+pageType+"&inout=OUT2";				
				}
				else if (state ==3)
				{
					var temp = 0;
					if (pageType == 'INFORMATICA')
					{
						temp = 1;
					}
					else
					{
						temp = 0;
					}
					cgibinURL ="/cgi-bin/reguser";
					window.location = siteURL+cgibinURL +"/showCourseList.pl?loggedInFrom="+pageType+"&inout=OUT3"+"&isOnlyQuiz="+temp;				
				}
					
				else if (state == 4)
				{
				//	document.forms[0].inout.value ="IN";
				//	document.forms[0].userid.value = userid;
				//	document.forms[0].sessionid.value =sessionid;
				//	document.forms[0].action = siteURL + cgibinURL +"/showCourseList.pl";
					parent.regBottomFrame.location = siteURL+cgibinURL +"/showCourseList.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&inout=IN"+"&isOnlyQuiz="+isOnlyQuiz;				
				
				//	document.forms[0].submit();
				}
				else if (state ==5)
				{
					cgibinURL ="/cgi-bin/reguser";
					window.location = siteURL+cgibinURL +"/showCourseList.pl?loggedInFrom=" + pageType + "&inout=OUT1&isOnlyQuiz=1";				
				}
				else if (state ==6)
				{
					cgibinURL ="/cgi-bin/reguser";
					window.location = siteURL+cgibinURL +"/showCourseList.pl?loggedInFrom="+pageType+"&inout=OUT2&isOnlyQuiz=1";				
				}
				else if (state ==7)
				{
					cgibinURL ="/cgi-bin/reguser";
					window.location = siteURL+cgibinURL +"/showCourseList.pl?loggedInFrom="+pageType+"&inout=OUT3&isOnlyQuiz=1";				
				}
									
				else if (state == 8)
				{
					//	document.forms[0].inout.value ="IN";
					//	document.forms[0].userid.value = userid;
					//	document.forms[0].sessionid.value =sessionid;
					//	document.forms[0].action = siteURL + cgibinURL +"/showCourseList.pl";
						window.location = siteURL+cgibinURL +"/showCourseList.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&inout=IN"+"&isOnlyQuiz=1";				
								
					//	document.forms[0].submit();
				}
				else if (state ==9)
				{
					var temp = 0;
					if (pageType == 'INFORMATICA')
					{
						temp = 1;
					}
					else
					{
						temp = 0;
					}
					cgibinURL ="/cgi-bin/reguser";
					parent.regBottomFrame.location = siteURL+cgibinURL +"/showCourseList.pl?loggedInFrom="+pageType+"&inout=INASOUT3"+"&isOnlyQuiz="+temp;				
				}
				else
				{
					
		      	}
				
				
	break;
	
	
	case 'COURSEDESCRIPTION' :
			
					// Added by Karthik - this generates the list of all courses 
					// available to a client 
					var courseid = pageType;
					// alert(courseid);
					var url = siteURL + "/cgi-bin/reguser/showCourseDescription.pl?courseid=" + courseid;
					window.open(url,courseid,'status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=640,height=640,dependent=false');
					
					break;
				
	case 'LOGIN'  :
			
			var typeOfUser;
			
			if (state ==1)
			{
				typeOfUser ="REGISTEREDUSER";
			}
			else if (state ==2)
			{
				typeOfUser ="CONSULTANT";
			}
			else if (state ==3)
			{
				typeOfUser ="INSTRUCTOR";
			}
			
			else if (state ==4)
			{
				typeOfUser ="ADMINISTRATOR";
			}
			
			else if (state ==5)
			{
				typeOfUser ="EDITOR";
			}
			
			else 
			{
			}

			var formName;
			
			if (typeof document.existingUsers != "undefined")
			{
				formName = document.existingUsers;
			}
			else
			{
				formName = document.forms[0];
			}
			
			var isValid = 0;
			
			if ((typeof document.forms[0].hiddenUserid != "undefined") && (document.forms[0].hiddenUserid.value == 1))
			{
				isValid = 1;
			}
			else
			{
				isValid = isLoginFormValid(formName);
			}
			if (isValid)
			{
				var url = secureSiteURL+cgibinDir+"/verifyUserLogin.pl";
				formName.action=url;
				formName.loggedInFrom.value = pageType;
				formName.typeOfUser.value = typeOfUser;
				formName.submit();
			}
	break;	
	
	case 'REGISTER' :
			
			if (state ==1)
			{
				if (isRegistrationFormValid(state))
				{
					document.forms[0].action=siteURL+cgibinDir+"/userRegistration.pl";
					document.forms[0].submit();
				}
			}
			else if ((state ==2) || (state == 5))
			{
				// When you register for a client course through ICtips
				if (isCourseRegistrationFormValid(state))
				{
					document.forms[0].action=secureSiteURL+cgibinDir+"/userCourseRegistration.pl";
					document.forms[0].registeredThru.value = pageType;
					document.forms[0].submit();
				}
			}
			else if (state ==3)
			{
				if (document.forms[0].registeredThru.value == 'INFORMATICA')
				{	
					if (isCreditCardFormValid() && confirm("Processing of the Credit Card may take a little while,During this process Please DO NOT close the browser window and Please DO NOT click on Submit twice"))
					{
						document.forms[0].action=secureSiteURL+thirdPartyLocation+"/payForCourse.pl";
						document.forms[0].submit();
					}
					else
					{
						return false;
					}
				}
				else
				{
					// Before paying the Credit Card
					if (isCreditCardFormValid())
					{
						document.forms[0].action=secureSiteURL+thirdPartyLocation+"/payForCourse.pl";
						// Check Whether the cookie value has to be passed
						var registrationCookieValue;
						
						if (document.forms[0].registeredThru.value == 'ARM')
						{	
							registrationCookieValue = getClientCookie('armPromotion');
							// alert(registrationCookieValue);
							document.forms[0].partnerKey.value = registrationCookieValue;
						}
						document.forms[0].submit();
					}
				}
			}
			else if (state ==4)
			{
					// This is required for those clients for which the Credit Card is bypassed 
						document.forms[0].action=siteURL+thirdPartyLocation+"/payForCourse.pl";
						document.forms[0].submit();
			}
			else if (state == 9)
			{
				
				//This is for Vitalect
				if (isVitalectRegistrationFormValid())
				{
					document.forms[0].action=siteURL+cgibinDir+"/userRegistration.pl";
					document.forms[0].submit();
					//document.forms[0].registeredThru.value = pageType;
				}
			}
			
	
	break;	
	
	
	case 'EXAMREGISTER' :
				
				if (state ==1 || state == 11)
				{
					var i,selectedValue;
					var url = secureSiteURL+"/cgi-bin/showProgress/showRemainingExams.pl";
					
					if (state == 1)
					{  
						for (i=0;i<document.newUsers.registrationType.length;i++)
						{
							if (document.newUsers.registrationType[i].checked)
							{
								selectedValue = document.newUsers.registrationType[i].value;
								break;
							}
						}

						if (selectedValue == 'PARTNER')
						{
							if (document.newUsers.partnerKey.value.length ==0)
							{
								alert ('Please enter a partner key');
								return;
							}
						}
		
						document.newUsers.action=url;
						document.newUsers.registeredThru.value = pageType;
						document.newUsers.submit();
					}					
					else
					{   
						document.examSelect.action=url;
						document.examSelect.registeredThru.value = pageType;
						document.examSelect.submit();
					}	
				}
				else if (state ==2)
				{
					
					if (isLoginFormValid(document.existingUsers))
					{
						document.existingUsers.action=secureSiteURL+"/cgi-bin/showProgress/showRemainingExams.pl";
						document.existingUsers.registeredThru.value = pageType;
						document.existingUsers.submit();
					}
				}
				else if (state == 3)
				{
					if (examSelectFormOk(document.examSelect))
					{   
						document.examSelect.action = secureSiteURL+cgibinDir+"/showRegistrationAgreement.pl"; 
						document.examSelect.registeredThru.value = pageType;
						document.examSelect.submit();
					}
				}

				else if (state == 4)
				{
					document.registrationAgreement.action = secureSiteURL+cgibinDir+"/submitRegistrationAgreement.pl"; 
					document.registrationAgreement.registeredThru.value = pageType;
					document.registrationAgreement.submit();
				}
				else if (state == 5)
				{
					if (pageType == 'MENTOR')
					{
						if (isMentorRegistrationFormValid())
						{
							document.forms[0].registeredThru.value = pageType;
							document.forms[0].action=secureSiteURL+cgibinDir+"/newExamRegistration.pl";
							document.forms[0].submit();
						}
					}
					else if (pageType == 'TOSHIBA')
					{
						document.forms[0].registeredThru.value = pageType;
						document.forms[0].action=secureSiteURL+cgibinDir+"/newExamRegistration.pl";
						document.forms[0].submit();
					}
					else if (pageType == 'D2L')
					{
						document.registrationForm.companyname.value=document.registrationForm.orgname.value;

						if (isD2LRegistrationFormValid())
						{
							document.forms[0].registeredThru.value = pageType;
							document.forms[0].action=secureSiteURL+cgibinDir+"/newExamRegistration.pl";
							document.forms[0].submit();
						}
					}
					else if (isExamRegistrationFormValid())
					{
						document.forms[0].registeredThru.value = pageType;
						document.forms[0].action=secureSiteURL+cgibinDir+"/newExamRegistration.pl";
						document.forms[0].submit();
					}
				}
				else if (state ==6)
				{
					if (pageType == 'INFORMATICA')
					{
						if (isCreditCardFormValid() && confirm("Processing of the Credit Card may take a little while,During this process Please DO NOT close the browser window and Please DO NOT click on Submit twice"))
						{
							document.forms[0].action=secureSiteURL+thirdPartyLocation+"/payForExam.pl";
							document.forms[0].registeredThru.value = pageType;

							document.forms[0].submit();
						}
						else
						{
							return false;
						}
					}else if (pageType == 'MAGMA-DA' || pageType == 'CLIENTDEMO'){
						var mode=document.forms[0].paymentMode.value;
						if (mode == "CARD")
						{
							if (isCreditCardFormValid())
							{
								document.forms[0].action=secureSiteURL+thirdPartyLocation+"/payForExam.pl";
								document.forms[0].registeredThru.value = pageType;
								document.forms[0].submit();
							}

						}else if (mode == "PORDER"){

							if (document.forms[0].purchaseOrderNumber.value == "")
							{
								alert ("Please enter the purchase order number");
								return 0;
							}else{
								document.forms[0].action=secureSiteURL+cgibinDir+"/submitOrderInformation.pl";
								document.forms[0].registeredThru.value = pageType;
								document.forms[0].submit();
							}

						}else if (mode == "CHECK"){
							//Do Nothing for now
								document.forms[0].action=secureSiteURL+cgibinDir+"/submitOrderInformation.pl";
								document.forms[0].registeredThru.value = pageType;
								document.forms[0].submit();
						}else{
							alert ("Invalid Mode of Purchase");
							return 0;
						}

					}
					else
					{
						// Before paying the Credit Card
						if (isCreditCardFormValid())
						{
							document.forms[0].action=secureSiteURL+thirdPartyLocation+"/payForExam.pl";
							document.forms[0].registeredThru.value = pageType;

							document.forms[0].submit();
						}
					}
				}
				else if (state ==4)
				{
						// This is required for those clients for which the Credit Card is bypassed 
							document.forms[0].action=siteURL+thirdPartyLocation+"/payForCourse.pl";
							document.forms[0].submit();
				}
				else if (state == 9)
				{
					
					//This is for Vitalect
					if (isVitalectRegistrationFormValid())
					{
						document.forms[0].action=siteURL+cgibinDir+"/userRegistration.pl";
						document.forms[0].submit();
						//document.forms[0].registeredThru.value = pageType;
					}
				}
		//		else if (state == 10)
		//		{
		//			if (isMentorRegistrationFormValid())
		//			{
		//				document.forms[0].registeredThru.value = pageType;
		//				document.forms[0].action=secureSiteURL+cgibinDir+"/newExamRegistration.pl";
		//				document.forms[0].submit();
		//			}
		//		}
				else if (state ==10)
				{

						// document.existingUsers.action=secureSiteURL+"/cgi-bin/showProgress/showRemainingExams.pl";
						// document.existingUsers.registeredThru.value = pageType;
						// document.existingUsers.submit();

						parent.regBottomFrame.location= secureSiteURL +"/cgi-bin/showProgress/showRemainingExams.pl?userid="+userid+"&sessionid="+sessionid+"&registeredThru="+loggedInFrom+"&pageType=inside" +"&userType=REGISTERED"+"&action="+action+"&isOnlyQuiz="+isOnlyQuiz;
			   }
				else if (state == 12)
				{
					var restricted = 1;
					if (isExamRegistrationFormValid(restricted))
					{
						document.forms[0].registeredThru.value = pageType;
						document.forms[0].action= secureSiteURL + cgibinDir+"/newAuthorSignup.pl";
						document.forms[0].submit();
					}
				}
				else if (state == 13)
				{
					var restricted = 1;
					if (isExamRegistrationFormValid(restricted))
					{
						document.forms[0].registeredThru.value = pageType;
						document.forms[0].action=secureSiteURL+cgibinDir+"/newExamRegistration.pl";
						document.forms[0].submit();
					}
				}
				else if (state == 14)
				{
					var restricted = 1;
					if (isExamRegistrationFormValid(restricted))
					{
						document.forms[0].registeredThru.value = pageType;
						document.forms[0].action=secureSiteURL+cgibinDir+"/newExamRegistration.pl";
						document.forms[0].submit();
					}
				}
				else if (state ==15)
				{
					//This is used to show the user transcript
					parent.regBottomFrame.location= siteURL + "/cgi-bin/showProgress/showRemainingExams.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showTranscript=1"+"&userType="+pageType+"&isOnlyQuiz="+isOnlyQuiz+"&pageType=inside"+"&registeredThru="+loggedInFrom;
				}
				else if (state == 16)
				{
					if (examSelectFormOk(document.examSelect))
					{
						document.examSelect.action = secureSiteURL+cgibinDir+"/submitRegistrationAgreement.pl"; 
						document.examSelect.registeredThru.value = pageType;
						document.examSelect.submit();
					}
				}	
				else if (state == 17)
				{
						document.newUsers.action = secureSiteURL+cgibinDir+"/showRegistrationAgreement.pl"; 
						document.newUsers.registeredThru.value = pageType;
						document.newUsers.submit();
				}
				else if (state ==18)
				{

						// document.existingUsers.action=secureSiteURL+"/cgi-bin/showProgress/showRemainingExams.pl";
						// document.existingUsers.registeredThru.value = pageType;
						// document.existingUsers.submit();

						//parent.regBottomFrame.location= secureSiteURL +"/cgi-bin/showProgress/getCoursesAndIltCourses.pl?userid="+userid+"&sessionid="+sessionid+"&registeredThru="+loggedInFrom+"&pageType=inside" +"&userType=REGISTERED"+"&action="+action+"&isOnlyQuiz="+isOnlyQuiz;
						parent.regBottomFrame.location= secureSiteURL +"/cgi-bin/showProgress/showRemainingExams.pl?userid="+userid+"&sessionid="+sessionid+"&registeredThru="+loggedInFrom+"&pageType=inside" +"&userType=REGISTERED"+"&action="+action+"&isOnlyQuiz="+isOnlyQuiz;
				}
				else if (state == 19)
				{
						document.registrationAgreement.action = secureSiteURL+cgibinDir+"/showRegistrationAgreement.pl"; 
						document.registrationAgreement.registeredThru.value = pageType;
						document.registrationAgreement.submit();
				}

                else if (state ==20)
				{		
						var value=document.examSelect.partnerKeyEnter.value;
						if(value==""){
							alert("Please Enter the Partner Key");
							document.examSelect.partnerKeyEnter.focus();
						}
						else{
						document.examSelect.action=secureSiteURL+"/cgi-bin/showProgress/showExamsToReturningUser.pl";
						document.examSelect.registeredThru.value = pageType;
						document.examSelect.submit();
						}
				}

		
	break;	
	
	
	case 'HINT' :
			
			var msg = "";
			if (state ==1)
			{
				msg = isLoginOk(msg);
				if (showAlertMsg(msg) != 0 ) 
				{
					document.forms[0].action=secureSiteURL+cgibinDir+"/getHint.pl";
					document.forms[0].submit();
				}
			}
			else if (state ==2)
			{
				msg = isHintAnswerOk(msg)
				if (showAlertMsg(msg) != 0 ) 
				{
					document.forms[0].action=secureSiteURL+cgibinDir+"/matchAnswer.pl";
					document.forms[0].submit();
				}
			}
			else if (state ==3)
			{
				if (isHintPasswordFormValid ())
				{
					document.forms[0].action=secureSiteURL+cgibinDir+"/updatePassword.pl";
					document.forms[0].submit();
				}
			}
			else if (state ==4)
			{
				msg = isLoginOk(msg);
				if (showAlertMsg(msg) != 0 ) 
				{
					document.forms[0].action=secureSiteURL+cgibinDir+"/updatePasswordReset.pl";
					document.forms[0].submit();
				}
			}
			else if (state ==9)
			{
				if (isForgotPasswordFormValid ())
				{
					document.forms[0].action=secureSiteURL+cgibinDir+"/matchAnsUpdatePassword.pl";
					document.forms[0].submit();
				}
			}
			
			
	break;
	
	case 'SIG' :
	
		if (state ==2)
		{
			if (isSigPostFormValid())
			{
				getCGIURL();
				document.forms[0].action=siteURL+cgibinDir +"/postSIG.pl";
				//document.forms[0].userid.value=userid;
				//document.forms[0].sessionid.value=sessionid;
				//document.forms[0].loggedInFrom.value=loggedInFrom;
				document.forms[0].submit();
			}
		}
		else if (state ==4)
		{
			if (isSigRegFormValid())
			{
				if (document.forms[0].fromPage.value==1)
				{
					document.forms[0].action=siteURL+cgibinDir +"/manageSIG.pl";
				}
				else
				{
					// is this used now ?
					
					document.forms[0].action=siteURL+cgibinURL +"/manageSIG.pl";
					document.forms[0].userid.value=userid;
					document.forms[0].sessionid.value=sessionid;
					document.forms[0].loggedInFrom.value=loggedInFrom;
				}
				document.forms[0].submit();
			}
		}	
		else if (state ==5)
		{
			// This will be used only if you call from Outside
			
			if (isLoginFormValid())
			{
				document.forms[0].action=siteURL+cgibinDir +"/showSIGOutsidePage.pl";
				document.forms[0].action1.value=action;
				document.forms[0].showPage.value=state;
				document.forms[0].submit();
			}
		}	
		else
		{
			window.location= siteURL+cgibinURL+"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType;
		}
	
	break;
	
	
	case 'ATE':
	
		if (state ==1)
		{
			window.location= siteURL+cgibinURL +"/showATEPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom;
		}
		
		else if (state ==2)
		{
			// This is the submission of ATE
			// Hence check the form
			if (isATEFormValid())
			{	
				document.forms[0].action = siteURL+cgibinURL +"/submitATE.pl";
				document.forms[0].userid.value=userid;
				document.forms[0].sessionid.value=sessionid;
				document.forms[0].loggedInFrom.value=loggedInFrom;
				document.forms[0].submit();
			}
		}
		else if (state ==4)
		{
			window.location=siteURL + cgibinURL + "/showJoinExpertsPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom;
		}
		else if (state ==5)
		{
			if (isJoinExpertsFormValid())
			{
				document.forms[0].action = siteURL + cgibinURL +"/joinExperts.pl";
				document.forms[0].userid.value=userid;
				document.forms[0].sessionid.value=sessionid;
				document.forms[0].loggedInFrom.value=loggedInFrom;
				document.forms[0].submit();
			}
				
		}
		else
		{
			window.location= siteURL + cgibinURL+"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType;
		}

	break;

	case 'QUIZ' : 
	
		if (state ==1)
		{
			window.location= siteURL + cgibinURL+"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType;
		}
		else 
		{
			  startQuiz();
		}
	break;
	
	
	case 'BBS' :

		if (state ==1)
		{
			window.location= siteURL + cgibinURL+"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType;
		}
		else
		{
		
			
			document.forms[0].action = siteURL + thirdPartyLocation+"/bbs.pl";
			document.forms[0].userid.value=userid;
			document.forms[0].sessionid.value=sessionid;
			document.forms[0].loggedInFrom.value=loggedInFrom;
			document.forms[0].submit();
		}
	
	break;

	case 'PROFILE' :
	
		if (state ==1)
		{
			parent.regBottomFrame.location= siteURL + cgibinURL+"/showProfilePage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
		}
		else		
		{
			if (isProfileFormValid())
			{
				document.forms[0].action = siteURL + cgibinURL +"/updateProfile.pl";
				document.forms[0].userid.value=userid;
				document.forms[0].sessionid.value=sessionid;
				document.forms[0].loggedInFrom.value=loggedInFrom;
				if (typeof document.forms[0].isOnlyQuiz != "undefined")
				{
					document.forms[0].isOnlyQuiz.value=isOnlyQuiz;
				}
				
				document.forms[0].submit();
			}
		}

	break;
	
	case 'SEARCHCOURSES' :
        if (state ==1)
		{
	      
		 parent.regBottomFrame.location= secureSiteURL +cgibinURL+"/searchAvailableCourses.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
		 
		}
		else if (state==2)
		{
         parent.regBottomFrame.location= secureSiteURL +cgibinURL+"/listAvailableCourses.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
		}
		else if (state ==3)

		{
			var country=document.forms[0].country.value;
			var city=document.forms[0].city.value;
			var searchfor=document.forms[0].searchfor.value;
			var trainingformat=document.forms[0].trainingformat.value;
			var from=document.forms[0].from.value;
			var To=document.forms[0].To.value;
            parent.regBottomFrame.location= secureSiteURL +cgibinURL+"/listAvailableCourses.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz+"&searchfor="+searchfor+"&trainingformat="+trainingformat+"&country="+country+"&city="+city+"&from="+from+"&To="+To;
		 
		 }
	break;

	case 'WIN' :
	
		if (state ==1)
		{
			window.location= siteURL + cgibinURL+"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType;
		}
		else if (state ==2)
		{
			window.location= siteURL + cgibinURL+"/showRegQuizEntryPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state;
		}
			
		else if (state ==3)
		{
			window.location= siteURL + cgibinURL+"/showRegQuizReportPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state;
		}
		else
		{
			if (isRegQuizEntryFormValid())
			{
				document.forms[0].action= siteURL + cgibinURL+"/submitRegQuizEntry.pl";
				document.forms[0].userid.value=userid;
				document.forms[0].sessionid.value=sessionid;
				document.forms[0].loggedInFrom.value=loggedInFrom;
				document.forms[0].submit();
			}
		}

	break;

	case 'STATISTICS' :
		
		window.location= siteURL + cgibinURL +"/showStatisticsPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType;
	break;	
	
	case 'SHOW_INSTRUCTOR' :
		
		parent.regBottomFrame.location= siteURL + "/cgi-bin/instructor/instructorLogin.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&isOnlyQuiz="+isOnlyQuiz+"&typeOfUser="+typeOfUser+"&action="+pageType;
	break;	
	
	case 'SHOW_EDITOR' :
			
		parent.regBottomFrame.location= siteURL + "/cgi-bin/editor/myCourses.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&isOnlyQuiz="+isOnlyQuiz+"&typeOfUser="+typeOfUser+"&action="+pageType;
	break;

	case 'UPLOAD_CONTENT' :
		 var url=siteURL + "/cgi-bin/editor/showUploadPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&isOnlyQuiz="+isOnlyQuiz+"&typeOfUser="+typeOfUser+"&action="+pageType;
		 window.open(url,'Upload_Content','status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=no,directories=no,copyhistory=no,width=780,height=670,dependent=false');
		//parent.regBottomFrame.location= siteURL + "/cgi-bin/editor/showUploadPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&isOnlyQuiz="+isOnlyQuiz+"&typeOfUser="+typeOfUser+"&action="+pageType;
	break;

	case 'SEARCHMULTIPLECOURSES' :

		if (state ==1)
		{
			//alert (siteURL + cgibinURL +"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz);
			parent.regBottomFrame.location=siteURL + cgibinURL +"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
		}
		else
		{
			if (document.forms[0].SearchText1.value=="")
			{
				alert ("Please enter a text to search");
				return 0;
			}

			
			if (confirm('Searching across courses could take a while - do you want to continue ?'))
			{
				var searchBar = document.getElementById("searchBar");
				searchBar.style.display="none";
				var processingBar=document.getElementById("processingBar");
				processingBar.style.display="block";
			}
			else
			{
				return 0;
			}


			if (document.forms[0].pageContent.checked && document.forms[0].faqItem.checked)
			{
				document.forms[0].resourceType.value="PAGE_AND_FAQ";
			}
			else if (document.forms[0].pageContent.checked)
			{
				document.forms[0].resourceType.value=document.forms[0].pageContent.value;
			}
			else if (document.forms[0].faqItem.checked)
			{
				document.forms[0].resourceType.value=document.forms[0].faqItem.value;
			}

			document.forms[0].action=siteURL + cgibinDir+"/searchCoursesClient.pl";
			document.forms[0].submit();
		}
		
	break;

	case 'SEARCHMULTIPLEDOCUMENTS' :
		
		if (state ==1)
		{
			//alert (siteURL + cgibinURL +"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz);
			parent.regBottomFrame.location=siteURL + cgibinURL +"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
		}
		else
		{
			if (document.form1.SearchText1.value=="")
			{
				alert ("Please enter a text to search");
				return 0;
			}
			if (null==document.form2.elements["selectCourse"])
			{
				alert ("There are no document(s) present");
				return false;
			}

			//This feature is done for DOCXI only as here you need to
			//have the ability to search for the word in chich you need to select the documents.
			if (undefined != document.form1.firstLevelSearch && document.form1.firstLevelSearch.value=="firstLevel")
			{
					var flag=0;
					var length=document.form2.selectCourse.length;
					var courseId="";

					if (length == undefined)
					{
						if (document.form2.selectCourse.checked)
						{
						  courseId=document.form2.selectCourse.value;
						  flag=1;
						}
					}
					else
					{
						for (counter = 0; counter < length; counter++)
						{
							if (document.form2.selectCourse[counter].checked)
							{
								courseId=courseId+document.form2.selectCourse[counter].value+"&";
								flag=1;
							}
						}
					}
					if (flag==0)
					{
						alert ("Please select the document(s) in which you need to search");
						return false;
					}
					//alert ("The Course id is: "+courseId);
					document.form1.selectedCourseId.value=courseId;					
			}

			
			if (confirm('Searching across documents could take a while - do you want to continue ?'))
			{
				var searchBar = document.getElementById("searchBar");
				searchBar.style.display="none";
				var processingBar=document.getElementById("processingBar");
				processingBar.style.display="block";

			}
			else
			{
				return 0;
			}


			if (document.form1.pageContent.checked && document.form1.faqItem.checked)
			{
				document.form1.resourceType.value="PAGE_AND_FAQ";
			}
			else if (document.form1.pageContent.checked)
			{
				document.form1.resourceType.value=document.form1.pageContent.value;
			}
			else if (document.form1.faqItem.checked)
			{
				document.form1.resourceType.value=document.form1.faqItem.value;
			}
			else
			{
			}

			document.form1.action=siteURL + cgibinDir+"/searchCoursesClient.pl";
			//alert ("Going to Submit: "+siteURL + cgibinDir);
			document.form1.submit();
		}



	break;
	
	case 'MERGEDOCUMENTS' :

		if (state==1)
		{
			//The Form name should be forms[1] as in DOCXI there are 3 forms
			document.form2.state.value = state;
			document.form2.action = siteURL+"/cgi-bin/administrator/collectListInformation.pl";
			document.form2.submit();
		}
		else
		{
			//The Form name should be forms[1] as in DOCXI there are 3 forms
			document.form2.state.value = state;
			document.form2.action = siteURL+"/cgi-bin/editor/docxi/showMergeDocumentsInfo.pl";
			document.form2.submit();

		}

	break;

	case 'DELETEREVIEWER':
		{
			if (state == 1)
			{
				//The Form name should be form2 as in DOCXI there are 3 forms
				document.form2.state.value = state;
				document.form2.action = siteURL+"/cgi-bin/administrator/docxi/showReviewersForDocuments.pl";
				document.form2.submit();

			}
			else if (state == 2)
			{
				if (document.form1.selectedUserId.value =="")
				{
					alert ("Please select the reviewer(s) to be deleted from the selected documents");
					return false;
				}
				document.form1.state.value = state;
				document.form1.action = siteURL+"/cgi-bin/administrator/docxi/showReviewersForDocuments.pl";
				document.form1.submit();
			}
			else if (state == 3) //This is the new state which was added in the UI change for DOCXI.
			{
				action="SHOW_DOCUMENTS_FOR_REVIEWER";
				var url = siteURL+"/cgi-bin/administrator/docxi/manageReviewer.pl";
				url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz+"&loginId="+pageType;
				parent.regBottomFrame.location = url;
			}
			else if (state == 4) //This is the new state which was added in the UI change for DOCXI.
			{
					var url = siteURL+"/cgi-bin/administrator/docxi/manageReviewer.pl";
					document.forms[0].submit();
			}
			else if (state == 5) //This is the new state which was added in the UI change for DOCXI.
			{
				action="DELETE_REVIEWER";
				var url = siteURL+"/cgi-bin/administrator/docxi/manageReviewer.pl";
				url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz+"&reviewerLogin="+pageType;
				parent.regBottomFrame.location = url;
			}
			else
			{
				alert ("Invalid State");
				return false;
			}
		}
		break;

	
	case 'DOCUMENT_GROUP':
		if (state ==1)
				{
					var action ="SHOWALL";
					var url = siteURL+"/cgi-bin/administrator/showGroup.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz;

					// url = escape(url);
					// var tempURL = siteURL + "/cgi-bin/reguser/showWaitPage.pl?url="+ url;					
					var tempURL = url;
					parent.regBottomFrame.location = tempURL;

				}
		else if (state ==2)
				{
					var action ="SHOW_ADD_GROUP";
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz;
					parent.regBottomFrame.location = url;
				}
		else if (state ==3)
				{
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					document.forms[0].submit();
				}
		else if (state ==4)
				{
					var action ="SHOW_ADD_REVIEWER";
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz;
					parent.regBottomFrame.location = url;
				}
		else if (state ==5)
				{
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					document.forms[0].submit();
				}
		else if (state ==6)
				{
					var action ="LIST_GROUPS";
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz;
					parent.regBottomFrame.location = url;
				}
		else if (state ==7)
				{	
					var action="SHOW_EDIT_GROUPS_INFO";
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz+"&groupId="+pageType;
					parent.regBottomFrame.location = url;
				}
		else if (state ==8)
				{
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					document.forms[0].submit();
				}
		else if (state ==9)
				{
					var action ="LIST_REVIEWERS";
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz;
					parent.regBottomFrame.location = url;
				}
		else if (state ==10)
				{	
					var action="SHOW_EDIT_REVIEWER_INFO";
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz+"&loginId="+pageType;
					parent.regBottomFrame.location = url;
				}
		else if (state ==11)
				{
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					document.forms[0].submit();
				}
		else if (state ==12)
				{	
					var action="DELETE_GROUP";
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupOperations.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz+"&groupId="+pageType;
					parent.regBottomFrame.location = url;
				}
		else if (state ==13)
				{
					var action ="LIST_GROUPS";
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupEmail.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz;
					parent.regBottomFrame.location = url;
				}
		else if (state ==14)
				{
					var action ="SHOW_EMAIL_FORM";
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupEmail.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz+"&groupId="+pageType;
					parent.regBottomFrame.location = url;
				}
		else if (state ==15)
				{
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupEmail.pl";
					document.forms[0].action = url;					
					document.forms[0].submit();
				}	
		else if (state ==16)
				{
					var action ="SHOW_UPLOAD_MULIPLE_USERS";
					var url = siteURL+"/cgi-bin/showProgress/createUsersFromCSV.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz;
					parent.regBottomFrame.location = url;
				}
		else if (state ==17)
				{
					var action ="SHOW_NOTIFY_REVIEWERS";
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupEmail.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz;
					parent.regBottomFrame.location = url;
				}
		else if (state ==18)
				{
					var url = siteURL+"/cgi-bin/administrator/docxi/performGroupEmail.pl";
					document.forms[0].action = url;					
					document.forms[0].submit();
				}	
		break;

	case 'SEARCHUSERGROUP':
				if (state ==1)
				{
					var url = siteURL+"/cgi-bin/administrator/docxi/searchUserAndGroup.pl";
					url =url+"?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz="+isOnlyQuiz+"&searchText="+pageType;
					parent.regBottomFrame.location = url;
				}
		break;
	case 'UPDATE':
				if (state == 1)
				{
					if (isUpdateUserFormValid(document.forms[0],pageType))
					{
						document.forms[0].action = siteURL+"/cgi-bin/administrator/showUpdateUser.pl";
						document.forms[0].pageType.value="showDeleteUser";
						document.forms[0].submit();
					}
				}
				else if (state == 2)
				{
							if (document.forms[0].areCoursesPresent.value == 'YES')
							{
								if (!isDeleteCourseSelectionOk(document.forms[0]))
								{
									return 0;
								}
								document.forms[0].action = siteURL+"/cgi-bin/reguser/docxi/deleteUserDocument.pl";
								document.forms[0].state.value=state;
								document.forms[0].submit();
							}
				}
			break;

	case 'SHOWPARTICULARCONTENT' :

			var url=siteURL + cgibinDir+"/showContentPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&loId="+state+"&resourceType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
			window.open(url,'SHOW_CONTENT','status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=640,height=640,dependent=false');
		
	break;


	case 'SEARCH_STATISTICS' :

		if (state ==1)
		{
			//alert (siteURL + "/cgi-bin/instructor/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz);
		
			parent.regBottomFrame.location=siteURL +"/cgi-bin/instructor/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
		}
		else
		{
			
			var url=siteURL + "/cgi-bin/instructor/searchStatistics.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
			url = escape(url);
			var tempURL = siteURL + "/cgi-bin/instructor/showWaitPage.pl?url="+url+"&loggedInFrom="+loggedInFrom;
			parent.regBottomFrame.location = tempURL;
		
		}
		
	break;

	case 'NDA_STATISTICS' :

			var url=siteURL + "/cgi-bin/instructor/searchNdaResults.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&state="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
			url = escape(url);
			var tempURL = siteURL + "/cgi-bin/instructor/showWaitPage.pl?url="+url+"&loggedInFrom="+loggedInFrom;
			parent.regBottomFrame.location = tempURL;
		
	break;

	case 'REPORT_SEARCH_USERS' :
		if (state != 1)
		{
			var url=siteURL + "/cgi-bin/instructor/reportSearchUsers.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&searchText="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
			url = escape(url);
			var tempURL = siteURL + "/cgi-bin/instructor/showWaitPage.pl?url="+url+"&loggedInFrom="+loggedInFrom;
			parent.regBottomFrame.location = tempURL;
		}
		else
		{
			alert ("Invalid State");
			return false;
		}
	
	break;

	case 'SHOW_SEARCH_INFO' :
		if (state != 1)
		{
			var url=siteURL + "/cgi-bin/instructor/showSearchInfo.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&rowId="+state+"&userResponse="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
			url = escape(url);
			var tempURL = siteURL + "/cgi-bin/instructor/showWaitPage.pl?url="+url+"&loggedInFrom="+loggedInFrom;
			parent.regBottomFrame.location = tempURL;
		}
		else
		{
			alert ("Invalid State");
			return false;
		}
	
	break
	
	case 'SUPPORT' :
		if (state ==3)
		{
			if (document.forms[0].fromPage.value ==1)
			{
				var msg = "";
				// Coming From Outside
				// Check for the Validity of the Support Form
				msg = isNameOk(msg);
				msg = isCompanyOk(msg);
				msg = isEmailOk(msg);
				msg = isLoginOk(msg);
				if (showAlertMsg(msg) == 0 ) {	break; }
				
				if (isSupportFormValid())
				{
					document.forms[0].action=siteURL + cgibinDir+"/submitSupport.pl";
					document.forms[0].submit();
				}
			}
			else
			{
				if (isSupportFormValid())
				{
					document.forms[0].action=siteURL + cgibinURL+"/submitSupport.pl";
					document.forms[0].userid.value=userid;
					document.forms[0].sessionid.value=sessionid;
					document.forms[0].loggedInFrom.value=loggedInFrom;
					if (typeof document.forms[0].isOnlyQuiz != "undefined")
					{
						document.forms[0].isOnlyQuiz.value=isOnlyQuiz;
					}
					document.forms[0].submit();
				}
			}
		}
		else
		{
			//alert (siteURL + cgibinURL +"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz);
			parent.regBottomFrame.location= siteURL + cgibinURL +"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
		}
	
	break;
	
	case 'REMOVE':
			
			
			document.forms[0].action =siteURL + cgibinDir +"/removeFromUpdates.pl";
			document.forms[0].submit();
			break;
		
	case 'SENDPAGE':
		
			if (isSendPageFormOk())
			{
				document.forms[0].action =siteURL + cgibinDir +"/sendPage.pl";
				document.forms[0].submit();
			}
		break;
	
	case 'BECOMEPARTNER':
			
			if (isBecomePartnerFormOk())
			{
				document.forms[0].action =siteURL + cgibinDir +"/becomePartner.pl";
				document.forms[0].submit();
			}
		break;
		
	case 'PLACEAD':
				
			if (isPlaceAdFormOk())
			{
				document.forms[0].action =siteURL + cgibinDir +"/placeAd.pl";
				document.forms[0].submit();
			}
		break;
	
	case 'FEEDBACK':
					
			if (isFeedbackFormOk())
			{
				document.forms[0].action =siteURL + cgibinDir +"/submitFeedback.pl";
				document.forms[0].submit();
			}
		break;
	
	case 'SEARCH':
			if (state ==1)
			{
				window.location= siteURL + cgibinURL +"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType;
			}
			else
			{
				if (isSearchFormValid())
				{
					// This will be used only if you call from Outside
					document.forms[0].action = thirdPartyLocation+"/submitSearch.pl";
					document.forms[0].submit();
				}
			}
		break;
		
	case 'SETUP' :
			
			var url = siteURL + cgibinURL +"/showSetupPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
			
				if (pageType == 'FIRSTTIME')
				{
					url = url +"&courseid="+courseid;
				}
			
				parent.regBottomFrame.location = url;
			
		break;
	
	case 'LICENSES' :
	
			if (state ==1)
			{
					document.forms[0].action=siteURL+"/cgi-bin/showProgress/takeCourse.pl";
					document.forms[0].userid.value=userid;
					document.forms[0].sessionid.value=sessionid;
					document.forms[0].loggedInFrom.value=loggedInFrom;
					document.forms[0].courseid.value=courseid_var;
					document.forms[0].fromPage.value=3;
					document.forms[0].submit();
			
			}
		break;
		
	case 'SKIPDEMO' :
	
			if (state ==1)
			{
					// alert('Hi');
					// alert(courseid_var);
					
					document.forms[0].action=siteURL+"/cgi-bin/showProgress/takeCourse.pl";
					document.forms[0].userid.value=userid;
					document.forms[0].sessionid.value=sessionid;
					document.forms[0].loggedInFrom.value=loggedInFrom;
					document.forms[0].courseid.value=courseid_var;
					document.forms[0].fromPage.value=4;
					document.forms[0].submit();
			
			}
		break;
	//Added for Shibu
	case 'VIEW_CERTIFICATE' :
	
			if (state ==1)
			{
					parent.regBottomFrame.location=siteURL+"/cgi-bin/reguser/showCertificateList.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
			}
			else
			{
 					parent.regBottomFrame.location=siteURL+"/cgi-bin/reguser/showCertificateList.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&isOnlyQuiz="+isOnlyQuiz;
			}
		break;
        
        case 'VIEW_OTHER_CERTIFICATE' :
            
                        if (state ==1)
                        {
                                        parent.regBottomFrame.location=siteURL+"/cgi-bin/reguser/showOtherCertificateList.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
                        }
                        else
                        {
                                        parent.regBottomFrame.location=siteURL+"/cgi-bin/reguser/showOtherCertificateList.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&isOnlyQuiz="+isOnlyQuiz;
                        }
                break;

	case 'SHOW_CERTIFIED_OUTSIDE':
			
			if (state ==1)
			{
				var url = siteURL+cgibinDir+"/showCertifiedUsers.pl";
				url =url+"?loggedInFrom="+pageType+"&action="+action+"&typeOfUser="+typeOfUser+"&isOnlyQuiz=1"+"&state="+state;
									
				self.location = url;
				// alert (url);
			}
			else
			{
				// Check whether the form is valid 
				if (isCertificationFormValid())
				{
				
					document.forms[0].action=siteURL+cgibinDir+"/showCertifiedUsers.pl";
					document.forms[0].actionValue.value = action;
					document.forms[0].state.value = state;
					document.forms[0].submit();
				}
			}
			
			break;
	
	case 'SHOW_CERTIFIED_INSIDE':
			
			if (state == 1)
			{
				parent.regBottomFrame.location= siteURL + cgibinURL +"/showCertifiedUsers.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&state="+state+"&isOnlyQuiz="+isOnlyQuiz+"&typeOfUser="+typeOfUser;
			}
			else
			{
				// Check whether the form is valid 
				if (isCertificationFormValid())
				{
				
					document.forms[0].action=siteURL+cgibinDir+"/showCertifiedUsers.pl";
					document.forms[0].actionValue.value = action;
					document.forms[0].state.value = state;
					document.forms[0].submit();
				}
			}
			break;

	case 'FAQ':

		var tempString="";
		if (pageType != "")
		{
			tempString = "#" + pageType;
			pageType="";
			
		}
		
		var url = siteURL + cgibinURL +"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz + tempString;
		parent.regBottomFrame.location=url;
		break;


	case 'REUPLOAD_DOCUMENT' :
			if (state !=1)
			{
					//parent.regBottomFrame.location=;
					 var url=siteURL+"/cgi-bin/editor/showUploadPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&documentType="+state+"&courseId="+pageType;
					 window.open(url,'Reupload_Content','status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=no,directories=no,copyhistory=no,width=780,height=670,dependent=false');

			}
			else
			{
				alert ("Invalid action");
			}
			break;

	case 'DELETECOURSE':
			if (state == 5)
				{
					if (confirm('This will permanently delete the selected documents - ok to continue ?'))
					{
						var deleteProcessingBar=document.getElementById("deleteProcessingBar");
						deleteProcessingBar.style.display="block";
						//The Form name should be form2 as in DOCXI there are 3 forms
						document.form2.state.value = state;
						// document.form2.action = siteURL+cgibinDir+"/editor/showDeleteCourse.pl";
						// document.form2.action = siteURL+"/cgi-bin/ex-imp/showDeleteCourse.pl";
						document.form2.action = siteURL+"/cgi-bin/ex-imp/nph-showDeleteCourse.pl";
						document.form2.submit();
					}
				}

			break;

	case 'INVITEUSERS':
			if (state == 1)
				{
						//The Form name should be form2 as in DOCXI there are 3 forms
						document.form2.state.value = state;
						document.form2.action = siteURL+"/cgi-bin/reguser/docxi/inviteUsers.pl";
						document.form2.submit();
				}
			else if (state == 2)
				{
						document.forms[0].state.value = state;
						document.forms[0].action = siteURL+"/cgi-bin/reguser/docxi/inviteUsers.pl";
						document.forms[0].submit();
				}

			break;

	case 'EXTENDUSERS':
			if (state == 1)
				{
						//The Form name should be form2 as in DOCXI there are 3 forms
						document.form2.state.value = state;
						document.form2.action = siteURL+"/cgi-bin/reguser/docxi/extendUsers.pl";
						document.form2.submit();
				}
			else if (state == 2)
				{
						document.form1.state.value = state;
						document.form1.action = siteURL+"/cgi-bin/reguser/docxi/extendUsers.pl";
						document.form1.submit();
				}

			break;

	case 'LISTEDITORS':
			if (state == 1)
				{

						//The Form name should be form2 as in DOCXI there are 3 forms
						document.form2.state.value = state;
						document.form2.clickedCourseName.value = "";
						document.form2.action = siteURL+"/cgi-bin/administrator/collectListInformation.pl";
						document.form2.submit();
				}
			else
				{
						//This part is entered when the users click the reviewer name
						document.form2.clickedCourseName.value = state;
						document.form2.state.value = 1;
						document.form2.action = siteURL+"/cgi-bin/administrator/collectListInformation.pl";
						document.form2.submit();
				}
			break;


	case 'CREATEAUTHOR':
		if (state == 1){
			var restricted = 1;
			if (isExamRegistrationFormValid(restricted))
		    {
				document.forms[0].registeredThru.value = pageType;
				document.forms[0].action= siteURL+"/cgi-bin/reguser/newAuthorSignup.pl";
				document.forms[0].submit();
			}
		}
		break;

	case 'CORPORATEREPORT':
		if (state ==1)
			{
				document.forms[0].action = siteURL+"/cgi-bin/administrator/corporateReport.pl";
				document.forms[0].submit();
			}
		 break;

case 'DOWNLOAD_LOGO':

	if (state == 1)
	{
    window.open (siteURL+"/templates/vitalectClients/informatica/images/certified_A.zip"); 
	}
	else if (state == 2)
	{
		window.open (siteURL+"/templates/vitalectClients/informatica/images/certified_D.zip"); 
	}
	else if (state == 3)
	{
		window.open (siteURL+"/templates/vitalectClients/informatica/images/certified_C.zip"); 
	}
        else if (state == 4)
        {
                window.open (siteURL+"/templates/vitalectClients/informatica/images/certified_S.zip");
        }

        else if (state == 5)
        {
                window.open (siteURL+"/templates/vitalectClients/informatica/images/certified_P.zip");
        }
   break;

	default
			 :
		// SETUP,NEWSLETTER,RESOURCES,PROMOTIONS,PRODUCTMALL,SITEMAP, CONTACTUS
		
		parent.regBottomFrame.location= siteURL + cgibinURL +"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"&showPage="+state+"&pageType="+pageType+"&isOnlyQuiz="+isOnlyQuiz;
		break;
}
	
return;
}

function performExtraAction (action,state,pageType,menuType,fileName)
{

var cgibinDir = getCGIURL();
var editorCgibinDir = getEditorCGIURL ();
var siteURL = getSiteURL();
var secureSiteURL = getSecureSiteURL();
var thirdPartyLocation = getThirdPartyLocation();

if (typeof pageType == "undefined")
{
	pageType="";
}
	
// First Perform the action on the lower frame
performAction(action,state,pageType);


var url = siteURL + cgibinURL +"/showMenuFrame.pl?userid=" + userid + "&sessionid=" + sessionid + "&loggedInFrom=" + loggedInFrom + "&isOnlyQuiz=" + isOnlyQuiz + "&typeOfUser=" + "&menuType=" + menuType + "&fileName="+fileName;

// Now, refresh the own window
// self.location = url;
if (typeof parent.menuFrame == "undefined")
{
	
}
else{
	parent.menuFrame.location = url;
}



return;

}

function killOldSession(userid,loggedInFrom,numPasswordChanges)
{
	
	var cgibinDir = getCGIURL();
	var siteURL = getSiteURL();
	var url;

	url =siteURL+cgibinDir+"/registerUserLogin.pl?userid="+userid+"&loggedInFrom="+loggedInFrom+"&pageType=1&numPasswordChanges="+numPasswordChanges;
	window.location = url;
}
	

function showThirdPartyPage(url,name,features)
{
var changedURL ;
var siteURL = getSiteURL();
	changedURL = siteURL + url;
	window.open(url,name,features);
	return;
}



function resourcesURL (action,target)
{
	var siteURL = getSiteURL();
	window.location= siteURL + cgibinURL +"/showPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&action="+action+"#"+target;
	return;
}

function checkEmailFormat(thisForm)
{

         if (thisForm.email.value.length == 0)
             {
             alert("Please enter the desired E-mail address");
             return 0;
             }

         if (thisForm.email.value.indexOf('@', 0) == -1 || thisForm.email.value.length <= 9 )
	   {
                alert("Please enter the E-mail address correctly");
                return 0;
            }

return 1;
}

function showAlertMsg(msg)
{
	// This is the final concatted string that is diplayed to user	
	if (msg.length != 0)
	{
		var mainMsg = "The following fields are required:\n" + msg;
		alert(mainMsg);
		return 0;
	}
	else
	{
		return 1;	
	}
}

function isNameOk(msg)
{

	if (document.forms[0].firstname.value.length ==0)
	{
		msg += "First Name\n";
		document.forms[0].firstname.focus();
	}
	if (document.forms[0].lastname.value.length ==0)
	{
		msg += "Last Name\n";
		if (document.forms[0].firstname.value.length ==0) { document.forms[0].firstname.focus(); }
		else {	document.forms[0].lastname.focus();	}
	}

	return msg;

}

function isLoginOk(msg,formName)
{
var loginText = "Vitalect Login";
var loginTerm = "login";
	
	if (typeof formName == "undefined")
	{
		formName = document.forms[0];
	}
	
	if (typeof formName.functionState != "undefined" && typeof formName.loggedInFrom !="undefined" && (formName.loggedInFrom.value!="DOCXI"))
	{
		if (formName.functionState.value == "NEW")
		{
			loginText ="Vitalect Username";
			loginTerm = "username";
		}
	}

	if (typeof formName.login != "undefined" || typeof formName.loggedInFrom =="undefined")
	{
		if (formName.login.value.length ==0)
		{
			msg += loginText + "\n";
		}
	}
	if (typeof formName.loggedInFrom!= "undefined" && formName.loggedInFrom.value=="DOCXI")
	{
		if (formName.login.value.length ==0)
		{
			msg += "Email" + "\n";
		}
	}

return msg;
}

function isPasswordOk(formName,msg)
{

	if (typeof formName == "undefined" && typeof formName.loggedInFrom !="undefined" && formName.loggedInFrom.value!="DOCXI")
	{
	

			if (document.forms[0].password.value.length ==0)
	        {
	                msg += "Vitalect password\n";
	        }
	}
	else
	{

			if (formName.password.value.length ==0)
	        {
	                msg += "Vitalect password\n";
	        }
	}

	if (typeof formName.loggedInFrom!= "undefined" && formName.loggedInFrom.value=="DOCXI")
	{
		if (formName.password.value.length ==0 || document.forms[0].password.value.length ==0)
		{
			msg += "Password" + "\n";
		}
	}
		

return msg;
}

function isHintAnswerOk(msg)
{

        if (document.forms[0].cluea.value.length ==0)
        {
                msg += "Hint Answer\n";
        }


return msg;
}
function isCompanyOk(msg) 
{

    if (document.forms[ 0 ].companyname.value.length == 0) { msg += "Company name\n"; }

	return msg;

}
function isOrgNameOk(msg) 
{

    if (document.forms[ 0 ].companyname.value.length == 0) { msg += "Organization name\n"; }

	return msg;

}
function isEmailOk(msg) 
{

	if (document.forms[ 0 ].email.value.length == 0) { msg += "E-mail address\n"; }
	if (document.forms[0].email.value.indexOf('@', 0) == -1 || document.forms[0].email.value.length <= 9 ) { msg += "A valid E-mail address\n"; }

	return msg;
}

function isAddressOk(msg)
{

	if (document.forms[ 0 ].street.value.length == 0) { msg += "Street Address\n";  }
	if (document.forms[ 0 ].city.value.length == 0)   { msg += "City\n";         }

	return msg;

}

function isDigit(c)
{ 

 var test = "" + c;

         if (test == "0" || test == "1" || test == "2" || test == "3" || test == "4" || test == "5" || test == "6" || test == "7" || test == "8" || test == "9")
	 {
             return 1;
         }

return 0;

}

function isAllDigits(s)
{

var test = "" + s;

	 for (var k = 0; k < test.length; k++)
 	{

	     var c = test.substring(k, k+1);

	      if (isDigit(c) == 0)
      	     {
        	 return 0;
     	     }

  	}

return 1;

}

function isDigitWithDecimal(c)
{ 

 var test = "" + c;

         if (test == "0" || test == "1" || test == "2" || test == "3" || test == "4" || test == "5" || test == "6" || test == "7" || test == "8" || test == "9" || test == ".")
	 {
             return 1;
         }

return 0;

}

function isAllDigitsWithDecimal(s)
{

var test = "" + s;

	 for (var k = 0; k < test.length; k++)
 	{

	     var c = test.substring(k, k+1);

	      if (isDigitWithDecimal(c) == 0)
      	     {
        	 return 0;
     	     }

  	}

return 1;

}

function isZipOk(msg)
{
        if (document.forms[ 0 ].zipcode.value.length ==0) { msg += "Zip Code\n"; }

		var zip = document.forms[ 0 ].zipcode.value;
		var result = isAllDigits(zip);
		result=1; 

		if (result == 0)
		{
			alert("The Zip Code entered contains an invalid character\n");
		}

	return msg;
}

/*
function isAcodeOk()
{

         if (document.forms[ 0 ].acode.value.length == 0)
             {
             alert("Please enter area code of your phone number");
             return 0;
             }

         if (isAllDigits(document.forms[ 0 ].acode.value) == 0)
             {
            	 alert("The Area code of the Phone Number entered contains an invalid character");
           	  return 0;
             }

return 1;

 }
*/
function isPhoneOk(msg)
{	

    if (document.forms[ 0 ].phone.value.length == 0) { msg += "Phone Number\n"; }
   // if (isAllDigits(document.forms[ 0 ].phone.value) == 0) { msg += "A Valid phone number (no characters)\n"; }

	if (document.forms[0].ext.value.length > 0)
	{
        if (isAllDigits(document.forms[ 0 ].ext.value) == 0)
		{
			msg += "The Phone Number Extension contains an invalid character\n";
		}
	}


	return msg;

}

function isDonationOk(msg)
{	

	if (document.forms[0].donationAmount.value.length > 0)
	{
        if (isAllDigitsWithDecimal(document.forms[ 0 ].donationAmount.value) == 0)
		{
			msg += "The Donation Amount contains invalid character(s)\n";
		}
	}


	return msg;

}

function isFaxOk(msg)

{
	if (document.forms[0].facode.value.length > 0)
	{
         if (isAllDigits(document.forms[ 0 ].facode.value) == 0)
         {
             msg += "The Fax Number entered contains an invalid character\n";
          }
         if (isAllDigits(document.forms[ 0 ].fphone.value) == 0)
         {
             msg += "The Fax Number entered contains an invalid character\n";
          }
	}
	
 return msg;

 }

function isJobDescriptionOk(msg)
{

var jobDescriptionLength = document.forms[0].jobDescription.options.length;
var jobDescriptionValue,i=0;
      
  while (i< jobDescriptionLength)
  {
    if (document.forms[0].jobDescription.options[i].selected == true)
    {
         jobDescriptionValue = document.forms[0].jobDescription.options[i].value;
         break;
    }
      i++
 }

 if (jobDescriptionValue == '0')
 {
 	msg += 'Please select your Job Description\n';

 }

 if (jobDescriptionValue == '1')
 {
	if (document.forms[0].otherJobDescription.value.length==0)
	{
		msg += 'Please enter your Job Description\n';
	}
	document.forms[0].actualJobDescription.value=document.forms[0].otherJobDescription.value;
	}
else
{
	document.forms[0].actualJobDescription.value=jobDescriptionValue;
}

return msg;

}
function isNumEmployeesOk(msg)
{

var numEmployeesLength = document.forms[0].numEmployees.options.length;
var numEmployeesValue,i=0;
      
  while (i< numEmployeesLength)
  {
    if (document.forms[0].numEmployees.options[i].selected == true)
    {
         numEmployeesValue = document.forms[0].numEmployees.options[i].value;
         break;
    }
      i++
 }

 if (numEmployeesValue == '0')
 {
 	msg += 'Select the number of Employees in your Company\n';
}

return msg;

}
function isAtypeOk(msg)
{

if (typeof document.forms[0].atype.options == "undefined")
{
	return msg;
}

var atypeLength = document.forms[0].atype.options.length;
var atypeValue,i=0;
      
  while (i< atypeLength)
  {
    if (document.forms[0].atype.options[i].selected == true)
    {
         atypeValue = document.forms[0].atype.options[i].value;
         break;
    }
      i++
 }

 if (atypeValue == '0')
 {
 	msg += 'Select Address Type for your address\n';

 }

return msg;

}
function isStateOk(msg)
{

var stateLength= document.forms[0].state.options.length;
var stateValue,i=0;
      
  while (i< stateLength)
  {
    if (document.forms[0].state.options[i].selected == true)
    {
         stateValue = document.forms[0].state.options[i].value;
         break;
    }
      i++
 }

 if (stateValue == '0')  { msg += "State / Province\n" ; }

return msg;

}


function isCountryOk(msg)
{

var countryLength= document.forms[0].country.options.length;
var countryValue,i=0;
      
  while (i< countryLength)
  {
    if (document.forms[0].country.options[i].selected == true)
    {
         countryValue = document.forms[0].country.options[i].value;
         break;
    }
      i++
 }

 if (countryValue == '0')
 {
 	msg += "Country\n"; }

return msg;

}



function areCoursesOk (msg)
{

var coursesLength= document.forms[0].courses.options.length;
var coursesValue,i=0;
var areCoursesSelected;

areCoursesSelected =0;

while (i< coursesLength)
{
    	if (document.forms[0].courses.options[i].selected == true)
    	{
    	     areCoursesSelected =1;
    	     break;
    	     
    	}
      i++
 }

 if ((areCoursesSelected == 0)&&(i == coursesLength)) { msg += 'Please select a course to register for\n'; }

return msg;

}

function isSiteIdOk(msg)
{	

    if (document.forms[ 0 ].siteid.value.length == 0) { msg += "Site Id\n"; }
    if (isAllDigits(document.forms[ 0 ].siteid.value) == 0) { msg += "A Valid Site Id (only numbers)\n"; }
     
     return msg;

}

function isRegistrationFormValid(state)
{
	var msg = "";
	if (state == 5)
	{
		msg = isNameOk(msg);
		msg = isCompanyOk(msg);
		msg = isEmailOk(msg);
		msg = isAddressOk(msg);
    	msg = isStateOk(msg);
    	msg = isZipOk(msg);
    	msg = isCountryOk(msg);
    	msg = isAtypeOk(msg);
	
    }
	else
	{
		msg = isNameOk(msg);
		msg = isLoginOk(msg);
		msg = isEmailOk(msg);
		msg = isAddressOk(msg);
		msg = isAtypeOk(msg);
    	msg = isStateOk(msg);
    	msg = isZipOk(msg);
    	msg = isCountryOk(msg);
  		
    }

	if (showAlertMsg(msg) != 0 ) {	return 1; }	
}

function isVitalectRegistrationFormValid()
{

	msg = isNameOk(msg);
	msg = isLoginOk(msg);
	msg = isEmailOk(msg);
	
    if (showAlertMsg(msg) != 0 ) {	return 1; }
}

function isExamRegistrationFormValid (restricted)
{	
	var msg = "";
	msg = isNameOk(msg);
	msg = isCompanyOk(msg);
	msg = isEmailOk(msg);   	
	
	if (typeof restricted == "undefined")
	{
		msg = isPhoneOk(msg);
		msg = isAddressOk(msg);
    		msg = isStateOk(msg);
    		msg = isZipOk(msg);
    		msg = isCountryOk(msg);
    		msg = isAtypeOk(msg);
    	}
    
    if (typeof document.forms[0].email_confirm != "undefined")
    {
 	// Do this only if the Email Confirm box is present 
 	
 	if (document.forms[0].email.value.length > 0 && (document.forms[0].email.value != document.forms[0].email_confirm.value)) 
 	{ 
 		msg += "Email doesn't match - please check and reconfirm\n"; 
 	}
    }
    
    if (showAlertMsg(msg) != 0 ) {	return 1; }
}

function isD2LRegistrationFormValid (restricted)
{	
	var msg = "";
	msg = isNameOk(msg);
	//msg = isOrgNameOk(msg);
	msg = isEmailOk(msg);   	
	
	if (typeof restricted == "undefined")
	{
		msg = isPhoneOk(msg);
		msg = isAddressOk(msg);
    	msg = isStateOk(msg);
    	msg = isZipOk(msg);
    	msg = isCountryOk(msg);
    	//msg = isAtypeOk(msg);
    }
		
	msg = isDonationOk(msg);
    if (typeof document.forms[0].email_confirm != "undefined")
    {
 	// Do this only if the Email Confirm box is present 
 	
 	if (document.forms[0].email.value.length > 0 && (document.forms[0].email.value != document.forms[0].email_confirm.value)) 
 	{ 
 		msg += "Email doesn't match - please check and reconfirm\n"; 
 	}
    }
    
    if (showAlertMsg(msg) != 0 ) {	return 1; }
}

function isMentorRegistrationFormValid ()
{

	var msg = "";
	msg = isNameOk(msg);
    if (document.forms[0].jobresp.value.length==0) { msg += "Job Title\n"; }
    msg = isCompanyOk(msg);
    // if (document.forms[0].siteid.value.length==0) { msg += "Site ID\n"; }
    // msg = isSiteIdOk(msg);
    msg = isAddressOk(msg);
    msg = isStateOk(msg);
    msg = isZipOk(msg);
    msg = isCountryOk(msg);  
    msg = isPhoneOk(msg);
    msg = isEmailOk(msg);
   if (document.forms[0].email.value.length > 0 && (document.forms[0].email.value != document.forms[0].email_confirm.value)) { msg += "Email doesn't match - please check and reconfirm\n"; }
    
   if (showAlertMsg(msg) != 0 ) {	return 1; }
}

function isLoginFormValid(formName)
{
	var msg = "";
	msg = isLoginOk(msg,formName);
	msg = isPasswordOk(formName,msg);
	
	if (showAlertMsg(msg) != 0 ) {	return 1; }
	else { return 0; }
	
}

function isCourseRegistrationFormValid(state)
{

	var userType = document.forms[0].userType.value;
	var msg = "";
	msg = areCoursesOk(msg);

	if (userType =='REGISTERED')
	{
		if (isLoginFormValid() && (showAlertMsg(msg) != 0 ))
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	else
	{
		if (isRegistrationFormValid(state) && (showAlertMsg(msg) != 0 ))
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}

return 1;

}


function isCreditCardFormValid ()
{

var cardTypeLength,expirationMonthLength,expirationYearLength;
var cardTypeValue,expirationMonthValue,expirationYearValue,i;


// Check For the Credit Card Type 

cardTypeLength= document.forms[0].cardType.options.length;

i=0;

while (i< cardTypeLength)
{
    	if (document.forms[0].cardType.options[i].selected == true)
    	{
	     cardTypeValue = document.forms[0].cardType.options[i].value;
    	     break;
    	     
    	}
      i++
 }
 
if (cardTypeValue =='0')
{
	alert('Please select the type of Credit Card');
	return 0;
}

// Check For the Card Number

if (document.forms[0].cardNumber.value =="")
{
	alert('Please enter your Credit Card Number');
	return 0;
}

// Check For the Month

expirationMonthLength= document.forms[0].expirationMonth.options.length;

i=0;

while (i< expirationMonthLength)
{
    	if (document.forms[0].expirationMonth.options[i].selected == true)
    	{
	     expirationMonthValue = document.forms[0].expirationMonth.options[i].value;
    	     break;
    	     
    	}
      i++
 }
 
if (expirationMonthValue =='0')
{
	alert('Please select the Month for the Expiration Date');
	return 0;
}

// Check For the Year

expirationYearLength= document.forms[0].expirationYear.options.length;

i=0;

while (i< expirationYearLength)
{
    	if (document.forms[0].expirationYear.options[i].selected == true)
    	{
	     expirationYearValue = document.forms[0].expirationYear.options[i].value;
    	     break;
    	     
    	}
      i++
 }

if (expirationYearValue =='0')
{
	alert('Please select the Year for the Expiration Date');
	return 0;
}

return 1;

}

function isSupportFormValid()
{

if (document.forms[ 0 ].browser.value.length == 0)
{
   alert("Please enter the Browser name");
   return 0;
}
if (document.forms[ 0 ].browserver.value.length == 0)
{
    alert("Please enter the version of the Browser");
    return 0;
}
if (document.forms[ 0 ].os.value.length == 0)
{
    alert("Please enter the Operating System ");
    return 0;
}
if (document.forms[ 0 ].osver.value.length == 0)
{
    alert("Please enter the version of the Operating System");
    return 0;
}
if (document.forms[ 0 ].summary.value.length == 0)
{  
    alert("Please enter a brief summary for your problem");
    return 0;
}

if (document.forms[ 0 ].details.value.length == 0)
{
    alert("Please enter the details of the problem");
    return 0;
}

// The form entries are valid - hence ready to be posted
return 1;

}

function isSearchFormValid ()
{

	if (document.forms[0].keywords.value.length==0)
	{
		alert ('Please enter the keywords to be searched');
		return 0;
	}


// The form entries are valid - hence ready to be posted
return 1;

}

function isATEFormValid()
{

var categoryength;
var i=0,categoryValue;

// Check for category validity 

categoryLength = document.forms[0].category.options.length;

        while (i< categoryLength)
        {
                if (document.forms[0].category.options[i].selected == true)
                {
                        categoryValue = document.forms[0].category.options[i].value;
                        break;
                }
        i++
        }

	if (categoryValue == '0')
	{
		alert ('Please select the category to which you want to post');
		return 0;
	}

// Check for question validity 

	if (document.forms[0].question.value.length==0)
	{
		alert ('Please enter the question to be posted');
		return 0;
	}


// The form entries are valid - hence ready to be posted
return 1;

}

function isSigPostFormValid()
{

	var signameLength;
	var i=0,signameValue;
	
	// Check For Email Validity 
	var msg = "";
	msg = isEmailOk(msg);
	if (showAlertMsg(msg) == 0 )
	{
		return 0;
	}

// Check for SIG name  validity 

signameLength = document.forms[0].signame.options.length;
        while (i< signameLength)
        {
                if (document.forms[0].signame.options[i].selected == true)
                {
                        signameValue = document.forms[0].signame.options[i].value;
                        break;
                }
        i++
        }

	if (signameValue == '0')
	{
		alert ('Please select the SIG to which you want to post');
		return 0;
	}

// Check for Message validity 

	if (document.forms[0].message.value.length==0)
	{
		alert ('Please enter the message to be posted');
		return 0;
	}

// Confirm whether the user wants the Subject to be empty
	
	if (document.forms[0].subject.value.length==0)
	{
		if (confirm('Subject field is blank - continue posting ?'))
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	
// The form entries are valid - hence ready to be posted

return 1;

}

function isSigRegFormValid()
{

// Check for selected Action
if (! ((document.forms[0].sigAction.options[1].selected==true) || (document.forms[0].sigAction.options[2].selected==true)))
{
	alert ("You must select the action to be performed: Subscribe or Unsubscribe");
	return 0;
}

// Check For Email Validity 

	var msg = "";
	msg = isEmailOk(msg);
	if (showAlertMsg(msg) == 0 )
	{
		return 0;
	}
// Check whether at least one of the options has been checked 

if ((document.forms[0].checkbox1.checked == 0)&&(document.forms[0].checkbox2.checked == 0)&&(document.forms[0].checkbox3.checked == 0)&&(document.forms[0].checkbox4.checked == 0)&&(document.forms[0].checkbox5.checked == 0)&&(document.forms[0].checkbox6.checked==0))
{
	alert ("You must select at least one of the SIGs to Register");
	return 0;
}


// The form entries are valid - hence ready to be posted

return 1;

}

function isProfileFormValid()
{
	var msg = "";
	msg = isNameOk(msg);
	msg = isCompanyOk(msg);
	msg = isAddressOk(msg);
	msg = isZipOk(msg);
	msg = isHintOk(msg);
	
	if (showAlertMsg(msg) != 0 )
	{
		return 1;
	}

	return 0;
}

function isPasswordFormValid()
{
         
	if (document.forms[ 0 ].cpwd.value.length == 0)
        {
             alert("Please enter your current Vitalect password");
             return 0;
        }
         if (document.forms[ 0 ].npwd1.value.length == 0)
        {
             alert("Please enter you new Vitalect password");
             return 0;
         }
        if (document.forms[ 0 ].npwd2.value.length == 0)
        {
             alert("Please confirm your new Password by entering it again");
              return 0;
        }

         if (document.forms[ 0 ].npwd1.value != document.forms[0].npwd2.value)
             {
             alert("The new Password and its Confirmation do not match");
             return 0;
        	}

	if (typeof document.forms[0].clueqpass != "undefined")
	{
		if ((document.forms[ 0 ].clueqpass.value.length !=0) && (document.forms[0].clueapass.value.length ==0))
		{ 
	             alert("Please enter the Answer to your Hint Question");
	             return 0;
		}
	}



return 1;
}

function isHintPasswordFormValid()
{
         
	
         if (document.forms[ 0 ].npwd1.value.length == 0)
        {
             alert("Please enter you new Vitalect password");
             return 0;
         }
        if (document.forms[ 0 ].npwd2.value.length == 0)
        {
             alert("Please confirm your new Password by entering it again");
              return 0;
        }

         if (document.forms[ 0 ].npwd1.value != document.forms[0].npwd2.value)
         {
             alert("The new Password and its Confirmation do not match");
             return 0;
       	}

return 1;
}

function isForgotPasswordFormValid()
{
    var msg = "";
    msg = isLoginOk(msg);
    msg = isEmailOk(msg);
    
	if (showAlertMsg(msg) != 0 ) {	return 1; }
    else { return 0; }
}


function isJoinExpertsFormValid()
{

// Check For Email Validity 
	var msg = "";
   	msg = isLoginOk(msg);
    msg = isEmailOk(msg);
	
	if (document.forms[0].workSummary.value.length==0)
	{
		msg = 'Please enter a brief work summary';
	}
	
	// The form entries are valid - hence ready to be posted
	if (showAlertMsg(msg) != 0 ) {	return 1; }
	else { return 0; }

}

function isRegQuizEntryFormValid()
{
var categoryLength,correctLength,difficultyLength;
var i=0,categoryValue,correctValue,difficultyValue;

// Check for the question
 
  if (document.forms[ 0 ].question.value.length == 0)
  {
       alert("Please enter your Question");
       return 0;
  }

// Check whether the choices have been entered or not 
        
 if ((document.forms[ 0 ].choice1.value.length == 0)||
        (document.forms[0].choice2.value.length==0) ||
        (document.forms[0].choice3.value.length==0) ||
        (document.forms[0].choice4.value.length==0))
 {
      alert("Please enter all the choices for the question");
      return 0;
 }

// Check for the Correct Choice

correctLength = document.forms[0].correctchoice.options.length;

while (i< correctLength)
{
    if (document.forms[0].correctchoice.options[i].selected == true)
   {
        correctValue = document.forms[0].correctchoice.options[i].value;
        break;
    }
        i++
}

if (correctValue == '0')
{
	alert ('Please select the Correct Choice for your Question');
	return 0;
}
 
// Check for the Keyword
 
if (document.forms[ 0 ].keyword.value.length == 0)  
{
      alert("Please enter the Keyword for the question");
      return 0;
}  


// Check for the Category 

i=0;
categoryLength = document.forms[0].category.options.length;

while (i< categoryLength)
{
    if (document.forms[0].category.options[i].selected == true)
   {
        categoryValue = document.forms[0].category.options[i].value;
        break;
    }
        i++
}

if (categoryValue == '0')
{
	alert ('Please select the Category to which your question belongs');
	return 0;
}

// Check for the Difficulty Level 

i=0;
difficultyLength = document.forms[0].level.options.length;

while (i< difficultyLength)
{
    if (document.forms[0].level.options[i].selected == true)
   {
        difficultyValue = document.forms[0].level.options[i].value;
        break;
    }
        i++;
}

if (difficultyValue == '0')
{
	alert ('Please select a Difficulty Level for your Question');
	return 0;
}

// Check for the Explanation
 
if (document.forms[ 0 ].explanation.value.length == 0)  
{
     alert("Please enter the Explanation for the question");
     return 0;
}

// The form entries are valid - hence ready to be posted
return 1;

}

function isSendPageFormOk()
{
        if (document.forms[0].name.value.length==0)
        {
                alert ('Please enter the name of your friend');
                return 0;
        }
        var msg = "";
        msg = isEmailOk(msg);
        if (showAlertMsg(msg) == 0) 
		{	
			return 0; 
		}
		if (document.forms[0].myname.value.length==0)
        {
                alert ('Please enter your name');
                return 0;
        }

return 1;
}

function isBecomePartnerFormOk()
{
   		var msg = "";
   		msg = isNameOk(msg);
   		msg = isEmailOk(msg);
   		msg = isCompanyOk(msg);
   		msg = isAddressOk(msg);
   		
        if (document.forms[0].phone.value.length==0)
        {
                msg = 'Please enter your Phone Number';
        }
        if (document.forms[0].title.value.length==0)
        {
                msg = 'Please enter your Job Title';
        }
		if (showAlertMsg(msg) == 0 )
		{
				return 0;
		}
return 1;
}

function isPlaceAdFormOk()
{
	var msg = "";
	msg = isCompanyOk(msg);
	msg = isNameOk(msg);
	msg = isEmailOk(msg);
	

	if (document.forms[0].phone.value.length==0)
	{
		msg = 'Please enter your telephone number';
	}
	if (document.forms[0].message.value.length==0)
	{
		msg = 'Please enter a brief message';
	}
	if (showAlertMsg(msg) == 0 )
	{
		return 0;
	}
	
	return 1;
}

function isFeedbackFormOk()
{
	var msg = "";
	msg = isEmailOk(msg);
	
	if (document.forms[0].message.value.length==0)
	{
			msg = 'Please enter your feedback';
	}
	if (showAlertMsg(msg) == 0 )
	{
			return 0;
	}
	return 1;
}

function startQuiz()
{

var oslength = document.forms[0].os.options.length;
var i=0,osvalue;
var url;

        while (i< oslength)
        {
                if (document.forms[0].os.options[i].selected == true)
                {
                        osvalue = document.forms[0].os.options[i].value;
                        break;
                }
        i++
        }

	if (osvalue == '0')
	{
		alert ('Please select your operating system');
		return;
	}

var siteURL = getSiteURL();
	url = siteURL + cgibinURL+"/takeQuiz.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&quizType="+osvalue;
	window.open(url,'quizWindow','scrollbars,resizable,height=560,width=800');
        
return;

}

function ictipsLogout()
{
var siteURL = getSiteURL();
	if (confirm("Are you sure you want to logout?"))
	{
		var cookieName = loggedInFrom + "LoginRememberMe";
		deleteCookie(cookieName);

		if (loggedInFrom == "D2L")
		{
			var logCookieName =""+userid+"LoginUserid";
			deleteCookie(logCookieName);
		}

		top.location = siteURL + cgibinURL+"/registerLogout.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&isOnlyQuiz="+isOnlyQuiz;
	return;
	}	
	return;
}

function doCookieTasks()
{

// First Read all the cookies in the current document

var allCookies = document.cookie;
var expiresAfter = 15;
var expiration;

// Time in milliseconds
expiresAfter = 15*24*3600000;
expiration = new Date((new Date()).getTime() + expiresAfter);

var value = allCookies.indexOf("ictipsCookie");

if (value == -1)
{
// cookie has not been set 
return;
//	document.cookie="ictipsCookie=1;expires="+expiration.toGMTString();
//	loadTour();
}
else
{
// cookie has been found
}

return;
}	

function loadTour()
{


// Detect for Flash 
         if ((navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") == -1 &&  navigator.appVersion.indexOf("3.1") == -1) || (navigator.plugins && navigator.plugins["Shockwave Flash"]) || (navigator.plugins["Shockwave Flash 2.0"]))
	{
              	// open a flashed tour
           	window.open('/ictour/flashed', 'tour', 'status=yes,toolbar=no,scrollbars=yes,location=no,directories=no,resize=yes,copyhistory=no,width=680,height=540');
         }
        else 
	{
              	// open a non flashed tour
           	window.open('/ictour/nonflashed', 'tour', 'status=yes,toolbar=no,scrollbars=yes,location=no,directories=no,resize=yes,copyhistory=no,width=680,height=540');
               
	}


return ;
}

function enterTheCourse (pageType,callbackURL,callbackSID)
{
callbackURL = escape(callbackURL);
callbackSID = escape(callbackSID);

    var siteURL = getSiteURL();
    window.location = siteURL + "/cgi-bin/showProgress/takeCourse.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&courseid="+courseid+"&fromPage=1"+"&pageType="+pageType+"&callbackURL="+callbackURL+"&callbackSID="+callbackSID;
	return;
}

function initialise(courseid)
{
	
	if (typeof self.notesWindowHandle != "undefined")
	{
		if (!self.notesWindowHandle.closed)
		{
			self.notesWindowHandle.close();
		}
	}
	
	if (typeof self.audioScriptWindowHandle != "undefined")
	{
		if (!self.audioScriptWindowHandle.closed)
		{
			self.audioScriptWindowHandle.close();
		}
	}
return ;
}


function startTheCourse (courseId,courseName,fromPage,version,action,loginId,email,launchurl,companyName)
{

var url;

var siteURL = getSiteURL();
var lmsurl = siteURL + "/cgi-bin/aicc/lmsActions.pl?courseid=" + courseId;
	
	if (fromPage ==1)
	{
		if (isOnlyQuiz == '1')
		{
			url = siteURL + "/cgi-bin/showProgress/takeCourse.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&courseid="+courseId+"&fromPage="+fromPage+"&isOnlyQuiz="+isOnlyQuiz+"&action="+action+"&companyName="+companyName;
		}
		else
		{
		
			url = siteURL + "/cgi-bin/showProgress/takeCourse.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&courseid="+courseId+"&fromPage="+fromPage+"&isOnlyQuiz="+isOnlyQuiz+"&companyName="+companyName;
			
		}
		if ((loggedInFrom =='DACAFE')&&(courseId =='a'))
		{
			window.location = url;
	
		}
		else
		{
			if (typeof self.wbtHandle != "undefined")
			{
				initialise(courseId);
			}			
			var name = new Date();
			// alert (url);
			self.CURRENT_SCO_ID = courseId;
			// For Docxi, open the window in a bigger size	
			if (loggedInFrom == 'DOCXI')
			{
				self.wbtHandle = window.open(url,courseId,'status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=1024,height=768,dependent=false');
			}else if (loggedInFrom == 'ALTRION'){
		              self.wbtHandle = window.open(url,courseId,'status=no,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=1024,height=768');

			}
			else if (loggedInFrom == 'D2L'){
                              self.wbtHandle = window.open(url,courseId,'status=no,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=no,directories=no,copyhistory=no,width=1024,height=525');

                        }

			else
			{
				self.wbtHandle = window.open(url,courseId,'status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=800,height=600,dependent=false');
			}
		}
		
	}
	else
	{

        	if (isSurveyFormValid())
		{
			document.forms[0].action=siteURL + "/cgi-bin/showProgress/takeCourse.pl";
			document.forms[0].userid.value=userid;
			document.forms[0].sessionid.value=sessionid;
			document.forms[0].loggedInFrom.value=loggedInFrom;
			document.forms[0].courseid.value=courseId;
			document.forms[0].fromPage.value=fromPage;
			document.forms[0].submit();
		}
	}
	return;
}

function startTheQuiz (courseId,courseName,fromPage,version,loginId)
{
var url;

var siteURL = getSiteURL();

	if (fromPage ==1)
	{
	
		if (version < 100) {
			url = siteURL + cgibinURL +"/takeWBLQuiz.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&courseid="+courseId+"&fromPage="+fromPage;
		} else {
			url = "http://psdev:8001/j/vitalect?userid="+userid+"&sessionid=12&objectid="+courseId+"&cms_role=learner&action=view&loginid="+loginId+"&courseName="+escape(courseName);
		}	
		var name = new Date();
		self.quizHandle = window.open(url,courseId,'status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=800,height=600,dependent=false');
	}
	else
	{

        	if (isSurveyFormValid())
		{
			document.forms[0].action=siteURL + cgibinURL+"/takeWBLQuiz.pl";
			document.forms[0].userid.value=userid;
			document.forms[0].sessionid.value=sessionid;
			document.forms[0].loggedInFrom.value=loggedInFrom;
			document.forms[0].courseid.value=courseId;
			document.forms[0].fromPage.value=fromPage;
			document.forms[0].submit();
		}
	}

return;
}


function startTheCourseLite (courseId,courseName,fromPage,version,action,loginId,email,launchurl,callbackURL,callbackSID,fromVariable)
{

var url;

var siteURL = getSiteURL();
var lmsurl = siteURL + "/cgi-bin/aicc/lmsActions.pl?courseid=" + courseId;

callbackURL = escape(callbackURL);
callbackSID = escape(callbackSID);

if (isOnlyQuiz == '1')
{
	//alert (action);
	url = siteURL + "/cgi-bin/showProgress/takeCourse.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&courseid="+courseId+"&fromPage="+fromPage+"&isOnlyQuiz="+isOnlyQuiz+"&action="+action+"&callbackURL="+callbackURL+"&callbackSID="+callbackSID;
}
else
{

	url = siteURL + "/cgi-bin/showProgress/takeCourse.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&courseid="+courseId+"&fromPage="+fromPage+"&isOnlyQuiz="+isOnlyQuiz+"&callbackURL="+callbackURL+"&callbackSID="+callbackSID;

}

if (fromVariable == 'CLOSE')
{
	window.open(url,courseId,'status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=800,height=600,dependent=false');
	self.close();
}
else
{
	window.location = url;
}	
return;

}

function isSurveyFormValid ()
{
// Check for the Preflanguage Radio button

        var preflangvalue="XXX";
        var i=0;

        for (i=0;i<5;i++)
        {
                if (document.forms[0].preflang[i].checked==1)
                {
                        preflangvalue=document.forms[0].preflang[i].value;
                        break;
                }
        }
        if (preflangvalue == 'XXX')
        {
                alert("Please select your preferred design language");
                return 0;
        }
        else
        {
                if (preflangvalue =='Other')
                {
                        preflangvalue=document.forms[0].preflangother.value;
                        if (preflangvalue.length ==0 )
                        {
                                alert('Please enter your preferred design language');
                                return 0;
                        }
                }
        }



// Check for the workex Radio button

        var workexvalue="XXX";

        for (i=0;i<6;i++)
        {
                if (document.forms[0].workex[i].checked==1)
                {
                        workexvalue = document.forms[0].workex[i].value;
                        break;
                }
        }
        if (workexvalue == 'XXX')
        {
                alert("Please select your work experience");
                return 0;
        }

// Check for the designfor Radio button


        var designforvalue="XXX";

        for (i=0;i<4;i++)
        {
                if (document.forms[0].designfor[i].checked==1)
                {
                        designforvalue=document.forms[0].designfor[i].value;
                        break;
                }
        }
        if (designforvalue == 'XXX')
        {
                alert("Please select what you design for");
                return 0;
        }


// Check for the expertise Radio button


        var expertisevalue="XXX";

        for (i=0;i<5;i++)
        {
                if (document.forms[0].expertise[i].checked==1)
                {
                        expertisevalue=document.forms[0].expertise[i].value;
                        break;
                }
        }
        if (expertisevalue == 'XXX')
        {
                alert("Please select your field of expertise");
                return 0;
        }
        else
        {
                if (expertisevalue =='Other')
                {
                        expertisevalue=document.forms[0].expertiseother.value;
                        if (expertisevalue.length ==0 )
                        {
                                alert('Please enter your area of expertise');
                                return 0;
                        }
                }
        }

// Check for the designtarget Radio button


        var designtargetvalue="XXX";

        for (i=0;i<6;i++)
        {
                if (document.forms[0].designtarget[i].checked==1)
                {
                        designtargetvalue=document.forms[0].designtarget[i].value;
                        break;
   }
        }
        if (designtargetvalue == 'XXX')
        {
                alert("Please select the target for your designs");
                return 0;
        }
        else
        {
                if (designtargetvalue =='Other')
                {
                designtargetvalue=document.forms[0].designtargetother.value;

                        if (designtargetvalue.length ==0 )
                        {
                                alert('Please enter the target for your designs');
                                return 0;
                        }
                }
        }


// Check for the jobresp Checkbox button

        var found=0;
        var jobrespvalue="";

        if (document.forms[0].jobresp1.checked==1)
        {
                jobrespvaluetemp=document.forms[0].jobresp1.value;
                jobrespvalue =jobrespvalue+jobrespvaluetemp+",";
                found =1;
        }
        if (document.forms[0].jobresp2.checked==1)
        {
                jobrespvaluetemp=document.forms[0].jobresp2.value;
                jobrespvalue =jobrespvalue+jobrespvaluetemp+",";
                found =1;
        }
        if (document.forms[0].jobresp3.checked==1)
        {
                jobrespvaluetemp=document.forms[0].jobresp3.value;
jobrespvalue =jobrespvalue+jobrespvaluetemp+",";
                found =1;
        }
        if (document.forms[0].jobresp4.checked==1)
        {
                jobrespvaluetemp=document.forms[0].jobresp4.value;
                jobrespvalue =jobrespvalue+jobrespvaluetemp+",";
                found =1;
        }
        if (document.forms[0].jobresp5.checked==1)
        {
                jobrespvaluetemp=document.forms[0].jobresp5.value;
                jobrespvalue =jobrespvalue+jobrespvaluetemp+",";
                found =1;
        }
        if (document.forms[0].jobresp6.checked==1)
        {
                jobrespvaluetemp=document.forms[0].jobresp6.value;
                jobrespvalue =jobrespvalue+jobrespvaluetemp+",";
                found =1;
        }
        if (document.forms[0].jobresp7.checked==1)
        {
                jobrespvaluetemp=document.forms[0].jobresp7.value;
                jobrespvalue =jobrespvalue+jobrespvaluetemp+",";
                found =1;
        }
        if (document.forms[0].jobresp8.checked==1)
        {
                jobrespvaluetemp=document.forms[0].jobrespother.value;
                        if (jobrespvaluetemp.length==0)
                        {
                                alert('Please enter your other job responsisbilties');
                                return 0;
                        }
                found =1;
                jobrespvalue =jobrespvalue+jobrespvaluetemp+" ";
        }

        if (found==0)
        {
         	alert("Please select your job responsibilities");
	                return 0;
	       }
	
	
	        document.forms[0].preflangother.value = preflangvalue ;
	        document.forms[0].workexother.value = workexvalue ;
	        document.forms[0].designforother.value = designforvalue ;
	        document.forms[0].expertiseother.value = expertisevalue ;
	        document.forms[0].jobrespother.value = jobrespvalue ;
        	document.forms[0].designtargetother.value = designtargetvalue ;


return 1;

}

function examSelectFormOk (formName) {

// First find out the total elements in the form

var i,j;

var numSelected = 0;
var selectedCoursesArray = new Array ();
var courseIndexArray = new Array ();
var seriesCoursesArray = new Array ();

var numSessionsSelected = 0;
var sessionsArray = new Array ();
var asyncCoursesArray = new Array ();
var asyncCourseNamesArray = new Array ();
var sessionNamesArray = new Array ();
var seriesArray = new Array ();
var selectedSeriesArray = new Array ();

var coursesLength = formName.courseCount.value;
var sessionsLength = formName.liveSessionsCount.value;
var asyncCoursesLength = 0;

var asyncCourseValue,courseValue,sessionName,asyncCourseName;
var seriesIdValue;


// alert ("coursesLength " + coursesLength);
for (i=0;i<coursesLength;i++)
{
	var elementValue = eval("formName." + "course" + i  + ".value");
	var isChecked = eval("formName." + "course" + i  + ".checked");
	var isSeriesValue = eval("formName." + "isSeries" + i  + ".value");
	//alert ("The Element Value: "+elementValue+ " and Checked is: "+isChecked);
	// alert("Pushing Course = " + elementValue + " with a value of = " + i);
	courseIndexArray[elementValue] = i;
	
	if (isChecked)
	{
		var courseLocation=eval("formName." + "courseLocation" + i);
		if (typeof courseLocation != "undefined")
		{
			var courseLocationValue=eval("formName." + "courseLocation" + i+ ".value");
		
			if (courseLocationValue == "-1")
			{
					alert ('Please select the course location');
					return 0;
			}
		}
		var courseDate=eval("formName." + "courseDate" + i);
		if (typeof courseDate != "undefined")
		{
			var courseDateValue=eval("formName." + "courseDate" + i+ ".value");
			if (courseDateValue == "-1")
			{
					alert ('Please select the course date');
					return 0;
			}

		}

		selectedCoursesArray[numSelected] = elementValue;
		numSelected ++;
		// alert("1");
		
		if (isSeriesValue == 1)
		{
			seriesArray[elementValue] = 1;
		}
		else
		{
			// alert("2");
			//alert ("Element Value is: "+elementValue);
			seriesIdValue = eval("formName." + elementValue + ".value");
			//alert("The Series Id Value is: "+seriesIdValue);
			if (seriesIdValue != "noseries")
			{
				if (typeof selectedSeriesArray[seriesIdValue] == "undefined")
				{
					selectedSeriesArray[seriesIdValue] = 0;
					seriesCoursesArray[seriesIdValue] = new Array();
				}
				selectedSeriesArray[seriesIdValue] = selectedSeriesArray[seriesIdValue] + 1;
				var length = (seriesCoursesArray[seriesIdValue]).length;
				seriesCoursesArray[seriesIdValue][length] = elementValue;
			}
		}
	}
	else
	{
		if (isSeriesValue == 1)
		{
			seriesArray[elementValue] = 0;
		}
	}
}

// First check whether there are any duplicate array selections

var selectedNumber,numberOfCourses;

for (var key in selectedSeriesArray) 
{ 
	// alert("3");

	// First Check whether this series has itself been selected
	if (seriesArray[key] == 1)
	{
//		alert("You have selected to register for a series and a module \n" + 
//		      "within the same series.\n\n" + 
//		      "Registering for a series alone will automatically register you for all the modules \n" + 
//		      "within the series.");		      
		
		var length = seriesCoursesArray[key].length;
		for (i=0; i< length; i++)
		{
			var tempValue = seriesCoursesArray[key][i];
			var elementIndex = courseIndexArray[tempValue];
			var tempElement = eval("formName." + "course" + elementIndex )
			tempElement.checked = 0;
		}
		
		// return 0;
	}
	//alert ("The key is: "+key);	
	selectedNumber = selectedSeriesArray[key];
	numberOfCourses = eval("formName." +  key  + ".value");
	
	if (selectedNumber == numberOfCourses)
	{
		// Check whether the series has been checked or not
		if (seriesArray[key] == 0)
		{
//			alert("You have selected to register for all the modules within a specific series.\n\n" + 
//			"Its normally cheaper to register for an entire series than to register for each module individually\n" + 
//			"within the series.");		      
			
			var elementIndex = courseIndexArray[key];
			var tempElement = eval("formName." + "course" + elementIndex )
			tempElement.checked = 1;
			
			var length = seriesCoursesArray[key].length;

			for (i=0; i< length; i++)
			{
				var tempValue = seriesCoursesArray[key][i];
				var elementIndex = courseIndexArray[tempValue];
				var tempElement = eval("formName." + "course" + elementIndex )
				tempElement.checked = 0;
			}
			
			
			//return 0;
		}
				

	}
} 

// Check whether any live session has been selected 
for (i=0; i < sessionsLength; i++)
{
	var elementValue = eval("formName." + "liveSessions" + i  + ".value");
	var isChecked = eval("formName." + "liveSessions" + i  + ".checked");

	if (isChecked)
	{
		sessionsArray[numSessionsSelected] = elementValue;
		var elementValue = eval ("formName." + "async" + i + ".value"); 
		// alert('Async Course = ' + elementValue);
		if (elementValue != "SYNCHRONOUS")
		{
			asyncCoursesLength = asyncCoursesArray.length;
			// alert('Inside ... Async Course = ' + elementValue);
			asyncCoursesArray[asyncCoursesLength] = elementValue;
	
			elementValue = eval ("formName." + "asyncName" + i + ".value");
			asyncCourseNamesArray[asyncCoursesLength] = elementValue;

			elementValue = eval ("formName." + "liveSessionsName" + i + ".value");
			sessionNamesArray[asyncCoursesLength] = elementValue;
			
		}
			
		numSessionsSelected ++;
	}
}

if (numSelected == 0)
{
	// No Asynchronous Courses/Exams have been selected 
	
	if (formName.isOnlyQuiz.value == '0')
	{
		if (sessionsLength == 0)
		{
			// No Live Sessions present	
			alert ('Please select at least one course to register');
			return 0;
		}
		else
		{
			if (numSessionsSelected == 0)
			{
				// No Live Sessions selected
				alert('Please select either a course or a live session');
				return 0;	
			}
			
		}
	}
	else
	{
		alert ('Please select at least one exam to register');
		return 0;
	}

	
		
}


asyncCoursesLength = asyncCoursesArray.length;

// Courses/Exams have been selected 
if (asyncCoursesLength > 0)
{	
	// We need to check whether the specific async course was selected or not
	for (i=0; i < asyncCoursesLength; i ++)
	{
		asyncCourseValue = asyncCoursesArray[i];
		var isSelected = 0;		
		for (j = 0; j < numSelected ; j ++)
		{
			courseValue = selectedCoursesArray[j];
			if (courseValue == asyncCourseValue)
			{
				isSelected = 1
				break
			}
		}
		if (!isSelected)
		{
			asyncCourseName = asyncCourseNamesArray[i];
			sessionName = sessionNamesArray[i];
			
			alert("One of the Live Sessions selected '" + sessionName + "' belongs to a \n" +
			 	"self-paced course '" + asyncCourseName + "'\n" + 
			 	"You need to select the self-paced course as well");
			return 0;
		}
	}
}	

return 1;
}


function showProgressDetails (seriesid,isSeries,courseid) 
{
var url = "/cgi-bin/showProgress/showProgressDetails.pl?userid="+userid+"&sessionid="+sessionid+"&seriesid="+seriesid+"&isSeries="+isSeries+"&courseid="+courseid;
var siteURL = getSiteURL();
url = siteURL + url;

var windowHandle = window.open(url,'COURSE_PROGRESS','status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=600,height=600,dependent=false');

return;


}


function getClientCookie (cookieName)
{
 var cookieString = document.cookie;
  // alert(cookieString);
  var cookieSet = cookieString.split (';');
  var setSize = cookieSet.length;
  var cookiePieces;
  var returnValue = "";
  var x = 0;

  for (x = 0; x < setSize; x++)
  {
    cookiePieces = cookieSet[x].split ('=');

    if (cookiePieces[0].substring (0,1) == ' ')
    {
      cookiePieces[0] = cookiePieces[0].substring (1, cookiePieces[0].length);
    }

    if (cookiePieces[0] == cookieName)
    {
      returnValue = cookiePieces[1];
      break;
   }

  }


return returnValue;
}

// These functions are required by the Editor - myCourses.htpl

function replaceChars(entry) {

var out = "."; // replace this
var add = "_"; // with this
var temp = "" + entry; // temporary holder

var pos;

while (temp.indexOf(out)>-1)
{
	pos= temp.indexOf(out);
	temp = "" + (temp.substring(0, pos) + add +
	temp.substring((pos + out.length), temp.length));
}

// Now replace the - with _ 

out = "-"; // replace this
add = "_"; // with this

pos = 0;

while (temp.indexOf(out)>-1)
{
	pos= temp.indexOf(out);
	temp = "" + (temp.substring(0, pos) + add +
	temp.substring((pos + out.length), temp.length));
}

return temp;

}

function StartEdit(courseid,pageType)
{
	url = "/cgi-bin/editor/editorEntry.pl?userid=" + userid + "&sessionid=" + sessionid + "&loggedInFrom=" + loggedInFrom + "&courseid="+courseid+"&pageType="+pageType;
	options = "status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=800,height=600,screenX=30,screenY=0,left=30,top=0";
	var tempURL = SITE_URL;
	var lead_slashes = tempURL.indexOf("//");
	var domain_start = lead_slashes + 2;
	var without_resource = tempURL.substring(domain_start, tempURL.length);
	without_resource = without_resource + '_EDITOR';
	without_resource = escape(without_resource);
	without_resource = replaceChars(without_resource);
	without_resource = without_resource + "_" + courseid;
	
	// First Check whether this name has been stored or not 
	var nameCounterValue = nameCounterArray[without_resource];
	// alert(nameCounterValue);
	if (typeof nameCounterValue == "undefined")
	{
		nameCounterValue = 1;
	}
	else
	{
		nameCounterValue ++ ;
	}
	
	nameCounterArray[without_resource]=nameCounterValue;
	
	without_resource = without_resource + "_" + nameCounterValue;
	// alert(without_resource);
	
	var wbtHandle = window.open(url,without_resource,options);
	
	registerWindowHandle(url,without_resource,wbtHandle);
}
 

function registerWindowHandle (url,name,windowHandle)
{
	// Check whether this name has already been stored
	var windowHandleValue = windowHandleArray[name];

	if (typeof windowHandleValue == "undefined")
	{
		windowHandleArray[name]= windowHandle;
		var windowNameLength = windowNameArray.length;
		windowNameArray[windowNameLength]=name;
	}
	else
	{
		windowHandleArray[name]= windowHandle;
	}
return;

}

function closeOtherWindows (windowHandle)
{
	// First figure out the total number of windows that have registered
	var windowNameLength = windowNameArray.length;
	var i;

	// alert(windowNameLength);
	var focusWindow;
	for (i=0;i<windowNameLength;i++)
	{
		var windowName = windowNameArray[i];
		
		// Find out the corresponding value of this
		var storedHandle = windowHandleArray[windowName];

		if (storedHandle == windowHandle)
		{
			// alert('This window will remain');
			focusWindow = storedHandle;
			// storedHandle.focus();
			
		}
		else
		{
			if (typeof storedHandle != "undefined")
			{
				// alert('This window will be closed');
				if (typeof storedHandle.close != "undefined")
				{
					storedHandle.close();
				}
				else
				{	
					// alert('Ok - This has already been closed');
				}
			}
			else
			{
				// alert('storedHandle is undefined');
			}
		}
	}
	
	// Every thing is done - now focus on the window 
	if (typeof focusWindow.focus != "undefined")
	{
		focusWindow.focus();
	}

return;
}

function LCMSCourseExit ()
{
	
// This is called by the LCMS when the Exit button is clicked
// Reload the Window after 1000 ms
setTimeout("self.location.reload()",5000);	

return;
}


function isHintOk(msg)
{
	if (typeof document.forms[0].clueqpass != "undefined")
	{
		if ((document.forms[ 0 ].clueqpass.value.length !=0) && (document.forms[0].clueapass.value.length ==0))
		{ 
			msg += "Password Hint Answer\n"; 
		}
	}

	return msg;
}

function isCertificationFormValid ()
{

	// Check whether at least one of the fields have been entered
	if ((document.forms[0].firstName.value.length == 0) && (document.forms[0].lastName.value.length == 0) && (document.forms[0].companyName.value.length == 0) && (document.forms[0].loginid.value.length == 0))
	{
		alert('Please enter a Search Criteria');
		return 0;
	}

// The form entries are valid - hence ready to be posted
return 1;

}

function getCookie (cookieName)
{
	var cookieString = document.cookie;
	var cookieSet = cookieString.split (';');
	var setSize = cookieSet.length;
	var cookiePieces;
	var returnValue = "";
	var x = 0;

	for (x = 0; x < setSize; x++)
	{
		cookiePieces = cookieSet[x].split ('=');
		// alert(cookiePieces);

		if (cookiePieces[0].substring (0,1) == ' ')
		{
			cookiePieces[0] = cookiePieces[0].substring (1, cookiePieces[0].length);
		}

		if (cookiePieces[0] == cookieName)
		{
			returnValue = cookiePieces[1];
		}

	   }

return returnValue;

}

function setNewCookie (cookieName,cookieValue,expiry,domain,path)
{

	var expDate = new Date();
	var string;

	// alert ('Setting the cookie for ' + cookieName + " whose value is " + cookieValue);

	if(expiry)
	{
		       // alert ('Setting the cookie for ' + cookieName + " whose value is " + cookieValue + "with an expiry date");

			expiry = expiry * 1 * 3600 * 1000; // The Expiry is given in days
			expDate.setTime (expDate.getTime() + expiry);
			string = cookieName + "=" + escape (cookieValue) + ";domain=" + domain + ";path=" + path + ";expires=" + expDate.toGMTString();
			document.cookie = string;
						
	}
	else
	{
			string = cookieName + "=" + escape (cookieValue) + ";domain=" + domain + ";path=" + path;
			document.cookie = string;
	}

return;

}

function setCookie (cookieName,cookieValue,expiry,domain,path)
{

	var expDate = new Date();
	var string;

	// alert ('Setting the cookie for ' + cookieName + " whose value is " + cookieValue);

	if(expiry)
	{
		       // alert ('Setting the cookie for ' + cookieName + " whose value is " + cookieValue + "with an expiry date");

			expiry = expiry * 24 * 3600 * 1000; // The Expiry is given in days
			expDate.setTime (expDate.getTime() + expiry);
			string = cookieName + "=" + escape (cookieValue) + ";domain=" + domain + ";path=" + path + ";expires=" + expDate.toGMTString();
			document.cookie = string;
						
	}
	else
	{
			string = cookieName + "=" + escape (cookieValue) + ";domain=" + domain + ";path=" + path;
			document.cookie = string;
	}

return;

}

function deleteCookie (cookieName)
{
	
	// First check whether the cookie is present
	var cookieValue = getCookie(cookieName);
	if (cookieValue == "" || typeof cookieValue == "undefined")
 	{
		// Do Nothing
 	}
 	else
 	{
		setCookie (cookieName,"","90","vitalect.com","/");
 	}

return;	
}	

function deleteRememberMeCookie()
{
	if (typeof document.forms[0] != "undefined")
	{
		var loggedInFrom = document.forms[0].loggedInFrom.value;
		var cookieName = loggedInFrom + "LoginRememberMe";
		deleteCookie(cookieName);
	}
	return;
}

function isUpdateUserFormValid(thisForm,pageType)
{

	if (pageType == 'NEW')
	{
		var loginidLength = thisForm.loginid.options.length;
		var loginidValue,flag,i;
		var flag = 0;
		var i = 0;
		
		while (i< loginidLength)
		{
		  	if (thisForm.loginid.options[i].selected == true)
	    	  	{
	         		flag =1;
	         		loginidValue = thisForm.loginid.options[i].value;
	    	  	  	break;
	    		}
	    		  i++;
	 	}
		
		 if (loginidValue == '0')
		 {
			alert ('Please select a user');
			return 0;
		 }

		 if (flag == 0)
		 {
		       alert ('Please select a user');
		       return 0;
		 }
	}
	else
	{
		if (!isLoginidOk(thisForm))
		{
			return 0;
		}
	}
		
return 1;
}

function isDeleteCourseSelectionOk(thisForm,objectType)
{

// This is for a single select Courses field

var coursesLength = thisForm.courses.options.length;
var coursesValue,i=0;
var flag;
if (typeof objectType =="undefined")
{
	objectType ="a Document";
}
else
{
	objectType = "an Exam";
}


	while (i< coursesLength)
	{
		flag =0;
		if (thisForm.courses.options[i].selected == true)
		{
			coursesValue = thisForm.courses.options[i].value;
			flag =1;
			break;
    		}
    		  i++
 	}

	if (coursesValue == '0')
 	{
 	       alert ('Please select ' + objectType);
 	       return 0;
	}

	if (flag == 0)
	{
	       alert ('Please select ' + objectType);
 	       return 0;
	}

return 1;
}

function showPageContent(showResource,loId,resourceType,showSave,nodeId,rootId)
{
	var cgibinDir = getCGIURL();
	var siteURL = getSiteURL();
	if (showResource=="SHOWPARTICULARCONTENT")
	{
		var url=siteURL + cgibinDir+"/showContentPage.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&loId="+loId+"&resourceType="+resourceType+"&showSave="+showSave+"&nodeId="+nodeId+"&rootId="+rootId;
		window.open(url,'SHOW_CONTENT','status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=640,height=640,dependent=false');

	}
	return;	
}

function showFeedBackForm(documentType,courseId,allNotes,onlySharedNotes,showUser,notesType,shadowCourseId)
{
	var siteURL = getSiteURL();
	
	var windowLocation=siteURL +"/cgi-bin/reguser/docxi/showAuthorFeedback.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&courseId="+courseId+"&allNotes="+allNotes+"&onlySharedNotes="+onlySharedNotes+"&showUser="+showUser+"&notesType="+notesType+"&documentType="+documentType+"&shadowCourseId="+shadowCourseId;
	//window.open(windowLocation,"Notes",'status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,directories=no,copyhistory=no,width=640,height=640,dependent=false');
	document.location=windowLocation;
 
}

function changeGroupAction (form)
{
	var chooseActionLength = form.chooseAction.options.length;
	var i=0;
	var flag =0;
	var chooseActionValue;

	while (i< chooseActionLength)
	{
		flag =0;
		if (form.chooseAction.options[i].selected == true)
		{
			chooseActionValue = form.chooseAction.options[i].value;
			flag =1;
			break;
    	}

    	i++;
 	}
	performAction('DOCUMENT_GROUP',chooseActionValue);

return;
}

function gotoUploadTab(userid,sessionid,loggedInFrom,isOnlyQuiz,pageType){
	var siteURL = getSiteURL();
	var cgibinDir = getCGIURL();
	window.opener.location= siteURL+cgibinURL+"/showRegFrame.pl?userid="+userid+"&sessionid="+sessionid+"&loggedInFrom="+loggedInFrom+"&isOnlyQuiz="+isOnlyQuiz+"&pageType="+pageType;
	
}

function addGroups(){
	performAction ('DOCUMENT_GROUP',2);
}
function addReviewers(){
	performAction ('DOCUMENT_GROUP',4);
}
function listGroups(){
	performAction ('DOCUMENT_GROUP',6);
}
function editGroup(groupId){
	performAction ('DOCUMENT_GROUP',7,groupId);
}
function listReviewers(){
	performAction ('DOCUMENT_GROUP',9);
}
function editReviewer(loginId){
	performAction ('DOCUMENT_GROUP',10,loginId);
}
function notifyDocumentReviewers(){
	performAction ('DOCUMENT_GROUP',17);
}
function removeGroup(groupId){
	if (confirm('Are you sure you want to the delete the group and its members?'))
	{
		performAction ('DOCUMENT_GROUP',12,groupId);
	}else{
		return false;
	}
}
function deleteReviewer(loginId){
	performAction ('DELETEREVIEWER',3,loginId);
}
function emailGroup(){
	performAction ('DOCUMENT_GROUP',13);
}

function addMultipleUsers(){
	performAction ('DOCUMENT_GROUP',16);
}
function deleteReviewerFromAllDocuments(loginId){
	performAction ('DELETEREVIEWER',5,loginId);
}

//AJAX Changes

var globalMessage="Updating...";	
var http_request = false;
var globalClientName;
function postSignup(obj,formName,clientName){
				
	var siteUrl=SECURE_SITE_URL;
	var msg = "";

	formName.registeredThru.value = clientName;
	var firstname=formName.firstname.value;
	var lastname=formName.lastname.value;
	var companyname=formName.companyname.value;
	var reconfirm_email=formName.reconfirm_email.value;
	var email=formName.email.value;
	if (isExamRegistrationFormValid())
	{
	
	globalClientName=clientName.toLowerCase();
	var poststr = "firstName=" + encodeURI(firstname)+"&lastName=" + encodeURI(lastname);
	poststr=poststr+"&companyName=" + encodeURI(companyname)+"&email=" + encodeURI(email);
	poststr=poststr+"&registeredThru=" + encodeURI(clientName);

    if (showAlertMsg(msg) != 0 ) {	
		makePOSTRequests(siteUrl+'/cgi-bin/reguser/checkUserEmailPresent.pl', poststr);
	}
	}
   
   }

function showAlertMsg(msg)
{
	// This is the final concatenated string that is displayed to user	
	if (msg.length != 0)
	{
		var mainMsg = "The following fields are required:\n" + msg;
		alert(mainMsg);
		return 0;
	}
	else
	{
		return 1;	
	}
}




   //This is mainly used to make the form post activities.

   function makePOSTRequests(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContent;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

 function alertContent() {
	    var serverResponse=document.getElementById('server_response');

		 if (http_request.readyState == 0) {
			serverResponse.innerHTML = "<span style='background-color:#FF6633\;'><b>Error...</b></span>"; 
		 }
	  
  	     if(http_request.readyState == 1 || http_request.readyState == 2 || http_request.readyState == 3){
		    serverResponse.innerHTML = "<span style='background-color:#FFFF99\;'><b>"+globalMessage+"</b></span>"; 
 	     }

		if (http_request.readyState == 4) {
			if (http_request.status == 200){
	 			  var result = http_request.responseText;
				  var resultArray=result.split("%");
				  var siteUrl=SITE_URL;
				  if (resultArray[0] == "REDIRECT")
				  {
					  performAction('EXAMREGISTER',5,'INFORMATICA');
				  }
				  else{
					  serverResponse.innerHTML = "<small><div style='background-color:#FFFF99\;display:block\;width:500px\;padding:5px\;'><b>"+resultArray[1]+".<BR>If you have forgotten your password, please reset it <a href='"+siteUrl+"/"+globalClientName+"/hint1.html'>here</a> using your existing login. <BR><BR>If you have forgotten your login, then please click support <a href='"+siteUrl+"/"+globalClientName+"/support.html'>here</a></b></div><small>";
				  }
			}
			else {
	            serverResponse.innerHTML = "<span style='background-color:#FF6633\;'><b>Failed...</b></span>"; 
		    }
		}
 }
