/* (C) Innoware Ltd 2007 */


/* innoware (object)
* Create a new instance of the JSInnowareConstructor to gain access to
* all public members and functions through this object and not globally.
*/
var innoware = new JSInnowareConstructor();


/* JSInnowareConstructor
* The main power constructor which creates and returns a new JavaScript object.
*/
function JSInnowareConstructor() {
    
	var that = {}; // Must use 'that' so not to confuse with 'this' which is the global object.

	/* Private Variables 
	*
	* These variables can only be accessed by functions inside the scope of this object
	*/
	var fadeInterval, iOpacity = 0;


    /* Private Functions 
	*
	* These functions can only be accessed by functions inside the scope of this object
	*/

	function changeOpac(opacity, id) {
		var object = document.getElementById(id).style;
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";

		if (SupportsAlpha(object)) {
			object.filters.alpha.opacity = iOpacity;
		}
	}

	function SupportsAlpha(obj) {
		if (obj.filters) {
			if (obj.filters.alpha) {
				return true;
			}
		}
		
		return false;
	}

    function IsValid(fieldID)
    {
    		
	    var objValue = innoware.MyObject('EditID'+ fieldID);
	    var fldTitle = innoware.MyObject('fld' + fieldID).innerHTML;
	    if (fldTitle.indexOf(":") > -1) 
		    fldTitle = fldTitle.substr(0,fldTitle.indexOf(":"));
    		
	    var charpos = objValue.value.search("[\~\|\^\<\>]"); 
        if(objValue.value.length > 0 &&  charpos >= 0) 
        { 
		    var strError = fldTitle +" contains invalid characters.  \nCharacters ~,^,|,<,> are not allowed."; 
		    alert(strError + "\n [Error character '" + objValue.value.charAt(charpos)+ "' found at position " + eval(charpos+1)+"]"); 
		    objValue.focus();
		    return false; 
        } 
        return true;
    }

	function GetKeyCode(e){
		var keycode = '';

		if (e == null) { // ie
			keycode = event.keyCode;
		} else { // mozilla
			keycode = e.which;
		}
		key = String.fromCharCode(keycode).toLowerCase();
		
		return key;
	}

	/* Public Variables 
	*
	* These variables are available from the returning object that this constructor creates,
	* new public variables can be added to the returning object at any time.
	*/
	that.undefined;


	/* Public Functions 
	*
	* These functions are available from the returning object that this constructor creates,
	* new public functions can be added to the returning object at any time.
	*/

	that.KeyDownHandler = function(btn) { 
		// process only the Enter key
		if (event !== undefined) {
			if (event.keyCode == 13)
			{
				// cancel the default submit
				event.returnValue=false;
				event.cancel = true;
				
				// submit the form by programmatically clicking the specified button
				document.getElementById(btn).click();
			}
		}
	};

	that.MyObject = function(sName) {
		return document.getElementById(sName);
	};

	that.Value = function(sName) {
		return document.getElementById(sName).value;
	};

	// Return the id of the selected ddl item
	that.ddlid = function(sName) {
		var ddl = document.getElementById(sName)
		if (ddl != null && ddl.selectedIndex != -1) {
			var res = ddl.options[ddl.selectedIndex].id;
			return res;
		}
		else
			return null;
	};

	that.ddlValue = function(sName) {
		var ddl = document.getElementById(sName)
		if (ddl != null && ddl.selectedIndex != -1) {
			var res = ddl.options[ddl.selectedIndex].value;
			return res;
		}
		else
			return null;
	};

	that.GetSelectedOptionValue = function(selectControlID) {
		var ddl = document.getElementById(selectControlID)
		if (ddl != null && ddl.selectedIndex != -1) {
			return ddl.options[ddl.selectedIndex].value;
		}
		else {
			return null;
		}
	};
    
    that.CustomSave = function(customAction,sEntityType, sOwnerFieldName, sOID, FieldList) {

	    var performEditAfterSave = (customAction == '');
	    var fieldValues = new Array();
	    var fields = FieldList.split('~');	
	    
	    for (i = 0; i < fields.length; i++)
	    {
		    if (innoware.MyObject('EditID' + fields[i]) != null)
		    {
			    if (innoware.MyObject('EditID' + fields[i]).tag == 'chk')
			    {
				    var controlValue = innoware.MyObject('EditID' + fields[i]).checked;
			    }
			    else
			    {
				    if (!IsValid(fields[i]))
					    return;  //cancel save
				    var  controlValue = innoware.Value('EditID' + fields[i]);			
			    }
			    fieldValues.push(fields[i] + '|' + controlValue);
		    }
	    } 
    	
	    //innoware.MyObject('SearchButtonWait').style.display = 'inline';
    		
	    var result = DefaultAdminEditBuilder.FireSaveAndReEdit(performEditAfterSave, sEntityType, sOwnerFieldName, sOID, fieldValues.join('~'))
    	
		    var listTokens = result.value.split('|')

		    if (listTokens[0] == '0')
			    alert(listTokens[1])
		    else
		    {
			    //document.getElementById(listTokens[0]).innerHTML = listTokens[1];
			    if (!performEditAfterSave)
				    eval(customAction);
			    else
				    alert('Saved OK');
		    }

	    //innoware.MyObject('SearchButtonWait').style.display = 'none';	
    };

	that.CloseRefreshParent = function() {
		window.parent.hidePopWin();
		window.parent.location.reload();
	};

	that.Place = function(res) {
		var result = res.value;

		if (result == '') {
			return true;
		}

		var listTokens = result.split('|');

		if (listTokens[0] == '0') {
			alert(listTokens[1]);
			return false;
		}
		else {
			document.getElementById(listTokens[0]).innerHTML = listTokens[1];
			return true;
		}
	};

	that.GotoPlace = function(res) {
		var result = res.value;
		var listTokens = result.split('|');

		if (listTokens[0] != '1') {
			document.getElementById(listTokens[0]).innerHTML = listTokens[1];
		}
		else {
			location.href = listTokens[1];
		}
	};

	that.GotoAlert = function(res) {
		var result = res.value;
		var listTokens = result.split('|');

		if (listTokens[0] != '1') {
			alert(listTokens[1]);
		}
		else {
			location.href = listTokens[1];
		}
	};

	that.AlertAndClosePopWin = function(res, msg) {
		var result = res.value;
		var listTokens = result.split('|');

		if (listTokens[0] == '0') {
			alert(listTokens[1]);
			return false;
		}
		else {
			alert(msg);
			window.parent.hidePopWin();
			return true;
		}
	};

	that.PlaceWaitButtonToggle = function(buttonId) {
		var ajaxCmd = MyObject(buttonId);	
		var ajaxCmdWaitUI = MyObject(buttonId + 'Wait');

		if (ajaxCmd != null && ajaxCmdWaitUI != null) {
			if (ajaxCmd.style.display == '') {
				ajaxCmd.style.display = 'none';
				ajaxCmdWaitUI.style.display = 'inline';
			}
			else {
				ajaxCmd.style.display = '';
				ajaxCmdWaitUI.style.display = 'none';		
			}
		}
	};
	
	that.PlaceInParent = function(res) {
		var result = res.value;
		var listTokens = result.split('|');

		if (listTokens[0] == '0') {
			alert(listTokens[1]);
			return false;
		}
		else {
			window.parent.document.getElementById(listTokens[0]).innerHTML = listTokens[1];
			return true;
		}
	};
	
	that.ActionConfirmAndPlace = function(confirmMessage,res) {
		var listTokens = res.value.split('|');

		if (listTokens[0] == '0') {
			alert(listTokens[1]);
		}
		else {
			alert(confirmMessage);
			document.getElementById(listTokens[0]).innerHTML = listTokens[1];
		}
	};

	that.AlertOnError = function(res) {
		var result = res.value;
		var listTokens = result.split('|');
						
		if (listTokens[0] == '0'){
			alert(listTokens[1]); 
		}
	};	

	that.AlertBoth = function(res) {
		var listTokens = res.value.split('|');

		if (listTokens[0] == '0') {
			alert(listTokens[1]);
			return false;
		}
		else {
			alert(listTokens[1]);
			return true;
		}
	};
	
	that.PlaceJump = function(res) {
		var result = res.value;

		if (result == '') {
			return true;
		}

		var listTokens = result.split('|');

		if (listTokens[0] == '0') {
			alert(listTokens[1]);
			return false;
		}
		else if (listTokens[0] == 'true') {
            //var answer = confirm("Would you like to continue and consult on another job role?");
            //if (answer) {
            //    location.href = "JobsCollection.aspx";
            //    return true;
            //}
            //else
           // {
            //    location.href = 'Logout.aspx';     // Page.aspx?uid=214
        		return false;
            //}
            //that.JobSkillsPageNav(4);
		}
		else if (listTokens[0] != 'false') {
			alert(listTokens[1]);
			return false;
		}
	};

	that.CharCount =  function(sTextID, NumChars){
		var sCommentText = document.getElementById(sTextID).innerText;
		var iCount = NumChars - sCommentText.length;

		if (iCount < 0)
		{	
			document.getElementById(sTextID).innerText = sCommentText.substring(0,NumChars);
			document.getElementById('iCount').innerHTML = '0';						
		}
		else
			document.getElementById('iCount').innerHTML = iCount;

		if (iCount <= 0)
			document.getElementById('CharCount').style.color = '#FF0000';
		else
			document.getElementById('CharCount').style.color = '#666666';
	};

	that.FadeIn = function(sID) {

		if (iOpacity >= 100) {
			fadeInterval = clearInterval(fadeInterval);
		}

		iOpacity += 10;
		changeOpac(iOpacity, sID);
	};

	that.AutoList = function(results) {
		var listTokens = results.split('|'), i, 
			AutoResults = new Array(listTokens.length), token;
		
		for(i=0; i < listTokens.length; i++) {
			if (listTokens[i] == '') {
				continue;
			}

			token = listTokens[i].split('&&');

			AutoResults[i] = {};
			AutoResults[i].id = token[0];
			AutoResults[i].text = token[1];
		}

		return AutoResults;
	};

	that.Logout = function() {
		location.href = 'Logout.aspx';
	};

	that.Login = function() {
		var sUsername = document.getElementById('username').value;

		that.GotoAlert(LoginControl.Login(sUsername));
	};
	
	that.Register = function() {
	    var sName  = innoware.Value('name');
	    var sEmail = innoware.Value('email');
	    var sOrg   = innoware.Value('organisation');
	    
	    that.GotoAlert(RegisterControl.Fire(sName, sEmail, sOrg));
	};
	
    that.ChooseNewUsersJob = function(ddl) {
		document.getElementById('JobRole').value = ddl.options[ddl.selectedIndex].id;
	};

	that.UpdateJobCount = function() {
		that.Place(ConsultorDetailsControl.UpdateJobCount());
	};

	that.RemoveExisting = function(sOID) {
		if (confirm('Are you sure you wish to remove this job?')) {
			if (that.Place(ConsultorJobCollectionControl.RemoveExisting(sOID))) {

				parent.innoware.UpdateJobCount();
			}
		}
	};

	that.GetJobs = function(sSearch) {
		var results = ConsultorJobCollectionControl.GetOCFJobs(sSearch).value;
		return that.AutoList(results);
	};
	
	that.GetFolders = function(sSearch) {
		var results = ConsultorJobCollectionControl.GetOCFFolders(sSearch).value;
		return that.AutoList(results);
	};

	that.HandleJobs = function(sID, sText, arrExtra) {
	};
	
	that.AddJobDLL = function(ddl) {
	    var sJobOID = ddl.options[ddl.selectedIndex].id || '';
		//that.GotoAlert(ConsultorJobCollectionControl.AddJob(sJobOID))
		document.getElementById('thePage').innerHTML = "<div id='LoadingStep'><img src='im/loading.gif' /> Creating selected job role for consultation... please wait.<br></br>This may take up to 30 seconds</div>";
		ConsultorJobCollectionControl.AddJob(sJobOID,
			function(res) {
				that.JobSkillsPageNav('2');
			});
	};

	that.AddJob = function() {
		var sJobOID = that.ddlid('SuggestResultsJobs') || '';

		//if (that.Place(ConsultorJobCollectionControl.AddJob(sJobOID))) {
            var e = ConsultorJobCollectionControl.AddJob(sJobOID);
			parent.innoware.UpdateJobCount();
			//that.SetJobID(e.value);
			that.JobSkillsPageNav('2');
	};

    that.AddJobFolder = function() {
		var sJobOID = that.ddlid('SuggestResultsFolder') || '';

		if (that.Place(ConsultorJobCollectionControl.AddJobFolder(sJobOID))) {

			parent.innoware.UpdateJobCount();
		}
	};
	
	that.AddNewConsultor = function() {
		that.Place(ConsultorSetupControl.AddNewConsultor());
	};

	that.SetSkillsAnswerYes = function(sSkillOID) {
		var eYes = document.getElementById('yes'+sSkillOID),
			eNo = document.getElementById('no'+sSkillOID),
			sComments = document.getElementById('blob_ConsultedJobSkillp_Comments'+sSkillOID).value || '';

		if (eYes.checked) {
			if (sComments.length < 1) {
				eNo.checked = false;
				ConsultorsJobSkillsControl.SetSkillAnswer(sSkillOID, 1, that.PlaceJump);
			}
			else {
				if (confirm('Choosing yes will clear out your comments. You only need to have comments when choosing no.\nDo you wish to proceed?')) {
					document.getElementById('blob_ConsultedJobSkillp_Comments'+sSkillOID).value = '';
					GridBuilderJS.EditBlob('_ConsultedJobSkill','p_Comments',sSkillOID);
					eNo.checked = false;
					txtarea = document.getElementById('blob_ConsultedJobSkillp_Comments' + sSkillOID);
					txtarea.disabled = true;
					ConsultorsJobSkillsControl.SetSkillAnswer(sSkillOID, 1,that.PlaceJump);
				}
				else {
					eYes.checked = false;
				}
			}
		}

		if (!eYes.checked && !eNo.checked) {
			ConsultorsJobSkillsControl.SetSkillAnswer(sSkillOID, 0,that.PlaceJump);
		}
	};

	that.SetSkillsAnswerNo = function(sSkillOID) {
		var eYes = document.getElementById('yes'+sSkillOID),
			eNo = document.getElementById('no'+sSkillOID),
			txtarea = document.getElementById('blob_ConsultedJobSkillp_Comments' + sSkillOID);
				
		if (eNo.checked) {	
			eYes.checked = false;
			ConsultorsJobSkillsControl.SetSkillAnswer(sSkillOID, 2, that.PlaceJump);
		    txtarea.disabled = false;
			GridBuilderJS.SwitchEdit('_ConsultedJobSkillp_Comments'+sSkillOID);
		}

		if (!eYes.checked && !eNo.checked) {
			ConsultorsJobSkillsControl.SetSkillAnswer(sSkillOID, 0, that.PlaceJump);
		}
	};

	that.SetDescriptionAnswerYes = function(sSkillOID) {
		var eYes = document.getElementById('yesDescription'+sSkillOID),
			eNo = document.getElementById('noDescription'+sSkillOID),
			sComments = document.getElementById('JobDescriptionComment').value || '';

		if (eYes.checked) {
			if (sComments.length < 1) {
				eNo.checked = false;
				NOSDescriptionControl.SetDescriptionAnswer(sSkillOID, 1, that.Place);
			}
			else {
				if (confirm('Choosing yes will clear out your comments. You only need to have comments when choosing no.\nDo you wish to proceed?')) {
					document.getElementById('JobDescriptionComment').value = '';
        			document.getElementById('JobDescriptionComment').focus()
					eNo.checked = false;
					NOSDescriptionControl.SetDescriptionAnswer(sSkillOID, 1, that.Place);
				}
				else {
					eYes.checked = false;
				}
			}
		}

		if (!eYes.checked && !eNo.checked) {
			NOSDescriptionControl.SetDescriptionAnswer(sSkillOID, 0, that.Place);
		}
	};

	that.SetDescriptionAnswerNo = function(sSkillOID) {
		var eYes = document.getElementById('yesDescription'+sSkillOID),
			eNo = document.getElementById('noDescription'+sSkillOID);

		if (eNo.checked) {	
			eYes.checked = false;
			NOSDescriptionControl.SetDescriptionAnswer(sSkillOID, 2, that.Place);
			document.getElementById('JobDescriptionComment').focus()
		}

		if (!eYes.checked && !eNo.checked) {
			NOSDescriptionControl.SetDescriptionAnswer(sSkillOID, 0, that.Place);
		}
	};

	that.SetTitleAnswerYes = function(sJobOID) {
		var eYes = document.getElementById('yesT'+sJobOID),
			eNo = document.getElementById('noT'+sJobOID),
			eTitleComms = document.getElementsByClassName('commentHide'), i,
			eComment = document.getElementById('GeneralComments');

		if (eComment.value !== '') {
			if (confirm('You have a comment, answering yes will remove your comment. Do you wish to continue?')) {
				eComment.value = '';
				that.SaveJobDescriptionComment(sJobOID);
				eYes.checked = true;
				document.getElementById('iCountGeneralComments').innerHTML = '2000';
			}
			else {
				eYes.checked = false;
				return;
			}
		}

		eNo.checked = false;
		ConsultorsJobSkillsControl.SetTitleAnswer(sJobOID, 1, that.Place);

//		for (i=0; i < eTitleComms.length; i++) {
//			eTitleComms[i].style.display = 'none';
//		}

		if (!eYes.checked && !eNo.checked) {
			ConsultorsJobSkillsControl.SetTitleAnswer(sJobOID, 0, that.Place);
		}
	};

	that.SetTitleAnswerNo = function(sJobOID) {
		var eYes = document.getElementById('yesT'+sJobOID),
			eNo = document.getElementById('noT'+sJobOID);

		eYes.checked = false;

		if (!eYes.checked && !eNo.checked) {
			ConsultorsJobSkillsControl.SetTitleAnswer(sJobOID, 0, that.Place);
		}
		else
		{
    		ConsultorsJobSkillsControl.SetTitleAnswer(sJobOID, 2, that.Place);
    		
    		document.getElementById('GeneralComments').disabled = false;
    		document.getElementById('GeneralComments').focus();
		}
	};

	that.AddEmail = function(sOID, bAllowed) {
		if (bAllowed == 'False') {
			alert('You can not send an email to this user as they have asked not to be contacted.');
			document.getElementById('sendMailTo'+sOID).checked = false;
			return;
		}

		var eEmails = document.getElementById('EmailOIDS'),
			sTxt = eEmails.value || '',
			bChk = document.getElementById('sendMailTo'+sOID).checked;

		if (bChk) {
			sTxt = sTxt + sOID + ',';
		}
		else {
			sTxt = sTxt.replace(sOID+',','');
		}

		eEmails.value = sTxt;
	};

	that.SendEmails = function() {
		var sEmailTo = document.getElementById('EmailOIDS').value || '';

		if (confirm('Are you sure you want to send emails out. If a user doesn\' have a valid address then no email will be sent for them.')) {
			ConsultorSetupControl.SendEmails(sEmailTo, that.Place);
		}
	};

	that.SendCompletionMail = function() {
		ConsultorsJobSkillsControl.SendCompletionMail(that.Place);
		history.back(1);
	};

	that.SaveJobDescriptionComment = function(sJobOID) {
		var sComment = document.getElementById('GeneralComments').value || '';
		
		var bResetCheckBoxes = ConsultorsJobSkillsControl.ForceComment().value;
		
		if (sComment == '' && bResetCheckBoxes == "true")
		{
    		var eYes = document.getElementById('yesT'+sJobOID),
			  eNo = document.getElementById('noT'+sJobOID);
		    eNo.checked = false;
		    eYes.checked = false;
    		ConsultorsJobSkillsControl.SetTitleAnswer(sJobOID, 0, that.Place);
		}
    		
    	ConsultorsJobSkillsControl.SaveJobDescriptionComment(sJobOID,sComment,that.Place);
	};

	that.SaveGeneralJobComment = function(sJobOID) {
		var sComment = document.getElementById('GeneralComments_D').value || '';
    		
    	ConsultorsJobSkillsControl.SaveGeneralJobComment(sJobOID,sComment, that.Place);
	};
	
	that.NOSTabClick = function(sTabName) {
		document.getElementById('descriptions').className = 'grey toptab';
		document.getElementById('performance').className = 'grey toptab';
		document.getElementById('knowledge').className = 'grey toptab';
		document.getElementById(sTabName).className = 'usgr toptab';

		document.getElementById('descriptionsDetails').style.display = 'none';
		document.getElementById('performanceDetails').style.display = 'none';
		document.getElementById('knowledgeDetails').style.display = 'none';
		document.getElementById(sTabName + 'Details').style.display = '';
	};
	
	function getIFrameDocument(aID) {
          var rv = null; 

          // if contentDocument exists, W3C compliant (Mozilla)
          if (document.getElementById(aID).contentDocument){
            rv = document.getElementById(aID).contentDocument;
          } else {
            // IE
            rv = document.frames[aID].document;
          }
          return rv;
    }

	that.showHideFolderContents = function(id, prefix, bIcons) 	{
		if (document.getElementById('Contents'+id+prefix).style.display == 'none')
		{
			document.getElementById('Contents'+id+prefix).style.display = '';
			if (bIcons) that.tickFolder(id,prefix);
		}
		else
		{
			document.getElementById('Contents'+id+prefix).style.display = 'none';
			if (bIcons) that.unTickFolder(prefix);
		}
	};

	that.tickFolder = function(id, prefix) {
		for (i = 0; i < document.getElementsByTagName('img').length; i++)
		{
			if (document.getElementsByTagName('img')[i].id.indexOf('Icon') == 0)
			{
				if (document.getElementsByTagName('img')[i].id == 'Icon'+id+prefix)
					document.getElementsByTagName('img')[i].src = 'images/check.gif';
				else
					document.getElementsByTagName('img')[i].src = 'images/dhtmlgoodies_folder.gif';
			}
		} 

		document.getElementById('SelectedFolder'+prefix).value = id;
	};

	that.unTickFolder = function(prefix) {
		for (i = 0; i < document.getElementsByTagName('img').length; i++)
		{
			if (document.getElementsByTagName('img')[i].id.indexOf('Icon') == 0)
				document.getElementsByTagName('img')[i].src = 'images/dhtmlgoodies_folder.gif';
		}
		document.getElementById('SelectedFolder'+prefix).value = '';
	};

    that.ContinueLater = function(sJobID) {
        ConsultorsJobSkillsControl.ContinueLater(sJobID, that.GotoAlert);
    };

    that.Stop = function(sJobID) {  
        var answer = confirm("Are you sure that you want to stop?");
        if (answer) {
            ConsultorsJobSkillsControl.Stop(sJobID, that.GotoAlert);
        }        
    };

	that.CheckComment = function(sSkillOID) {
		var sNewValue = document.getElementById('blob_ConsultedJobSkillp_Comments'+sSkillOID).value || '',
			eYes = document.getElementById('yes'+sSkillOID);

		if (eYes.checked && sNewValue.length > 0) {
			document.getElementById('blob_ConsultedJobSkillp_Comments'+sSkillOID).value = '';
			GridBuilderJS.EditBlob('_ConsultedJobSkill','p_Comments',sSkillOID);
			alert('You can\'t add comments for yes answers');
			return;
		}

		if (!eYes.checked && sNewValue.length < 1) {
			document.getElementById('no'+sSkillOID).checked = false;
			ConsultorsJobSkillsControl.SetSkillAnswer(sSkillOID, 0, that.Place);
			alert('You must enter a comment if answering no.');
		}
	};

	that.CheckDescriptionComment = function(sSkillOID) {
		var sNewValue = document.getElementById('blob_ConsultedJobSkillp_DescriptionComments'+sSkillOID).value || '',
			eYes = document.getElementById('yesDescription'+sSkillOID);

		if (eYes.checked && sNewValue.length > 0) {
			document.getElementById('blob_ConsultedJobSkillp_DescriptionComments'+sSkillOID).value = '';
			GridBuilderJS.EditBlob('_ConsultedJobSkill','p_DescriptionComments',sSkillOID);
			alert('You can\'t add comments for yes answers');
			return;
		}

		if (!eYes.checked && sNewValue.length < 1) {
			document.getElementById('noDescription'+sSkillOID).checked = false;
			ConsultorsJobSkillsControl.SetDescriptionAnswer(sSkillOID, 0, that.Place);
			alert('You must enter a comment if answering no.');
		}
	};
	
    that.OpenTab = function(id,tabLink){
	    var eTabs = document.getElementsByClassName('tabs');
	    for (i=0; i < eTabs.length; i++) {
		    eTabs[i].style.display = 'none';

		    if (eTabs[i].id == id) {
			    eTabs[i].style.display = '';
		    }
	    }

		var tabLinks = document.getElementsByClassName('laTab');
		for (i = 0; i < tabLinks.length; i++) {
			tabLinks[i].className = 'laTab';
		}
		tabLink.className = 'laTab tabOn';
    };
    
    that.JobSkillsPageNav = function(pagenum)
    {
		document.getElementById('thePage').innerHTML = "<div id='LoadingStep'><img src='im/loading.gif' /> Loading next step... please wait.<br></br>This may take up to 30 seconds</div>";
        ConsultorsJobSkillsControl.ChangePage(pagenum, that.Place);
    };
	
	that.SaveGeneralComments = function(sUserID)
	{
		var sComment = document.getElementById('GeneralComments').value || '';

		CommentControl.SaveGeneralComment(sUserID, sComment, that.GotoAlert);
	};

    that.CheckAndJump  = function(sSkillOid)
    {			
        ConsultorsJobSkillsControl.CheckAndJump(sSkillOid, that.PlaceJump);
    }

    that.StartAgain = function()
    {
        ConsultorsJobSkillsControl.StartAgain();
        location.href = 'JobCompetencies.aspx';
    };

	that.FilterConsultorGrid = function() {
		AdminReportLevelOneControl.FilterGrid(document.getElementById('DateStart').value,document.getElementById('DateEnd').value, that.Place);
	};
	
	that.RemoveFilterConsultorGrid = function() {
	    document.getElementById('DateStart').value = '';
	    document.getElementById('DateEnd').value='';
		that.FilterConsultorGrid();
	};
	
	that.LoadSkills = function(sTabName, sJobID, sIsTab3)
	    {
    	    var bContinue = false;
    	    
    	    if (document.getElementById(sTabName + 'Core') != null){
    	        if (document.getElementById(sTabName + 'Core').innerHTML == ''){
    	            bContinue = true;
    	            document.getElementById(sTabName + 'Core').innerHTML = "<div id='LoadingStep'><img src='im/loading.gif' />Loading Core Skills... please wait.<br></br>This may take up to 30 seconds</div>"}}
    	        
    	    if (document.getElementById(sTabName + 'Variable') != null){
    	        if (document.getElementById(sTabName + 'Variable').innerHTML == ''){
    	            bContinue = true;
    	            document.getElementById(sTabName + 'Variable').innerHTML = "<div id='LoadingStep'><img src='im/loading.gif' />Loading Variable Skills... please wait.<br></br>This may take up to 30 seconds</div>"}}    
    	    
	        if (bContinue)
	        {
	            ConsultorsJobSkillsControl.LoadSkills(sTabName, sJobID, sIsTab3, 
	            function(res){
	            
	            var List = res.value.split('|');
        	    
	            if (List[0].length != 0)
	            {
	                document.getElementById(sTabName + 'Core').innerHTML = List[0];
	            }
        	    
	            if (List[1].length != 0)
	            {
	                document.getElementById(sTabName + 'Variable').innerHTML = List[1];
	            }
	            });
	        }
	    };
	    

	/* 
	* This (or that) is the object returned with all public members and
	* functions included above when the contructor is instantiated.
	*/
    return that;
}

