//=========================================================================
//
//WAGEINFO Page Functions
//=======================

//	This following javascript functions are used on
//	various pages in the WAGEINFO website.

//Region:Occinfo
//Reason:Wageinfo used Occinfo project so copy all Occinfo function in here
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 printPage(sPage, sMenu,value) {
	var strValue="";
	var valueName ="";
	var loc = "RequestAction.asp?";
	loc = loc + "format=html" + String.fromCharCode("38") + "aspAction=" + sPage + String.fromCharCode("38") + "Page=" + sMenu ; 
	
	switch (sPage)
	{
	  case  "GetWageNOCSearchResultPrintF": 
	     valueName = value;
	      loc = loc + "&" + valueName;			
	     break;
	 case  "GetWageSalarySearchResultPrintF": 
	    	   valueName = value;
	    	   loc = loc + "&" + valueName;			
	   break;
	   case  "GetWageKeyWordSearchResultPrintF": 
	   	   valueName = value;
	   	   loc = loc + "&" + valueName;			
	   break;
	   case "GetWageAlphaSearchResultPrintF":
	  	   valueName = value;
	    	   loc = loc + "&" + valueName;			
	 break;
	   case "GetWageSurveyPrintF":
	         valueName = "SNT_ID=";
	         loc = loc + "&" + valueName + value;			
	   break;
	   case "GetWageAnalysisPrintF":
	         valueName = "SNT_ID=";
	         loc = loc + "&" + valueName + value;			
	   break;
	   
	}
				      	
	
	
	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 = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	//window.open(loc, "", options);
	window.open(loc);
}


// Open the Noc Code Keyword search results in a new window
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 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&";
			loc = loc + "format=html&";
			loc = loc + "Page=NocSearch&";
			//loc = loc + "NOC=" + NOC;
			loc = loc + "NOC=" + strNOC;
			open(loc, "", options);
			return false;
		}
	}
}


function 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&format=html&Page=NocSearch&NOC=" + NOC;
	window.open(loc, "", options);
}
		

//Region End



//this function return the current year 
function getCurrentDateYear()
{
	var today = new Date();
	var Year = takeYear(today);
	return Year;
}

function takeYear(theDate)
{
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}

//	If the required number of characters are entered
//	then submit the Keyword Search, otherwise show an alert.
function GetIndustryWagePage(NocCode,IndustryCode)
{

	var width = 640;
	var height = 480;
	var left = window.screen.availWidth/8;
	var top = window.screen.availHeight/10;
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	window.open("RequestAction.asp?aspAction=GetWageIndustryWage" + String.fromCharCode("38") + "format=html" + String.fromCharCode("38") + "NocCode=" + NocCode + String.fromCharCode("38") + "IndustryCode=" +IndustryCode, "test2", options);
	//open("RequestAction.asp?aspAction=GetWageIndustryWage" + String.fromCharCode("38") + "format=html" + String.fromCharCode("38") + "NocCode=" + NocCode + String.fromCharCode("38") + "IndustryCode=" +IndustryCode, "winIndustry", "");
}
    

function WageSearch(strPage)
{
     var obj;
     obj =  document.frmWageSearch.sltRegion;
   
     document.frmWageSearch.RegionID.value =  new String(trim(obj.options[obj.selectedIndex].value));
  		
  	
    switch(strPage)
	   {
	      case "SearchKeyword":
	         var str =  new String(trim(document.frmWageSearch.SearchContent.value));
			 if (str.length < 3)
			 {
					alert("Please enter at least 3 characters in the Keyword field.");
					return false;
					break;
			  }
			  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;
						break;
					}
				 else
					{  	return true;
					    break;
					 }
			 }
		  case "SearchNoc":
		      var str =  new String(trim(document.frmWageSearch.SearchContent.value));
	          if (str.length != 4)
			  {
				alert("Please enter a 4 digit number in the NOC field.");
				return false;
				break;
			  }
		     else
			 {	//Check for invalid characters
				if (isNaN(document.frmWageSearch.SearchContent.value))
				{
					alert("Please enter a valid numeric NOC number.");
					return false;
					break;
				 }
		        else
				{  	return true; 
				    break;
				}
			 }
		case "SearchSalary":
		       return confirmSalary();
		        break;
			
    
	    }
}


function confirmSalary()
{

   
    var MinSal = new String(trim(document.frmWageSearch.MinSal.value));
    var MaxSal =new String(trim(document.frmWageSearch.MaxSal.value));
  
   //check if user enter the maximum salary 
   if ((MaxSal == "") || (MaxSal == ".00") || MaxSal=="0" ||MaxSal < 1)
	{
	  alert("Please enter the Maximum Annual Salary.");
	  return false; 
	}
 
     //check if the Min Salary and Max salary contain invalid character
     if (isNaN(MinSal.replace(".","").replace(",","")))
	{
	   alert("Please enter a valid numeric Minimum Annual Salary.");
	   return false;
	}

  	if (isNaN(MaxSal.replace(".","").replace(",","")))
	{
	   alert("Please enter a valid numeric Maximum Annual Salary.");
	 	return false;
	}
	
	//only allow 7 characher on Salary textbox
	if (MaxSal.length >7 || MinSal.length > 7) 
	{
	 alert("Maximum Annual Salary and Minimum Annual Salary can't enter more than 7 characher.");
	 return false;
	}

	if (MinSal == "" || MinSal == ".00" ) 
	{
	   MinSal = "0";
	}
  
	MinSal = MinSal.replace(",","");
	MaxSal = MaxSal.replace(",","");
        
    if ( Number(MinSal) > Number(MaxSal)) 
    {
     alert("Please ensure the Maximum Annual Salary is greater than the Minimum Annual Salary.");
     return false; 
    }
	
  	document.frmWageSearch.MinSal.value =Math.round(MinSal) ;
	document.frmWageSearch.MaxSal.value =Math.round(MaxSal) ;
	
}

//when user click the enter key,It will submit form
function TestKeyPress(PageName) 
{
   if (event.keyCode == 13)
   {
	    switch(PageName)
	   {
	      case "SearchKeyword":
	          if (WageSearch(PageName))
				{document.frmWageSearch.submit();}
				break;
		   case "SearchNoc":		
				if (WageSearch(PageName))
				{document.frmWageSearch.submit();}
				break;
		   case "SearchSalary":
		         SalaryButtonClick();
		   		
	    }
	}
}
				
				
	
//function to redirect the asp page
function getPages(sAction, sPage) 
{ 
   	var loc = "RequestAction.asp?";
	loc = loc + "format=html" + String.fromCharCode("38") + "aspAction=" + sAction + String.fromCharCode("38") ;
	loc= loc +  "Page=" + sPage; 
	
	top.document.location.href = loc;
}
	
//add snip code ID as a parameter to retrieve the snip code information
function getPagesWithSnip(sAction, sPage,sSnipCodeID)
{
	var loc = "RequestAction.asp?";
	loc = loc + "format=html" + String.fromCharCode("38") + "aspAction=" + sAction + String.fromCharCode("38") ;
	loc= loc +  "Page=" + sPage; 
	loc=loc + String.fromCharCode("38") +"SNT_ID=" + sSnipCodeID;
	top.document.location.href = loc;
}



function getTitles(FirstLetter) 
{
	 var obj;
     obj =  document.frmWageSearch.sltRegion;
     var regionID; 
     var ProfileType;
     regionID =  new String(trim(obj.options[obj.selectedIndex].value));
     obj =  document.frmWageSearch.sltProfile;
     ProfileType =  new String(trim(obj.options[obj.selectedIndex].value));

    document.frmWageSearch.RegionID.value =  new String(trim(obj.options[obj.selectedIndex].value));
  	var loc = "RequestAction.asp?aspAction=GetWageAlphaSearchResult" + String.fromCharCode("38");
	loc = loc + "format=html" + String.fromCharCode("38");
	loc = loc + "Page=SearchAlpha" + String.fromCharCode("38");
	loc = loc + "SearchContent=" + FirstLetter + String.fromCharCode("38");
	loc = loc + "RegionID=" + regionID+ String.fromCharCode("38");
	loc = loc + "ProfileType=" + ProfileType;
	document.location.href = loc;
}


			
function getOther()
 {
	 var obj;
     obj =  document.frmWageSearch.sltRegion;
     var regionID; 
     var ProfileType;
     regionID =  new String(trim(obj.options[obj.selectedIndex].value));
     obj =  document.frmWageSearch.sltProfile;
     ProfileType =  new String(trim(obj.options[obj.selectedIndex].value));
  	var loc = "RequestAction.asp?aspAction=GetWageAlphaSearchResult" + String.fromCharCode("38");
	loc = loc + "format=html" + String.fromCharCode("38");
	loc = loc + "Page=SearchAlpha" + String.fromCharCode("38");
	loc = loc + "SearchContent=Other" + String.fromCharCode("38");
	loc = loc + "RegionID=" + regionID+ String.fromCharCode("38");
	loc = loc + "ProfileType=" + ProfileType;
	document.location.href = loc;
}
	
			
function getAll()
 {
	 var obj;
     obj =  document.frmWageSearch.sltRegion;
     var regionID; 
     var ProfileType;
     regionID =  new String(trim(obj.options[obj.selectedIndex].value));
     obj =  document.frmWageSearch.sltProfile;
     ProfileType =  new String(trim(obj.options[obj.selectedIndex].value));
  	var loc = "RequestAction.asp?aspAction=GetWageAlphaSearchResult" + String.fromCharCode("38");
	loc = loc + "format=html" + String.fromCharCode("38");
	loc = loc + "Page=SearchAlpha" + String.fromCharCode("38");
	loc = loc + "SearchContent=All" + String.fromCharCode("38");
	loc = loc + "RegionID=" + regionID+ String.fromCharCode("38");
	loc = loc + "ProfileType=" + ProfileType;
	document.location.href = loc;
}

	


function SalaryButtonClick()
{

        
     var obj;
     obj =  document.frmWageSearch.sltRegion;
     document.frmWageSearch.RegionID.value =  new String(trim(obj.options[obj.selectedIndex].value));
               
     var MinSal = new String(trim(document.frmWageSearch.MinSal.value));
     var MaxSal =new String(trim(document.frmWageSearch.MaxSal.value));
        
          
    //check if user enter the maximum salary 
     if ((MaxSal == "") || (MaxSal == ".00") || MaxSal=="0" ||MaxSal < 1)
	{
	  alert("Please enter the Maximum Annual Salary.");
	  return false; 
	}
 
     //check if the Min Salary and Max salary contain invalid character
     if (isNaN(MinSal.replace(".","").replace(",","")))
	{
	   alert("Minimum Annual Salary can't contain invalid character.");
	   return false;
	}
	
	
	if (isNaN(MaxSal.replace(".","").replace(",","")))
	{
	   alert("Maximum Annual Salary can't contain invalid character.");
    	return false;
	}
	
	
	//only allow 7 characher on Salary textbox
	if (MaxSal.length >7 || MinSal.length > 7) 
	{
	 alert("Maximum Annual Salary and Minimum Annual Salary can't enter more than 7 characher.");
	 return false;
	}


	
	if (MinSal == "" || MinSal == ".00" ) 
	{
	   MinSal = "0";
	}
  
	MinSal = MinSal.replace(",","");
	MaxSal = MaxSal.replace(",","");
    
    
    if ( Number(MinSal) > Number(MaxSal)) 
    {
     alert("Please ensure the Maximum Annual Salary is greater than the Minimum Annual Salary.");
     return false; 
    }
     var obj;
     obj =  document.frmWageSearch.sltRegion;
     var regionID; 
    regionID =  new String(trim(obj.options[obj.selectedIndex].value));
  	var loc = "RequestAction.asp?aspAction=GetWageSalarySearchResult" + String.fromCharCode("38");
	loc = loc + "format=html" + String.fromCharCode("38");
	loc = loc + "Page=SearchSalary" + String.fromCharCode("38");
	loc = loc + "MinSal=" + Math.round(MinSal) + String.fromCharCode("38");
	loc = loc + "MaxSal=" + Math.round(MaxSal) + String.fromCharCode("38");
	loc = loc + "RegionID=" + regionID;
	document.location.href = loc;

}




function openWageDetail(NOC_CODE,Region_ID)
{
 
   	var width = 640;
	var height = 480;
	var left = window.screen.availWidth/8;
	var top = window.screen.availHeight/10;
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
//	open("RequestAction.asp?aspAction=GetWageDetail" +  String.fromCharCode("38") + "format=html" + String.fromCharCode("38") + "RegionID=" + Region_ID + String.fromCharCode("38") + "NOC=" +NOC_CODE, "winWageDetail", options);
  open("RequestAction.asp?aspAction=GetWageDetail" + String.fromCharCode("38") + "format=html" + String.fromCharCode("38") + "RegionID=" + Region_ID + String.fromCharCode("38") + "NOC=" +NOC_CODE, "","" );	

}



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 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 trim(aString) {
	return rtrim(ltrim(aString));
}



//function to search title based on SearchContent 
function getWageTitles(SearchContent)
 {
  
				var loc = "RequestAction.asp?aspAction=GetWageTitleSearchResult" + String.fromCharCode("38");
				loc = loc + "format=html" + String.fromCharCode("38");
				loc = loc + "Page=SearchResult" + String.fromCharCode("38")
				loc = loc + "SearchContent=" + SearchContent+ String.fromCharCode("38");
				loc = loc + "SearchType=alphabetic";
			//	loc = loc + "SearchType=alphabetic" + String.fromCharCode("38"); 
			//	loc=loc + "region=" + document.frmWageSearch.sltRegion.options.selectedIndex.value;
				document.location.href = loc;
}
	
			
function openNocProfileWindow(NocCode)
{
  

	
	var strCode ="";
	//test if the Noc code include.

	 if (NocCode.length > 4)
	 {
	
		if (NocCode.indexOf(".") > -1 ) 
		{
		  NocCode = NocCode.substring(0,NocCode.indexOf("."));
		}
		if ( NocCode.length >4 ) 
		{ strCode = NocCode.substring(0,4);}
		else
		{strCode = NocCode.substring(0,NocCode.length);}
			
	 }
	 else
	{
		 if ( NocCode.length > 0 )
		{ strCode = NocCode ;}
		else
	    { alert("invalid Noc Code");
			strCode =""
	    }   
	}		
	
	var width = 640;
	var height = 400;
	var left =window.screen.availWidth/8;
	var top = (window.screen.availHeight - height)/10;
	var URL;
	if (strCode.length > 0) 
	{ 
	//URL = "http://www23.hrdc-drhc.gc.ca/2001/e/groups/" + strCode + ".shtml";
	URL = "http://www5.hrsdc.gc.ca/NOC/English/NOC/2006/QuickSearch.aspx?val65=" + strCode;
	//var options = "menubar=yes;toolbar=yes;resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	window.open(URL, "", options);
	//window.open(URL);
	}
	
 	
	
}


function openProfileWindow(occPro_ID,SNT_ID) {
	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");;
    loc = loc + "SNT_ID=" + SNT_ID;
	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;
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height;
	window.open(loc, "", options);
	
}


//	Open the profile with the given id in a
//	new browser window.
function openOccproProfileWindow(occPro_ID,SNT_ID) {
	var loc = "RequestAction.asp?aspAction=GetWageOccproHTMLProfile" + String.fromCharCode("38");
	loc = loc + "format=html" + String.fromCharCode("38");
	loc = loc + "OCCPRO_ID=" + occPro_ID+ String.fromCharCode("38");
    loc = loc + "SNT_ID=" + SNT_ID;
	var width = 640;
	var height = 480;
	var left =window.screen.availWidth/8;
	var top = (window.screen.availHeight - height)/10;
	
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	window.open(loc, "", options);
	//window.open(loc);
	
}



//	Open the Wage page  with the given NOCID in a new browser window.
function OpenWageViewPage(NOC_ID) {
	var loc = "RequestAction.asp?aspAction=GetWageViewPageHTMLProfile" + String.fromCharCode("38");
	loc = loc + "format=html" + String.fromCharCode("38");
	loc = loc + "NOC_ID=" + NOC_ID;

	var width = 640;
	var height = 480;
	//var left = (window.screen.availWidth - width)/8;
	//var top = (window.screen.availHeight - height)/10;

	//var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height;
	window.open(loc, "", options);

}



//	Opens the selected profiles in a new browser window.
function printSelected(frm) {
	var loc = "RequestAction.asp?aspAction=GetHTMLProfile" + String.fromCharCode("38");
	loc = loc + "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.');
}


//	Open the given Help File in a
//	new browser window.


function openHelpWindow(File) {
	var width = 500;
	var height = 400;
	var left = (window.screen.availWidth - width)/8;
	var top = (window.screen.availHeight - height)/10;
	var options = "resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	window.open(File, "Help", options);
	//window.open(File, "Help", "");
}

//	Open the given reports in a new browser window.
function openReportWindow(Report) {
	var File = "../Content/RequestReport.asp?Format=HTML&aspAction=" + Report 
	window.open(File, "Report"); 
}

//	Open the given statement snippet in a
//	new browser window.
function openWageStatementWindow(Statement, width, height) {
	
	var left = (window.screen.availWidth - width)/8;
	var top = (window.screen.availHeight - height)/10;
	var File = "../Content/RequestAction.asp?Format=HTML&aspAction=GetWageSnippet&SNT_ID=" + Statement

	var options = "title=test,resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	window.open(File, "", options);

}





//***************************************************************
//	Cookie Handling Functions from Cookie Functions -- "Night of 
//	the Living Cookie" Version (25-Jul-96)

//
// "Internal" function to return the decoded value of a cookie
//
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 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 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 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 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";
  }
}


//=========================================================================
//
//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.");
  }
}

//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>');
	}
}

// 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 = "???";
	}	
}

