// JavaScript Document

function sidebarSetup() {
	var nextMeeting = document.getElementById('nextMeeting');
	nextMeeting.href = "http://www.naic.org/meetings_home.htm";
	
	var allMeetings = document.getElementById('allMeetings');
	allMeetings.href = "http://www.naic.org/meetings_future_meetings.htm";
	
	var ereg = document.getElementById('ereg');
	ereg.innerHTML = "NAIC/NIPR E-Regulation Conference: May 6-9, 2007";
	ereg.href = "http://www.naic.org/ereg/";
	
	var naic = document.getElementById('naicWeb');
	naic.href = "http://www.naic.org/";
	
	var serff = document.getElementById('serff');
	serff.href = "http://www.serff.org/";
	
	var isite = document.getElementById('isite');
	isite.href = "http://i-site.naic.org/";
	
	var nipr = document.getElementById('nipr');
	nipr.href = "http://www.nipr.com/";
	
	var aithent = document.getElementById('aithent');
	aithent.href = "http://www.aithent.com/";
	
	var promissor = document.getElementById('promissor');
	promissor.href = "http://www.promissor.com/";
	
	var prometric = document.getElementById('prometric');
	prometric.href = "http://www.prometric.com/Default.htm";
}

function switchState(state) {
  if (state != "") {
    //RLW - remove '-public' from url - 08/27/08
    var OLSLinkString = "<a href='https://sbs-"
    OLSLinkString += state;
    OLSLinkString += ".naic.org/Lion-Web/jsp/onlineserv/profile.jsp' target='blank'>Online Licensee Services</a>";

    //RLW - remove '-public' from url - 08/27/08
    var ORLLinkString = "<a href='https://sbs-"
    ORLLinkString += state;
    ORLLinkString += ".naic.org/Lion-Web/jsp/ext/login/UserVerification.jsp' target='blank'>Online Resident Licensing</a>";

    //RLW - remove '-public' from url - 08/27/08
    var LicenseRenewLinkString = "<a href='https://sbs-";
    LicenseRenewLinkString += state;
    LicenseRenewLinkString += ".naic.org/Lion-Web/jsp/login/login_main.jsp' target='blank'>Renew Your Resident License</a>";

    var SERFFLinkString = "<a href='https://login.serff.com/' target='blank'>SERFF</a>";

    //RLW - remove '-public' from url - 08/27/08
    var LookUpLinkString = "<a href='https://sbs-";
    LookUpLinkString += state;
    LookUpLinkString += ".naic.org/Lion-Web/jsp/sbsreports/AgentLookup.jsp' target='blank'>Licensee Lookup</a>";

    //RLW - remove '-public' from url - 08/27/08
    var CourseCatalogString = "<a href='https://sbs-";
    CourseCatalogString += state;
    CourseCatalogString += ".naic.org/Lion-Web/jsp/extcelookup/ProviderLookup.jsp' target='blank'>Online Course Catalog</a>";

    if (state == "dc") {
      var stWeb = "<a href='http://disr.washingtondc.gov/disr/site/default.asp' target='blank'>State Web Site</a>";
    }
    else if (state == "de") {
      var stWeb = "<a href='http://www.delawareinsurance.gov/' target='blank'>State Web Site</a>";
    }
    else if (state == "ia") {
      var stWeb = "<a href='http://www.iid.state.ia.us/' target='blank'>State Web Site</a>";
    }    
    else if (state == "nj") {
      var stWeb = "<a href='http://www.state.nj.us/dobi/index.shtml' target='blank'>State Web Site</a>";
    }
    else if (state == "nh") {
      var stWeb = "<a href='https://www.nh.gov/insurance/' target='blank'>State Web Site</a>";
    }
    else if (state == "ri") {
      var stWeb = "<a href='http://www.dbr.state.ri.us/' target='blank'>State Web Site</a>";
    }
    else if (state == "nc") {
      var stWeb = "<a href='http://www.ncdoi.com/' target='blank'>State Web Site</a>";
    }
    else if (state == "fl") {
      var stWeb = "<a href='http://www.floir.com/' target='blank'>State Web Site</a>";
    }
    else if (state == "al") {
      var stWeb = "<a href='http://www.aldoi.org/' target='blank'>State Web Site</a>";
    }
    //12/9/08 - RLW - Add Kansas
    else if (state == "ks") {
      var stWeb = "<a href='http://www.ksinsurance.org/' target='blank'>State Web Site</a>";
    }

    var _mydiv = document.getElementById('services');
    
    /*if (state == "nj" || state == "ia") {
      _mydiv.innerHTML = ""
      _mydiv.innerHTML += OLSLinkString + "<br>";
      //_mydiv.innerHTML += ORLLinkString + "<br>";
      _mydiv.innerHTML += LicenseRenewLinkString + "<br>";
      _mydiv.innerHTML += LookUpLinkString + "<br>";
      _mydiv.innerHTML += stWeb;
    }
    else if (state == "de" || state == "ri") {
      _mydiv.innerHTML = ""
      _mydiv.innerHTML += OLSLinkString + "<br>";
      _mydiv.innerHTML += ORLLinkString + "<br>";
      _mydiv.innerHTML += LicenseRenewLinkString + "<br>";
      _mydiv.innerHTML += LookUpLinkString + "<br>";
      _mydiv.innerHTML += CourseCatalogString + "<br>";
      _mydiv.innerHTML += stWeb;
    }
    else if (state == "fl") {
      _mydiv.innerHTML = "<br>"
      //_mydiv.innerHTML += OLSLinkString + "<br>";
      //_mydiv.innerHTML += ORLLinkString + "<br>";
      //_mydiv.innerHTML += LicenseRenewLinkString + "<br>";
      //_mydiv.innerHTML += LookUpLinkString + "<br>";
      //_mydiv.innerHTML += CourseCatalogString + "<br>";
      _mydiv.innerHTML += stWeb;
    }
    else
    {
      _mydiv.innerHTML = ""
      _mydiv.innerHTML += OLSLinkString + "<br>";
      _mydiv.innerHTML += ORLLinkString + "<br>";
      _mydiv.innerHTML += LicenseRenewLinkString + "<br>";
      _mydiv.innerHTML += LookUpLinkString + "<br>";
      _mydiv.innerHTML += stWeb;
    }*/

    //RLW - remove '-public' from url - 08/27/08
    /*_mydiv.innerHTML = "<br><br><div style='margin-left:45px;'>"
    				 + "<a href=\"https://sbs-" + state
    				 + ".naic.org/Lion-Web/jsp/ext/login/launch.jsp\" "
    				 + " onMouseOver = \"button_ok.src='images/button-OK-over.jpg';\" "
					 + " onMouseOut  = \"button_ok.src='images/button-OK.jpg';\" >"
					 + "<img name='button_ok' src='images/button-OK.jpg' border='0' align='center'></a></div>";*/

    //RLW - remove '-public' from url - 08/27/08
    window.location = "https://sbs-" + state + ".naic.org/Lion-Web/jsp/ext/login/launch.jsp";
  }
  else
  {
    var _mydiv = document.getElementById('services');
    _mydiv.innerHTML = "<br>Select a State to access its services.";
  }
}

/**
 * function: 	createHeadlineTbl
 *
 * Description: creates a table containing SBS headlines and links
 * 				to the corresponding news releases.
 *	 number: the number of NEWEST news releases to display, so if
 *			 you only want to display the 4 newest news items,
 *			 number = 4
 *	 all:	 boolean, display all of the news items. If true,
 *			 the number parameter is disreguarded as irrevelant.
 *	 color1: the first alternating background color
 *	 color2: the second alternating background color
 *
 * How to add a headline:
 *  - add 1 to the value that the var total is set to.
 *  - copy and paste the last block of the array initializers. 
 *  - make alterations to that block accordingly:
 *		- place headline title in the headlineTitles[]
 *		- place news release source in the headlineLinks[] (where it links to)
 *		- place the date of the news release in the headlineDates[]
 */
function createHeadlineTbl(number,all,color1,color2) {
	var total = 15; // Total number of news items (make sure it is remains correct).
	var count = 0;  // keeps track of row number.
	
	var headlineTitles = new Array();
	var headlineLinks  = new Array();
	var headlineDates  = new Array();
	
	headlineTitles[0]  = "NAIC Partners with Aithent to Develop Insurance Regulatory Software.";
	headlineLinks[0]   = "http://www.naic.org/sbs/documents/Aithent_NAIC_press_release.pdf";
	headlineDates[0]   = "7/29/02";
	
	headlineTitles[1]  = "NJ To Offer E-Licensing.";
	headlineLinks[1]   = "http://www.insurancetech.com/resources/fss/showArticle.jhtml?articleID=14705447";
	headlineDates[1]   = "4/01/03";
	
	headlineTitles[2]  = "D.C. Insurance Regulator to Receive Distinguished Public Service Honor.";
	headlineLinks[2]   = "http://www.naic.org/Releases/2004_docs/12-10-04_Luther_Ellis_Award.pdf";
	headlineDates[2]   = "12/10/04";
	
	headlineTitles[3]  = "New Hampshire Insurance Department Announces Use of State Based Systems.";
	headlineLinks[3]   = "http://www.naic.org/Releases/2005_docs/NH_SBS.pdf";
	headlineDates[3]   = "6/30/05";
	
	headlineTitles[4]  = "Rhode Island Division of Insurance Hosts SBS Licensee Summit";
	headlineLinks[4]   = "http://www.naic.org/Releases/2006_docs/SBS_release.htm";
	headlineDates[4]   = "10/13/06";
	
	headlineTitles[5]  = "NAIC Announces New State Based Systems Web Site";
	headlineLinks[5]   = "http://www.naic.org/Releases/2006_docs/sbs_new_website.htm";
	headlineDates[5]   = "10/17/06";
	
	headlineTitles[6]  = "NAIC Emphasizes Importance of SBS In State-Based Insurance Regulation";
	headlineLinks[6]   = "http://www.naic.org/Releases/2006_docs/naic_emphasizes_importance_sbs_ins_reg.htm";
	headlineDates[6]   = "12/9/06";
	
	headlineTitles[7]  = "Iowa Division of Insurance Teams Up with State Based Systems";
	headlineLinks[7]   = "http://www.naic.org/Releases/2007_docs/iowa_sbs.htm";
	headlineDates[7]   = "2/23/07";
	
	headlineTitles[8]  = "North Carolina Department of Insurance Licenses State Based Systems";
	headlineLinks[8]   = "http://www.naic.org/Releases/2007_docs/sbs_north_carolina.htm";
	headlineDates[8]   = "3/10/07";

    //RLW - Remove 'Maryland and ' from headline title 9/9/08
	headlineTitles[9]  = "Puerto Rico Insurance Departments Select State Based Systems";
	headlineLinks[9]   = "http://www.naic.org/Releases/2007_docs/sbs_md_pr.htm";
	headlineDates[9]   = "3/10/07";
	
	headlineTitles[10] = "Alabama, Kansas and Missouri Select State Based Systems";
	headlineLinks[10]  = "http://www.naic.org/Releases/2007_docs/sbs_07winter.htm";
	headlineDates[10]  = "12/3/07";

	headlineTitles[11] = "Tennessee Joins State Based Systems";
	headlineLinks[11]  = "http://www.naic.org/Releases/2008_docs/tennessee_sbs.htm";
	headlineDates[11]  = "7/14/08";

	headlineTitles[12] = "Illinois and North Dakota Choose State Based Systems";
	headlineLinks[12]  = "http://www.naic.org/Releases/2008_docs/IL_ND_SBS.htm";
	headlineDates[12]  = "12/06/08";   
	
	headlineTitles[13] = "SBS and OPTins Add Two More States";
	headlineLinks[13]  = "http://www.naic.org/Releases/2009_docs/sbs_optins_add_two.htm";
	headlineDates[13]  = "9/22/09";   
	
	headlineTitles[14] = "Maryland Insurance Administration Joins SBS";
	headlineLinks[14]  = "http://www.naic.org/Releases/2009_docs/md_sbs.htm";
	headlineDates[14]  = "12/05/09"; 	
	
	if(all == true) {
		number = 0;
	} else {
		number = total - number;
	}
	
	var color=color1;
	
	document.write('<table id="headlines" width="99.6%" border="0" cellspacing="0" cellpadding="2" class="style1" style="font-size:13px;margin-left:1px;" bgcolor="#CCCCCC">');
	
	for (i = (total-1); i >= number; i--) {
		document.write('<tr bgcolor="' + color + '">');
        document.write('  <td height="40" valign="top"><strong>' + headlineDates[i] + '</strong></td>');
        document.write('  <td height="40" valign="top"><a href="' + headlineLinks[i] + '" target="_blank">' + headlineTitles[i] + '</a></td>');
        document.write('</tr>');
        
        if (color == color1) {
        	color = color2;
        } else {
        	color = color1;
        }
	}
	
	document.write('</table>');
}

/**
 * function: 	createStateDropDown
 *
 * Description: creates the state services drop-down menu
 *
 * How to add a state:
 *  - copy and paste the last block of the array initializers. 
 *  - make alterations to that block accordingly:
 *		- place the state's full name in stateNames[] array
 *		- place the state's full name in the index of the
 *		  stateAbbr[] array, and the lower-case abbreviation
 *		  as the value (this is creating a hash table, since
 *		  if using an index, sorting the first array would 
 *		  mess up the correspondence). This way the states
 *		  will always be in sorted order, without having
 *		  to do it manually in the indexing!
 */
function createStateDropDown(){
	var stateNames = new Array();
	var stateAbbr  = new Array();
	
	stateNames[0] = "Delaware";
	stateAbbr['Delaware'] = "de";

	stateNames[1] = "District of Columbia";
	stateAbbr['District of Columbia'] = "dc";
	
	stateNames[2] = "Florida";
	stateAbbr['Florida'] = "fl";

	stateNames[3] = "Iowa";
	stateAbbr['Iowa'] = "ia";

	stateNames[4] = "North Carolina";
	stateAbbr['North Carolina'] = "nc";

	stateNames[5] = "New Hampshire";
	stateAbbr['New Hampshire'] = "nh";

	stateNames[6] = "New Jersey";
	stateAbbr['New Jersey'] = "nj";

	stateNames[7] = "Rhode Island";
	stateAbbr['Rhode Island'] = "ri";

	stateNames[8] = "Alabama";
	stateAbbr['Alabama'] = "al";

	stateNames[9] = "Missouri";
	stateAbbr['Missouri'] = "mo";


    //12/9/08 - RLW - Add Kansas
    stateNames[10] = "Kansas";
	stateAbbr['Kansas'] = "ks";	

	stateNames[11] = "North Dakota";
	stateAbbr['North Dakota'] = "nd";
	
	stateNames[12] = "Tennessee";
	stateAbbr['Tennessee'] = "tn";
	
	stateNames.sort();

	document.write('<select name="state" id="state" onChange="javascript:switchState(this.value);" style="width:145px; border:1px solid #000000;">');
	document.write('<option value="" selected> </option>');

	for(i = 0; i < stateNames.length; i++){
		document.write('<option value="' + stateAbbr[stateNames[i]] + '">' + stateNames[i] + '</option>');
	}

	document.write('</select>');
}
		
	

/*functions for uniform right column on web page*/
var reqResults = null;

function getColumnLinks()
{
  var dateMillis = (new Date()).getMilliseconds();
  var url = ("column_links.xml?rand=" + dateMillis);

  // branch for native XMLHttpRequest object
  if (window.XMLHttpRequest) {
    reqResults = new XMLHttpRequest();
    reqResults.onreadystatechange = processReqChange;
    reqResults.open("GET", url, true);
    reqResults.send(null);
  // branch for IE/Windows ActiveX version
  } else if (window.ActiveXObject) {
    reqResults = new ActiveXObject("Microsoft.XMLHTTP");
    if (reqResults) {
      reqResults.onreadystatechange = processReqChange;
      reqResults.open("GET", url, true);
      reqResults.send();
    }
  }    
}