/*
function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


// JavaScript Document -- copied from navmenu.js - MM
navHover = function() {
var lis = document.getElementById("navmenu")
if (lis != null) {
lis = lis.getElementsByTagName("LI");
for (var i=0; i<lis.length; i++) {
lis[i].onmouseover=function() {
this.className+=" iehover";
}
lis[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" iehover\\b"), "");
}
}
}
}
if (window.attachEvent) window.attachEvent("onload", navHover);
*/

// return a random number
function rand(number) {
    return Math.ceil(Math.random() * number);
}

// store info on cookie.
function SetCookie(name, value, days) {

    var expire = new Date();
    expire.setTime(expire.getTime() + (24 * 60 * 60 * 1000) * days);
    document.cookie = name + "=" + escape(value) + "; path=/;domain=." + GetBaseDomain() + ";expires=" + expire.toGMTString() + ";";
}

// retrieve info on cookie.
function GetCookie(name) {

    var cookies = document.cookie;
    var startIndex = 0;

    while (cookies.length > 0) {

        startIndex = cookies.indexOf(name + "=");
        if (startIndex == -1) {
            return null;
        }

        if (startIndex == 0) {
            break;
        }
        if ((cookies.charAt(startIndex - 1) == ' ') || (cookies.charAt(startIndex - 1) == ';')) {
            break;
        }
        cookies = cookies.substring(startIndex + name.length + 1);
    }
    if (cookies.length == 0) {
        return null;
    }

    var endIndex = cookies.indexOf(";", startIndex);
    if (endIndex == -1) {
        endIndex = cookies.length;
    }
    return unescape(cookies.substring(startIndex + name.length + 1, endIndex));
}

// this creates a unique value for sourceid - if it does not exist
function SetClickTracksCookie() {
    var thisCookie = GetCookie("sourceid");
    if (thisCookie != null) {
        SetCookie("sourceid", thisCookie, 1);
        return;
    }

    //create a unique random cookie value
    var myValue = new Date();
    var randNum = rand(1000);
    var tracker = myValue.getTime() + "_" + randNum;

    SetCookie("sourceid", tracker, 365 * 5);
}

// this looks for the name in the url and if it's there, stores it - only if not already a cookie
function StoreVar(name) {

    var thisCookie = GetCookie(name);
    if (thisCookie != null) {
        SetCookie(name, thisCookie, 365 * 5);
        return;
    }

    var query = this.location.search.substring(1);
    if (query.length > 0) {
        var params = query.split("&");
        for (var i = 0; i < params.length; i++) {
            var assignIndex = params[i].indexOf("=");
            if (name == params[i].substring(0, assignIndex)) {
                var val = params[i].substring(assignIndex + 1);
                SetCookie(name, val, 365 * 5);
                return;
            }
        }
    }
}

// this looks for the referer and if it's there, stores it - only if not already a cookie
function StoreReferrer(name) {

    if (IsReferredFromMe()) {
        return;
    }

    var thisCookie = GetCookie(name);
    if (thisCookie != null) {
        SetCookie(name, thisCookie, 365 * 5);
        return;
    }

    var val = document.referrer;
    if ((val == null) || (val.length == 0)) {
        SetCookie(name, "none", 365 * 5);
        return;
    }

    var index = val.indexOf('//');
    if (index != -1) {
        val = val.substring(index + 2);
    }
    index = val.indexOf('/');
    if (index != -1) {
        val = val.substring(0, index);
    }

    SetCookie(name, val, 365 * 5);
}

// this grabs a referrer with keywords and stores it if no previous cookie
function StoreKeyWordReferrer(name) {

    if (IsReferredFromMe()) {
        return;
    }

    var val = document.referrer;
    var thisCookie = GetCookie(name);
    var re = new RegExp("[\&\?]([qps]|query|search|qry|keywords|Keywords|KeyWords)\=([^\&]*)");

    if ((val == null) || (val.length == 0) || (thisCookie != null)) {
        return;
    }

    if (val.match(re)) {
        SetCookie(name, val, 365 * 5);
    }
}

// this looks for the full referer and if it's there, stores it 
function StoreTodayReferrer(name) {

    if (IsReferredFromMe()) {
        return;
    }

    var val = document.referrer;
    if ((val == null) || (val.length == 0)) {
        return;
    }

    SetCookie(name, val, 365 * 5);
}

// this looks for the full referer and if it's there, stores it - only if not already a cookie
function StoreFullReferrer(name) {

    if (IsReferredFromMe()) {
        return;
    }

    var thisCookie = GetCookie(name);
    if (thisCookie != null) {
        SetCookie(name, thisCookie, 365 * 5);
        return;
    }

    var val = document.referrer;
    if ((val == null) || (val.length == 0)) {
        SetCookie(name, "none", 365 * 5);
        return;
    }

    SetCookie(name, val, 365 * 5);
}

// returns true if referrer is this site
function IsReferredFromMe() {

    var ref = document.referrer;
    if ((ref == null) || (ref.length == 0)) {
        return false;
    }
    if (ref.indexOf("http://") == 0) {
        ref = ref.substring(7);
    }

    if (ref.indexOf("www.") == 0) {
        ref = ref.substring(4);
    }

    ref = ref.toLowerCase();

    var myDomain = document.domain;
    if ((myDomain == null) || (myDomain.length == 0)) {
        return false;
    }
    if (myDomain.indexOf("http://") == 0) {
        myDomain = myDomain.substring(7);
    }
    if (myDomain.indexOf("www.") == 0) {
        myDomain = myDomain.substring(4);
    }
    myDomain = myDomain.toLowerCase();

    return ref.indexOf(myDomain) == 0;
}

function GetBaseDomain() {

    var parts = document.domain.split(".");
    if (parts.length < 2) {
        return document.domain;
    }

    return parts[parts.length - 2] + "." + parts[parts.length - 1];
}

// set all tracking cookies
function SetAll() {
    SetClickTracksCookie();
    StoreVar('source');
    StoreVar('id');
    StoreReferrer('referrer');
    StoreFullReferrer('fullreferrer');
    StoreTodayReferrer('todayreferrer');
    StoreKeyWordReferrer('keywordreferrer');
}

SetAll();

/***********************************************
* DD Tab Menu II script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/*
//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display]:
var initialtab=[1, "sc1"]

//Turn menu into single level image tabs (completely hides 2nd level)?
var turntosingle=0 //0 for no (default), 1 for yes

//Disable hyperlinks in 1st level tab images?
var disabletablinks=0 //0 for no (default), 1 for yes


////////Stop editting////////////////

var previoustab=""

if (turntosingle==1)
document.write('<style type="text/css">\n#tabcontentcontainer{display: none;}\n</style>')

function expandcontent(cid, aobject) {

if (disabletablinks==1)
aobject.onclick=new Function("return false")

if (document.getElementById && turntosingle==0){
highlighttab(aobject)
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
document.getElementById(cid).style.display="block"
previoustab=cid
}
}

function clearcontent(aobject) {

if (disabletablinks==1)
aobject.onclick=new Function("return false")

if (document.getElementById && turntosingle==0) {
highlighttab(aobject)
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
previoustab=""
}
}


function highlighttab(aobject) {

if (typeof tabobjlinks=="undefined")
collectddimagetabs()
for (i=0; i<tabobjlinks.length; i++)
tabobjlinks[i].className=""
aobject.className="current"
}

function collectddimagetabs() {

var tabobj=document.getElementById("ddimagetabs")
tabobjlinks=tabobj.getElementsByTagName("A")
}

function do_onload() {

collectddimagetabs()
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
}

// call this from html!
function setuptabs(num, id) {

initialtab=[num, id]

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload
}
*/


