var splashpage = {
    // Splash Page Script Activation (1=enabled, 0=completely disabled!)
    splashenabled: 1,

    //1) URL to file on your server to display as the splashpage
    splashpageurl: "http://www.mantank.com/splash/index.htm",

    //2) Enable frequency control? (1=yes, 0=no)
    enablefrequency: 1,

    //3) display freqency: "sessiononly" or "x days" (string value). Only applicable if 3) above is enabled
    displayfrequency: "365 days",

    //4) HTML for the header bar portion of the Splash Page
    // Make sure to create a link that calls "javascript:splashpage.closeit()")
    // An IE bug means you should not right align any image within the bar, but instead use "position:absolute" and the "right" attribute

    defineheader: '<div style="padding: 5px; color: black; font: bold 16px Verdana; background: white url(blockdefault.gif) center center repeat-x;"><a style="position:absolute; top: 2px; right: 5px" href="javascript:splashpage.closeit()" title="Skip to Content"><img src="img/skip.gif" border="0" width="114px" height="23px" /></a></div>',

    //5) cookie setting: ["cookie_name", "cookie_path"]
    cookiename: ["splashpagecookie", "path=/"],

    //6) Auto hide Splash Page after x seconds (Integer value, 0=no)?
    //autohidetimer: 10,

    ////No need to edit beyond here//////////////////////////////////

    launch: false,
    browserdetectstr: (window.opera && window.getSelection) || (!window.opera && window.XMLHttpRequest), //current browser detect string to limit the script to be run in (Opera9 and other "modern" browsers)

    output: function() {
        document.write('<div id="slashpage" style="position: absolute; z-index: 400;background: black; filter:alpha(opacity=40); opacity:0.4;"></div>') //Main splashpage container
        //document.write(this.defineheader) //header portion of splashpage
        //document.write('<div id="diviframe" style="position: absolute; z-index: 900;background: blue;"><iframe name="splashpage-iframe" src="about:blank" style="margin:0; padding:0; width:100%; height: 100%"></iframe><a style="position:absolute; top: 2px; right: 5px" href="javascript:splashpage.closeit()" title="Skip to Content"><img src="img/skip.gif" border="0" width="114px" height="23px" /></a></div>') //iframe
        document.write('<div id="diviframe" style="position: absolute; z-index: 900;color: white; background: black;">')
        // PUT SPLASH PAGE HTML CODE BELOW
        document.write('<table cellpadding="0" cellspacing="0" border="0"><tr valign="top"><td width="500"><img src="img/splash_top.jpg" width="479" height="21" border="0" alt=""><a href="javascript:splashpage.closeit()" title="Skip to Content"><img src="img/splash_close.jpg" width="21" height="21" border="0" alt=""></a><br><img src="img/splash_middle.jpg" width="500" height="192" border="0" alt=""><br><a href="green/refillable.htm"><img src="img/splash_1lb.jpg" width="97" height="179" border="0" alt="Learn more about our 1# Refillable Cylinders!"></a><a href="green/smalldot.htm"><img src="img/splash_smalldot.jpg" width="91" height="179" border="0" alt="Learn more about our Small DOT Cylinders!"></a><a href="green/mower.htm"><img src="img/splash_mower.jpg" width="87" height="179" border="0" alt="Learn more about our Mower Cylinders!"></a><a href="green/motorfuel.htm"><img src="img/splash_motorfuel.jpg" width="225" height="179" border="0" alt="Learn more about our Motor Fuel Cylinders!"></a><br><img src="img/splash_bottom.jpg" width="500" height="74" border="0" alt=""><br><img src="img/splash_bottomleft.jpg" width="178" height="34" border="0" alt=""><a href="javascript:splashpage.nomore()" title="Do not show this page again"><img src="img/splash_nomore.jpg" width="145" height="34" border="0" alt=""></a><img src="img/splash_bottomright.jpg" width="177" height="34" border="0" alt=""></td></tr></table>')
        document.write('</div>')
        this.splashpageref = document.getElementById("slashpage")
        this.diviframe = document.getElementById("diviframe")
        //this.splashiframeref = window.frames["splashpage-iframe"]
        //this.splashiframeref.location.replace(this.splashpageurl) //Load desired URL into splashpage iframe
        this.standardbody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body
        if (!/safari/i.test(navigator.userAgent)) //if not Safari, disable document scrollbars
        //this.standardbody.style.overflow = "hidden"
            this.splashpageref.style.left = 0
        this.splashpageref.style.top = 0
        this.splashpageref.style.width = "100%"
        this.splashpageref.style.height = "100%"

        //This is where you set the iframe size.  Height, width and then half them for left and top.
        this.diviframe.style.width = 500
        this.diviframe.style.height = 500
        this.diviframe.style.left = (document.body.offsetWidth / 2) - 250
        if (navigator.userAgent.indexOf("Firefox")!=-1) {
					this.diviframe.style.top = (window.innerHeight / 2) - 250
				}
				else {
					this.diviframe.style.top = (document.body.offsetHeight / 2) - 250
				}
        this.moveuptimer = setInterval("window.scrollTo(0,0)", 50)


    },

    closeit: function() {
        clearInterval(this.moveuptimer)
        this.splashpageref.style.display = "none"
        //this.splashiframeref.location.replace("about:blank")
        //this.standardbody.style.overflow = "auto"
        this.diviframe.style.display = "none"
    },

    gogreen: function() {
        clearInterval(this.moveuptimer)
        this.splashpageref.style.display = "none"
        //this.splashiframeref.location.replace("about:blank")
        //this.standardbody.style.overflow = "auto"
        this.diviframe.style.display = "none"

        //Close it and go somewhere        
        document.URL = "http://jtonedesigns.com/mantank/green/refillable.htm"

    },
    nomore: function() {
        clearInterval(this.moveuptimer)
        this.splashpageref.style.display = "none"
        //this.splashiframeref.location.replace("about:blank")
        //this.standardbody.style.overflow = "auto"
        this.diviframe.style.display = "none"
        this.setCookie(this.cookiename[0], this.displayfrequency, this.displayfrequency)
    },

    init: function() {
        //alert(this.getCookie(this.cookiename[0]))
        if (this.getCookie(this.cookiename[0]) == null) { //if persistent cookie is empty or admin has changed number of days to persist from that of the stored value (meaning, reset it)
            this.launch = true
        }
        else {
            this.launch = false
        }
        //if we change the default freq, expire the cookie
        if (parseInt(this.getCookie(this.cookiename[0])) != parseInt(this.displayfrequency)) {
            //alert("freq change")
            this.setCookie(this.cookiename[0], 0, 0)
            this.launch = true
        }
        if (this.launch) {
            this.output()
            if (parseInt(this.autohidetimer) > 0)
                setTimeout("splashpage.closeit()", parseInt(this.autohidetimer) * 1000)
        }
    },

    getCookie: function(Name) {
        var re = new RegExp(Name + "=[^;]+", "i"); //construct RE to search for target name/value pair
        if (document.cookie.match(re)) {
            //if cookie found
            return document.cookie.match(re)[0].split("=")[1] //return its value
        }
        else {
            return null
        }
    },

    setCookie: function(name, value, days) {
        var expireDate = new Date()
        //set "expstring" to either an explicit date (past or future)
        if (typeof days != "undefined") { //if set persistent cookie
            var expstring = expireDate.setDate(expireDate.getDate() + parseInt(days))
            document.cookie = name + "=" + value + "; expires=" + expireDate.toGMTString() + "; " + splashpage.cookiename[1] //last portion sets cookie path
        }
        else //else if this is a session only cookie setting
            document.cookie = name + "=" + value + "; " + splashpage.cookiename[1] //last portion sets cookie path
    }
}
if (splashpage.browserdetectstr && splashpage.splashenabled == 1)
    splashpage.init()
