//=========================================================================
//
//OCCINFO Page Functions
//=======================

//	This following javascript functions are used on
//	various pages in the OCCINFO website.
//all function ordered by the first Alphberic characher



//=========================================================================
//
//Personal List Functions
//=======================

//	This following javascript functions are for managing a
//	user's personal list of occupational profiles.

//	The personal list is stored as a delimited list of
//	occupational profile ids.  The list is stored in a
//	client side cookie that exists until the user's session
//	expires, and is accessed through javascript.
//
//	The basic cookie handling routines are used courtesy of
//	Bill Dortch:
//		Cookie Functions -- "Night of the Living Cookie"
//				Version (25-Jul-96)
//				Bill Dortch, hIdaho Design <bdortch@hidaho.com>
//				Available from: http://www.hidaho.com/cookies/cookie.txt

// Constants
var COOKIENAME = "PersonalList";
var SEPERATOR = ",";
// Add the specified Item to the Personal List
// if it is not already in the list
function addToList(Item){

	var val = GetCookie(COOKIENAME);

	if (val){
		if (val.indexOf(Item + SEPERATOR) < 0)
			val = val + Item + SEPERATOR;
	}else{
		val = Item + SEPERATOR;
	}
	SetCookie(COOKIENAME, val);
}


// Add all checked items from the given form's
// elements to the personal list.
function addItemsToList(frm){
	var items = frm.elements;
	var count = 0;
	for (var i = 0; i < items.length; i++)
		if (items[i].type == "checkbox" && items[i].checked == true) {
			addToList(items[i].value);
			count++;
		}
		if (count > 0) {
			alert("" + count + " profile(s) have been added to your Personal List");
			frm.reset();
		}
		if (count==0)
		{
		  alert("Please select at least one occupational profile.");
		}
}


// Browser detect for Noc Search tree view
function BrowserCheck()
{
	var browser;
	if (navigator.appName=="Netscape" && parseInt(navigator.appVersion.charAt(0)) >= 5)
		document.location.href = "appletFrame_NC6.html"
	else{
		if (navigator.appName.indexOf("Netscape") >= 0)       browser = "NC4";
		else if (navigator.appName.indexOf("Microsoft") >= 0) browser = "IE4";
		else                                                  browser = "???";
	}	
}


function BackToClusters(sPage){
	history.back();
}



function CheckBoxClick(object,frm){
	var items =frm.elements;
	for(var j=0;j<items.length;j++){
		if (items[j].type == "hidden" && items[j].name==object.value){
			for (var i = 0; i < items.length; i++){
				if (items[i].type == "checkbox" && items[i].value==items[j].value) 
					items[i].checked = object.checked;
			}
		}   
	}	      
}
 


//  Function to delete a cookie. (Sets expiration date to start of epoch)
//    name -   String object containing the cookie name
//    path -   String object containing the path of the cookie to delete.  This MUST
//             be the same as the path used to create the cookie, or null/omitted if
//             no path was specified when creating the cookie.
//    domain - String object containing the domain of the cookie to delete.  This MUST
//             be the same as the domain used to create the cookie, or null/omitted if
//             no domain was specified when creating the cookie.

function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function DisplayOccproByID(ID,Type)
{       
    var loc = "RequestAction.asp?format=html"+String.fromCharCode("38")+"aspAction=GetOccproByFieldOrSubjectID";
    loc=loc+String.fromCharCode("38")+"Page=PrintablePosterPage"+String.fromCharCode("38")+"ID="+ID;
    loc=loc+String.fromCharCode("38")+"Type="+Type; 
   	var width = 640;
	var height = 480;
	var options = "width=" + width + ",height=" + height;
	window.open(loc, "","");
}


// Delete the Personal List
function deleteList() {
	DeleteCookie(COOKIENAME);
}

function ltrim(aString){
	var str;
	str = new String(aString);
	
	while (str.indexOf(" ") == 0 && str.length > 0)
		str = str.substring(1, str.length);
	return str;
}

function DisplayOccproByID(ID,Type){      
    var loc = "RequestAction.asp?format=html"+String.fromCharCode("38")+"aspAction=GetOccproByFieldOrSubjectID";
    loc=loc+String.fromCharCode("38")+"Page=PrintablePosterPage"+String.fromCharCode("38")+"ID="+ID;
    loc=loc+String.fromCharCode("38")+"Type="+Type; 
   	var width = 640;
	var height = 480;
	var options = "width=" + width + ",height=" + height;
	window.open(loc, "","");
}

function DisplayNocSearchResult(){
	alert("DisplayNocSearchResult");
    var strNOC = new String(trim(document.frmNOCSearch.elements["NOC"].value));
	if (strNOC.length <= 0 || strNOC.lenght > 6) {
		alert("Please enter 1 to 5 digits for the NOC Number Search.");
		return false;
	}else{
		var NOC = new Number(strNOC);
		// To make sure the NOC is a number
		if (isNaN(NOC)) {
			alert("Please enter 1 to 5 digits for the NOC Number Search.");
			return false;
		}else{
			var loc = "RequestAction.asp?SNT_ID=28"+ String.fromCharCode("38") +"aspAction=GetTitlesForNOC&";
			loc = loc + "format=html&";
			loc = loc + "Page=NocSearch&";
			loc = loc + "NOC=" + strNOC;
			alert("loc is:" + top.document.location);
			top.document.location.href = loc;
		    return true;
			
		}
	}
}

function DropDownListClick(strType){
	//get lastest one
	var currentIndex;
	var RnadDSelectIndex;
	var RnadISelectIndex;
	var RnadMSelectIndex;
	var RnadOSelectIndex;
	var RnadSSelectIndex;
	RnadDSelectIndex=document.frmInterestSearch.RandD.selectedIndex;
	RnadISelectIndex=document.frmInterestSearch.RandI.selectedIndex;
	RnadMSelectIndex=document.frmInterestSearch.RandM.selectedIndex;
	RnadOSelectIndex=document.frmInterestSearch.RandO.selectedIndex;
	RnadSSelectIndex=document.frmInterestSearch.RandS.selectedIndex;
	document.frmInterestSearch.RandD.disabled = false;
	document.frmInterestSearch.RandI.disabled = false; 
	document.frmInterestSearch.RandM.disabled = false;
	document.frmInterestSearch.RandO.disabled = false; 
	document.frmInterestSearch.RandS.disabled = false;
	switch (strType){
	case  "D": 
	    CurrentIndex =document.frmInterestSearch.RandD.selectedIndex;
	    if (CurrentIndex==RnadISelectIndex)
	       document.frmInterestSearch.RandI.options[0].selected = true;
	    if (CurrentIndex==RnadMSelectIndex)
	       document.frmInterestSearch.RandM.options[0].selected = true;   
	    if (CurrentIndex==RnadOSelectIndex)
	       document.frmInterestSearch.RandO.options[0].selected = true;
	    if (CurrentIndex==RnadSSelectIndex)
	       document.frmInterestSearch.RandS.options[0].selected = true;      
        break;
    case  "I": 
	    CurrentIndex =document.frmInterestSearch.RandI.selectedIndex;
	    if (CurrentIndex==RnadDSelectIndex)
	       document.frmInterestSearch.RandD.options[0].selected = true;
	    if (CurrentIndex==RnadMSelectIndex)
	       document.frmInterestSearch.RandM.options[0].selected = true;   
	    if (CurrentIndex==RnadOSelectIndex)
	       document.frmInterestSearch.RandO.options[0].selected = true;
	    if (CurrentIndex==RnadSSelectIndex)
	       document.frmInterestSearch.RandS.options[0].selected = true;  
	    break;
	case  "M": 
	    CurrentIndex =document.frmInterestSearch.RandM.selectedIndex;
	    if (CurrentIndex==RnadDSelectIndex)
	       document.frmInterestSearch.RandD.options[0].selected = true;
	    if (CurrentIndex==RnadISelectIndex)
	       document.frmInterestSearch.RandI.options[0].selected = true;
	    if (CurrentIndex==RnadOSelectIndex)
	       document.frmInterestSearch.RandO.options[0].selected = true;
	    if (CurrentIndex==RnadSSelectIndex)
	       document.frmInterestSearch.RandS.options[0].selected = true;  
	    break;
	case  "O": 
	    CurrentIndex =document.frmInterestSearch.RandO.selectedIndex;
	    if (CurrentIndex==RnadDSelectIndex)
	       document.frmInterestSearch.RandD.options[0].selected = true;
	    if (CurrentIndex==RnadISelectIndex)
	       document.frmInterestSearch.RandI.options[0].selected = true;
	    if (CurrentIndex==RnadMSelectIndex)
	       document.frmInterestSearch.RandM.options[0].selected = true;   
	    if (CurrentIndex==RnadSSelectIndex)
	       document.frmInterestSearch.RandS.options[0].selected = true;  
	    break;
	case  "S": 
	    CurrentIndex =document.frmInterestSearch.RandS.selectedIndex;
	    if (CurrentIndex==RnadDSelectIndex)
	       document.frmInterestSearch.RandD.options[0].selected = true;
	    if (CurrentIndex==RnadISelectIndex)
	       document.frmInterestSearch.RandI.options[0].selected = true;
	    if (CurrentIndex==RnadMSelectIndex)
	       document.frmInterestSearch.RandM.options[0].selected = true;
	    if (CurrentIndex==RnadOSelectIndex)
	       document.frmInterestSearch.RandO.options[0].selected = true;      
	    break;            
	}
	//disable the other two dropdown list
	var selectedIndex ;
	selectedIndex = document.frmInterestSearch.RandD.selectedIndex ;
	selectedIndex = selectedIndex + ";" + document.frmInterestSearch.RandI.selectedIndex;
	selectedIndex = selectedIndex + ";" + document.frmInterestSearch.RandM.selectedIndex;
	selectedIndex = selectedIndex + ";" + document.frmInterestSearch.RandO.selectedIndex;
	selectedIndex = selectedIndex + ";" + document.frmInterestSearch.RandS.selectedIndex;
	if (selectedIndex.indexOf("1") > -1  &&  selectedIndex.indexOf("2") > -1 && selectedIndex.indexOf("3") > -1){
		if (document.frmInterestSearch.RandD.options[0].selected){ document.frmInterestSearch.RandD.disabled = true; }
		if (document.frmInterestSearch.RandI.options[0].selected){ document.frmInterestSearch.RandI.disabled = true; }
		if (document.frmInterestSearch.RandM.options[0].selected){ document.frmInterestSearch.RandM.disabled = true; }
		if (document.frmInterestSearch.RandO.options[0].selected){ document.frmInterestSearch.RandO.disabled = true; }
		if (document.frmInterestSearch.RandS.options[0].selected){ document.frmInterestSearch.RandS.disabled = true; }      
	}
}
	
	
	
//  Function to correct for 2.x Mac date bug.  Call this function to
//  fix a date object prior to passing it to SetCookie.
//  IMPORTANT:  This function should only be called *once* for
//  any given date object!  See example at the end of this document.
function FixCookieDate (date){
	var base = new Date(0);
	var skew = base.getTime(); // dawn of (Unix) time - should be 0
	if (skew > 0)  // Except on the Mac - ahead of its time
		date.setTime (date.getTime() - skew);
}

function FieldStudySearch(frm,Snip_Code){
   	var items =frm.elements; 
    var count = 0;
	var strSubjectID="";
	for (var i = 0; i < items.length; i++){
		if (items[i].type == "checkbox" && items[i].checked == true){
			if(strSubjectID.length>0){
				strSubjectID=strSubjectID+","+items[i].value;
			}else{
				strSubjectID=items[i].value;
			}
			count++;
		}
	}
	if(count == 0){
		alert("Please select at least one field of study.");
		return false;
	}else{
		if (count > 6){
			alert("Please select fewer than seven fields of study.");
			return false;
		}else{
			var loc = "RequestAction.asp?";
			loc = loc + "format=html"+String.fromCharCode("38")+"aspAction=GetFieldStudySearchResult"+String.fromCharCode("38")+"Page=FieldStudyResult"+String.fromCharCode("38")+"FIELD_ID_LIST="+strSubjectID; 
			loc =loc + String.fromCharCode("38")+"SNT_ID_LIST="+Snip_Code;
			top.document.location.href = loc;
			return true;
		}
	}
}


function getList(){
	var list = GetCookie(COOKIENAME);
	if (list)
		list = list.substr(0, list.length - 1);
	return list;
}

			
function getCookieVal (offset){
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

//  Function to return the value of the cookie specified by "name".
//    name - String object containing the cookie name.
//    returns - String object containing the cookie value, or null if
//      the cookie does not exist.
function GetCookie (name){
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen){
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return null;
}

function getSize() {
      var height ;
      //height = top.document.body.clientHeight;
      top.window.scroll(0,1000);
}

function getNocSearch(){ top.document.location.href = "NocSearch.asp"; }

function getReport(sPage){ document.location.href = "RequestReport.asp?aspAction=" + sPage + String.fromCharCode("38") + "Format=HTML"; }

function getAll(SNT_ID){
	var loc = "RequestAction.asp?SNT_ID="+ SNT_ID + String.fromCharCode("38") +"aspAction=GetTitlesSearchAll" + String.fromCharCode("38");
	loc = loc + "Page=TitleSearch" + String.fromCharCode("38");
	loc = loc + "Results=TRUE"  + String.fromCharCode("38");
	loc = loc + "format=html";
	document.location.href = loc;
}

function getInterestPage(sPage,sMenu,sCode,sSplit){
   	var loc = "RequestAction.asp?";
	loc = loc + "format=html" + String.fromCharCode("38") + "aspAction=" + sPage + String.fromCharCode("38") + "Page=" + sMenu + String.fromCharCode("38") + "SNT_CODE_LIST=" + sCode+ String.fromCharCode("38") + "SPLIT=" + sSplit; 
	top.document.location.href = loc;
}

function getSubjectPage(sPage,sMenu,sCode){
   	var loc = "RequestAction.asp?aspAction=" + sPage;
	loc = loc + String.fromCharCode("38") + "Page=" + sMenu;
	loc = loc + String.fromCharCode("38") + "SNT_ID=" + sCode; 
	loc = loc + String.fromCharCode("38") + "format=html";
	top.document.location.href = loc;
}

function getTitles(FirstLetter){
	var loc = "RequestAction.asp?aspAction=GetTitlesSearchFirstLetter";
	loc = loc + String.fromCharCode("38") + "Page=TitleSearch";
	loc = loc + String.fromCharCode("38") + "SNT_ID=55";
	loc = loc + String.fromCharCode("38") + "FirstLetter=" + FirstLetter;
	loc = loc + String.fromCharCode("38") + "Results=TRUE";
	loc = loc + String.fromCharCode("38") + "format=html";
	document.location.href = loc;
}

function getNewUpdate(){
	var loc = "RequestAction.asp?aspAction=GetTitlesSearchNewUpdated";
	loc = loc + String.fromCharCode("38") + "Page=TitleSearch";
	loc = loc + String.fromCharCode("38") + "SNT_ID=55";
	loc = loc + String.fromCharCode("38") + "Results=TRUE";
	loc = loc + String.fromCharCode("38") + "format=html";
	document.location.href = loc;
}



function getOther(){
	var loc = "RequestAction.asp?aspAction=GetTitlesSearchOtherLetter";
	loc = loc + String.fromCharCode("38") + "Page=TitleSearch";
	loc = loc + String.fromCharCode("38") + "SNT_ID=55";
	loc = loc + String.fromCharCode("38") + "Results=TRUE";
	loc = loc + String.fromCharCode("38") + "format=html";
	document.location.href = loc;
}

function getPages(sPage,sMenu){
	var loc = "RequestAction.asp?aspAction=" + sPage;
	loc = loc + String.fromCharCode("38") + "Page=" + sMenu ; 
	loc = loc + String.fromCharCode("38") + "format=html";
	top.document.location.href = loc;
}

function getUpdatedPage(sPage, sMenu, sSnippet){
	var loc = "RequestAction.asp?aspAction=" + sPage;
	loc = loc + String.fromCharCode("38") + "Page=" + sMenu;
	loc = loc + String.fromCharCode("38") + "SNT_ID=" + sSnippet; 
	loc = loc + String.fromCharCode("38") + "format=html";
	top.document.location.href = loc;
}

function getPersonalList(SNT_ID_Y,SNT_ID_N){
	var loc = "RequestAction.asp?aspAction=GetTitlesFromList";
	loc = loc + String.fromCharCode("38") + "Page=PersonalList";
	loc = loc + String.fromCharCode("38") + "List=" + getList();
	loc = loc + String.fromCharCode("38") + "SNT_ID_Y=" + SNT_ID_Y;
	loc = loc + String.fromCharCode("38") + "SNT_ID_N=" + SNT_ID_N;
	loc = loc + String.fromCharCode("38") + "format=html";
	top.document.location.href = loc;		
}	

function getReportsPage(sPage,sMenu,sCode){
   	var loc = "RequestAction.asp?aspAction=" + sPage;
	loc = loc + String.fromCharCode("38") + "Page=" + sMenu;
	loc = loc + String.fromCharCode("38") + "SNT_ID=" + sCode; 
	loc = loc + String.fromCharCode("38") + "format=html";
	top.document.location.href = loc;
}		

function ClusterNewSearch(){
	var loc = "RequestAction.asp?aspAction=GetAllClusterTitles";
	loc = loc + String.fromCharCode("38") + "Page=ClusterSearch" ;
	loc = loc + String.fromCharCode("38") + "format=html";
	top.document.location.href = loc;
}

function newSearch(sPage) {
	if (sPage != 'GetTitlesForNOC') {
		var loc = "RequestAction.asp?format=html" + String.fromCharCode("38")
		if(sPage == 'GetTitlesAdv')
			loc =  loc + "aspAction=GetAdvSearch" + String.fromCharCode("38") + "Page=AdvSearch" ;					
		else
			loc =  loc + "aspAction=GetTitleSearch" + String.fromCharCode("38") + "Page=TitleSearch" ;
		top.document.location.href = loc					
	}else{
		var loc = "NOCSearch.asp";
		top.document.location.href = loc;
	}
}

function KeywordSearch() {
	var str = new String(trim(document.frmKeywordSearch.Keyword.value));
	
	//Check if the search string if long enough (at least 3 char)
	if (str.length < 3) {
		alert("You must enter at least 3 characters in the Keyword field.");
		return false;
	}else{
		//Check for invalid characters
		if (str.indexOf("%") >= 0 || str.indexOf("_") >= 0 || str.indexOf("[") >= 0 || str.indexOf("]") >= 0 ){
			alert("You keyword search may not contain %, _, [, or ] characters.");
			return false;
		}
	}
	return true;
}

 function PrintInterestResultPage(Int1,Int2,Int3,SNT_CODE_1,SNT_CODE_2){
 	  var loc = "RequestAction.asp?aspAction=GetInterestSearchResultPrintF";
	  loc = loc + String.fromCharCode("38") + "Page=InterestSearchResultPrintF";
	  loc = loc + String.fromCharCode("38") + "INT_1=" + Int1; 
	  loc = loc + String.fromCharCode("38") + "INT_2=" + Int2;
	  loc = loc + String.fromCharCode("38") + "INT_3=" + Int3; 
	  loc = loc + String.fromCharCode("38") + "Results=true";
	  loc = loc + String.fromCharCode("38") + "SNT_CODE_1="+SNT_CODE_1;
	  loc = loc + String.fromCharCode("38") + "SNT_CODE_2="+SNT_CODE_2;
	  loc = loc + String.fromCharCode("38") + "format=html";
	  window.open(loc);
}   

function printClusterPage(sPage,sMenu,CltID,SNT_ID){    
	var loc = "RequestAction.asp?aspAction=" + sPage; 
	loc = loc + String.fromCharCode("38") + "Page=" + sMenu ; 
	loc = loc + String.fromCharCode("38") + "SNT_ID="+ SNT_ID; 
	loc = loc + String.fromCharCode("38") + "CLT_ID=" + CltID;  
	loc = loc + String.fromCharCode("38") + "format=html";
	window.open(loc);		           
}

function printTitleSearchPage(sPage,sMenu,searchValue,SNT_ID){
	var searchKey; 

	switch (sPage){
	case "GetTitlesSearchKeywordPrintF":
		searchKey ="keyword=" + searchValue;
		break;
	case "GetTitlesSearchFirstLetterPrintF":
		searchKey ="FirstLetter=" + searchValue;
		break;
	}
	var loc = "RequestAction.asp?aspAction=" + sPage;
	loc = loc + String.fromCharCode("38") + "Page=" + sMenu ; 
	loc = loc + String.fromCharCode("38") + "SNT_ID=" + SNT_ID;
	loc = loc + String.fromCharCode("38") + searchKey;
	loc = loc + String.fromCharCode("38") + "format=html";
	window.open(loc);	
}

function printNOCSearchPage(sPage,sMenu,nocCode,SNT_ID){
	var loc = "RequestAction.asp?aspAction=" + sPage;
	loc = loc + String.fromCharCode("38") + "Page=" + sMenu ; 
	if (SNT_ID != '') {loc = loc + String.fromCharCode("38") + "SNT_ID=" + SNT_ID;}
	loc = loc + String.fromCharCode("38") + "NOC=" + nocCode;
	loc = loc + String.fromCharCode("38") + "format=html";
	window.open(loc);	
}

//If the browser detected is IE 4.0, then insert a Web Browser
//ActiveX object to provide print functionality
function insertWBforIE4() {
	if (da && !pr && !mac) {
	  document.writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
	  document.writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
	  document.writeln('Sub window_onunload');
	  document.writeln('  On Error Resume Next');
	  document.writeln('  Set WB = nothing');
	  document.writeln('End Sub');
	  document.writeln('Sub vbPrintPage');
	  document.writeln('  OLECMDID_PRINT = 6');
	  document.writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
	  document.writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
	  document.writeln('  On Error Resume Next');
	  document.writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER');
	  document.writeln('End Sub');
	  document.writeln('<' + '/SCRIPT>');
	}
}

function InterestSearch(SNT_CODE_1,SNT_CODE_2){
	var RnadDSelectIndex=document.frmInterestSearch.RandD.selectedIndex;
	var RnadISelectIndex=document.frmInterestSearch.RandI.selectedIndex;
	var RnadMSelectIndex=document.frmInterestSearch.RandM.selectedIndex;
	var RnadOSelectIndex=document.frmInterestSearch.RandO.selectedIndex;
	var RnadSSelectIndex=document.frmInterestSearch.RandS.selectedIndex;
	var Int1;
	var int2;
	var Int3;
	var cout=0;
	//D selected index
	switch (RnadDSelectIndex){
	case 0:
		cout = cout + 1;
		break;
	case 1: 
		Int1="D"; 
		break;
	case 2:
		Int2="D";
		break;
	case 3:
		Int3="D";  
		break;
	}
    
    //I selected index
	switch (RnadISelectIndex){
	case 0:
		cout = cout + 1;
		break;
	case 1: 
		Int1="I"; 
		break;
	case 2:
		Int2="I";
		break;
	case 3:
		Int3="I";  
		break;
	} 
    
    //M selected index
	switch (RnadMSelectIndex){
	case 0:
		cout = cout + 1;
		break;
	case  1: 
		Int1="M"; 
		break;
	case 2:
		Int2="M"; 
		break;
	case 3:
		Int3="M";   
		break;
	} 
    
	//O selected index
	switch (RnadOSelectIndex){
	case 0:
		cout = cout + 1;
		break;
	case 1: 
		Int1="O"; 
		break;
	case 2:
		Int2="O";
		break;
	case 3:
		Int3="O";  
		break;
	} 
    
	//S selected index
	switch (RnadSSelectIndex){
	case 0:
		cout = cout + 1;
		break;
	case  1: 
		Int1="S"; 
		break;
	case 2:
		Int2="S";
		break;
	case 3:
		Int3="S";  
		break;
    }
	if (cout > 2 ){
		alert("Please rank three interests");
		return false;
	}else{
		var loc = "RequestAction.asp?";
		loc = loc + "format=html" + String.fromCharCode("38") + "aspAction=GetInterestSearchResult"+ String.fromCharCode("38") + "Page=InterestSearchResult"+ String.fromCharCode("38") + "INT_1=" + Int1; 
		loc = loc + String.fromCharCode("38") + "INT_2=" + Int2+ String.fromCharCode("38") + "INT_3=" + Int3; 
		loc =loc + String.fromCharCode("38")+"Results=true";
		loc =loc + String.fromCharCode("38")+"SNT_CODE_1="+ SNT_CODE_1+String.fromCharCode("38")+"SNT_CODE_2="+SNT_CODE_2;
		top.document.location.href = loc;
		return true;
	}
}

function NOCSearch(){
	if (document.frmProgramSearch.NOC.value.length < 3 ||
		document.frmProgramSearch.NOC.value.Length > 6) {
		alert("You must enter 3-5 digits in the NOC field.");
	}else{
		document.frmProgramSearch.aspAction.value = "NOCSearch";
		document.frmProgramSearch.submit();
	}
}	
	
function openKeyReportWindow(Report,SnipCodeIntro,SnipCodeIntD,SnipCodeIntI,SnipCodeIntM,SnipCodeIntO,SnipCodeIntS,SnipCodefooter){
	var File = "../Content/RequestReport.asp?Format=HTML&aspAction=" + Report ;
	File = File + String.fromCharCode("38") + "SnipCodeIntro=" + SnipCodeIntro + String.fromCharCode("38") + "SnipCodeIntD=" + SnipCodeIntD + String.fromCharCode("38") + "SnipCodeIntI=" + SnipCodeIntI; 
	File = File + String.fromCharCode("38") + "SnipCodeIntM=" + SnipCodeIntM + String.fromCharCode("38") + "SnipCodeIntO=" + SnipCodeIntO + String.fromCharCode("38") + "SnipCodeIntS=" + SnipCodeIntS; 
	File = File + String.fromCharCode("38") + "SnipCodefooter=" + SnipCodefooter; 
	window.open(File, "Report"); 
}

function openHelpWindow(File){
	var width = 500;
	var height = 400;
	var left = (window.screen.availWidth - width)/2;
	var top = (window.screen.availHeight - height)/2;
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	window.open(File, "Help", options);
}

function openInterestProfileWindow(TLT_TITLE,NOC_CODE,INT_CODE_LIST){
	var loc = "RequestAction.asp?aspAction=GetHTMLInterestProfile";
	loc = loc + String.fromCharCode("38") + "TLT_TITLE=" + TLT_TITLE;
	loc = loc + String.fromCharCode("38") + "NOC_CODE=" + NOC_CODE;
	loc = loc + String.fromCharCode("38") + "INT_CODE_LIST=" + INT_CODE_LIST;
	loc = loc + String.fromCharCode("38") + "format=html";
	
	var width = 640;
	var height = 480;
	var left =50;
	var top = 0;
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
    window.open(loc, "", options);
}


/*function openNocList(){
	var strNOC = new String(trim(document.frmNOCSearch.elements["NOC"].value));
	if (strNOC.length <= 0 || strNOC.lenght > 6) {
		alert("Please enter 1 to 5 digits for the NOC Number Search.");
		return false;
	}else{
		var NOC = new Number(strNOC);
		// To make sure the NOC is a number
		if (isNaN(NOC)){
			alert("Please enter 1 to 5 digits for the NOC Number Search.");
			return false;
		}else{
			var loc = "../RequestAction.asp?SNT_ID=28"+ String.fromCharCode("38") +"aspAction=GetTitlesForNOC&";
			loc = loc + "format=html&";
			loc = loc + "Page=NocSearch&";
			loc = loc + "NOC=" + strNOC;
			alert("loc is:" + loc);
			top.document.location.href = loc;
		    return true;
		}
	}
}
*/

function openNocSearchResults(){
	alert("openNocSearchResults");
	var NOC = document.frmOpenNOCList.elements["NocCode"].value;
	var width = window.screen.availWidth/2;
	var height = window.screen.availHeight/2;
	var left = window.screen.availWidth/4;
	var top = window.screen.availHeight/4;
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	var loc = "RequestAction.asp?aspAction=GetTitlesForNOC&Page=NocSearch&NOC=" + NOC + "&format=html";
	window.open(loc, "", options);
}

function openProfileWindow(occPro_ID,SNT_ID){
	//Open the profile with the given id in a new browser window.
	var loc = "RequestAction.asp?aspAction=GetHTMLProfile" + String.fromCharCode("38");
	loc = loc + "format=html" + String.fromCharCode("38");
	loc = loc + "occPro_ID=" + occPro_ID+ String.fromCharCode("38");
	if (isNaN(SNT_ID)){
		loc = loc +"SNT_ID=25";
	}else{
		loc = loc +"SNT_ID=" + SNT_ID;
	}
    var left =0;
	var top = 0;
	var width = 640;
	var height = 480;
	var left = (window.screen.availWidth - width)/2;
	var top = (window.screen.availHeight - height)/2;
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	window.open(loc, "", options);
}

function openReportWindow(Report){
	//	Open the given reports in a new browser window.
	var File = "../Content/RequestReport.asp?Format=HTML&aspAction=" + Report 
	window.open(File, "Report"); 
}


function openStatementWindow(Statement, width, height){
	//	Open the given statement snippet in a new browser window.
	var left = (window.screen.availWidth - width)/2;
	var top = (window.screen.availHeight - height)/2;
	var File = "../Content/RequestAction.asp?Format=HTML&aspAction=GetSnippet&SNT_ID=" + Statement
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	window.open(File, "", options);
}

//=========================================================================
//
//IE 4.0 Print Compatibility Functions
//====================================
//	This following javascript functions provide javascript
//	print compatibility for IE 4.0
// The flow of the printing process is: 
//		PrintThis() -> vbPrintPage()

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 
function printThis(){
	if (pr) { 						// NS4, IE5
		window.print();
	}else if (da && !mac) { 		// IE4 (Windows)
		vbPrintPage();
	}else{ 							// other browsers
		alert("Sorry, your browser doesn't support this feature.");
	}
}



function printSelected(frm){
	//	Opens the selected profiles in a new browser window.
	var loc = "RequestAction.asp?aspAction=GetHTMLProfile" + String.fromCharCode("38") + "format=html";
	var items = frm.elements;
	var match = false;
	for (var i = 0; i < items.length; i++)
		if (items[i].type == "checkbox" && items[i].checked == true){
			loc = loc + "&OCCPRO_ID=" + items[i].value;
			match = true;
		}

	if (match){
		var width = 600;
		var height = 400;
		var left = (window.screen.availWidth - width)/2;
		var top = (window.screen.availHeight - height)/2;
		var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
		window.open(loc, "", options);
	}
	else
		alert ('Please select at least one profile.');
}


function printInterestPage(sPage, sMenu,snt_value,splitor){
	var loc = "RequestAction.asp?aspAction=" + sPage;
	loc = loc + String.fromCharCode("38") + "Page=" + sMenu;
	loc = loc + String.fromCharCode("38") + "SNT_CODE_LIST=" + snt_value;
	loc = loc + String.fromCharCode("38") + "SPLIT=" + splitor;
	loc = loc + String.fromCharCode("38") + "format=html";
	
	//get the option for dropdown list
	var currentIndex;
	var RnadDSelectIndex;
	var RnadISelectIndex;
	var RnadMSelectIndex;
	var RnadOSelectIndex;
	var RnadSSelectIndex;
	RnadDSelectIndex=document.frmInterestSearch.RandD.selectedIndex;
	RnadISelectIndex=document.frmInterestSearch.RandI.selectedIndex;
	RnadMSelectIndex=document.frmInterestSearch.RandM.selectedIndex;
	RnadOSelectIndex=document.frmInterestSearch.RandO.selectedIndex;
	RnadSSelectIndex=document.frmInterestSearch.RandS.selectedIndex;    
	loc = loc + String.fromCharCode("38") + "D=" + document.frmInterestSearch.RandD.options[document.frmInterestSearch.RandD.selectedIndex].value;
	loc = loc + String.fromCharCode("38") + "I=" + document.frmInterestSearch.RandI.options[document.frmInterestSearch.RandI.selectedIndex].value;
	loc = loc + String.fromCharCode("38") + "M=" + document.frmInterestSearch.RandM.options[document.frmInterestSearch.RandM.selectedIndex].value;
	loc = loc + String.fromCharCode("38") + "O=" + document.frmInterestSearch.RandO.options[document.frmInterestSearch.RandO.selectedIndex].value;
	loc = loc + String.fromCharCode("38") + "S=" + document.frmInterestSearch.RandS.options[document.frmInterestSearch.RandS.selectedIndex].value;
	//var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	window.open(loc);
}

function printPersonListPage(sPage, sMenu,sSNT_IDY,sSNT_IDN)
{
   var loc = "RequestAction.asp?";
   var List  = getList();
   loc = loc + "format=html" + String.fromCharCode("38") + "aspAction=" + sPage + String.fromCharCode("38") + "Page=" + sMenu ; 
   loc = loc + String.fromCharCode("38") + "List=" + List;
   loc = loc +  String.fromCharCode("38")+ "SNT_ID_Y=" + sSNT_IDY + String.fromCharCode("38")+ "SNT_ID_N=" + sSNT_IDN;
   	window.open(loc);
}

function getEmergingOccupations(){
	var loc = "RequestAction.asp?aspAction=GetTitlesSearchEmergingOccs";
	loc = loc + String.fromCharCode("38") + "Page=EmergingOccs";
	loc = loc + String.fromCharCode("38") + "SNT_ID=55";
	loc = loc + String.fromCharCode("38") + "format=html";
	document.location.href = loc;
}

function printPage(sAction, sMenu, value){
	getPage(sAction, sMenu, value);
}

function getPage(sAction, sMenu, value){		
	var loc = "RequestAction.asp?aspAction=" + sAction;
	loc = loc + String.fromCharCode("38") + "Page=" + sMenu ; 
	
	switch (sAction){
		case "GetFieldStudySearchPrintF":
		case "GetPrintPosterSearchPrintF":
		case "GetReportsPagePrintF":		
		case "GetSchoolSubjectSearch":
		case "GetSchoolSubjectSearchPrintF":
		case "GetSubjectSearchPrintF":
		case "GetTitlesSearchAllPrintF":
		case "GetTitlesSearchEmergingOccsPrintF":
		case "GetTitlesSearchNewUpdatedPrintF":
		case "GetTitlesSearchOtherLetterPrintF":
			loc = loc + String.fromCharCode("38") + "SNT_ID=" + value;
			break;
		case "GetFieldStudySearchResultPrintF":
		case "GetSchoolSubjectSearchResultPrintF":
			loc = loc + String.fromCharCode("38") + value.replace(";",String.fromCharCode("38"));
			break; 	
		case "GetAllClusterTitlesPrintF": 
	
		case "GetNOCSearchPrintF":
			loc = loc + String.fromCharCode("38") + "NOC=" + trim(document.frmNOCSearch.NOC.value);
			break;
		case "GetClusterKeywordSearchPrintF":
			loc = loc + String.fromCharCode("38") + "Keyword=" + value;
			break;		
	}

	loc = loc + String.fromCharCode("38") + "format=html";		      	
       			 			             
	if(sAction=='GetAdvSearchPrintF'){ 
		var arr;
		var arrValue;
		var x = 1;
		var index = 0;
		var strURL = "";
		for(index = 0; index < value.length; index++){value = value.replace(",","/");}
		arr = value.split(";");
		if(arr.length>0){ 				    			  
			for (x = 1; x < arr.length; x++){
				arrValue = arr[x];
				if(arrValue.indexOf("/")>0){
					var items = arrValue.split("=");
					if(items.length > 1){
						var name = items[0];
						var valueList = items[1];
						var arrValueList = valueList.split("/");
						if (arrValueList.length > 0){
							for(index = 0; index < arrValueList.length; index++){
								if(strURL==""){
									strURL = name + '=' + arrValueList[index];
								}else{
									strURL = strURL + "&" + name + '=' + arrValueList[index];
								}  
							}
							for(index = 0; index < strURL.length; index++){strURL = strURL.replace(" ","");}     
						}
					}   	    
				}else{
					if(arr[x].indexOf("aspAction") == -1 ){
						if(strURL == "") 
							strURL = arr[x];
						else
							strURL = strURL + String.fromCharCode("38") + arr[x];
					}
				}     
			}
			loc = "RequestAction.asp?aspAction=" + sAction + "&" + strURL
			//keep the checkbox status
			var Trachecked= false;
			if (document.frmAdvancedSearch.Apprentice.checked) {Trachecked = true;}
			var PID=0;
			index =document.frmAdvancedSearch.LiftingLevel.selectedIndex;
			PID= document.frmAdvancedSearch.LiftingLevel.options[index].value; 
			loc = loc + String.fromCharCode("38") + "TradeChk=" + Trachecked;
			loc = loc + String.fromCharCode("38") + "PID=" + PID;
						 
		}
	}
							
										
	if(sAction=='GetTitlesAdvPrintF'){
		var arr,arrValue;
		var x = 1;
		var index = 0;
		var strURL = "";
		for(index = 0; index < value.length; index++){value = value.replace(",","/");}
		arr = value.split(";");
		if(arr.length > 0){ 				    			  
			for (x = 1; x < arr.length; x++){
				arrValue = arr[x];
				if(arrValue.indexOf("/")>0){
					var items = arrValue.split("=");
					if(items.length > 1){
						var name = items[0];
						var valueList = items[1];
						var arrValueList = valueList.split("/");
						if (arrValueList.length>0){
							for(index = 0; index < arrValueList.length; index++){
								if(strURL == ""){
									strURL = name + '=' + arrValueList[index];
								}else{
									strURL = strURL + "&" + name + '=' + arrValueList[index];
								}  
							}
							for(index = 0; index < strURL.length; index++){strURL = strURL.replace(" ","");}     
						}
					}   	    
				}else{
					if(arr[x].indexOf("aspAction") == -1 ){
						if(strURL == "") 
							strURL = arr[x];
						else
							strURL = strURL + String.fromCharCode("38") + arr[x];
					}
				}     
			}
			loc = "RequestAction.asp?aspAction=" + sAction + "&" + strURL;
		}
	}
	window.open(loc);
}


// Remove the specified Item from the Personal List if it is already in the list.
function removeFromList(Item) {

	var val = GetCookie(COOKIENAME);
	if (val){
		var i = val.indexOf(Item + SEPERATOR);
		if (i >= 0){
			val = val.substring(0, i) + val.substring((i + Item.length + SEPERATOR.length), val.length);
			SetCookie(COOKIENAME, val);
		}
	}
}


function removeItemsFromList(frm){
	var items = frm.elements;
	for (var i = 0; i < items.length; i++)
		if (items[i].type == "checkbox" && items[i].checked == true)
			removeFromList(items[i].value);
}


function removeSelected(frm,SNT_Y,SNT_N){
	//removeItemsFromList(frm);
	var items = frm.elements;
	var count = 0;
	for (var i = 0; i < items.length; i++)
		if (items[i].type == "checkbox" && items[i].checked == true){
			removeFromList(items[i].value);
			count++;
		}
	if (count > 0){
		alert("" + count + " profile(s) have been removed from your Personal List");
		var loc = "RequestAction.asp?aspAction=GetTitlesFromList";
		loc = loc + String.fromCharCode("38") + "SNT_ID_Y=" + SNT_Y;
		loc = loc + String.fromCharCode("38") + "SNT_ID_N=" +SNT_N;
		loc = loc + String.fromCharCode("38") + "Page=PersonalList";
		loc = loc + String.fromCharCode("38") + "List=" + getList();
		loc = loc + String.fromCharCode("38") + "format=html";
		document.location.href = loc;
	}

	if (count==0){
	alert("Please select at least one occupational profile.");
	return false;
	}		
}

function ResetInterest()
{
     document.frmInterestSearch.RandD.options[0].selected = true;
     document.frmInterestSearch.RandI.options[0].selected = true;
     document.frmInterestSearch.RandM.options[0].selected = true;   
     document.frmInterestSearch.RandO.options[0].selected = true;
     document.frmInterestSearch.RandS.options[0].selected = true; 
     document.frmInterestSearch.RandD.disabled = false;
     document.frmInterestSearch.RandI.disabled = false; 
     document.frmInterestSearch.RandM.disabled = false;
     document.frmInterestSearch.RandO.disabled = false; 
     document.frmInterestSearch.RandS.disabled = false;
    
}

function rtrim(aString) {
	var str;
	str = new String(aString);
	
	while (str.lastIndexOf(" ") == str.length-1 && str.length > 0)
		str = str.substring(0, str.length-1);
	return str;
}


 function schoolSearchResSelectAll(frm)
 { 	var items =frm.elements;
	for (var i = 0; i < items.length; i++)
	{ if (items[i].type == "checkbox") 
			{    items[i].checked = true;
		     
		    }  		    
	}   
}
 
 
function schoolSearchResDeSelectAll(frm)
 {
	var items =frm.elements;
	for (var i = 0; i < items.length; i++)
	{ if (items[i].type == "checkbox") 
			    items[i].checked = false;
	}   
}

 		

function SchoolSubjectSearch(frm,Snip_Code_1,Snip_Code_2)
{
   	//var items = document.frmSchoolSubjectSearch.elements;
	var items =frm.elements; 
	var count = 0;
	var strSubjectID="";
	for (var i = 0; i < items.length; i++)
	{  if (items[i].type == "checkbox" && items[i].checked == true) 
		{	if(strSubjectID.length>0)
		    {   strSubjectID=strSubjectID+","+items[i].value;}
		    else
		    { strSubjectID=items[i].value;}
			count++;
		}
	}
	if(count == 0)
	{   alert("Please select at least one subject.");
		return false;
	}
	else
	{  if (count > 6)
	   { alert("Please select fewer than seven subjects.");
		 return false;
	   }
	   else
	   { var loc = "RequestAction.asp?";
		 loc = loc + "format=html" + String.fromCharCode("38") + "aspAction=GetSchoolSubjectSearchResult"+ String.fromCharCode("38") + "Page=SchoolSubjectSearchResult"+ String.fromCharCode("38") + "SUBJECT_ID_LIST=" + strSubjectID; 
		 loc =loc + String.fromCharCode("38")+"SCODE="+Snip_Code_1+","+Snip_Code_2;
		 top.document.location.href = loc;
		 return true;
	   }
	}
}


function selectLevel()
 {
	
	document.frmAdvancedSearch.aspAction.value = "GetAdvSearch";
	document.frmAdvancedSearch.submit();
}

//  Function to create or update a cookie.
//    name - String object containing the cookie name.
//    value - String object containing the cookie value.  May contain
//      any valid string characters.
//    [expires] - Date object containing the expiration data of the cookie.  If
//      omitted or null, expires the cookie at the end of the current session.
//    [path] - String object indicating the path for which the cookie is valid.
//      If omitted or null, uses the path of the calling document.
//    [domain] - String object indicating the domain for which the cookie is
//      valid.  If omitted or null, uses the domain of the calling document.
//    [secure] - Boolean (true/false) value indicating whether cookie transmission
//      requires a secure channel (HTTPS).  
//
//  The first two parameters are required.  The others, if supplied, must
//  be passed in the order listed above.  To omit an unused optional field,
//  use null as a place holder.  For example, to call SetCookie using name,
//  value and path, you would code:
//
//      SetCookie ("myCookieName", "myCookieValue", null, "/");
//
//  Note that trailing omitted parameters do not require a placeholder.
//
//  To set a secure cookie for path "/myPath", that expires after the
//  current session, you might code:
//
//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
//
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}


	
				
function trim(aString)
 {
	return rtrim(ltrim(aString));
}

	function openNocList() {
			var NOC;
			if ( document.frmNOCSearch.elements["NOC"] != null)
			{	 NOC = document.frmNOCSearch.elements["NOC"].value;
                NOC= NOC.replace('.0','');	
           	}
				var width = window.screen.availWidth/2;
				var height = window.screen.availHeight/2;
				var left = window.screen.availWidth/4;
				var top = window.screen.availHeight/4;
				var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
				open("RequestAction.asp?SNT_CODE=NOCHSSResultYes"+ String.fromCharCode("38") +"aspAction=GetTitlesForNOC" + String.fromCharCode("38") + "format=html" + String.fromCharCode("38") + "Page=NocSearch" + String.fromCharCode("38") + "NOC=" + NOC, "", options);
				//window.location.reload(false);
				//document.frmNOCSearch.elements["NOC"].value = NOC;
			}
			
			
function tabOnEnter (field, evt) 
{
  var keyCode = document.layers ? evt.which:document.all ?evt.keyCode : evt.keyCode;
  if (keyCode == 13)
    {        //pop up new window 
              var NOC;
				if ( document.frmNOCSearch.elements["NOC"] != null)
				{	 NOC = document.frmNOCSearch.elements["NOC"].value;
					NOC= NOC.replace('.0','');	
           		}
				var width = window.screen.availWidth/2;
				var height = window.screen.availHeight/2;
				var left = window.screen.availWidth/4;
				var top = window.screen.availHeight/4;
				var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
				window.open("RequestAction.asp?SNT_CODE=NOCHSSResultYes"+ String.fromCharCode("38") +"aspAction=GetTitlesForNOC" + String.fromCharCode("38") + "format=html" + String.fromCharCode("38") + "Page=NocSearch" +       		String.fromCharCode("38") + "NOC=" + NOC, "", options);
				return false;
  }
}

function toggleDisplay(idnum)
{
	//toggle the plus/minus img
	img = document.getElementById('img' + idnum);
	if (img.src.indexOf('plus.gif') > 0) {
		img.src = '../images/minus.gif';
		img.alt = 'Minus';
	} else {
		img.src = '../images/plus.gif';
		img.alt = 'Plus';
	}
	
	//check all rows of the table for the ones to hide/show
	els = document.getElementsByTagName('TR');
	for (i = 0; i < els.length; i++) {
		if (els[i].id == idnum) {
			if (els[i].style.display == 'none')
				els[i].style.display = 'block';
			else
				els[i].style.display = 'none';
		}
	}
}


