	function Link(title,url,target) {
  this.title = title;
  this.url = url;
  this.target = target;
}

Link.prototype.html = function() {
  return "<a href='"+this.url+"' "+((this.target==null)?"":"target='"+this.target+"'")+">"+this.title+"</a>";
}

function Company(host) {
 if (host == "") host='test-agents.indiana-ins.com'; //to force a value for testing.
 this.currenthost = host;
 var shost = host.split('.')[1].toLowerCase();
 this.shorthost = shost;
 var subdomain = host.split('.')[0].toLowerCase();
 if (shost == 'americafirst-ins') {
  this.name		= 'America First Insurance';
  this.code		= 'AFI';
  this.phone      	= '800-678-6548';
  this.email      	= 'afi-helpdesk@americafirst-ins.com';
  this.websiteAvail	= 'Monday - Saturday 7:00 a.m. to 7:00 p.m. CST and Sunday 1:00 p.m. to 7:00 p.m. CST*';
  this.aisgAvail	= 'Monday - Friday 7:00 a.m. to 7:00 p.m. CST';
  this.realtimeCID	= '1142006544251';
  this.ryp		= 'RYPAmericaFirst.html';
  this.eservicesLogo	= 'americafirst';
  this.msgGroup		= 1;
  this.msgDates		= new Array ('01/19/2009','02/19/2009');
}
if (shost == 'coloradocasualty-ins') {
  this.name		= 'Colorado Casualty';
  this.code		= 'CCIC';
  this.phone      	= '866-338-6229';
  this.email      	= 'helpdesk-ecommerce@coloradocasualty.com';
  this.websiteAvail	= 'Monday - Saturday 6:00 a.m. to 6:00 p.m. MST and Sunday 12:00 p.m. to 6:00 p.m. MST*';
  this.aisgAvail	= 'Monday - Friday 6:00 a.m. to 6:00 p.m. MST';
  this.realtimeCID	= '1142006553263';
  this.ryp		= 'RYPColoradoCasualty.html';
  this.eservicesLogo	= 'coloradocasualty';
  this.msgGroup		= 1;
  this.msgDates		= new Array ('01/19/2009','02/19/2009');
}
if (shost == 'goamericaauto-ins') {
  this.name		= 'GoAmerica Auto Insurance';
  this.code		= 'GAAI';
  this.phone      	= '800-876-3500 (option 7; then option 1)';
  this.email      	= 'goamericahelpdesk@goamericaautoins.com';
  this.websiteAvail	= 'Monday through Saturday 8 a.m. to 8 p.m. and Sunday 2 p.m. to 8 p.m.*';
  this.aisgAvail	= 'Monday through Friday, 8 a.m. to 8 p.m. EST';
  this.realtimeCID	= '';
  this.ryp		= 'RYPGoAmericaAuto.html';
  this.eservicesLogo	= 'goamericaauto';
  this.msgGroup		= 0;
  this.msgDates		= new Array ();
}
if (shost == 'goldeneagle-ins') {
  this.name		= 'Golden Eagle Insurance';
  this.code		= 'GEIC';
  this.phone      	= '800-863-2042';
  this.email      	= 'geiecom@goldeneaglecorp.com';
  this.websiteAvail	= 'Monday - Saturday 5:00 a.m. to 5:00 p.m. PST and Sunday 11:00 a.m. to 5:00 p.m. PST*';
  this.aisgAvail	= 'Monday - Friday 5:00 a.m. to 5:00 p.m. PST';
  this.realtimeCID	= '1142006553371';
  this.ryp		= 'RYPGEIC.html';
  this.eservicesLogo	= 'geic';
  this.msgGroup		= 0;
  this.msgDates		= new Array ();
}
if (shost == 'indiana-ins') {
  this.name		= 'Indiana Insurance';
  this.code		= 'IIC';
  this.phone      	= '888-473-0019';
  this.email      	= 'interface.support@indiana-ins.com';
  this.websiteAvail	= 'Monday through Saturday 8 a.m. to 8 p.m. and Sunday 2 p.m. to 8 p.m.*';
  this.aisgAvail	= 'Monday through Friday, 8 a.m. to 8 p.m. EST';
  this.realtimeCID	= '1142006553383';
  this.ryp		= 'RYPIndiana.html';
  this.eservicesLogo	= 'indiana';
  this.msgGroup		= 1;
  this.msgDates		= new Array ('01/19/2009','02/19/2009','05/28/2009', '06/24/2009');
}
if (shost == 'libertynorthwest-ins') {
  this.name 		= 'Liberty Northwest Insurance Corporation';
  this.code 		= 'LNW';
  this.phone      	= '866-862-6225';
  this.email      	= 'lnwinterface.support@libertynorthwest.com';
  this.websiteAvail	= 'Monday through Saturday 5 a.m. to 5 p.m. PST and Sunday 11 a.m. to 5 p.m. PST*';
  this.aisgAvail	= 'Monday through Friday, 5 a.m. to 5 p.m. PST';
  this.realtimeCID	= '';
  this.ryp		= 'RYPLibertynorthwest.html';
  this.eservicesLogo	= 'lnw';
  this.msgGroup		= 1;
  this.msgDates		= new Array ('03/10/2009');
}
if (shost == 'montgomery-ins') {
  this.name		= 'Montgomery Insurance ';
  this.code		= 'MIC';
  this.phone      	= '866-749-3168';
  this.email      	= 'agency.interface@montgomery-ins.com';
  this.websiteAvail	= 'Monday through Saturday 8 a.m. to 8 p.m. and Sunday 2 p.m. to 8 p.m.*';
  this.aisgAvail	= 'Monday through Friday, 8 a.m. to 8 p.m. EST';
  this.realtimeCID	= '1142006553389';
  this.ryp		= 'RYPMontgomery.html';
  this.eservicesLogo	= 'montgomery';
  this.msgGroup		= 1;
  this.msgDates		= new Array ('01/19/2009');
}
if (shost == 'ohiocasualty-ins') {
  this.name		= 'Ohio Casualty';
  this.code		= 'OC';
  this.phone      	= '866-768-7614';
  this.email      	= 'ocinterface.support@ohiocasualty-ins.com';
  this.websiteAvail	= 'Monday through Saturday 8 a.m. to 8 p.m. and Sunday 2 p.m. to 8 p.m.*';
  this.aisgAvail	= 'Monday through Friday, 8 a.m. to 8 p.m. EST';
  this.realtimeCID	= '1138352543683';
  this.ryp		= 'RYPOhioCasualty.html';
  this.eservicesLogo	= 'ohiocasualty';
  this.msgGroup		= 4;
  this.msgDates		= new Array ('07/15/2009','09/17/2009');
}
if (shost == 'peerless-ins') {
  this.name       	= 'Peerless Insurance';
  this.code       	= 'PIC';
  this.phone      	= '866-331-6224';
  this.email      	= 'interface.help@peerless-ins.com';
  this.websiteAvail	= 'Monday through Saturday 8 a.m. to 8 p.m. and Sunday 2 p.m. to 8 p.m.*';
  this.aisgAvail	= 'Monday through Friday, 8 a.m. to 8 p.m. EST';
  this.realtimeCID	= '1142006548934';
  this.ryp		= 'RYPPeerless.html';
  this.eservicesLogo	= 'peerless';
  this.msgGroup		= 5;
  this.msgDates		= new Array ('10/01/2009');
}
 if (subdomain == 'agents') {
  this.msgHost = 'http://www.'+shost+'.com';
  this.consumerHost = 'http://www.'+shost+'.com';
  this.splashHost = 'http://agents.'+shost+'.com';
  this.portalHost = 'https://agents.'+shost+'.com';
  this.eservicesHost = 'https://eservices.lmig.com';
} else {
  this.msgHost = 'http://stage-www.'+shost+'.com';
  this.consumerHost = 'http://stage-www.'+shost+'.com';
  this.splashHost = 'http://'+subdomain+'.'+shost+'.com';
  this.portalHost = 'https://'+subdomain+'.'+shost+'.com';
  this.eservicesHost = ((subdomain == 'dev-agents')?'https://dev-eservices.lmig.com':'https://test-eservices.lmig.com');
}
this.logoURL = '/images/logo'+this.code+'.gif';
this.LinkHelp = new Link('Web Site Help','mailto:'+this.email+'&amp;subject=Web%20Site%20Help','_blank');
this.LinkDUR = new Link('Register New User',this.eservicesHost+'/DUR/Start.do?logo='+this.eservicesLogo,'_blank');
this.LinkRYP = new Link('Forgot Password?',this.portalHost+'/portal/password/'+this.ryp,'_blank');
this.LinkMEA = new Link('Modify Existing Accounts',this.eservicesHost+'/EDA/enduser/Start.do?logo='+this.eservicesLogo,'_blank');
this.LinkCA = new Link('Corporate Administrator',this.eservicesHost+'/EDA/corpadmin/Start.do?logo='+this.eservicesLogo,'_blank');
this.LinkRealTime = new Link('Real Time/Download',this.consumerHost+'/omapps/ContentServer?cid='+this.realtimeCID+'&pagename=ramInternet/Page/ramContentOnly','_blank');
this.welcome  = '<strong>Welcome to the '+this.name+' Agents\' Portal</strong><br/>';
this.welcome  += 'This site allows our agents to easily and securely do business with us. If you are an appointed '+this.name;
this.welcome  += ' agent, please <a id="loginLink" href="javascript:linkToLogin()"><strong>LOGIN</strong></a> ';
this.welcome  += 'to either quote/submit new business or to service an existing '+this.name+' policyholder. ';
this.welcome  += 'The Agents\' Portal is available '+this.websiteAvail;
this.help   = '<strong>Agents\' Portal Help</strong> ';
this.help   += 'Our Agency Interface Support Group (AISG) is available from '+this.aisgAvail+'. If you have a technical issue, please contact the AISG by ';
this.help   += '<a href="mailto:'+this.email+'&amp;subject=Web%20Site%20Help">e-mail</a> or by phone at <strong>'+this.phone+'</strong>.';

var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var current_date = new Date(month +'/' + day + '/' + year);

this.msgURL = "";
this.msgParm = null;

for (i=0;i<this.msgDates.length;i++) {
  d = new Date(this.msgDates[i]);
  if (current_date >= d) {
    dmonth = d.getMonth()+1;
    dday   = d.getDate();
    dyear  = d.getFullYear();
    ddate  = ""+dyear+(dmonth<10?"0"+dmonth:dmonth)+(dday<10?"0"+dday:dday);
    this.msgURL = "SplashMessages/"+this.code+"_Msg_"+ddate+".html";
  }
}

/*
this.msgURL = this.consumerHost+'/omapps/ContentServer';
this.msgParm = {
    pagename: 'apPortal/Splash',
    company: this.code
}
this.maintURL = this.consumerHost+'/omapps/BlobServer';
this.maintParm = {
    blobtable: 'apDocument',
    blobcol: 'urlupload',
    blobheader: 'text/xml',
    blobkey: 'name',
    blobwhere: this.code+'_MaintenanceSchedule',
    blobnocache: 'true'
}
*/

this.maintURL = "MaintenanceSchedule.xml";
this.maintParm = null;

}

  var theCompany = new Company(document.location.host);

  var months=new Array();
  months[1]="January";
  months[2]="February";
  months[3]="March";
  months[4]="April";
  months[5]="May";
  months[6]="June";
  months[7]="July";
  months[8]="August";
  months[9]="September";
  months[10]="October";
  months[11]="November";
  months[12]="December";
  var time=new Date();
  var hours=time.getHours();
  var minutes=time.getMinutes()
  var month=time.getMonth()+1;
  var lmonth=months[month];
  var day=time.getDate();
  var year=time.getFullYear();
  var displaydate=lmonth+" "+day+", "+year;
  var maintenancedate  = ""+year+(month<10?"0"+month:month)+(day<10?"0"+day:day);
  var maintenancetime  = (hours<10?"0"+hours:hours)+":"+(minutes<10?"0"+minutes:minutes)+":"
  var csError=false;
  var csFunction="";
  var errorRefreshMinutes=10;

  function ConvertTime(t,zone) {
  var visitortime = new Date();
  var o = visitortime.getTimezoneOffset()/60;
  //o+=1;
  if (zone == "EDT") adjust = o-4;
  if (zone == "EST") adjust = o-5;
  var newtime = parseInt(t.replace(":"," "));
  if (newtime != NaN) newtime-=adjust;
  ampm ="a.m.";
  if (newtime > 12) {
  newtime-=12;
  ampm="p.m.";
  }
  if (newtime == 0) newtime = 12;
  return(newtime+":"+t.substring(3)+ampm);
  }

  $(document).ready(function() {

  $(document).ajaxError(function(e1) {
/*
    //alert(csFunction);
    csError = true;
    var msg = "<strong>Please Note:</strong> We may be experiencing problems with our Portal Website!&nbsp;&nbsp;We advise that you wait until this message clears before entering!  (This page will automatically update every "+errorRefreshMinutes+" minutes!)";
    var msg1 = "Please Note: We may be experiencing problems with our Portal Website!  Click OK to continue, or Cancel to wait!";
    $("#loginLink").click(function(e) {
      //alert(window.location.href);
      if(!confirm(msg1)) {
      e.preventDefault();
      window.location.href=window.location.href;
      }
    });
    $("#loginButton").click(function(e) {
      if(!confirm(msg1))  e.preventDefault();
    });
    $("#Message").html("<div style='color:white;background-color:dd0000;border:solid 3 #7f8eb0'>"+msg+"</div><br/>");
    setTimeout('top.location.href=\"' + window.location.href + '\"', errorRefreshMinutes*60000);
*/
    if (csFunction == "getMessage") $("#Message").html("<br/>");
  });

  if (theCompany.msgURL == "") {
    $("#Message").html("<br/>");
  } else {
    csFunction="getMessage";
    $.post(theCompany.msgURL, theCompany.msgParm, function(xml) {
      if (!csError) {
        //alert("["+xml+"]");
        if (xml != " Error ") {
          //alert(xml);
          $("#Message").html("<br/>").append(xml).append("<br/>");
        } else {
          $("#Message").html("<br/>");
        }
      }
     });
   } //end getMessage
/*
  csFunction="getMaintenance";
  $.post(theCompany.maintURL, theCompany.maintParm, function(xml2) {
    if (!csError) {
    if ($("Date[id='"+maintenancedate+"'] Message", xml2)) {
      $("Date[id='"+maintenancedate+"'] Message", xml2).each(function(i) {
       var starttime = $(this).attr("starttime");
       var endtime = ($(this).attr("endtime") > $(this).attr("starttime"))?$(this).attr("endtime"):"24:00";
       if ((starttime <= maintenancetime) && (endtime > maintenancetime)) {
         st = ConvertTime($(this).attr("starttime"),$(this).attr("timezone"));
         et = ConvertTime($(this).attr("endtime"),$(this).attr("timezone"));
         m = "<strong>( "+st+" - "+et+" )</strong>"+$(this).text();
          $("#MaintenanceWarn").append("<div style='background-color:dd0000;border:3 solid #aa0000;color:white'>"+$(this).attr("type")+" ==> "+m+"</div>");
       }
     });
    }

    var datelist = "";
    $("Message[type='Maintenance']",$("Date",xml2).filter(function () {return $(this).attr("id") >= maintenancedate;})).each(function(i) {
      if (datelist == "") {
        datelist += $(this).attr("scheduleddate");
      } else {
        datelist += ", "+$(this).attr("scheduleddate");
      }
     });
     if (datelist != "") $("#MaintSched").append(" Scheduled maintenance dates are: <strong>"+datelist+"</strong>. Please contact the AISG if you have any questions.<br/>");
     }
    });
  }); //end getMaintenance
*/

  }); //end document ready

// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();
// *** BROWSER VERSION ***
var is_major = parseInt(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var ie4  = (is_ie && (is_major >= 4));
function linkToLogin() {
/*  if(!ie4)
    showAlert();
	else
*/
	  window.location=theCompany.portalHost+"/portal/LRAMStart?URL=/omapps/ContentServer?pagename=apPortal/Initialize";
}
/*
function showAlert() {
  alert('You must use Internet Explorer 5.5 or higher to view this site.  Please use the link on this page to download the newest IE version');
}
*/