﻿//following code used on statelanding page

var SelectedState = '';
    
    function SelectState(obj) {
        var stateTrigger=document.getElementById("stateTrigger");
        stateTrigger.innerHTML = '&nbsp;&nbsp;&nbsp;<a href="#" onclick="return false;">'+ obj.innerHTML +'</a>';
        SelectedState = obj.href;
        ToggleDiv('statemenu1');
    }
    
    function Navigate() {
        if ( SelectedState == '' )
            alert('Please select your state first.');
        else
            location.href = SelectedState;
    }
    
    

function ToggleDiv(ElementID)
{
    var d = document;
    var el=d.getElementById?d.getElementById(ElementID):d.all?d.all[id]:d.layers[id];
    if ( el.style.visibility == "visible" )
        el.style.visibility = "hidden";
    else
        el.style.visibility = "visible";
}



// JScript File
function GetPreviewURL() {
 var url = self.location.href;
 var arString = url.split('?')
 if (arString.length > 1) { url = url + "&amp;cmsMode=Preview"}
 else { url = url + "?cmsMode=Preview"}
 return url;
}
function PopUpWindow(url, hWind, nWidth, nHeight, nScroll, nResize) { return (EkTbWebMenuPopUpWindow (url, hWind, nWidth, nHeight, nScroll, nResize));}
function ecmPopUpWindow (url, hWind, nWidth, nHeight, nScroll, nResize) { 
 PopUpWindow(url, hWind, nWidth, nHeight, nScroll, nResize) ; 
 } 




//alert('global.js');
function processCustomerStateSelection()
{
    StateSelect = document.getElementById("StateSelect");
    if ( !StateSelect) return;
    if ( StateSelect.selectedIndex == 0 )
        alert('Please Select your State');
    else
        window.location = "StateLanding.aspx?StateID=" + StateSelect.options[StateSelect.selectedIndex].value;
}
function processAgentStateSelection()
{
    StateSelect = document.getElementById("StateSelect");
    if ( !StateSelect) return;
    if ( StateSelect.selectedIndex == 0 )
        alert('Please Select your State');
    else
        window.location = "StateLanding.aspx?StateID=" + StateSelect.options[StateSelect.selectedIndex].value;
}
function processQuikFormStateSelection()
{
    StateSelect = document.getElementById("StateSelect");
    if ( !StateSelect) return;
    if ( StateSelect.selectedIndex == 0 )
        alert('Please Select your State');
    else
        window.location =  StateSelect.options[StateSelect.selectedIndex].value;
}

function processFindADoctorSelection()
{
    StateSelect = document.getElementById("StateSelect");
    if ( !StateSelect) return;
    if ( StateSelect.selectedIndex == 0 )
        alert('Please Select your State');
    else
        window.location =  StateSelect.options[StateSelect.selectedIndex].value;
}

function openDropDownLink(dropdownID) {
    dropdownlist = document.getElementById(dropdownID);
    if ( dropdownlist && dropdownlist.options  && dropdownlist.selectedIndex && dropdownlist.options[dropdownlist.selectedIndex].value )
    {
        if ( dropdownlist.options[dropdownlist.selectedIndex].value != "" )
        {
            newurl = dropdownlist.options[dropdownlist.selectedIndex].value;
            newurl = newurl.replace("/https:/","https://");
            window.location = newurl;
        }    
    }
}

function openDropDownLinkInNewWindow(dropdownID) {
    dropdownlist = document.getElementById(dropdownID);
    if ( dropdownlist && dropdownlist.options  && dropdownlist.selectedIndex && dropdownlist.options[dropdownlist.selectedIndex].value )
    {
        if ( dropdownlist.options[dropdownlist.selectedIndex].value != "" )
        {
        
            newurl = dropdownlist.options[dropdownlist.selectedIndex].value;
            newurl = newurl.replace("/https:/","https://");
            openPopup(newurl);           
        }    
    }
}


function openPopup(url) 
{
	NewWindowName = url.replace("http://","").replace(/\W/g,"") //take out any non-alphanumeric characters from url
	//i.e. Http://www.chicagotribune.com/february -> wwwchicagotribunecomfebruary
	myNewWindow = window.open(url, NewWindowName, "status = 1, height = 680, width = 880, resizable = 1, menubar = 0, scrollbars = 1, status = 0, toolbar = 0, location = 0");
	myNewWindow.focus();
}

 /*this function can be called by the onKeyDown event of a textbox, 
and will trigger a specific button to fire when enter key is pressed*/
function fnTrapKD(btn, event)
{
try 
{
	if (event.keyCode == 13)
	{
		event.returnValue=false;
		event.cancel = true;
		if ( btn )
		{
			if ( btn.setActive )
			   btn.setActive();
			if ( btn.click )
			   btn.click();
		}
	}
}
catch (er)
{
;
}

}//fnTrapKD

 function CreateBookmarkLink(url) {

     title = "Celtic Insurance"; 

    //url = "http://www.Celtic-net.com";

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }



function whichBrs() {
	var agt=navigator.userAgent.toLowerCase();

	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'IE';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	if (agt.indexOf('\/') != -1) {
		if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
			return navigator.userAgent.substr(0,agt.indexOf('\/'));}
		else
			return 'Netscape';}
	else if (agt.indexOf(' ') != -1)
		return navigator.userAgent.substr(0,agt.indexOf(' '));
	else
		return navigator.userAgent;
}

