﻿// JScript File
var arVersion = navigator.appName;
function  show_hide_menu(id)
{
    var oElem = document.getElementById(id);
    if(oElem.style.display == "none" || oElem.style.display == "")
    {
        oElem.style.display = "block";
        if(arVersion != "Microsoft Internet Explorer")
        {
            oElem.parentNode.setAttribute("class", "activeMenu");
        }
        else
        {
            oElem.parentElement.setAttribute("className", "activeMenu");
        }
    }
    else
    {
        oElem.style.display = "none";
        if(arVersion != "Microsoft Internet Explorer")
        {
            oElem.parentNode.setAttribute("class", "");
        }
        else
        {
            oElem.parentElement.setAttribute("className", "");
        }
    }
}
function setMenuActive()
{    
    show_hide_menu("personalinsurance", "businessinsurance", "ouragency");
}
function tabclick(id)
{
    var oTab1 = document.getElementById("tab1");
    var oPanel1 = document.getElementById("description");
    var oTab2 = document.getElementById("tab2");
    var oPanel2 = document.getElementById("label");
    
    if(oTab1.id == id)
    {
        oTab1.style.background = "#8ed1eb url(/images/tabactive.jpg) no-repeat 0 0";
        oPanel1.style.display = "block";
        oTab2.style.background = "#fff url(/images/tab.jpg) no-repeat 0 0";
        oPanel2.style.display = "none";
    }
    else
    {
        oTab2.style.background = "#8ed1eb url(/images/tabactive.jpg) no-repeat 0 0";
        oPanel2.style.display = "block";
        oTab1.style.background = "#fff url(/images/tab.jpg) no-repeat 0 0";
        oPanel1.style.display = "none";
    }
}
function  show_hide_faq(id)
{
    var oElem = document.getElementById(id);
    if(oElem.style.display == "none" || oElem.style.display == "")
    {
        oElem.style.display = "block";
    }
    else
    {
        oElem.style.display = "none";
    }
}
/*
    ------------------------------------------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------------------------------------------
*/
function submitVerify(form)
{
    var str = "";
    var pass = false;
    for(var c = 0; c < form.elements.length; c++)
    {
        switch(form.elements[c].name)
        {
            case "fname": if(form.elements[c].value == "")
                         {
                             str = str + "First name is a required field.\n";
                             pass = false;
                         }
                         else
                         {
                            pass = true;
                         }
                         break;
            case "lname": if(form.elements[c].value == "")
                            {
                                str = str + "Last name is a required field.\n";
                                pass = false;
                            }
                            else
                            {
                                pass = true;
                            }
                            break;
            case "email":   if(form.elements[c].value == "")
                            {
                                str = str + "Email is a required field.\n";
                                pass = false;
                            }
                            else
                            {
                                if(echeck(form.elements[c].value) == true)
                                {
                                    pass = true;
                                }
                                else
                                {
                                    str = str + "Email is invalid.\n";
                                    pass = false;
                                }
                            }
                            break;
        }
    }
    if(str != "")
    {
        window.alert(str);
    }
    return pass;
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
