//**SKIP INTRO FUNCTIONALITY**
// There is a browser cookie setting which records how many times you come in to the site through the intro page.  When the 
// counter reaches 10, it skips the intro page. This cookie remains on your machine till you clear it or for 3 months, 
// whichever occurs first. Change the following variables to change those limit values. 
var NUM_VISITS_BEFORE_INTRO_SKIP = 10
var NUM_MONTHS_BEFORE_COOKIE_EXPIRES = 3


//variables
var expireDate = new Date           
var numVisits = 0            
var skipFlashURL = "main.aspx"

//START

//If there is no cookie (first time visitor) set one
if (document.cookie == "") 
{
    setCookie()
}
//If there is a cookie (visitor has been here before) update cookie
else 
{
    var dummy = document.cookie.split("=")
    numVisits = dummy[1]
    expireDate.setMonth(expireDate.getMonth() + NUM_MONTHS_BEFORE_COOKIE_EXPIRES)
    document.cookie = "numVisits=" + ++numVisits + "; expires=" + expireDate.toGMTString()
}

//If visitor has been to the site many times or does not have flash skip flash intro
if ((document.cookie != "" && numVisits > NUM_VISITS_BEFORE_INTRO_SKIP) || !hasFlash()) 
{
    document.location = skipFlashURL
}

//END



//checks for flash depending on browser
function hasFlash()
{
    var BrowserhasFlash = false;

    //Check for flash if browser is netscape
    //submitted to www.a1javascripts.com by Joshua Luft-Glidden
    if(navigator.appName == "Netscape")
    {
        for(i=0; i<navigator.plugins.length; i++)
        {
            if(navigator.plugins[i].name == "Shockwave Flash")
            {
                BrowserhasFlash = true
                break;
	        }
        }
    }
    //check for flash if browser is IE
    else if(navigator.appName == "Microsoft Internet Explorer")
    {
        document.writeln("<script language='VBscript'>")
        document.writeln('\'Test to see if VBScripting works')
        document.writeln("detectableWithVB = False")
        document.writeln("If ScriptEngineMajorVersion >= 2 then")
        document.writeln("   detectableWithVB = True")
        document.writeln("End If")
        document.writeln('\'This will check for the plugin')
        document.writeln("Function detectActiveXControl(activeXControlName)")
        document.writeln("   on error resume next")
        document.writeln("   detectActiveXControl = False")
        document.writeln("   If detectableWithVB Then")
        document.writeln("      detectActiveXControl = IsObject(CreateObject(activeXControlName))")
        document.writeln("   End If")
        document.writeln("End Function")
        document.writeln("</scr" + "ipt>")
        BrowserhasFlash = detectActiveXControl("ShockwaveFlash.ShockwaveFlash.1")
	}				

    return BrowserhasFlash;
}


//Sets the browser cookie
function setCookie() 
{
    expireDate.setMonth(expireDate.getMonth() + NUM_MONTHS_BEFORE_COOKIE_EXPIRES)
    document.cookie = "numVisits=" + 0 + "; expires=" + expireDate.toGMTString()
}



